protected void frmvwAddUpdateVitalSign_ItemCommand(object sender, FormViewCommandEventArgs e)
        {
            TextBox txtTestDate = (TextBox)frmvwAddUpdateVitalSign.FindControl("txtTestDate");
            TextBox txtPulse    = (TextBox)frmvwAddUpdateVitalSign.FindControl("txtPulse");
            TextBox txtWeight   = (TextBox)frmvwAddUpdateVitalSign.FindControl("txtWeight");
            TextBox txtSBP      = (TextBox)frmvwAddUpdateVitalSign.FindControl("txtSBP");
            TextBox txtDBP      = (TextBox)frmvwAddUpdateVitalSign.FindControl("txtDBP");

            if (e.CommandName == "AddVitalSign")
            {
                DC_Message           _msg    = new DC_Message();
                DC_VitalSignsReports _objAdd = new DC_VitalSignsReports();
                _objAdd.TestDate    = Convert.ToDateTime(txtTestDate.Text);
                _objAdd.PatientID   = GetPatientID();
                _objAdd.Pulse       = Convert.ToString(txtPulse.Text);
                _objAdd.Weight      = txtWeight.Text;
                _objAdd.SBP         = txtSBP.Text;
                _objAdd.DBP         = txtDBP.Text;
                _objAdd.CreatedBy   = "Ajay";
                _objAdd.CreatedDate = DateTime.Today;
                _msg = _objDL.AddUpdateVitalSingsReports(_objAdd);
                if (_msg.StatusCode == ReadOnlyMessage.StatusCode.Success)
                {
                    BootstrapAlert.BootstrapAlertMessage(divmsg, _msg.StatusMessage, BootstrapAlertType.Success);
                    frmvwAddUpdateVitalSign.ChangeMode(FormViewMode.Insert);
                    BindGridDetails();
                }
            }
            if (e.CommandName == "UpdateVitalSign")
            {
                DC_Message           _msg    = new DC_Message();
                DC_VitalSignsReports _objAdd = new DC_VitalSignsReports();
                _objAdd.VSR_TestReportID = Guid.Parse(Convert.ToString(frmvwAddUpdateVitalSign.DataKey.Value));
                _objAdd.Pulse            = Convert.ToString(txtPulse.Text);
                _objAdd.Weight           = txtWeight.Text;
                _objAdd.TestDate         = Convert.ToDateTime(txtTestDate.Text);
                _objAdd.SBP        = txtSBP.Text;
                _objAdd.DBP        = txtDBP.Text;
                _objAdd.EditedBy   = "Ajay";
                _objAdd.EditedDate = DateTime.Today;
                _msg = _objDL.AddUpdateVitalSingsReports(_objAdd);
                if (_msg.StatusCode == ReadOnlyMessage.StatusCode.Success)
                {
                    BootstrapAlert.BootstrapAlertMessage(divmsg, _msg.StatusMessage, BootstrapAlertType.Success);
                    frmvwAddUpdateVitalSign.ChangeMode(FormViewMode.Insert);
                    BindGridDetails();
                }
            }
        }
 private void BindFormView()
 {
     try
     {
         List <DC_VitalSignsReports> _lstDC_VitalSignsReports = new List <DC_VitalSignsReports>();
         DC_VitalSignsReports        _objvsr = new DC_VitalSignsReports();
         _lstDC_VitalSignsReports.Add(_objvsr);
         frmvwAddUpdateElectrolytes.DataSource = _lstDC_VitalSignsReports;
         frmvwAddUpdateElectrolytes.DataBind();
     }
     catch (Exception)
     {
         throw;
     }
 }
        public DC_Message AddUpdateVitalSingsReports(DC_VitalSignsReports _objSave)
        {
            DC_Message _msg = new DC_Message();

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

                        if (report != null)
                        {
                            report.TestDate   = _objSave.TestDate;
                            report.IsActive   = _objSave.IsActive;
                            report.EditedBy   = _objSave.EditedBy;
                            report.EditedDate = _objSave.EditedDate;
                            report.Pulse      = _objSave.Pulse;
                            report.SBP        = _objSave.SBP;
                            report.DBP        = _objSave.DBP;
                            report.Weight     = Convert.ToDecimal(_objSave.Weight);
                            if (context.SaveChanges() == 1)
                            {
                                _msg.StatusMessage = "Vital Sign has been" + ReadOnlyMessage.strUpdatedSuccessfully;
                                _msg.StatusCode    = ReadOnlyMessage.StatusCode.Success;
                            }
                            else
                            {
                                _msg.StatusMessage = "Vital Sign has been" + ReadOnlyMessage.strFailed;
                                _msg.StatusCode    = ReadOnlyMessage.StatusCode.Failed;
                            }
                        }
                        else
                        {
                            tbl_VitalSignsReports _objnew = new tbl_VitalSignsReports();
                            _objnew.VSR_TestReportID = Guid.NewGuid();
                            _objnew.PatientID        = _objSave.PatientID;
                            _objnew.CreatedBy        = _objSave.CreatedBy;
                            _objnew.CreatedDate      = _objSave.CreatedDate;
                            _objnew.Weight           = Convert.ToDecimal(_objSave.Weight);
                            _objnew.SBP      = _objSave.SBP;
                            _objnew.DBP      = _objSave.DBP;
                            _objnew.Pulse    = _objSave.Pulse;
                            _objnew.IsActive = _objSave.IsActive;
                            _objnew.TestDate = _objSave.TestDate;

                            context.tbl_VitalSignsReports.Add(_objnew);
                            if (context.SaveChanges() == 1)
                            {
                                _msg.StatusMessage = "Vital Sign has been" + ReadOnlyMessage.strAddedSuccessfully;
                                _msg.StatusCode    = ReadOnlyMessage.StatusCode.Success;
                            }
                            else
                            {
                                _msg.StatusMessage = "Vital Sign has been" + ReadOnlyMessage.strFailed;
                                _msg.StatusCode    = ReadOnlyMessage.StatusCode.Failed;
                            }
                        }
                    }
                    else
                    {
                        tbl_VitalSignsReports _objnew = new tbl_VitalSignsReports();
                        _objnew.VSR_TestReportID = Guid.NewGuid();
                        _objnew.PatientID        = _objSave.PatientID;
                        _objnew.CreatedBy        = _objSave.CreatedBy;
                        _objnew.CreatedDate      = _objSave.CreatedDate;
                        _objnew.Weight           = Convert.ToDecimal(_objSave.Weight);
                        _objnew.SBP      = _objSave.SBP;
                        _objnew.DBP      = _objSave.DBP;
                        _objnew.Pulse    = _objSave.Pulse;
                        _objnew.IsActive = _objSave.IsActive;
                        _objnew.TestDate = _objSave.TestDate;

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