private void GetTemplateDetails(int templateid, bool isfranchisee) { var masterDal = new MasterDAL(); EScheduleTemplate objscheduletemplate = masterDal.GetScheduleTemplateDetails(templateid); //ViewState["EditObject"] = objscheduletemplate; txtschedulename.Text = objscheduletemplate.Name; chkisactive.Checked = objscheduletemplate.IsActive; txtdescription.Text = objscheduletemplate.Description; if (isfranchisee == false) { if (objscheduletemplate.Global) { rbtAllFranchisee.Checked = true; } else { rbtSpecFranch.Checked = true; ClientScript.RegisterStartupScript(typeof(string), "jsspecificfranch", " HandleDivHide('block'); ", true); foreach (EScheduleTemplateFranchiseeAccess objfranchiseeaccess in objscheduletemplate.ScheduleTemplateFranchiseeAccess) { ListItem itemtemp = chklstFranchisee.Items.FindByValue(objfranchiseeaccess.FranchiseeID.ToString()); if (itemtemp != null) { itemtemp.Selected = true; } } } } int index = 0; foreach (EScheduleTemplateTime objscheduletemplatetime in objscheduletemplate.ScheduleTemplateTime) { string starttime = objscheduletemplatetime.StartTime; if (index == 0) { index++; } else { txttimeslots.Text += "\n"; } txttimeslots.Text += starttime; } }
/// <summary> /// Page Load for time slots pop up. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { if (Request.Params["__EVENTTARGET"].ToString().Equals("GetValue")) { var masterDal = new MasterDAL(); EScheduleTemplate objscheduletemplate = masterDal.GetScheduleTemplateDetails(Convert.ToInt32(Request.Params["__EVENTARGUMENT"])); spschedtemplatename.InnerText = objscheduletemplate.Name; DataTable dttimeslots = new DataTable(); dttimeslots.Columns.Add("TimeSlot"); dttimeslots.Columns.Add("NumberPatient"); string prevslot = ""; int timecount = 0; if (objscheduletemplate != null && objscheduletemplate.ScheduleTemplateTime != null) { for (int icount = 0; icount < objscheduletemplate.ScheduleTemplateTime.Count; icount++) { if (prevslot == objscheduletemplate.ScheduleTemplateTime[icount].StartTime) { timecount = Convert.ToInt32(dttimeslots.Rows[dttimeslots.Rows.Count - 1]["NumberPatient"]); timecount++; dttimeslots.Rows[dttimeslots.Rows.Count - 1]["NumberPatient"] = timecount; continue; } timecount = 0; dttimeslots.Rows.Add(new object[] { objscheduletemplate.ScheduleTemplateTime[icount].StartTime, 1 }); prevslot = objscheduletemplate.ScheduleTemplateTime[icount].StartTime; } gvtimeslots.DataSource = dttimeslots; gvtimeslots.DataBind(); } } } }
private void save() { var masterDal = new MasterDAL(); EScheduleTemplate objSchedule = new EScheduleTemplate(); if (Request.QueryString["TemplateID"] != "") { objSchedule.ScheduleTemplateID = Convert.ToInt32(Request.QueryString["TemplateID"]); } objSchedule.Name = txtschedulename.Text; objSchedule.ScheduleTemplateFranchiseeAccess = null; objSchedule.ScheduleTemplateTime = null; objSchedule.Name = txtschedulename.Text; objSchedule.Description = txtdescription.Text; objSchedule.IsActive = chkisactive.Checked; objSchedule.Global = false; var currentOrgRole = IoC.Resolve <ISessionContext>().UserSession.CurrentOrganizationRole; if (currentOrgRole.CheckRole((long)Roles.FranchiseeAdmin)) { objSchedule.ScheduleTemplateFranchiseeAccess = new List <EScheduleTemplateFranchiseeAccess>(); objSchedule.Global = false; objSchedule.ScheduleTemplateFranchiseeAccess.Add(new EScheduleTemplateFranchiseeAccess { FranchiseeID = currentOrgRole.OrganizationId }); } else { if (rbtAllFranchisee.Checked) { objSchedule.Global = true; objSchedule.ScheduleTemplateFranchiseeAccess = null; } else { objSchedule.ScheduleTemplateFranchiseeAccess = new List <EScheduleTemplateFranchiseeAccess>(); foreach (ListItem itemtemp in chklstFranchisee.Items) { if (itemtemp.Selected) { objSchedule.ScheduleTemplateFranchiseeAccess.Add(new EScheduleTemplateFranchiseeAccess { FranchiseeID = Convert.ToInt32(itemtemp.Value) }); } } } } objSchedule.ScheduleTemplateTime = new List <EScheduleTemplateTime>(); foreach (string str in txttimeslots.Text.Split(new char[] { '\n' })) { DateTime timevar; if (DateTime.TryParse(str.Trim(), out timevar) == true) { if (objSchedule.ScheduleTemplateTime.Count > 0) { EScheduleTemplateTime objScheduleTemplateTime = objSchedule.ScheduleTemplateTime.Find(eSchedule => eSchedule.StartTime == timevar.ToString("hh:mm tt")); if (objScheduleTemplateTime != null) { objScheduleTemplateTime.AppointmentCount++; continue; } } objSchedule.ScheduleTemplateTime.Add(new EScheduleTemplateTime() { StartTime = timevar.ToString("hh:mm tt"), AppointmentCount = 1 }); } } if (objSchedule.ScheduleTemplateID > 0) { objSchedule.ModifiedByRole = false; if (currentOrgRole.CheckRole((long)Roles.FranchisorAdmin)) { objSchedule.ModifiedByRole = true; } objSchedule.ModifiedBy = currentOrgRole.OrganizationRoleUserId; } else { objSchedule.CreatedByRole = false; if (currentOrgRole.CheckRole((long)Roles.FranchisorAdmin)) { objSchedule.CreatedByRole = true; } objSchedule.CreateBy = currentOrgRole.OrganizationRoleUserId; } Int64 returnresult; if (objSchedule.ScheduleTemplateID > 0) { returnresult = masterDal.SaveScheduleTemplate(objSchedule, Convert.ToInt16(Falcon.App.Core.Enum.EOperationMode.Update)); } else { returnresult = masterDal.SaveScheduleTemplate(objSchedule, Convert.ToInt16(Falcon.App.Core.Enum.EOperationMode.Insert)); } if (returnresult == -6) { divErrorMsg.InnerText = "Template Name entered is not unique. Please provide a new name."; divErrorMsg.Visible = true; } if (returnresult > 0) { if (objSchedule.ScheduleTemplateID > 0) { ClientScript.RegisterStartupScript(typeof(string), "jscode_DisplayMsg", "DisplaySuccessMessage(false);", true); } else { ClientScript.RegisterStartupScript(typeof(string), "jscode_DisplayMsg", "DisplaySuccessMessage(true);", true); } } }