protected void gvAdminList_SelectedIndexChanged(object sender, EventArgs e) { hdnAppointmentId.Value = ((HiddenField)gvAdminList.Rows[gvAdminList.SelectedIndex].FindControl("hdnId")).Value; this.mdlPopup.Show(); string strBranchinformation = ddlBranchName.SelectedItem.Text; // date selection ddlChoosedate.Items.Add(new ListItem("Please select date", "-1")); // DataTable dtBrachtiming = BAL_branchtime.GetTiming(ddlBranchName.SelectedItem.Value); ViewState["LocationData"] = dtBrachtiming; ddlAvailabletimeslot.Items.Clear(); ddlChoosedate.Items.Clear(); //ddlChoosedate.Items.Add(new ListItem("Please select time", "-1")); DataTable dtApDate = new DataTable(); dtApDate.Columns.Add("ApDate", Type.GetType("System.DateTime")); for (int selecteddate = 0; selecteddate < 14; selecteddate++) { foreach (DataRow dr in dtBrachtiming.Rows) { if (dr["WorkingHoursFrom"].ToString() != dr["WorkingHoursTo"].ToString()) { //select the date using the week string strDay = dr["WorkingDay"].ToString(); DateTime currentdate = System.DateTime.Now; currentdate = currentdate.AddDays(selecteddate); //Response.Write("<br>" + currentdate.Date.DayOfWeek.ToString().ToLower() + " " + strDay.ToString().ToLower()); if (currentdate.Date.DayOfWeek.ToString().ToLower() == strDay.ToLower()) { DataRow drAp = dtApDate.NewRow(); drAp["ApDate"] = currentdate.ToShortDateString(); dtApDate.Rows.Add(drAp); } } } } DataView dvAp = dtApDate.DefaultView; dvAp.Sort = "Apdate ASC"; foreach (DataRowView item in dvAp) { ddlChoosedate.Items.Add(new ListItem(((DateTime)item[0]).ToShortDateString(), ((DateTime)item[0]).Date.ToShortDateString())); } ddlChoosedate.Items.Insert(0, new ListItem("Please select date", "-1")); //timing selection ddlAvailabletimeslot.Items.Insert(0, new ListItem("Please select time", "-1")); }
protected void ddlChooseBranch_SelectedIndexChanged(object sender, EventArgs e) { log.Debug("Into ChooseBranch"); Session["branchname"] = ddlChooseBranch.SelectedItem.Text; DataTable dtBrachtiming = BAL_branchtime.GetTiming(ddlChooseBranch.SelectedItem.Value); ViewState["LocationData"] = dtBrachtiming; ddlAvailabletimeslot.Items.Clear(); ddlChoosedate.Items.Clear(); // date selection //ddlChoosedate.Items.Add(new ListItem("Please select date", "-1")); DataTable dtApDate = new DataTable(); dtApDate.Columns.Add("ApDate", Type.GetType("System.DateTime")); DataTable dtAppBlockDate = new DataTable(); //dtAppBlockDate = BALBlockedAppointments.SelectBlockAppointment("appstatus", 0, int.Parse(ddlChooseBranch.SelectedItem.Value)); dtAppBlockDate = BALBlockedAppointments.SelectBlockAppointment("appstatuslocationwise", 0, int.Parse(ddlChooseBranch.SelectedItem.Value)); ViewState["BlockDate"] = dtAppBlockDate; for (int selecteddate = 0; selecteddate < 14; selecteddate++) { foreach (DataRow dr in dtBrachtiming.Rows) { if (!Convert.ToBoolean(dr["IsClosed"])) { if (dr["WorkingHoursFrom"].ToString() != dr["WorkingHoursTo"].ToString()) { //select the date using the week string strDay = dr["WorkingDay"].ToString(); DateTime currentdate = System.DateTime.Now; currentdate = currentdate.AddDays(selecteddate); //Response.Write("<br>" + currentdate.Date.DayOfWeek.ToString().ToLower() + " " + strDay.ToString().ToLower()); //check the blockdate Boolean Isblocked = false; foreach (DataRow item in dtAppBlockDate.Rows) { //if (Convert.ToDateTime(item["appdate"].ToString()) == currentdate) if (Convert.ToDateTime(item["appdate"].ToString()).ToShortDateString() == currentdate.ToShortDateString()) { if (item["op"].ToString().ToLower() == "Restrict".ToLower()) { Isblocked = true; } } } if (currentdate.Date.DayOfWeek.ToString().ToLower() == strDay.ToLower()) { if (!Isblocked) { if (Session["branchname"].ToString().ToLower() == "swansea") { if (currentdate.CompareTo(DateTime.Parse("02/12/2013")) <= 0) { DataRow drAp = dtApDate.NewRow(); drAp["ApDate"] = currentdate.ToShortDateString(); dtApDate.Rows.Add(drAp); } } else { DataRow drAp = dtApDate.NewRow(); drAp["ApDate"] = currentdate.ToShortDateString(); dtApDate.Rows.Add(drAp); } } } } } } } DataView dvAp = dtApDate.DefaultView; dvAp.Sort = "Apdate ASC"; foreach (DataRowView item in dvAp) { ddlChoosedate.Items.Add(new ListItem(((DateTime)item[0]).ToShortDateString(), ((DateTime)item[0]).Date.ToShortDateString())); } ddlChoosedate.Items.Insert(0, new ListItem("Please select date", "-1")); //timing selection ddlAvailabletimeslot.Items.Insert(0, new ListItem("Please select time", "-1")); log.Debug("Done Choosebranch"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { log.Debug("Into IsPostBack"); imgCarPhoto.Src = "~/getcarimage.aspx"; ////get the brach information //DataTable dtLocation = BAL_location.GetCMSByCMSId(0); //string strBranchinformation = dtLocation.Rows[0]["LocationName"].ToString(); //hdnId.Value = dtLocation.Rows[0]["LocationId"].ToString(); DataTable dt = BAL_location.GetCMSByCMSId(0); DataRow tdr = dt.NewRow(); tdr[0] = "0"; tdr[1] = "Please select"; dt.Rows.InsertAt(tdr, 0); ddlChooseBranch.DataSource = dt; ddlChooseBranch.DataValueField = dt.Columns["LocationId"].ToString(); ddlChooseBranch.DataTextField = dt.Columns["LocationName"].ToString(); ddlChooseBranch.DataBind(); Session["branchname"] = ddlChooseBranch.SelectedItem.Text; DataTable dtBrachtiming = BAL_branchtime.GetTiming(ddlChooseBranch.SelectedItem.Value); ViewState["LocationData"] = dtBrachtiming; ddlAvailabletimeslot.Items.Clear(); ddlChoosedate.Items.Clear(); // date selection //ddlChoosedate.Items.Add(new ListItem("Please select date", "-1")); DataTable dtApDate = new DataTable(); dtApDate.Columns.Add("ApDate", Type.GetType("System.DateTime")); DataTable dtAppBlockDate = new DataTable(); dtAppBlockDate = BALBlockedAppointments.SelectBlockAppointment("appstatus", 0, int.Parse(ddlChooseBranch.SelectedItem.Value)); ViewState["BlockDate"] = dtAppBlockDate; for (int selecteddate = 0; selecteddate < 14; selecteddate++) { foreach (DataRow dr in dtBrachtiming.Rows) { if (dr["WorkingHoursFrom"].ToString() != dr["WorkingHoursTo"].ToString()) { //select the date using the week string strDay = dr["WorkingDay"].ToString(); DateTime currentdate = System.DateTime.Now; currentdate = currentdate.AddDays(selecteddate); //Response.Write("<br>" + currentdate.Date.DayOfWeek.ToString().ToLower() + " " + strDay.ToString().ToLower()); //check the blockdate Boolean Isblocked = false; foreach (DataRow item in dtAppBlockDate.Rows) { //if (Convert.ToDateTime(item["appdate"].ToString()) == currentdate) if (Convert.ToDateTime(item["appdate"].ToString()).ToShortDateString() == currentdate.ToShortDateString()) { if (item["op"].ToString().ToLower() == "Restrict".ToLower()) { Isblocked = true; } } } if (currentdate.Date.DayOfWeek.ToString().ToLower() == strDay.ToLower()) { if (!Isblocked) { if (Session["branchname"].ToString().ToLower() == "swansea") { if (currentdate.CompareTo(DateTime.Parse("02/12/2013")) <= 0) { DataRow drAp = dtApDate.NewRow(); drAp["ApDate"] = currentdate.ToShortDateString(); dtApDate.Rows.Add(drAp); } } else { DataRow drAp = dtApDate.NewRow(); drAp["ApDate"] = currentdate.ToShortDateString(); dtApDate.Rows.Add(drAp); } } } } } } DataView dvAp = dtApDate.DefaultView; dvAp.Sort = "Apdate ASC"; foreach (DataRowView item in dvAp) { ddlChoosedate.Items.Add(new ListItem(((DateTime)item[0]).ToShortDateString(), ((DateTime)item[0]).Date.ToShortDateString())); } ddlChoosedate.Items.Insert(0, new ListItem("Please select date", "-1")); //timing selection ddlAvailabletimeslot.Items.Insert(0, new ListItem("Please select time", "-1")); } ddlAvailabletimeslot.Visible = true; spanBooked.Visible = false; hlCarButton.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable dt = BAL_location.GetCMSByCMSId(-10); ddlBranchName.DataSource = dt; ddlBranchName.DataValueField = dt.Columns["LocationId"].ToString(); ddlBranchName.DataTextField = dt.Columns["LocationName"].ToString(); ddlBranchName.DataBind(); //load the previous value in dropdown dt = BAL_branchtime.GetTiming(ddlBranchName.SelectedItem.Value); foreach (DataRow item in dt.Rows) { string[] strFrom = item["WorkingHoursFrom"].ToString().Split(' '); string[] strTo = item["WorkingHoursTo"].ToString().Split(' '); switch (item["WorkingDay"].ToString()) { case "Monday": ddlMondayFrom.SelectedValue = strFrom[0]; ddlMondayFromAMPM.SelectedValue = strFrom[1]; ddlMondayTo.SelectedValue = strTo[0]; ddlMondayToAMPM.SelectedValue = strTo[1]; break; case "Tuesday": ddlTuesdayFrom.SelectedValue = strFrom[0]; ddlTuesdayFromAMPM.SelectedValue = strFrom[1]; ddlTuesdayTo.SelectedValue = strTo[0]; ddlTuesdayToAMPM.SelectedValue = strTo[1]; chkBranchClosedTue.Checked = Convert.ToBoolean(item["IsClosed"]); break; case "Wednesday": ddlWednesdayFrom.SelectedValue = strFrom[0]; ddlWednesdayFromAMPM.SelectedValue = strFrom[1]; ddlWednesdayTo.SelectedValue = strTo[0]; ddlWednesdayToAMPM.SelectedValue = strTo[1]; chkBranchClosedWed.Checked = Convert.ToBoolean(item["IsClosed"]); break; case "Thursday": ddlThursdayFrom.SelectedValue = strFrom[0]; ddlThursdayFromAMPM.SelectedValue = strFrom[1]; ddlThursdayTo.SelectedValue = strTo[0]; ddlThursdayToAMPM.SelectedValue = strTo[1]; chkBranchClosedThu.Checked = Convert.ToBoolean(item["IsClosed"]); break; case "Friday": ddlFridayFrom.SelectedValue = strFrom[0]; ddlFridayFromAMPM.SelectedValue = strFrom[1]; ddlFridayTo.SelectedValue = strTo[0]; ddlFridayToAMPM.SelectedValue = strTo[1]; chkBranchClosedFri.Checked = Convert.ToBoolean(item["IsClosed"]); break; case "Saturday": ddlSaturdayFrom.SelectedValue = strFrom[0]; ddlSaturdayFromAMPM.SelectedValue = strFrom[1]; ddlSaturdayTo.SelectedValue = strTo[0]; ddlSaturdayToAMPM.SelectedValue = strTo[1]; chkBranchClosedSat.Checked = Convert.ToBoolean(item["IsClosed"]); break; case "Sunday": ddlSundayFrom.SelectedValue = strFrom[0]; ddlSundayFromAMPM.SelectedValue = strFrom[1]; ddlSundayTo.SelectedValue = strTo[0]; ddlSundayToAMPM.SelectedValue = strTo[1]; chkBranchClosedSun.Checked = Convert.ToBoolean(item["IsClosed"]); break; } } } }
protected void ddlBranchName_SelectedIndexChange(object sender, EventArgs e) { DataTable dt = new DataTable(); dt = BAL_branchtime.GetTiming(ddlBranchName.SelectedItem.Value); foreach (DataRow item in dt.Rows) { string[] strFrom = item["WorkingHoursFrom"].ToString().Split(' '); string[] strTo = item["WorkingHoursTo"].ToString().Split(' '); switch (item["WorkingDay"].ToString()) { case "Monday": ddlMondayFrom.SelectedValue = strFrom[0]; ddlMondayFromAMPM.SelectedValue = strFrom[1]; ddlMondayTo.SelectedValue = strTo[0]; ddlMondayToAMPM.SelectedValue = strTo[1]; chkBranchClosedMon.Checked = Convert.ToBoolean(item["IsClosed"]); break; case "Tuesday": ddlTuesdayFrom.SelectedValue = strFrom[0]; ddlTuesdayFromAMPM.SelectedValue = strFrom[1]; ddlTuesdayTo.SelectedValue = strTo[0]; ddlTuesdayToAMPM.SelectedValue = strTo[1]; chkBranchClosedTue.Checked = Convert.ToBoolean(item["IsClosed"]); break; case "Wednesday": ddlWednesdayFrom.SelectedValue = strFrom[0]; ddlWednesdayFromAMPM.SelectedValue = strFrom[1]; ddlWednesdayTo.SelectedValue = strTo[0]; ddlWednesdayToAMPM.SelectedValue = strTo[1]; chkBranchClosedWed.Checked = Convert.ToBoolean(item["IsClosed"]); break; case "Thursday": ddlThursdayFrom.SelectedValue = strFrom[0]; ddlThursdayFromAMPM.SelectedValue = strFrom[1]; ddlThursdayTo.SelectedValue = strTo[0]; ddlThursdayToAMPM.SelectedValue = strTo[1]; chkBranchClosedThu.Checked = Convert.ToBoolean(item["IsClosed"]); break; case "Friday": ddlFridayFrom.SelectedValue = strFrom[0]; ddlFridayFromAMPM.SelectedValue = strFrom[1]; ddlFridayTo.SelectedValue = strTo[0]; ddlFridayToAMPM.SelectedValue = strTo[1]; chkBranchClosedFri.Checked = Convert.ToBoolean(item["IsClosed"]); break; case "Saturday": ddlSaturdayFrom.SelectedValue = strFrom[0]; ddlSaturdayFromAMPM.SelectedValue = strFrom[1]; ddlSaturdayTo.SelectedValue = strTo[0]; ddlSaturdayToAMPM.SelectedValue = strTo[1]; chkBranchClosedSat.Checked = Convert.ToBoolean(item["IsClosed"]); break; case "Sunday": ddlSundayFrom.SelectedValue = strFrom[0]; ddlSundayFromAMPM.SelectedValue = strFrom[1]; ddlSundayTo.SelectedValue = strTo[0]; ddlSundayToAMPM.SelectedValue = strTo[1]; chkBranchClosedSun.Checked = Convert.ToBoolean(item["IsClosed"]); break; } } }