search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Howt to call a custom method that executes a new SQLstatement from the refresh method

Asked by John
13 years ago.

I am trying to getthe calendar to run a new SQL databind base on the user choosing a new date. I tried to call a custom method that calls the SQL from the refresh method, but it never works. Is there a good way to pass the new start date data that comes from the javascript.dc1.refreshcallback method into a place where I can then run my custom SQL to bring back the new data for a refreshed calendar. I know that the refresh will bring a new view on the exiting set of data, but I need to bring back a whole new set of data based on some custom filters in addition to the date filter.


protected void datab(String ndate){

Response.Write(ndate);

m= Request.Form["month"];
y= Request.Form["year"];
RadioGroup1a = Request.Form["RadioGroup1a"];
typ= Request.Form["type"];
department = Request.Form["department"];
ctype = Request.Form["ctype"];


if(m != null){

if( RadioGroup1a == "resolved") {
addstuff = addstuff + " AND ( resolved = 1 )";
}

if( RadioGroup1a == "unresolved") {
addstuff = addstuff + " AND ( resolved = 0 )";
}

if(typ != null){
typ = Regex.Replace(typ, "'","*");
}

if( typ == "4" ) {
addstuff = addstuff;
}else{
addstuff = addstuff +" And a1actor = " + typ + " ";
}


if( department == "18" ) {
}else{
addstuff = addstuff + " And csusers.department = " + department + " ";
}


if( ctype == "All" ) {
}else{
addstuff = addstuff + " And citystat.ctype = '" + ctype + "' ";
}

}

// Response.Write("XXXXXXXXXXXXX" + m);

if(m == null){

m = "current";
y = "current";

}
DateTime dtVariable = DateTime.Now;


if(m == "current"){ mx= (dtVariable.Month); }
if(y == "current"){ yx= (dtVariable.Year); }
dx= (dtVariable.Day);

dex = dx + 7;

//

dbstring = mx +"/" + 1 + "/" + yx;


if(mx == 12){ mx = 1; yx = yx +1;}else{ mx = mx + 1;}

destring = mx +"/" + 1 + "/" + yx;

// Convert.ToDateTime(mx +"/" + dx + "/" + yx);
// Response.Write("XXXXXXXXXXXXX" + m);
//

DataTable dt;
dt= new DataTable();

Response.Write( "SELECT citystat.id, [ctype], [A1begin], [A1date], [allday] FROM [citystat] INNER JOIN csusers ON citystat.a1actor = CSusers.id INNER JOIN CSdepartments ON csusers.department = CSdepartments.id WHERE [A1date] <= '" + destring + "' AND [A1begin] >= '" + dbstring + "' " + addstuff + " ");

// Response.End();

using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["daypilot"].ConnectionString))
{
con.Open();


SqlDataAdapter ad = new SqlDataAdapter("SELECT citystat.id, [ctype], [A1begin], [A1date], [allday] FROM [citystat] INNER JOIN csusers ON citystat.a1actor = CSusers.id INNER JOIN CSdepartments ON csusers.department = CSdepartments.id WHERE [A1date] <= '" + destring + "' AND [A1begin] >= '" + dbstring + "' " + addstuff + " ", con);

DataSet ds = new DataSet();

ad.Fill(ds,"Categories");

DayPilotCalendar1.StartDate = Convert.ToDateTime(dtVariable);


DayPilotCalendar1.DataSource = ds;
}


}

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.