protected void frmvwAddUpdateKidneyFunction_ItemCommand(object sender, FormViewCommandEventArgs e) { TextBox txtTestDate = (TextBox)frmvwAddUpdateKidneyFunction.FindControl("txtTestDate"); TextBox txtSCreatinine = (TextBox)frmvwAddUpdateKidneyFunction.FindControl("txtSCreatinine"); TextBox txtUrineACR = (TextBox)frmvwAddUpdateKidneyFunction.FindControl("txtUrineACR"); TextBox txtUrea = (TextBox)frmvwAddUpdateKidneyFunction.FindControl("txtUrea"); TextBox txtBUN = (TextBox)frmvwAddUpdateKidneyFunction.FindControl("txtBUN"); TextBox txtSUricAcid = (TextBox)frmvwAddUpdateKidneyFunction.FindControl("txtSUricAcid"); if (e.CommandName == "AddKidneyFunction") { DC_Message _msg = new DC_Message(); DC_KidneyFunctionsReports _objAdd = new DC_KidneyFunctionsReports(); _objAdd.TestDate = Convert.ToDateTime(txtTestDate.Text); _objAdd.KFR_TestReportID = Guid.NewGuid(); _objAdd.PatientID = GetPatientID(); _objAdd.SCreatinine = txtSCreatinine.Text; _objAdd.UrineACR = txtUrineACR.Text; _objAdd.Urea = txtUrea.Text; _objAdd.Bun = txtBUN.Text; _objAdd.SUricAcid = txtSUricAcid.Text; _objAdd.CreatedBy = "Ajay"; _objAdd.CreatedDate = DateTime.Today; _msg = _objDL.AddUpdateKidneyFunctionsReports(_objAdd); if (_msg.StatusCode == ReadOnlyMessage.StatusCode.Success) { BootstrapAlert.BootstrapAlertMessage(divmsg, _msg.StatusMessage, BootstrapAlertType.Success); frmvwAddUpdateKidneyFunction.ChangeMode(FormViewMode.Insert); BindGridDetails(); } } if (e.CommandName == "UpdateKidneyFunction") { DC_Message _msg = new DC_Message(); DC_KidneyFunctionsReports _objAdd = new DC_KidneyFunctionsReports(); _objAdd.KFR_TestReportID = Guid.Parse(Convert.ToString(frmvwAddUpdateKidneyFunction.DataKey.Value)); _objAdd.TestDate = Convert.ToDateTime(txtTestDate.Text); _objAdd.SCreatinine = txtSCreatinine.Text; _objAdd.UrineACR = txtUrineACR.Text; _objAdd.Urea = txtUrea.Text; _objAdd.Bun = txtBUN.Text; _objAdd.SUricAcid = txtSUricAcid.Text; _objAdd.EditedBy = "Ajay"; _objAdd.EditedDate = DateTime.Today; _msg = _objDL.AddUpdateKidneyFunctionsReports(_objAdd); if (_msg.StatusCode == ReadOnlyMessage.StatusCode.Success) { BootstrapAlert.BootstrapAlertMessage(divmsg, _msg.StatusMessage, BootstrapAlertType.Success); frmvwAddUpdateKidneyFunction.ChangeMode(FormViewMode.Insert); BindGridDetails(); } } }
private void BindFormView() { try { List <DC_KidneyFunctionsReports> _lstDC_KidneyFunctionsReports = new List <DC_KidneyFunctionsReports>(); DC_KidneyFunctionsReports _objvsr = new DC_KidneyFunctionsReports(); _lstDC_KidneyFunctionsReports.Add(_objvsr); frmvwAddUpdateKidneyFunction.DataSource = _lstDC_KidneyFunctionsReports; frmvwAddUpdateKidneyFunction.DataBind(); } catch (Exception) { throw; } }
public DC_Message AddUpdateKidneyFunctionsReports(DC_KidneyFunctionsReports _objSave) { DC_Message _msg = new DC_Message(); try { using (CLMS_DBEntities context = new CLMS_DBEntities()) { if (_objSave.KFR_TestReportID != null && _objSave.KFR_TestReportID != Guid.Empty) { var isDuplicate = (from x in context.tbl_KidneyFunctionsReports where x.KFR_TestReportID != _objSave.KFR_TestReportID && x.PatientID == x.PatientID && x.TestDate == _objSave.TestDate select x).Count() == 0 ? false : true; if (isDuplicate) { _msg.StatusMessage = "Report " + ReadOnlyMessage.strAlreadyExist; _msg.StatusCode = ReadOnlyMessage.StatusCode.Duplicate; return(_msg); } var report = context.tbl_KidneyFunctionsReports.Find(_objSave.KFR_TestReportID); if (report != null) { report.TestDate = _objSave.TestDate; report.IsActive = _objSave.IsActive; report.EditedBy = _objSave.EditedBy; report.EditedDate = _objSave.EditedDate; report.KFR_TestReportID = _objSave.KFR_TestReportID; report.SCreatinine = _objSave.SCreatinine; report.UrineACR = _objSave.UrineACR; report.Urea = _objSave.Urea; report.Bun = _objSave.Bun; report.SUricAcid = _objSave.SUricAcid; if (context.SaveChanges() == 1) { _msg.StatusMessage = "Kidney Function Report has been" + ReadOnlyMessage.strUpdatedSuccessfully; _msg.StatusCode = ReadOnlyMessage.StatusCode.Success; } else { _msg.StatusMessage = "Kidney Function Report has been" + ReadOnlyMessage.strFailed; _msg.StatusCode = ReadOnlyMessage.StatusCode.Failed; } } else { tbl_KidneyFunctionsReports _objnew = new tbl_KidneyFunctionsReports(); _objnew.KFR_TestReportID = Guid.NewGuid(); _objnew.PatientID = _objSave.PatientID; _objnew.TestDate = _objSave.TestDate; _objnew.CreatedBy = _objSave.CreatedBy; _objnew.CreatedDate = _objSave.CreatedDate; _objnew.KFR_TestReportID = _objSave.KFR_TestReportID; _objnew.SCreatinine = _objSave.SCreatinine; _objnew.UrineACR = _objSave.UrineACR; _objnew.Urea = _objSave.Urea; _objnew.Bun = _objSave.Bun; _objnew.SUricAcid = _objSave.SUricAcid; context.tbl_KidneyFunctionsReports.Add(_objnew); if (context.SaveChanges() == 1) { _msg.StatusMessage = "Kidney Function Report has been" + ReadOnlyMessage.strAddedSuccessfully; _msg.StatusCode = ReadOnlyMessage.StatusCode.Success; } else { _msg.StatusMessage = "Kidney Function Report has been" + ReadOnlyMessage.strFailed; _msg.StatusCode = ReadOnlyMessage.StatusCode.Failed; } } } else { tbl_KidneyFunctionsReports _objnew = new tbl_KidneyFunctionsReports(); _objnew.KFR_TestReportID = Guid.NewGuid(); _objnew.PatientID = _objSave.PatientID; _objnew.CreatedBy = _objSave.CreatedBy; _objnew.CreatedDate = _objSave.CreatedDate; _objnew.TestDate = _objSave.TestDate; _objnew.KFR_TestReportID = _objSave.KFR_TestReportID; _objnew.SCreatinine = _objSave.SCreatinine; _objnew.UrineACR = _objSave.UrineACR; _objnew.Urea = _objSave.Urea; _objnew.Bun = _objSave.Bun; _objnew.SUricAcid = _objSave.SUricAcid; context.tbl_KidneyFunctionsReports.Add(_objnew); if (context.SaveChanges() == 1) { _msg.StatusMessage = "Kidney Function Report has been" + ReadOnlyMessage.strAddedSuccessfully; _msg.StatusCode = ReadOnlyMessage.StatusCode.Success; } else { _msg.StatusMessage = "Kidney Function Report has been" + ReadOnlyMessage.strFailed; _msg.StatusCode = ReadOnlyMessage.StatusCode.Failed; } } } } catch (Exception ex) { } return(_msg); }