protected void btnSave_Click(object sender, EventArgs e) { try { Client client = new Client(); #region CLient Data //Load the data into the object //Re Initialize int id = Convert.ToInt32(Request.QueryString["id"]); client.CLientId = id; client.FirstName = txtFName.Text; client.MiddleName = txtMiddleName.Text; client.SurrName = txtSurrName.Text; client.City = txtCity.Text; client.Country = drpCountry.SelectedItem.Text; client.Address = txtAdress.Text; client.Telephone = txtTelephone.Text; client.Mob = txtMob.Text; client.DateOfBirth = Convert.ToDateTime(txtDateOf.Text); client.Gender = drpGender.SelectedItem.Text; client.Notes = txtNotes.Text; client.CreatedBy = ClientBLL.GetItem(id).CreatedBy; client.CreationDate = ClientBLL.GetItem(id).CreationDate; client.IsActive = IsActive.Active; #endregion #region Relation Data if (Application["flag"] == "true") { if (rdlst.SelectedIndex == 0) { Relatives relative = new Relatives(); relative.ClientId = Convert.ToInt32(Request.QueryString["id"]); relative.CLientRelId = Convert.ToInt32(drpClients.SelectedItem.Value); relative.RelationName = txtRelName.Text; RelativesBLL.Update(relative); client.HasArelation = HasRelations.yes; clientID = ClientBLL.Update(client); } } else { if (rdlst.SelectedIndex == 0) { Relatives rel = new Relatives(); rel.ClientId = Convert.ToInt32(Request.QueryString["id"]); rel.CLientRelId = Convert.ToInt32(drpClients.SelectedItem.Value); rel.RelationName = txtRelName.Text; RelativesBLL.Insert(rel); client.HasArelation = HasRelations.yes; clientID = ClientBLL.Update(client); } else { try { List <Relatives> rel = RelativesBLL.GetByClient(Convert.ToInt32(Request.QueryString["id"])); foreach (Relatives item in rel) { RelativesBLL.Delete(item); } client.HasArelation = HasRelations.no; } catch (Exception) { } clientID = ClientBLL.Update(client); } } #endregion //session fore firing the jquery notify string message = "CLient has been Updated"; Response.Redirect("/Clients/Clients.aspx?message=" + message, false); } catch (Exception ex) { string message = ex.Message.Replace("\n", " "); Response.Redirect("/Clients/Clients.aspx?message=" + message, false); } }
protected void btnSendToConfirm_OnClick(object sender, EventArgs e) { try { using (TransactionScope trans = new TransactionScope()) { #region Objects //Client Object Client client = new Client(); //Case object ClientCase clientCase = new ClientCase(); //Session ibject Sessions casesession = new Sessions(); SessionQuestion sessionQuestions = new SessionQuestion(); //Prescription Object Prescription prsc = new Prescription(); PrescriptionSession prescSession = new PrescriptionSession(); PrescriptionCourses prscCourse = new PrescriptionCourses(); PrescriptionCD prscCd = new PrescriptionCD(); #endregion #region CLient and relation data //Load the data into the object client.FirstName = txtFName.Text; client.MiddleName = txtMiddleName.Text; client.SurrName = txtSurrName.Text; client.CreationDate = DateTime.Now; client.CreatedBy = userName; client.IsActive = IsActive.Active; client.Notes = txtNotes.Text; //ClientDetail client.CLientId = client.CLientId; client.City = txtCity.Text; client.Country = drpCountry.Text; client.Address = txtAdress.Text; client.Telephone = txtTelephone.Text; client.Mob = txtMob.Text; client.DateOfBirth = Convert.ToDateTime(txtDateOf.Text); client.Gender = drpGender.Text; if (HasArelation()) { client.HasArelation = HasRelations.yes; } else { client.HasArelation = HasRelations.no; } client.CLientId = ClientBLL.Insert(client); Thread.Sleep(150); #region Relation Data if (HasArelation()) { Relatives relative = new Relatives(); relative.ClientId = client.CLientId; relative.CLientRelId = Convert.ToInt32(drpClients.SelectedItem.Value); relative.RelationName = txtRelName.Text; Thread.Sleep(150); RelativesBLL.Insert(relative); } #endregion #endregion #region Client case clientCase.ClientId = client.CLientId; clientCase.CaseNumber = txtCaseNumber.Text; clientCase.CaseStatus = CaseStatus.opened; clientCase.dateTime = DateTime.Now; Thread.Sleep(150); clientCase.CaseId = ClientCaseBLL.Insert(clientCase); #endregion #region Questions and answers //Session Insertion casesession.CaseId = clientCase.CaseId; casesession.Report = txtReport.Text; casesession.Notes = string.Empty; //Session Questions Insertion Thread.Sleep(150); int sessionId = SessionBLL.Insert(casesession); foreach (RepeaterItem item in questionRepeater.Items) { sessionQuestions.SessionId = sessionId; Label lblQuestion = (Label)item.FindControl("lblQuestion"); sessionQuestions.Question = lblQuestion.Text; TextBox txtAns = (TextBox)item.FindControl("txtAns"); sessionQuestions.Answer = ""; sessionQuestions.Answer = txtAns.Text; if (txtAns != null) { SessionQuestionBLL.Insert(sessionQuestions); } } #endregion #region Prescription #region Prescription Insertion prsc.CaseId = clientCase.CaseId; prsc.Report = txtFinalReport.Text; prsc.Status = PrescriptionStatus.onhold; //Init prsc.ConfirmedComment prsc.ConfermedComment = string.Empty; Thread.Sleep(150); int prescriptionId = PrescriptionBLL.Insert(prsc); #endregion //Prescription CD #region Prescription CD foreach (ListItem cdItem in lstCD.Items) { if (cdItem.Selected) { prscCd.PrescriptionId = prescriptionId; prscCd.CdName = cdItem.Text; prscCd.Note = string.Empty; PrescriptionCdBLL.Insert(prscCd); } } #endregion //Prescription Coursesls #region Prescription Courseslst foreach (ListItem courseItem in lstCourses.Items) { if (courseItem.Selected) { prscCourse.PrescriptionId = prescriptionId; prscCourse.CourseName = courseItem.Text; prscCourse.Notes = string.Empty; PrescriptionCoursesBLL.Insert(prscCourse); } } #endregion //Prescription Sessions #region Prescription Sessions foreach (RepeaterItem sessionItem in repeatSessions.Items) { prescSession.PrescriptionId = prescriptionId; CheckBox chkSession = (CheckBox)sessionItem.FindControl("chkCourse"); if (chkSession.Checked) { //Session Name TextBox txtSessionName = (TextBox)sessionItem.FindControl("txtSessionName"); prescSession.SessionName = ""; prescSession.SessionName = txtSessionName.Text; //Session Counter TextBox txtCounter = (TextBox)sessionItem.FindControl("txtCounter"); prescSession.Number = Convert.ToInt32(txtCounter.Text); TextBox txtComment = (TextBox)sessionItem.FindControl("txtComment"); prescSession.Comment = ""; prescSession.Comment = txtComment.Text; PrescriptionSessionBLL.Insert(prescSession); } } #endregion #endregion trans.Complete(); //session fore firing the jquery notify string message = "CLient has been saved and waiting to be revised"; Response.Redirect("/Clients/Clients.aspx?message=" + message, false); } } catch (Exception ex) { string message = ex.Message; Response.Redirect("/Clients/Clients.aspx?message=" + message, false); } }