protected void btCreateNewP_Click(object sender, EventArgs e) { if (ModelState.IsValid) { PatientBO PatientBO = new PatientBO(); Patient newPatient = new Patient(); string hcpFirstName = txtPFirstName.Text.Trim(); if (!string.IsNullOrEmpty(hcpFirstName)) { newPatient.FirstName = hcpFirstName; newPatient.LastName = txtPLastName.Text.Trim(); newPatient.HealthCardNo = txtPHealthCardNo.Text.Trim(); newPatient.Address1 = txtPAddress1.Text.Trim(); newPatient.Address2 = txtPAddress2.Text.Trim(); newPatient.HomePhone = txtPHomePhone.Text.Trim(); newPatient.CellPhone = txtPCellPhone.Text.Trim(); newPatient.DateOfBirth = DateTime.Parse(txtPDateOfBirth.Text.Trim()); newPatient.Active = cbPActive.Checked; newPatient.DateEntered = DateTime.Now; newPatient.UserIdEntered = 0; PatientBO.Add(newPatient); PatientBO.Save(); txtPFirstName.Text = ""; cbPActive.Checked = false; // lblMasterStatus //this.Master.ActionStatusMessage = string msg = string.Format("Patient {0} created.", hcpFirstName); Response.Redirect("~/PatientType/PatientList.aspx?msg=" + msg); } else { string str = string.Format("First Name field Can't be empty."); lblMsg.Text = str; return; } } }
protected void btUpdateP_Click(object sender, EventArgs e) { if (Page.IsPostBack) { PatientBO PatientBO = new PatientBO(); DataLayer.Patient editPatient = new Patient(); int PatientId = Convert.ToInt32(Session["PrimaryKeyPatient"]); editPatient = PatientBO.Get(PatientId); if (editPatient == null) { string str = string.Format("Patient Type with Id {0} not found for Update.", PatientId); return; } string PFirstName = txtPFirstName.Text.Trim(); if (!string.IsNullOrEmpty(PFirstName)) { editPatient.FirstName = PFirstName; editPatient.Active = cbPActive.Checked; editPatient.DateEntered = DateTime.Now; editPatient.UserIdEntered = 0; PatientBO.Edit(editPatient); PatientBO.Save(); txtPFirstName.Text = ""; cbPActive.Checked = false; string msg = string.Format("Patient {0} Updated.", PFirstName); Response.Redirect("~/PatientType/PatientList.aspx?msg=" + msg); } else { string str = string.Format("First Name field Can't be empty."); lblMsg.Text = str; return; } } }