private void BindFormView()
 {
     try
     {
         List <DC_ThyroidProfileReports> _lstDC_VitalSignsReports = new List <DC_ThyroidProfileReports>();
         DC_ThyroidProfileReports        _objvsr = new DC_ThyroidProfileReports();
         _lstDC_VitalSignsReports.Add(_objvsr);
         frmvwAddUpdateThyroidProfile.DataSource = _lstDC_VitalSignsReports;
         frmvwAddUpdateThyroidProfile.DataBind();
     }
     catch (Exception)
     {
         throw;
     }
 }
        protected void frmvwAddUpdateThyroidProfile_ItemCommand(object sender, FormViewCommandEventArgs e)
        {
            TextBox txtTestDate = (TextBox)frmvwAddUpdateThyroidProfile.FindControl("txtTestDate");
            TextBox txtFreeT3   = (TextBox)frmvwAddUpdateThyroidProfile.FindControl("txtFreeT3");
            TextBox txtFreeT4   = (TextBox)frmvwAddUpdateThyroidProfile.FindControl("txtFreeT4");
            TextBox txtTSH      = (TextBox)frmvwAddUpdateThyroidProfile.FindControl("txtTSH");

            if (e.CommandName == "AddThyroidProfile")
            {
                DC_Message _msg = new DC_Message();
                DC_ThyroidProfileReports _objAdd = new DC_ThyroidProfileReports();
                _objAdd.TestDate    = Convert.ToDateTime(txtTestDate.Text);
                _objAdd.PatientID   = GetPatientID();
                _objAdd.FreeT3      = txtFreeT3.Text;
                _objAdd.FreeT4      = txtFreeT4.Text;
                _objAdd.TSH         = txtTSH.Text;
                _objAdd.CreatedBy   = "Ajay";
                _objAdd.CreatedDate = DateTime.Today;
                _msg = _objDL.AddUpdateThyroidProfileReports(_objAdd);
                if (_msg.StatusCode == ReadOnlyMessage.StatusCode.Success)
                {
                    BootstrapAlert.BootstrapAlertMessage(divmsg, _msg.StatusMessage, BootstrapAlertType.Success);
                    frmvwAddUpdateThyroidProfile.ChangeMode(FormViewMode.Insert);
                    BindGridDetails();
                }
            }
            if (e.CommandName == "UpdateThyroidProfile")
            {
                DC_Message _msg = new DC_Message();
                DC_ThyroidProfileReports _objAdd = new DC_ThyroidProfileReports();
                _objAdd.TPR_TestReportID = Guid.Parse(Convert.ToString(frmvwAddUpdateThyroidProfile.DataKey.Value));
                _objAdd.TestDate         = Convert.ToDateTime(txtTestDate.Text);
                _objAdd.PatientID        = GetPatientID();
                _objAdd.FreeT3           = txtFreeT3.Text;
                _objAdd.FreeT4           = txtFreeT4.Text;
                _objAdd.TSH        = txtTSH.Text;
                _objAdd.EditedBy   = "Ajay";
                _objAdd.EditedDate = DateTime.Today;
                _msg = _objDL.AddUpdateThyroidProfileReports(_objAdd);
                if (_msg.StatusCode == ReadOnlyMessage.StatusCode.Success)
                {
                    BootstrapAlert.BootstrapAlertMessage(divmsg, _msg.StatusMessage, BootstrapAlertType.Success);
                    frmvwAddUpdateThyroidProfile.ChangeMode(FormViewMode.Insert);
                    BindGridDetails();
                }
            }
        }
Esempio n. 3
0
        public DC_Message AddUpdateThyroidProfileReports(DC_ThyroidProfileReports _objSave)
        {
            DC_Message _msg = new DC_Message();

            try
            {
                using (CLMS_DBEntities context = new CLMS_DBEntities())
                {
                    if (_objSave.TPR_TestReportID != null && _objSave.TPR_TestReportID != Guid.Empty)
                    {
                        var isDuplicate = (from x in context.tbl_ThyroidProfileReports
                                           where x.TPR_TestReportID != _objSave.TPR_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_ThyroidProfileReports.Find(_objSave.TPR_TestReportID);

                        if (report != null)
                        {
                            report.TestDate   = _objSave.TestDate;
                            report.IsActive   = _objSave.IsActive;
                            report.EditedBy   = _objSave.EditedBy;
                            report.EditedDate = _objSave.EditedDate;
                            report.FreeT3     = _objSave.FreeT3;
                            report.FreeT4     = _objSave.FreeT4;
                            report.TSH        = _objSave.TSH;
                            if (context.SaveChanges() == 1)
                            {
                                _msg.StatusMessage = "Thyroid Profile Reports has been" + ReadOnlyMessage.strUpdatedSuccessfully;
                                _msg.StatusCode    = ReadOnlyMessage.StatusCode.Success;
                            }
                            else
                            {
                                _msg.StatusMessage = "Thyroid Profile Reports has been" + ReadOnlyMessage.strFailed;
                                _msg.StatusCode    = ReadOnlyMessage.StatusCode.Failed;
                            }
                        }
                        else
                        {
                            tbl_ThyroidProfileReports _objnew = new tbl_ThyroidProfileReports();
                            _objnew.TPR_TestReportID = Guid.NewGuid();
                            _objnew.PatientID        = _objSave.PatientID;
                            _objnew.CreatedBy        = _objSave.CreatedBy;
                            _objnew.CreatedDate      = _objSave.CreatedDate;
                            _objnew.FreeT3           = _objSave.FreeT3;
                            _objnew.FreeT4           = _objSave.FreeT4;
                            _objnew.TSH      = _objSave.TSH;
                            _objnew.IsActive = _objSave.IsActive;
                            _objnew.TestDate = _objSave.TestDate;

                            context.tbl_ThyroidProfileReports.Add(_objnew);
                            if (context.SaveChanges() == 1)
                            {
                                _msg.StatusMessage = "Thyroid Profile Reports has been" + ReadOnlyMessage.strAddedSuccessfully;
                                _msg.StatusCode    = ReadOnlyMessage.StatusCode.Success;
                            }
                            else
                            {
                                _msg.StatusMessage = "Thyroid Profile Reports has been" + ReadOnlyMessage.strFailed;
                                _msg.StatusCode    = ReadOnlyMessage.StatusCode.Failed;
                            }
                        }
                    }
                    else
                    {
                        tbl_ThyroidProfileReports _objnew = new tbl_ThyroidProfileReports();
                        _objnew.TPR_TestReportID = Guid.NewGuid();
                        _objnew.PatientID        = _objSave.PatientID;
                        _objnew.CreatedBy        = _objSave.CreatedBy;
                        _objnew.CreatedDate      = _objSave.CreatedDate;
                        _objnew.FreeT3           = _objSave.FreeT3;
                        _objnew.FreeT4           = _objSave.FreeT4;
                        _objnew.TSH      = _objSave.TSH;
                        _objnew.IsActive = _objSave.IsActive;
                        _objnew.TestDate = _objSave.TestDate;

                        context.tbl_ThyroidProfileReports.Add(_objnew);
                        if (context.SaveChanges() == 1)
                        {
                            _msg.StatusMessage = "Thyroid Profile Reports has been" + ReadOnlyMessage.strAddedSuccessfully;
                            _msg.StatusCode    = ReadOnlyMessage.StatusCode.Success;
                        }
                        else
                        {
                            _msg.StatusMessage = "Thyroid Profile Reports has been" + ReadOnlyMessage.strFailed;
                            _msg.StatusCode    = ReadOnlyMessage.StatusCode.Failed;
                        }
                    }
                }
            }
            catch (Exception ex) { }
            return(_msg);
        }