This topic is locked
[SOLVED]

 Disable Days in Datepicker

6/16/2020 7:11:32 PM
ASPRunner.NET General questions
I
i.NoLim author

Hello,
I currently have a "Scheduling App" where users select a Day and then enter an activity. I would like to cap the number of activities allowed per day to 10.
I already had something like the following but it requires the user to click "Save" before finding out if that particular date is available. I would like something where its visible in the calendar itself which days are open.



string strGetEntries = "select COUNT(ID) TotalEntries from Table where ChooseDay = '" + values["ChooseDay"].ToString()+"'";

XVar EntriesRunQuery = CommonFunctions.db_query(strGetEntries, null);

XVar EntriesData = CommonFunctions.db_fetch_array(EntriesRunQuery);
if(EntriesData["TotalEntries"] < 10)

{

return true;

}

else

{

XSession.Session["message"] = "";

MVCFunctions.EchoToOutput("<script>alert('Limit number of activities has been reached. Please select a different day');</script>");

return false;

}
admin 6/17/2020

I kind of miss the question here.
Is this what you looking for:

https://xlinesoft.com/phprunner/docs/setallowedinterval.htm

I
i.NoLim author 6/18/2020



I kind of miss the question here.
Is this what you looking for:

https://xlinesoft.com/phprunner/docs/setallowedinterval.htm



I've seen that page before but none of those examples are quite what I'm trying to do. Essentially, this is what I would like to happen before the "Add New Entry" page loads:

  1. Run a query to count how many entries there are per day
  2. In the calendar, disable choosing days for which 10 entries have already been made



As seen in my original post, I already have the SQL query. How do I pass these values to the calendar so it can disable the dates with 10 entries?
Additionally, I would also like for the limit to be 15 if the chosen date lands on a Friday.

admin 6/19/2020

So your question is how to pass data from C# event to Javascript so you can disable some days?
This?

https://xlinesoft.com/asprunnernet/docs/setproxyvalue.htm

I
i.NoLim author 6/23/2020

I haven't been able to resolve this yet but I'll keep trying.
Is there a way to find out the day of the week for an input field? Similar to this and this.
I already tried doing the following but I received a "'runnerDotNet.XVar' does not contain a definition for 'DayOfWeek'" error.

message = "Pick up day: " + values["PickupDay"].DayOfWeek;



Additionally, I opened include/commonfunctions and found getdayofweek. I wrote the following in my event, but the output was only '3' completely ignoring "Pick up day: " The day I selected was 06/26/2020, which lands on a Friday. How do I confirm that 3 is in fact Friday? Is this even correct? Why is it omitting part of the message?

message = "Pick up day: " + CommonFunctions.getdayofweek(values["PickupDay"]);
FrankR_ENTA 6/23/2020



I haven't been able to resolve this yet but I'll keep trying.
Is there a way to find out the day of the week for an input field? Similar to this and this.
I already tried doing the following but I received a "'runnerDotNet.XVar' does not contain a definition for 'DayOfWeek'" error.

message = "Pick up day: " + values["PickupDay"].DayOfWeek;



Additionally, I opened include/commonfunctions and found getdayofweek. I wrote the following in my event, but the output was only '3' completely ignoring "Pick up day: " The day I selected was 06/26/2020, which lands on a Friday. How do I confirm that 3 is in fact Friday? Is this even correct? Why is it omitting part of the message?

message = "Pick up day: " + CommonFunctions.getdayofweek(values["PickupDay"]);



"Pick up day: " is a string. The return type from that CommonFunctions function is probably an XVar. Add a .ToString() to the end of that line, and see how that changes things.
Better yet, tell us the datatype of values["PickupDay"] and we can identify a C# way to do this.

I
i.NoLim author 6/23/2020



"Pick up day: " is a string. The return type from that CommonFunctions function is probably an XVar. Add a .ToString() to the end of that line, and see how that changes things.
Better yet, tell us the datatype of values["PickupDay"] and we can identify a C# way to do this.



Ah! Yeah, that fixed the "Pick up day: " not appearing in the output. Unfortunately, I still got "Pick Up day: 3" even when I chose 06/23/2020 which is a Monday.
Datatype for values["PickupDay"] is datetime. That's what I was trying to do with values["PickupDay"].DayOfWeek but got that "'runnerDotNet.XVar' does not contain a definition for 'DayOfWeek'" error.
Thank you so much for your assistance!

admin 6/23/2020

values["PickupDay"] has the datatype of XVar. You need to convert it to DateTime object first in order to use the DayOfWeek property.

I
i.NoLim author 6/23/2020



values["PickupDay"] has the datatype of XVar. You need to convert it to DateTime object first in order to use the DayOfWeek property.



Thank you! That worked.
I'll post when I manage to make the other one work. Thank you again.