using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Telerik.Web.UI; using Google.GData.Calendar; using System.Data; using System.Configuration; using System.Drawing; using CenterAppointmentScheduler.App.Data; using CenterAppointmentScheduler.App.BusinessEntities; using System.Text; using System.IO; using System.Text.RegularExpressions; using CenterAppointmentScheduler.App.GoogleApi3Helper; using Google.Apis.Calendar.v3; using Google.Apis.Calendar.v3.Data; using System.Threading; using System.Globalization; namespace CenterAppointmentScheduler2 { public partial class CenterAppointmentDetails : CenterAppointSchedulerBasePage { string Apidomain = string.Empty; string ApiUserName = string.Empty; string ApiPassword = string.Empty; string sCenterGUID = string.Empty; DateTime selecteddate; CenterAppointmentScheduler.App.Data.SchedulerDataGlobalHelper helper; CenterAppointmentScheduler.App.BusinessEntities.CallSession callsession; string culture = string.Empty; protected void FillPageFromResourcesFile() { this.lnkBack.Text = Resources.localized.home.lnkBack; this.lblScheduleanAppointment.Text = Resources.localized.home.lblScheduleanAppointment; } protected override void OnInit(EventArgs e) { base.OnInit(e); helper = new CenterAppointmentScheduler.App.Data.SchedulerDataGlobalHelper(); this.RadScheduler2.AppointmentContextMenuItemClicked += new AppointmentContextMenuItemClickedEventHandler(RadScheduler2_AppointmentContextMenuItemClicked); callsession = (CenterAppointmentScheduler.App.BusinessEntities.CallSession)Session["CallSession"]; if ((callsession.countryCode == "MEX") || (callsession.countryCode == "PAN")) { culture = "es-MX"; Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture); } if (callsession.CenterGUID != null) sCenterGUID = callsession.CenterGUID.ToString(); if (callsession.AppointmentDate != DateTime.MinValue) selecteddate = callsession.AppointmentDate; else selecteddate = DateTime.Now; if (!IsPostBack) { FillPageFromResourcesFile(); filldata(); } } private void EnableDisable() { callsession = ( .CenterAppointmentScheduler.App.BusinessEntities.CallSession)Session["CallSession"]; if (callsession.UserType != null) { string sUserType = callsession.UserType.ToString(); if (sUserType.ToLower() == "staff") { this.RadScheduler2.WeekView.UserSelectable = true; this.RadScheduler2.DayView.UserSelectable = true; this.RadScheduler2.MonthView.UserSelectable = true; } else { this.RadScheduler2.WeekView.UserSelectable = false; this.RadScheduler2.DayView.UserSelectable = false; this.RadScheduler2.MonthView.UserSelectable = true; } } } void RadScheduler2_AppointmentContextMenuItemClicked(object sender, AppointmentContextMenuItemClickedEventArgs e) { DataSet ds = helper.GetAppointmentByAppointmentID(Convert.ToInt32(e.Appointment.ID)); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { if (e.MenuItem.Value == "commandReschedule") { string selectedappointmentid = string.Empty; callsession = ( .CenterAppointmentScheduler.App.BusinessEntities.CallSession)Session["CallSession"]; callsession.AppointmentDate = this.RadScheduler2.SelectedDate; if (callsession.CallTypeID == .CenterAppointmentScheduler.App.BusinessEntities.CallType.CALLTYPEID_INCOMING || callsession.CallTypeID == .CenterAppointmentScheduler.App.BusinessEntities.CallType.CALLTYPEID_OUTGOING) Response.Redirect("CallCenterAppointment.aspx"); else if (callsession.CallTypeID == .CenterAppointmentScheduler.App.BusinessEntities.CallType.CALLTYPEID_SCHEDULER || callsession.CallTypeID == 0) { //callsession.GoogleEventID = ds.Tables[0].Rows[0]["GoogleEventID"].ToString();// e.Appointment.ID.ToString(); callsession.RescheduleAppointmentID = Convert.ToInt32(e.Appointment.ID); Response.Redirect("CenterAppointment.aspx"); } } else if (e.MenuItem.Value == "commandCancel") { string selectedappointmentid = string.Empty; callsession = ( .CenterAppointmentScheduler.App.BusinessEntities.CallSession)Session["CallSession"]; callsession.AppointmentDate = this.RadScheduler2.SelectedDate; callsession.AppointmentID = Convert.ToInt32(e.Appointment.ID); Response.Redirect("CancelAppointment.aspx"); } } } private List Appointments { get { List sessApts = ViewState["AppointmentList"] as List; if (sessApts == null) { sessApts = new List(); ViewState["AppointmentList"] = sessApts; } return sessApts; } } private void filldata() { if (!(selecteddate <= DateTime.MinValue || selecteddate >= DateTime.MaxValue)) { DateTime date11 = selecteddate; //date11 = Convert.ToDateTime(DateTime.Parse(selecteddate.ToShortDateString()).ToString(CultureInfo.GetCultureInfo("en-US").DateTimeFormat.ShortDatePattern)); this.RadScheduler2.SelectedDate = date11; if (ViewState["AppointmentList"] == null) { InitializeAppointments(date11); } } } private void InitializeAppointments(DateTime date1) { string centerid = string.Empty; //DateTime date11 = this.RadScheduler2.SelectedDate; //Get CenterID from CenterGUID DataSet dsCenterInfo = helper.GetCenterIDFromCenterGUID(sCenterGUID); if (dsCenterInfo.Tables[0].Rows.Count > 0) { centerid = dsCenterInfo.Tables[0].Rows[0]["centerid"].ToString().Trim(); callsession.countryCode = dsCenterInfo.Tables[0].Rows[0]["CountryCD"].ToString().Trim(); } if (centerid.Trim().Length > 0) { //Get all Google Appointment for the selected date(whole day) //BuildAppointmentsFromGoogle(date1, centerid); //Get appointment From the LocalDatabase BuildAppointmentsFromLocal(date1, centerid); this.RadScheduler2.DataSource = Appointments; } } private void BuildAppointmentsFromLocal(DateTime date1, string centerid) { // DateTime date2 = Convert.ToDateTime(date1.Month.ToString() + "/01/" + date1.Year.ToString() + " 00:00:00 "); //DateTime startdatetime1 = Convert.ToDateTime(DateTime.Parse(date2.ToShortDateString()).ToString(CultureInfo.GetCultureInfo("en-US").DateTimeFormat.ShortDatePattern)); .CenterAppointmentScheduler.App.BusinessEntities.CallSession callsession = ( .CenterAppointmentScheduler.App.BusinessEntities.CallSession)Session["CallSession"]; .CenterAppointmentScheduler.App.BusinessEntities.ZipCode zipcode = ( .CenterAppointmentScheduler.App.BusinessEntities.ZipCode)callsession.ZipCode; int userID = 0; callsession = ( .CenterAppointmentScheduler.App.BusinessEntities.CallSession)Session["CallSession"]; if (callsession != null) { userID = GeneralHelper.ConvertToInt32(callsession.UserID, false); } DateTime date2 = Convert.ToDateTime(date1.Month.ToString() + "/01/" + date1.Year.ToString() + " 00:00:00 "); if ((callsession.countryCode == "MEX") || (callsession.countryCode == "PAN")) { date2 = Convert.ToDateTime("01/" + date1.Month.ToString() + "/" + date1.Year.ToString() + " 00:00:00 "); } DateTime startdatetime = date2.AddDays(-10); DateTime enddatetime = date2.AddDays(45); DataSet dsLocalAppointments = helper.GetAppointmentsByCenterGUID(callsession.CenterGUID.ToString(), startdatetime, enddatetime, userID); Appointments.Clear(); string sUserType = string.Empty; callsession = ( .CenterAppointmentScheduler.App.BusinessEntities.CallSession)Session["CallSession"]; if (callsession.UserType != null) { sUserType = callsession.UserType.ToString(); } foreach (DataRow dr in dsLocalAppointments.Tables[0].Rows) { Telerik.Web.UI.Appointment app = new Telerik.Web.UI.Appointment(); app.ID = dr["AppointmentID"].ToString().Trim(); // telerik object doesnt have properties to hold AppointmentID & GoogleEventID. //app.ID = dr["GoogleEventID"].ToString().Trim(); // telerik object doesnt have properties to hold AppointmentID & GoogleEventID. app.Subject = dr["FirstName"].ToString().Trim() + " " + dr["LastName"].ToString().Trim() + " " + dr["PhoneNumber"].ToString().Trim(); DateTime dtStarttime = Convert.ToDateTime(Convert.ToDateTime(dr["AppointmentDate"]).ToShortDateString() + " " + dr["StartTime"].ToString()); DateTime dtEndtime = Convert.ToDateTime(Convert.ToDateTime(dr["AppointmentDate"]).ToShortDateString() + " " + dr["EndTime"].ToString()); //app.Start = GoogleCalendarHelper.ConvertTimeToCenterTimeZoneGet(dtStarttime, zipcode.TimeZone, zipcode.DST); //app.End = GoogleCalendarHelper.ConvertTimeToCenterTimeZoneGet(dtEndtime, zipcode.TimeZone, zipcode.DST); app.Start = dtStarttime; app.End = dtEndtime; app.Attributes.Add("StartTime", dr["StartTime"].ToString()); app.Attributes.Add("EndTime", dr["EndTime"].ToString()); //app.Attributes.Add("MyDuration", dr["Duration"].ToString()); app.Attributes.Add("Email", dr["Email"].ToString()); app.Attributes.Add("Description", dr["Email"].ToString()); app.Attributes.Add("AppointmentCreatedate", dr["CreateDate"].ToString()); app.Attributes.Add("CreatedName", dr["CreatedName"].ToString()); app.Attributes.Add("AppointmentModifieddate", dr["ModifyDate"].ToString()); app.Attributes.Add("ModifiedName", dr["ModifiedName"].ToString()); app.Attributes.Add("InitialApptCreateDate", dr["InitialApptCreateDate"].ToString()); app.Attributes.Add("InitialApptCreateBy", dr["InitialApptCreateBy"].ToString()); app.Attributes.Add("VisibilityLabel", dr["VisibilityLabel"].ToString()); DataView dv = dsLocalAppointments.Tables[1].DefaultView; dv.RowFilter = "AppointmentID = " + dr["AppointmentID"].ToString(); dv.Sort = "AppointmentStudentID ASC"; int i = 1; foreach (DataRow dr1 in dv.ToTable().Rows) { if (i == 1) { app.Attributes.Add("Child1Name", dr1["FirstName"].ToString()); app.Attributes.Add("Child1LName", dr1["LastName"].ToString()); app.Attributes.Add("Child1Age", dr1["Age"].ToString()); app.Attributes.Add("Child1Grade", dr1["Grade"].ToString()); app.Attributes.Add("Student1ID", dr1["StudentID"].ToString()); } if (i == 2) { app.Attributes.Add("Child2Name", dr1["FirstName"].ToString()); app.Attributes.Add("Child2LName", dr1["LastName"].ToString()); app.Attributes.Add("Child2Age", dr1["Age"].ToString()); app.Attributes.Add("Child2Grade", dr1["Grade"].ToString()); app.Attributes.Add("Student2ID", dr1["StudentID"].ToString()); } if (i == 3) { app.Attributes.Add("Child3Name", dr1["FirstName"].ToString()); app.Attributes.Add("Child3LName", dr1["LastName"].ToString()); app.Attributes.Add("Child3Age", dr1["Age"].ToString()); app.Attributes.Add("Child3Grade", dr1["Grade"].ToString()); app.Attributes.Add("Student3ID", dr1["StudentID"].ToString()); } if (i == 4) { app.Attributes.Add("Child4Name", dr1["FirstName"].ToString()); app.Attributes.Add("ChildLName", dr1["LastName"].ToString()); app.Attributes.Add("Child4Age", dr1["Age"].ToString()); app.Attributes.Add("Child4Grade", dr1["Grade"].ToString()); app.Attributes.Add("Student4ID", dr1["StudentID"].ToString()); } i++; } Appointments.Add(app); } } /// /// BuildAppointmentsFromGoogle /// NOT USED AS OF NOW SINCE BUILD FROM DB /// /// /// protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e) { //Appointments.Add(new AppointmentInfo(e.Appointment)); } protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e) { Telerik.Web.UI.Appointment ai = FindById(e.ModifiedAppointment.ID.ToString()); //ai.CopyInfo(e.ModifiedAppointment); } protected void RadScheduler1_AppointmentDelete(object sender, SchedulerCancelEventArgs e) { Appointments.Remove(FindById(e.Appointment.ID.ToString())); ViewState["AppointmentList"] = null; DeleteAppointment(e.Appointment.ID.ToString()); } private void Reschedule(AppointmentCommandEventArgs e) { string selectedappointmentid = string.Empty; selectedappointmentid = ((TextBox)e.Container.FindControl("txtAppointmentID")).Text; Response.Redirect("CenterAppointmentMain.aspx?p1=" + sCenterGUID + "&p2=" + this.RadScheduler2.SelectedDate.ToShortDateString() + "&p3=" + selectedappointmentid); } protected void lnkCancelAppointment_Click(object sender, EventArgs e) { } protected void lnkSave_Click(object sender, EventArgs e) { } private void CancelAppointment(AppointmentCommandEventArgs e) { string selectedappointmentid = string.Empty; string centerid = string.Empty; try { selectedappointmentid = ((TextBox)e.Container.FindControl("txtAppointmentID")).Text; bool useGoogle = Convert.ToBoolean(ConfigurationManager.AppSettings["UseGoogle"]); if (useGoogle) { DataSet ds = helper.GetAppointmentByAppointmentID(Convert.ToInt32(selectedappointmentid)); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { int i = helper.CancelAppointmentByEventID(ds.Tables[0].Rows[0]["GoogleEventID"].ToString(), Convert.ToInt32(callsession.UserID)); } } else { int i = helper.CancelAppointmentByAppointmentID(Convert.ToInt32(selectedappointmentid), Convert.ToInt32(callsession.UserID)); } Response.Redirect("CenterAppointmentDetails.aspx?p1=" + sCenterGUID + "&p2=" + callsession.AppointmentDate); } catch (Exception ex) { ExceptionUtility.LogException(ex, "CancelAppointment"); } } /// /// SaveAppointment /// VJ - 2012-07-18 /// /// private void SaveAppointment(AppointmentCommandEventArgs e) { try { // Create appointment object .CenterAppointmentScheduler.App.BusinessEntities.Appointment appt = new .CenterAppointmentScheduler.App.BusinessEntities.Appointment(); string sIPAddress = Request.UserHostAddress; // Set properties appt.CenterGUID = new Guid(sCenterGUID); string googleEventID = ((TextBox)e.Container.FindControl("txtGoogleEventID")).Text; string AppointmentID = ((TextBox)e.Container.FindControl("txtAppointmentID")).Text; string txtAppointmentDate = ((TextBox)e.Container.FindControl("txtAppointmentDate")).Text; string txtStartTime = ((TextBox)e.Container.FindControl("txtStartTime")).Text; DateTime centerCurrentTime = DateTime.Now; DataSet ds = helper.GetCenterTimeByCenterID(callsession.CenterID); if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) centerCurrentTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["CenterCurrentTime"]); //No Show Appointment //DateTime myDate = DateTime.Parse(txtAppointmentDate); DateTime myDate = Convert.ToDateTime(Convert.ToDateTime(txtAppointmentDate).ToShortDateString() + " " + txtStartTime.ToString()); int resultNoShow = DateTime.Compare(myDate, centerCurrentTime); if (resultNoShow < 0) { Boolean blnNoShow = ((CheckBox)e.Container.FindControl("chkNoShow")).Checked; // List for AppointmentStudent List< .CenterAppointmentScheduler.App.BusinessEntities.AppointmentStudent> lstAppointmentStudent = new List< .CenterAppointmentScheduler.App.BusinessEntities.AppointmentStudent>(); StudentType studenttype = null; Subject subject = null; // Add items to list if (((TextBox)e.Container.FindControl("txtChildName1")).Text.Trim().Length > 0) { subject = new Subject(); subject.Description = ((DropDownList)e.Container.FindControl("ddlSubject1")).SelectedItem.Text; subject.SubjectID = Convert.ToByte(((DropDownList)e.Container.FindControl("ddlSubject1")).SelectedValue); lstAppointmentStudent.Add(new AppointmentStudent(((TextBox)e.Container.FindControl("txtChildName1")).Text.Trim(), ((TextBox)e.Container.FindControl("txtChildLName1")).Text.Trim(), ((TextBox)e.Container.FindControl("txtStudentID1")).Text.Trim(), ((DropDownList)e.Container.FindControl("ddlGrade1")).Text.Trim(), "", subject, studenttype)); } if (((TextBox)e.Container.FindControl("txtChildName2")).Text.Trim().Length > 0) { subject = new Subject(); subject.Description = ((DropDownList)e.Container.FindControl("ddlSubject2")).SelectedItem.Text; subject.SubjectID = Convert.ToByte(((DropDownList)e.Container.FindControl("ddlSubject2")).SelectedValue); lstAppointmentStudent.Add(new AppointmentStudent(((TextBox)e.Container.FindControl("txtChildName2")).Text.Trim(), ((TextBox)e.Container.FindControl("txtChildLName2")).Text.Trim(), ((TextBox)e.Container.FindControl("txtStudentID2")).Text.Trim(), ((DropDownList)e.Container.FindControl("ddlGrade2")).Text.Trim(), "", subject, studenttype)); } if (((TextBox)e.Container.FindControl("txtChildName3")).Text.Trim().Length > 0) { subject = new Subject(); subject.Description = ((DropDownList)e.Container.FindControl("ddlSubject3")).SelectedItem.Text; subject.SubjectID = Convert.ToByte(((DropDownList)e.Container.FindControl("ddlSubject3")).SelectedValue); lstAppointmentStudent.Add(new AppointmentStudent(((TextBox)e.Container.FindControl("txtChildName3")).Text.Trim(), ((TextBox)e.Container.FindControl("txtChildLName3")).Text.Trim(), ((TextBox)e.Container.FindControl("txtStudentID3")).Text.Trim(), ((DropDownList)e.Container.FindControl("ddlGrade3")).Text.Trim(), "", subject, studenttype)); } if (((TextBox)e.Container.FindControl("txtChildName4")).Text.Trim().Length > 0) { subject = new Subject(); subject.Description = ((DropDownList)e.Container.FindControl("ddlSubject4")).SelectedItem.Text; subject.SubjectID = Convert.ToByte(((DropDownList)e.Container.FindControl("ddlSubject4")).SelectedValue); lstAppointmentStudent.Add(new AppointmentStudent(((TextBox)e.Container.FindControl("txtChildName4")).Text.Trim(), ((TextBox)e.Container.FindControl("txtChildLName4")).Text.Trim(), ((TextBox)e.Container.FindControl("txtStudentID4")).Text.Trim(), ((DropDownList)e.Container.FindControl("ddlGrade4")).Text.Trim(), "", subject, studenttype)); } appt.GoogleEventID = googleEventID; appt.AppointmentID = Convert.ToInt32(AppointmentID); appt.AppointmentStudents = lstAppointmentStudent; appt.Notes = ((TextBox)e.Container.FindControl("txtDescription")).Text; // Get from session .CenterAppointmentScheduler.App.BusinessEntities.CallSession callSession = ( .CenterAppointmentScheduler.App.BusinessEntities.CallSession)Session["CallSession"]; callSession = ( .CenterAppointmentScheduler.App.BusinessEntities.CallSession)Session["CallSession"]; if (callSession != null) { int userID = GeneralHelper.ConvertToInt32(callSession.UserID, false); int result = helper.SaveAppointmentNoShow(blnNoShow, userID, appt); } } else { appt.GoogleEventID = googleEventID; appt.AppointmentID = Convert.ToInt32(AppointmentID); appt.FirstName = ((TextBox)e.Container.FindControl("txtFirstName")).Text; appt.LastName = ((TextBox)e.Container.FindControl("txtLastName")).Text; DateTime dtAppt = new DateTime(); dtAppt = Convert.ToDateTime(txtAppointmentDate).Date; appt.AppointmentDate = dtAppt; appt.StartTime = ((TextBox)e.Container.FindControl("txtStartTime")).Text; //appt.EndTime = ((TextBox)e.Container.FindControl("txtEndTime")).Text; appt.Duration = GeneralHelper.ConvertToInt16(((TextBox)e.Container.FindControl("txtDuration")).Text, false); string PhoneNumber = string.Empty; string PhoneExtNumber = string.Empty; PhoneNumber = ((TextBox)e.Container.FindControl("txtPhoneNumber")).Text; if (PhoneNumber.Length > 0) { PhoneNumber = PhoneNumber.Replace("(", "").Replace(")", "-").Replace("_",""); if (PhoneNumber == "--") PhoneNumber = ""; } PhoneExtNumber = ((TextBox)e.Container.FindControl("txtPhoneExt")).Text; //if (PhoneExtNumber.Length > 0) // appt.PhoneNumber = PhoneNumber.Trim() + " Ext: " + PhoneExtNumber.Trim(); //else // appt.PhoneNumber = PhoneNumber.Trim(); appt.PhoneNumber = PhoneNumber.Trim(); appt.PhoneExt = PhoneExtNumber.Trim(); // appt.PhoneNumber = ((TextBox)e.Container.FindControl("txtPhoneNumber")).Text; appt.Email = ((TextBox)e.Container.FindControl("txtEmail")).Text; //appt.Address1 = ((TextBox)e.Container.FindControl("txtAddress1")).Text; //appt.Address2 = ((TextBox)e.Container.FindControl("txtAddress2")).Text; //appt.City = ((TextBox)e.Container.FindControl("txtCity")).Text; //appt.ZipCode = new ZipCode(); //appt.ZipCode.zipCode = ((TextBox)e.Container.FindControl("txtZipCode")).Text; appt.Notes = ((TextBox)e.Container.FindControl("txtDescription")).Text; //string ddlStateValue = ((DropDownList)e.Container.FindControl("ddlState")).SelectedValue; //string ddlCountryValue = ((DropDownList)e.Container.FindControl("ddlCountry")).SelectedValue; //string ddllanguage = ((DropDownList)e.Container.FindControl("ddlLanguage")).SelectedValue; //appt.StateID = Convert.ToInt32(ddlStateValue); //appt.CountryID = Convert.ToInt32(ddlCountryValue); //appt.languageID = Convert.ToInt16(ddllanguage); //appt.ParentMentionedPromotion = ((Label)e.Container.FindControl("lblPromoCode")).Text; if (appt.CountryID == 2) { string strConsentYesOrNo = ((Label)e.Container.FindControl("lblEmailConsentValue")).Text; if (strConsentYesOrNo.ToLower() == "yes") { appt.IsOptedIn = true; } else { appt.IsOptedIn = false; } } string strSMSConsentYesOrNo = ((RadioButtonList)e.Container.FindControl("rbSMSOptInOut")).SelectedValue; if (strSMSConsentYesOrNo != "") { if (strSMSConsentYesOrNo == "1") { appt.IsSMSOptedIn = true; } else { appt.IsSMSOptedIn = false; } } // List for AppointmentStudent List< .CenterAppointmentScheduler.App.BusinessEntities.AppointmentStudent> lstAppointmentStudent = new List< .CenterAppointmentScheduler.App.BusinessEntities.AppointmentStudent>(); StudentType studenttype = null; Subject subject = null; // Add items to list if (((TextBox)e.Container.FindControl("txtChildName1")).Text.Trim().Length > 0) { subject = new Subject(); subject.Description = ((DropDownList)e.Container.FindControl("ddlSubject1")).SelectedItem.Text; subject.SubjectID = Convert.ToByte(((DropDownList)e.Container.FindControl("ddlSubject1")).SelectedValue); lstAppointmentStudent.Add(new AppointmentStudent(((TextBox)e.Container.FindControl("txtChildName1")).Text.Trim(), ((TextBox)e.Container.FindControl("txtChildLName1")).Text.Trim(), ((DropDownList)e.Container.FindControl("ddlGrade1")).Text.Trim(), "", subject, studenttype)); } if (((TextBox)e.Container.FindControl("txtChildName2")).Text.Trim().Length > 0) { subject = new Subject(); subject.Description = ((DropDownList)e.Container.FindControl("ddlSubject2")).SelectedItem.Text; subject.SubjectID = Convert.ToByte(((DropDownList)e.Container.FindControl("ddlSubject2")).SelectedValue); lstAppointmentStudent.Add(new AppointmentStudent(((TextBox)e.Container.FindControl("txtChildName2")).Text.Trim(), ((TextBox)e.Container.FindControl("txtChildLName2")).Text.Trim(), ((DropDownList)e.Container.FindControl("ddlGrade2")).Text.Trim(), "", subject, studenttype)); } if (((TextBox)e.Container.FindControl("txtChildName3")).Text.Trim().Length > 0) { subject = new Subject(); subject.Description = ((DropDownList)e.Container.FindControl("ddlSubject3")).SelectedItem.Text; subject.SubjectID = Convert.ToByte(((DropDownList)e.Container.FindControl("ddlSubject3")).SelectedValue); lstAppointmentStudent.Add(new AppointmentStudent(((TextBox)e.Container.FindControl("txtChildName3")).Text.Trim(), ((TextBox)e.Container.FindControl("txtChildLName3")).Text.Trim(), ((DropDownList)e.Container.FindControl("ddlGrade3")).Text.Trim(), "", subject, studenttype)); } if (((TextBox)e.Container.FindControl("txtChildName4")).Text.Trim().Length > 0) { subject = new Subject(); subject.Description = ((DropDownList)e.Container.FindControl("ddlSubject4")).SelectedItem.Text; subject.SubjectID = Convert.ToByte(((DropDownList)e.Container.FindControl("ddlSubject4")).SelectedValue); lstAppointmentStudent.Add(new AppointmentStudent(((TextBox)e.Container.FindControl("txtChildName4")).Text.Trim(), ((TextBox)e.Container.FindControl("txtChildLName4")).Text.Trim(), ((DropDownList)e.Container.FindControl("ddlGrade4")).Text.Trim(), "", subject, studenttype)); } // Set AppointmentStudents property appt.AppointmentStudents = lstAppointmentStudent; // source heard from //appt.HowDidYouHear = ((Label)e.Container.FindControl("lblSourceHeardFrom")).Text; //Below code commented on 8/13/2015 by VG, because while updating the appointment, zipcode was getting overwritten by center zipcode ////Set ZipCode .CenterAppointmentScheduler.App.BusinessEntities.CallSession callSession = ( .CenterAppointmentScheduler.App.BusinessEntities.CallSession)Session["CallSession"]; .CenterAppointmentScheduler.App.BusinessEntities.ZipCode zipcode = ( .CenterAppointmentScheduler.App.BusinessEntities.ZipCode)callsession.ZipCode; //zipcode.zipCode = ((TextBox)e.Container.FindControl("txtZipCode")).Text; //appt.ZipCode = zipcode; appt.IPAddress = sIPAddress; // Save to database string callTypeID = string.Empty; int userID = 1; int callID = 0; byte saveMode = 1; try { //appt.AppointmentSourceID = this.GetAppointmentSourceID(); appt.AppointmentSourceID = 1; // Below added on 8/18/2015, as parent zipcode is getting over written by center zipcode. //appt.ZipCode = new ZipCode(); //appt.ZipCode.zipCode = ((TextBox)e.Container.FindControl("txtZipCode")).Text; // Get from session callSession = ( .CenterAppointmentScheduler.App.BusinessEntities.CallSession)Session["CallSession"]; if (callSession != null) { callTypeID = GeneralHelper.ConvertToString(callSession.CallTypeID, false); userID = GeneralHelper.ConvertToInt32(callSession.UserID, false); } // Save Appointment to DB int result = helper.SaveAppointment(appt, callID, saveMode, userID, callsession.countryCode); DateTime finaldate = Convert.ToDateTime(Convert.ToDateTime(txtAppointmentDate).Month.ToString() + "/01/" + Convert.ToDateTime(txtAppointmentDate).Year.ToString()); if ((callsession.countryCode == "MEX") || (callsession.countryCode == "PAN")) { finaldate = Convert.ToDateTime("01/" + Convert.ToDateTime(txtAppointmentDate).Month.ToString() + "/" + Convert.ToDateTime(txtAppointmentDate).Year.ToString()); } InitializeAppointments(finaldate); } catch (Exception exDB) { string Source = " CenterGUID : " + callSession.CenterGUID.ToString() + " Location : 2"; StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); System.Xml.Serialization.XmlSerializer parentInfo = new System.Xml.Serialization.XmlSerializer(appt.GetType()); parentInfo.Serialize(sw, appt); string Errorstring = sw.ToString() + Environment.NewLine + exDB.Message; ExceptionUtility.LogErrors(Errorstring, Source); } } } catch (Exception ex) { ExceptionUtility.LogException(ex, "SaveAppointment"); } } private void DeleteAppointment(string eventid) { string centerid = string.Empty; bool useGoogle = Convert.ToBoolean(ConfigurationManager.AppSettings["UseGoogle"]); if (useGoogle) { //Get CenterID from CenterGUID DataSet dsCenterInfo = helper.GetCenterIDFromCenterGUID(sCenterGUID); if (dsCenterInfo.Tables[0].Rows.Count > 0) { centerid = dsCenterInfo.Tables[0].Rows[0]["centerid"].ToString().Trim(); string googleCalendarID = dsCenterInfo.Tables[0].Rows[0]["GoogleCalendarID"].ToString().Trim(); GoogleCalendarHelper gcHelper = new GoogleCalendarHelper(); string retValue = gcHelper.DeleteEvent(googleCalendarID, eventid); // Delete from the local database helper.DeleteAppointmentByEventID(eventid, Convert.ToInt32(callsession.UserID)); } } else { if (eventid.Trim().Length <= 0) return; helper.DeleteAppointmentByAppointmentID(Convert.ToInt32(eventid), Convert.ToInt32(callsession.UserID)); } } private Telerik.Web.UI.Appointment FindById(string ID) { foreach (Telerik.Web.UI.Appointment ai in Appointments) { if (ai.ID.Equals(ID)) { return ai; } } return null; } protected void RadScheduler2_Load(object sender, EventArgs e) { string ss = this.RadScheduler2.SelectedDate.ToShortDateString(); } protected void RadScheduler2_NavigationCommand(object sender, SchedulerNavigationCommandEventArgs e) { DateTime dateselected = this.RadScheduler2.SelectedDate; DateTime finaldate; //if (ViewState["AppointmentList"] != null) //{ if (e.Command == SchedulerNavigationCommand.NavigateToNextPeriod) { //if (this.RadScheduler2.SelectedView != SchedulerViewType.DayView && this.RadScheduler2.SelectedView != SchedulerViewType.MonthView) //{ finaldate = Convert.ToDateTime(dateselected.Month.ToString() + "/01/" + dateselected.Year.ToString()).AddMonths(1); if ((callsession.countryCode == "MEX") || (callsession.countryCode == "PAN")) { //date2 = Convert.ToDateTime("01/" + date1.Month.ToString() + "/" + date1.Year.ToString() + " 00:00:00 "); finaldate = Convert.ToDateTime("01/" + dateselected.Month.ToString() + "/" + dateselected.Year.ToString()).AddMonths(1); } InitializeAppointments(finaldate); //} } else if(e.Command == SchedulerNavigationCommand.NavigateToPreviousPeriod) { //if (this.RadScheduler2.SelectedView != SchedulerViewType.DayView && this.RadScheduler2.SelectedView != SchedulerViewType.MonthView) //{ finaldate = Convert.ToDateTime(dateselected.Month.ToString() + "/01/" + dateselected.Year.ToString()).AddMonths(-1); if ((callsession.countryCode == "MEX") || (callsession.countryCode == "PAN")) { finaldate = Convert.ToDateTime("01/" + dateselected.Month.ToString() + "/" + dateselected.Year.ToString()).AddMonths(-1); } InitializeAppointments(finaldate); //} } else if( e.Command == SchedulerNavigationCommand.NavigateToSelectedDate) { dateselected = e.SelectedDate; finaldate = Convert.ToDateTime(dateselected.Month.ToString() + "/01/" + dateselected.Year.ToString()); if ((callsession.countryCode == "MEX") || (callsession.countryCode == "PAN")) { finaldate = Convert.ToDateTime("01/" + dateselected.Month.ToString() + "/" + dateselected.Year.ToString()); } InitializeAppointments(finaldate); } else { List Appointments1 = ViewState["AppointmentList"] as List; this.RadScheduler2.DataSource = Appointments1; } //} } protected void RadScheduler2_FormCreated(object sender, SchedulerFormCreatedEventArgs e) { RadScheduler scheduler = (RadScheduler)sender; try { if (e.Container.Mode == SchedulerFormMode.AdvancedEdit) { FillPopUp(e); Session["popupevent"] = null; Session.Add("popupevent", e); } } catch (Exception ex) { ExceptionUtility.LogException(ex, "RadScheduler2_FormCreated"); } } protected void RadScheduler2_AppointmentCommand(object sender, AppointmentCommandEventArgs e) { if (e.CommandName == "Update") { SaveAppointment(e); } else if (e.CommandName == "Reschedule") { Reschedule(e); } else if (e.CommandName == "CancelAppointment") { CancelAppointment(e); } } //protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e) //{ // SchedulerFormCreatedEventArgs event1 = (SchedulerFormCreatedEventArgs) Session["popupevent"]; // fillStates(event1); //} protected void FillPageFromResourcesFile(SchedulerFormCreatedEventArgs e) { try { string culture = string.Empty; if ((callsession.countryCode == "MEX") || (callsession.countryCode == "PAN")) { culture = "es-MX"; Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture); } ((Label)e.Container.FindControl("lblEditAppointment")).Text = Resources.localized.CenterAppointmentDetails.lblEditAppointment; ((Label)e.Container.FindControl("Label1")).Text = Resources.localized.CenterAppointmentDetails.Label1; ((Label)e.Container.FindControl("Label4")).Text = Resources.localized.CenterAppointmentDetails.Label4; ((Label)e.Container.FindControl("lblAppointmentCreateDateDisp")).Text = Resources.localized.CenterAppointmentDetails.lblAppointmentCreateDateDisp; ((Label)e.Container.FindControl("lblAppointmentCreatedByDisp")).Text = Resources.localized.CenterAppointmentDetails.lblAppointmentCreatedByDisp; ((Label)e.Container.FindControl("lblLastModifiedDateDisp")).Text = Resources.localized.CenterAppointmentDetails.lblLastModifiedDateDisp; ((Label)e.Container.FindControl("lblLastModifiedByDisp")).Text = Resources.localized.CenterAppointmentDetails.lblLastModifiedByDisp; ((Label)e.Container.FindControl("lblPFname")).Text = Resources.localized.CenterAppointmentDetails.lblPFname; ((Label)e.Container.FindControl("lblPLname")).Text = Resources.localized.CenterAppointmentDetails.lblPLname; ((Label)e.Container.FindControl("validationFirstName")).Text = Resources.localized.CenterAppointmentDetails.validationFirstName; ((Label)e.Container.FindControl("validationLastName")).Text = Resources.localized.CenterAppointmentDetails.validationLastName; ((Label)e.Container.FindControl("lblContactNumber")).Text = Resources.localized.CenterAppointmentDetails.lblContactNumber; ((Label)e.Container.FindControl("lblExt")).Text = Resources.localized.CenterAppointmentDetails.lblExt; ((Label)e.Container.FindControl("regExpPhoneNo")).Text = Resources.localized.CenterAppointmentDetails.regExpPhoneNo; ((Label)e.Container.FindControl("validatorPhoneNumber")).Text = Resources.localized.CenterAppointmentDetails.validatorPhoneNumber; ((Label)e.Container.FindControl("lblEmail")).Text = Resources.localized.CenterAppointmentDetails.lblEmail; ((Label)e.Container.FindControl("regExpEmail")).Text = Resources.localized.CenterAppointmentDetails.regExpEmail; ((Label)e.Container.FindControl("validatorEmail")).Text = Resources.localized.CenterAppointmentDetails.validatorEmail; ((Label)e.Container.FindControl("lblNotes")).Text = Resources.localized.CenterAppointmentDetails.lblNotes; ((Label)e.Container.FindControl("lblSFirstName")).Text = Resources.localized.CenterAppointmentDetails.lblSFirstName; ((Label)e.Container.FindControl("lblSLastName")).Text = Resources.localized.CenterAppointmentDetails.lblSLastName; ((Label)e.Container.FindControl("lblGrade")).Text = Resources.localized.CenterAppointmentDetails.lblGrade; ((Label)e.Container.FindControl("lblSubject")).Text = Resources.localized.CenterAppointmentDetails.lblSubject; ((Label)e.Container.FindControl("lblStudentID")).Text = Resources.localized.CenterAppointmentDetails.lblStudentID; ((Label)e.Container.FindControl("RegularExpressionValidator1")).Text = Resources.localized.CenterAppointmentDetails.RegularExpressionValidator1; ((Label)e.Container.FindControl("RegularExpressionValidator2")).Text = Resources.localized.CenterAppointmentDetails.RegularExpressionValidator2; ((Label)e.Container.FindControl("RegularExpressionValidator3")).Text = Resources.localized.CenterAppointmentDetails.RegularExpressionValidator3; ((Label)e.Container.FindControl("RegularExpressionValidator4")).Text = Resources.localized.CenterAppointmentDetails.RegularExpressionValidator4; ((Label)e.Container.FindControl("lblEmailConsent")).Text = Resources.localized.CenterAppointmentDetails.lblEmailConsent; ((CheckBox)e.Container.FindControl("chkNoShow")).Text = Resources.localized.CenterAppointmentDetails.chkNoShow; ((LinkButton)e.Container.FindControl("lnkSave")).Text = ((LinkButton)e.Container.FindControl("lnkSave")).ToolTip = Resources.localized.CenterAppointmentDetails.lnkSave; ((LinkButton)e.Container.FindControl("lnkCancel")).Text = ((LinkButton)e.Container.FindControl("lnkCancel")).ToolTip = Resources.localized.CenterAppointmentDetails.lnkCancel; ((LinkButton)e.Container.FindControl("CancelButton")).Text = ((LinkButton)e.Container.FindControl("CancelButton")).ToolTip = Resources.localized.CenterAppointmentDetails.CancelButton; } catch (Exception ex) { ExceptionUtility.LogException(ex, "FillPageFromResourcesFile"); } } private void FillPopUp(SchedulerFormCreatedEventArgs e) { try { FillPageFromResourcesFile(e); //string AppointmentID = ((TextBox)e.Container.FindControl("txtAppointmentID")).Text; string AppointmentID = e.Container.Appointment.ID.ToString(); if (Convert.ToInt32(AppointmentID) <= 0) return; int userID = 0; if (callsession != null) { userID = GeneralHelper.ConvertToInt32(callsession.UserID, false); } DataSet ds = helper.GetAppointmentByAppointmentIDByUser(Convert.ToInt32(AppointmentID), userID); //DataSet ds = helper.GetAppointmentByEventID(googleeventid); FillOtherDetails(e); //fillCountries(e); //fillLanguages(e); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { if (Convert.ToBoolean(ds.Tables[0].Rows[0]["VisibilityLabel"])) { ((Label)e.Container.FindControl("Label1")).Visible = true; ((Label)e.Container.FindControl("Label2")).Visible = true; ((Label)e.Container.FindControl("Label3")).Visible = true; ((Label)e.Container.FindControl("Label4")).Visible = true; ((Label)e.Container.FindControl("Label2")).Text = ds.Tables[0].Rows[0]["InitialApptCreateDate"].ToString(); ((Label)e.Container.FindControl("Label3")).Text = ds.Tables[0].Rows[0]["InitialApptCreateBy"].ToString(); } else { ((Label)e.Container.FindControl("Label1")).Visible = ((Label)e.Container.FindControl("Label2")).Visible = ((Label)e.Container.FindControl("Label3")).Visible = ((Label)e.Container.FindControl("Label4")).Visible = false; } ((Label)e.Container.FindControl("lblAppointCreateDate")).Text = ds.Tables[0].Rows[0]["AppointmentCreatedate"].ToString(); ((Label)e.Container.FindControl("lblAppointCreatedBy")).Text = ds.Tables[0].Rows[0]["CreatedName"].ToString(); ((Label)e.Container.FindControl("lblAppointModifedDate")).Text = ds.Tables[0].Rows[0]["AppointmentModifieddate"].ToString(); ((Label)e.Container.FindControl("lblAppointModifedBy")).Text = ds.Tables[0].Rows[0]["ModifiedName"].ToString(); ((TextBox)e.Container.FindControl("txtGoogleEventID")).Text = ds.Tables[0].Rows[0]["GoogleEventID"].ToString(); ((TextBox)e.Container.FindControl("txtFirstName")).Text = ds.Tables[0].Rows[0]["FirstName"].ToString(); //((TextBox)e.Container.FindControl("txtFirstName")).ReadOnly = true; ((TextBox)e.Container.FindControl("txtLastName")).Text = ds.Tables[0].Rows[0]["LastName"].ToString(); string PhoneExt = string.Empty; if (ds.Tables[0].Rows[0]["PhoneNumber"].ToString().Length > 0) { string PhoneNumber = ds.Tables[0].Rows[0]["PhoneNumber"].ToString(); int indExt = PhoneNumber.IndexOf("Ext"); if (indExt >= 0) { PhoneExt = PhoneNumber.Substring(indExt); ((TextBox)e.Container.FindControl("txtPhoneExt")).Text = PhoneExt.Replace("Ext: ", ""); PhoneNumber = PhoneNumber.Substring(0, indExt - 1); } PhoneNumber = PhoneNumber.Replace("(", "").Replace(")", "-"); ((TextBox)e.Container.FindControl("txtPhoneNumber")).Text = PhoneNumber; } //((TextBox)e.Container.FindControl("txtAddress1")).Text = ds.Tables[0].Rows[0]["Address1"].ToString(); //((TextBox)e.Container.FindControl("txtAddress2")).Text = ds.Tables[0].Rows[0]["Address2"].ToString(); //((TextBox)e.Container.FindControl("txtCity")).Text = ds.Tables[0].Rows[0]["City"].ToString(); //((TextBox)e.Container.FindControl("txtZipCode")).Text = ds.Tables[0].Rows[0]["ZipCode"].ToString(); ((TextBox)e.Container.FindControl("txtDescription")).Text = ds.Tables[0].Rows[0]["Notes"].ToString(); ((TextBox)e.Container.FindControl("txtDuration")).Text = ds.Tables[0].Rows[0]["Duration"].ToString(); // ((Label)e.Container.FindControl("lblPromoCode")).Text = ds.Tables[0].Rows[0]["PromotionMentioned"].ToString(); //((DropDownList)e.Container.FindControl("ddlLanguage")).SelectedValue = ds.Tables[0].Rows[0]["LanguageID"].ToString(); //if (ds.Tables[0].Rows[0]["CountryID"].ToString() != "") // ((DropDownList)e.Container.FindControl("ddlCountry")).SelectedValue = ds.Tables[0].Rows[0]["CountryID"].ToString(); //fillStates(e); //if (ds.Tables[0].Rows[0]["StateID"].ToString() != "") //((DropDownList)e.Container.FindControl("ddlState")).SelectedValue = ds.Tables[0].Rows[0]["StateID"].ToString(); if (ds.Tables[0].Rows[0]["CountryID"].ToString() == "2") { ((Label)e.Container.FindControl("lblEmailConsent")).Visible = true; ((Label)e.Container.FindControl("lblEmailConsentValue")).Visible = true; if (((bool)ds.Tables[0].Rows[0]["IsOptedIn"] == false)) { ((Label)e.Container.FindControl("lblEmailConsentValue")).Text = "No"; // regardless of the Email consent, Parent wEmail needs to be displayed to Instructor. //((Label)e.Container.FindControl("lblEmail")).Visible = false; //((TextBox)e.Container.FindControl("txtEmail")).Visible = false; } else { ((Label)e.Container.FindControl("lblEmailConsentValue")).Text = "Yes"; } } displayConsent(ds.Tables[0].Rows[0]["CountryID"].ToString(), e); if ((callsession.countryCode == "USA") || (callsession.countryCode == "CAN")) { object objParentSMSConsent = ds.Tables[0].Rows[0]["ParentSMSConsent"]; if (objParentSMSConsent != DBNull.Value) { bool isParentSMSConsent = false; isParentSMSConsent = Convert.ToBoolean(ds.Tables[0].Rows[0]["ParentSMSConsent"]); if (isParentSMSConsent) ((RadioButtonList)e.Container.FindControl("rbSMSOptInOut")).Items.FindByValue("1").Selected = true; else ((RadioButtonList)e.Container.FindControl("rbSMSOptInOut")).Items.FindByValue("2").Selected = true; } } else { Label lblConsent = ((Label)e.Container.FindControl("lblConsentText")); lblConsent.Text = ""; lblConsent.Visible = false; RadioButtonList rr = ((RadioButtonList)e.Container.FindControl("rbSMSOptInOut")); rr.CausesValidation = false; rr.Visible = false; } //No Show Appointment DateTime myDate = DateTime.Parse(ds.Tables[0].Rows[0]["AppointmentDate"].ToString()); int result = DateTime.Compare(myDate, DateTime.Now); if (result < 0) { ((CheckBox)e.Container.FindControl("chkNoShow")).Visible = true; object value = ds.Tables[0].Rows[0]["NoShow"]; if (value != DBNull.Value) { if (Convert.ToBoolean(ds.Tables[0].Rows[0]["NoShow"])) { ((CheckBox)e.Container.FindControl("chkNoShow")).Checked = true; } } ((TextBox)e.Container.FindControl("txtStudentID1")).Visible = true; ((TextBox)e.Container.FindControl("txtStudentID2")).Visible = true; ((TextBox)e.Container.FindControl("txtStudentID3")).Visible = true; ((TextBox)e.Container.FindControl("txtStudentID4")).Visible = true; ((Label)e.Container.FindControl("lblStudentID")).Visible = true; } else { ((TextBox)e.Container.FindControl("txtStudentID1")).Visible = false; ((TextBox)e.Container.FindControl("txtStudentID2")).Visible = false; ((TextBox)e.Container.FindControl("txtStudentID3")).Visible = false; ((TextBox)e.Container.FindControl("txtStudentID4")).Visible = false; ((Label)e.Container.FindControl("lblStudentID")).Visible = false; } // to manage student id column //string txtAppointmentDate = ((TextBox)e.Container.FindControl("txtAppointmentDate")).Text; string txtAppointmentDate = ds.Tables[0].Rows[0]["AppointmentDate"].ToString(); DateTime dtStartTime = Convert.ToDateTime(Convert.ToDateTime(ds.Tables[0].Rows[0]["AppointmentDate"]).ToShortDateString() + " " + ds.Tables[0].Rows[0]["StartTime"].ToString()); DateTime centerCurrentTime = DateTime.Now; DataSet dsCenterTime = helper.GetCenterTimeByCenterID(callsession.CenterID); if (dsCenterTime != null && dsCenterTime.Tables[0] != null && dsCenterTime.Tables[0].Rows.Count > 0) centerCurrentTime = Convert.ToDateTime(dsCenterTime.Tables[0].Rows[0]["CenterCurrentTime"]); //No Show Appointment //DateTime myDate1 = DateTime.Parse(txtAppointmentDate); int resultNoShow = DateTime.Compare(dtStartTime, centerCurrentTime); if (resultNoShow < 0) { ((TextBox)e.Container.FindControl("txtFirstName")).ReadOnly = true; ((TextBox)e.Container.FindControl("txtLastName")).ReadOnly = true; ((TextBox)e.Container.FindControl("txtPhoneNumber")).ReadOnly = true; ((TextBox)e.Container.FindControl("txtPhoneExt")).ReadOnly = true; ((TextBox)e.Container.FindControl("txtEmail")).ReadOnly = true; ((TextBox)e.Container.FindControl("txtDuration")).ReadOnly = true; ((TextBox)e.Container.FindControl("txtDuration")).ReadOnly = true; ((TextBox)e.Container.FindControl("txtChildName1")).ReadOnly = true; ((TextBox)e.Container.FindControl("txtChildLName1")).ReadOnly = true; ((DropDownList)e.Container.FindControl("ddlGrade1")).Enabled = false; ((DropDownList)e.Container.FindControl("ddlSubject1")).Enabled = false; ((TextBox)e.Container.FindControl("txtChildName2")).ReadOnly = true; ((TextBox)e.Container.FindControl("txtChildLName2")).ReadOnly = true; ((DropDownList)e.Container.FindControl("ddlGrade2")).Enabled = false; ((DropDownList)e.Container.FindControl("ddlSubject2")).Enabled = false; ((TextBox)e.Container.FindControl("txtChildName3")).ReadOnly = true; ((TextBox)e.Container.FindControl("txtChildLName3")).ReadOnly = true; ((DropDownList)e.Container.FindControl("ddlGrade3")).Enabled = false; ((DropDownList)e.Container.FindControl("ddlSubject3")).Enabled = false; ((TextBox)e.Container.FindControl("txtChildName4")).ReadOnly = true; ((TextBox)e.Container.FindControl("txtChildLName4")).ReadOnly = true; ((DropDownList)e.Container.FindControl("ddlGrade4")).Enabled = false; ((DropDownList)e.Container.FindControl("ddlSubject4")).Enabled = false; } } if (ds.Tables[1].Rows.Count > 0) { int i = 1; DataSet dsGradeLevel = helper.GetGradeLevel(callsession.countryCode); foreach (DataRow dr in ds.Tables[1].Rows) { ((TextBox)e.Container.FindControl("txtChildName" + i.ToString())).Text = ds.Tables[1].Rows[i - 1]["FirstName"].ToString(); ((TextBox)e.Container.FindControl("txtChildLName" + i.ToString())).Text = ds.Tables[1].Rows[i - 1]["LastName"].ToString(); DropDownList ddl = ((DropDownList)e.Container.FindControl("ddlGrade" + i.ToString())); if (ds.Tables[1].Rows[i - 1]["Grade"].ToString() == "") ((DropDownList)e.Container.FindControl("ddlGrade" + i.ToString())).SelectedIndex = 0; else ((DropDownList)e.Container.FindControl("ddlGrade" + i.ToString())).SelectedIndex = GetSelectedIndex(dsGradeLevel.Tables[0], ds.Tables[1].Rows[i - 1]["Grade"].ToString()); if (ds.Tables[1].Rows[i - 1]["SubjectID"].ToString() == "") ((DropDownList)e.Container.FindControl("ddlSubject" + i.ToString())).SelectedIndex = 0; else ((DropDownList)e.Container.FindControl("ddlSubject" + i.ToString())).SelectedValue = ds.Tables[1].Rows[i - 1]["SubjectID"].ToString(); if (ds.Tables[1].Rows[i - 1]["StudentID"].ToString().Trim().Length == 0) { ((TextBox)e.Container.FindControl("txtStudentID" + i.ToString())).Text = string.Empty; } else { ((TextBox)e.Container.FindControl("txtStudentID" + i.ToString())).Text = ds.Tables[1].Rows[i - 1]["StudentID"].ToString(); } i++; } } } } catch (Exception ex) { ExceptionUtility.LogException(ex, "FillPopUp"); } } private int GetSelectedIndex(DataTable dt, string grade) { int i = 1; //DataView dv = dt.DefaultView; // dv.Sort = "GradeLevelCD ASC"; foreach (DataRow dr in dt.Rows) { if (dr["GradeLevelCD"].ToString().Trim() == grade) break; i++; } return i; } private void FillOtherDetails(SchedulerFormCreatedEventArgs e) { try { // For GradeLevel DataRow dr; DataSet dsGradeLevel = helper.GetGradeLevel(callsession.countryCode); dr = dsGradeLevel.Tables[0].NewRow(); dr["GradeLevelCD"] = ""; dsGradeLevel.Tables[0].Rows.InsertAt(dr, 0); if (dsGradeLevel != null && dsGradeLevel.Tables.Count > 0 && dsGradeLevel.Tables[0].Rows.Count > 0) { ((DropDownList)e.Container.FindControl("ddlGrade1")).DataSource = dsGradeLevel.Tables[0]; ((DropDownList)e.Container.FindControl("ddlGrade1")).DataTextField = "GradeLevelCD"; ((DropDownList)e.Container.FindControl("ddlGrade1")).DataValueField = "GradeLevelCD"; ((DropDownList)e.Container.FindControl("ddlGrade1")).DataBind(); ((DropDownList)e.Container.FindControl("ddlGrade1")).SelectedIndex = 0; ((DropDownList)e.Container.FindControl("ddlGrade2")).DataSource = dsGradeLevel.Tables[0]; ((DropDownList)e.Container.FindControl("ddlGrade2")).DataTextField = "GradeLevelCD"; ((DropDownList)e.Container.FindControl("ddlGrade2")).DataValueField = "GradeLevelCD"; ((DropDownList)e.Container.FindControl("ddlGrade2")).DataBind(); ((DropDownList)e.Container.FindControl("ddlGrade2")).SelectedIndex = 0; ((DropDownList)e.Container.FindControl("ddlGrade3")).DataSource = dsGradeLevel.Tables[0]; ((DropDownList)e.Container.FindControl("ddlGrade3")).DataTextField = "GradeLevelCD"; ((DropDownList)e.Container.FindControl("ddlGrade3")).DataValueField = "GradeLevelCD"; ((DropDownList)e.Container.FindControl("ddlGrade3")).DataBind(); ((DropDownList)e.Container.FindControl("ddlGrade3")).SelectedIndex = 0; ((DropDownList)e.Container.FindControl("ddlGrade4")).DataSource = dsGradeLevel.Tables[0]; ((DropDownList)e.Container.FindControl("ddlGrade4")).DataTextField = "GradeLevelCD"; ((DropDownList)e.Container.FindControl("ddlGrade4")).DataValueField = "GradeLevelCD"; ((DropDownList)e.Container.FindControl("ddlGrade4")).DataBind(); ((DropDownList)e.Container.FindControl("ddlGrade4")).SelectedIndex = 0; } // For Subject DataSet dsSubject = helper.GetSubject(callsession.countryCode, "", callsession.CenterID, 1); dr = dsSubject.Tables[0].NewRow(); dr["SubjectName"] = ""; dr["SubjectCD"] = "0"; dsSubject.Tables[0].Rows.InsertAt(dr, 0); if (dsSubject != null && dsSubject.Tables.Count > 0 && dsSubject.Tables[0].Rows.Count > 0) { ((DropDownList)e.Container.FindControl("ddlSubject1")).DataSource = dsSubject.Tables[0]; ((DropDownList)e.Container.FindControl("ddlSubject1")).DataTextField = "SubjectName"; ((DropDownList)e.Container.FindControl("ddlSubject1")).DataValueField = "SubjectCD"; ((DropDownList)e.Container.FindControl("ddlSubject1")).DataBind(); ((DropDownList)e.Container.FindControl("ddlSubject1")).SelectedIndex = 0; ((DropDownList)e.Container.FindControl("ddlSubject2")).DataSource = dsSubject.Tables[0]; ((DropDownList)e.Container.FindControl("ddlSubject2")).DataTextField = "SubjectName"; ((DropDownList)e.Container.FindControl("ddlSubject2")).DataValueField = "SubjectCD"; ((DropDownList)e.Container.FindControl("ddlSubject2")).DataBind(); ((DropDownList)e.Container.FindControl("ddlSubject2")).SelectedIndex = 0; ((DropDownList)e.Container.FindControl("ddlSubject3")).DataSource = dsSubject.Tables[0]; ((DropDownList)e.Container.FindControl("ddlSubject3")).DataTextField = "SubjectName"; ((DropDownList)e.Container.FindControl("ddlSubject3")).DataValueField = "SubjectCD"; ((DropDownList)e.Container.FindControl("ddlSubject3")).DataBind(); ((DropDownList)e.Container.FindControl("ddlSubject3")).SelectedIndex = 0; ((DropDownList)e.Container.FindControl("ddlSubject4")).DataSource = dsSubject.Tables[0]; ((DropDownList)e.Container.FindControl("ddlSubject4")).DataTextField = "SubjectName"; ((DropDownList)e.Container.FindControl("ddlSubject4")).DataValueField = "SubjectCD"; ((DropDownList)e.Container.FindControl("ddlSubject4")).DataBind(); ((DropDownList)e.Container.FindControl("ddlSubject4")).SelectedIndex = 0; } } catch (Exception ex) { ExceptionUtility.LogException(ex, "FillOtherDetails"); } } private void displayConsent(string countryID, SchedulerFormCreatedEventArgs e) { Label lblConsentText = ((Label)e.Container.FindControl("lblConsentText")); if (countryID == "1") { lblConsentText.Text = "Before we conclude, I would like to inform you that you will receive emails confirming your appointment status. Would you like to receive texts related to your appointment status as well?"; } else { lblConsentText.Text = "Before we conclude, I would like to inform you that you will receive emails confirming your appointment status. Would you like to receive texts related to your appointment status as well?"; } } protected void RadScheduler2_ResourcesPopulating(object sender, ResourcesPopulatingEventArgs e) { } protected void RadScheduler2_FormCreating(object sender, SchedulerFormCreatingEventArgs e) { } protected void RadScheduler2_AppointmentDataBound(object sender, SchedulerEventArgs e) { //e.Appointment.BackColor = System.Drawing.Color.FromArgb(208, 236, 187); } protected void lnkBack_Click(object sender, EventArgs e) { callsession = ( .CenterAppointmentScheduler.App.BusinessEntities.CallSession)Session["CallSession"]; callsession.GoogleEventID = string.Empty; Response.Redirect("CenterAppointment.aspx"); } } }