private void BindPrescriptionData() { try { List <PrescriptionCourseData> prsc = PrescriptionCourseDataBLL.GetList(); lstCourses.DataSource = prsc; lstCourses.DataBind(); List <PrescriptionCdData> prscCdData = PrescriptionCdDataBLL.GetList(); lstCD.DataSource = prscCdData; lstCD.DataBind(); List <PrescriptionCD> prsCds = PrescriptionCdBLL.GetListByPrescription(prescription.PrescriptionId); List <PrescriptionCourses> prsCourseses = PrescriptionCoursesBLL.GetListByPrescription(prescription.PrescriptionId); foreach (var item in prsCds) { lstCD.Items.FindByText(item.CdName).Selected = true; } foreach (var item in prsCourseses) { lstCourses.Items.FindByText(item.CourseName).Selected = true; } txtFinalReport.Text = prescription.Report; txtComment.Text = prescription.ConfermedComment; } catch (Exception ex) { string message = ex.Message.Replace('\n', ' ') + " for CD's Or Courses."; this.ShowHelperMessage("Warning", message, HelperNotify.NotificationType.info); } }
protected void btnUpdate_OnClick(object sender, EventArgs e) { using (TransactionScope trans = new TransactionScope()) { #region Prescription //Objects Init Prescription prsc = PrescriptionBLL.GetByCase(id); PrescriptionSession prscSession = new PrescriptionSession(); PrescriptionCD prscCD = new PrescriptionCD(); PrescriptionCourses prscCourses = new PrescriptionCourses(); //Lists for Delete purpose. List <PrescriptionSession> _prscSession = PrescriptionSessionBLL.GetListByPrescription(prsc.PrescriptionId); List <PrescriptionCourses> _prscCourse = PrescriptionCoursesBLL.GetListByPrescription(prsc.PrescriptionId); List <PrescriptionCD> _prscCd = PrescriptionCdBLL.GetListByPrescription(prsc.PrescriptionId); #region Prescription Update prsc.CaseId = id; prsc.Report = txtFinalReport.Text; prsc.Status = PrescriptionStatus.revised; //Init prsc.ConfirmedComment prsc.ConfermedComment = txtComment.Text; Thread.Sleep(150); int prescriptionId = PrescriptionBLL.UpdateByCase(prsc); #endregion //Prescription CD #region Prescription CD foreach (PrescriptionCD item in _prscCd) { PrescriptionCdBLL.Delete(item); } foreach (ListItem cdItem in lstCD.Items) { if (cdItem.Selected) { prscCD.PrescriptionId = prescription.PrescriptionId; prscCD.CdName = cdItem.Text; prscCD.Note = string.Empty; PrescriptionCdBLL.Insert(prscCD); } } #endregion //Prescription Courses lest #region Prescription Courses lest foreach (PrescriptionCourses item in _prscCourse) { PrescriptionCoursesBLL.Delete(item); } foreach (ListItem courseItem in lstCourses.Items) { if (courseItem.Selected) { prscCourses.PrescriptionId = prescription.PrescriptionId; prscCourses.CourseName = courseItem.Text; prscCourses.Notes = string.Empty; PrescriptionCoursesBLL.Insert(prscCourses); } } #endregion //Prescription Sessions #region Prescription Sessions foreach (PrescriptionSession item in _prscSession) { PrescriptionSessionBLL.Delete(item); } foreach (RepeaterItem sessionItem in repeatSessions.Items) { prscSession.PrescriptionId = prescription.PrescriptionId; CheckBox chkSession = (CheckBox)sessionItem.FindControl("chkCourse"); if (chkSession.Checked) { //Session Name TextBox txtSessionName = (TextBox)sessionItem.FindControl("txtSessionName"); prscSession.SessionName = ""; prscSession.SessionName = txtSessionName.Text; //Session Counter TextBox txtCounter = (TextBox)sessionItem.FindControl("txtCounter"); prscSession.Number = Convert.ToInt32(txtCounter.Text); TextBox txtSessionComment = (TextBox)sessionItem.FindControl("txtComment"); prscSession.Comment = ""; prscSession.Comment = txtSessionComment.Text; PrescriptionSessionBLL.Insert(prscSession); } } #endregion #endregion trans.Complete(); //session fore firing the jquery notify string message = "The case has been revised successfully"; Response.Redirect("/Cases/view.aspx?message=" + message, false); } }