protected void btnsave_Click(object sender, EventArgs e) { objLHRDAO = new LHR_Visit_ImportDAO(); objLHR = new LHR_Visit_Import(); DateTime dt = new DateTime(); string timed = ""; if (txtPatientFirstName.Text == string.Empty || txtPatientFirstName.Text == "" || txtPatientLastName.Text == string.Empty || txtPatientLastName.Text == "" || txtPatientID.Text == string.Empty || txtPatientID.Text == "" || txtPatientAppoinmentID.Text == string.Empty || txtPatientAppoinmentID.Text == "" || txtProcedureCode.Text == string.Empty || txtProcedureCode.Text == "" || txtProcedureDesc.Text == string.Empty || txtProcedureDesc.Text == "" || timeVisitTime.Value == null || cmbState.SelectedIndex == -1 || cmbModality.SelectedIndex == -1 || cmbBoxCaseType.SelectedIndex == -1 || cmbGender.SelectedIndex == -1) { return; } objLHRDAO.SZ_First_Name = txtPatientFirstName.Text; objLHRDAO.SZ_Last_Name = txtPatientLastName.Text; objLHRDAO.SZ_Patient_ID = txtPatientID.Text; objLHRDAO.SZ_Case_ID = txtPatientAppoinmentID.Text; if (dtDOB.Value != null) { dt = Convert.ToDateTime(dtDOB.Value); objLHRDAO.SZ_Date_Of_Birth = dt.ToString("MM/dd/yyyy"); } objLHRDAO.SZ_Gender = Convert.ToString(cmbGender.SelectedItem.Value); objLHRDAO.SZ_Address = txtPatientAddr.Text; objLHRDAO.SZ_Address2 = txtPatientAddr2.Text; objLHRDAO.SZ_City = txtPatientCity.Text; objLHRDAO.SZ_Zip = txtPatientZipCode.Text; if (cmbBoxCaseType.SelectedIndex != -1) { objLHRDAO.SZ_Case_Type = Convert.ToString(cmbBoxCaseType.SelectedItem); } objLHRDAO.SZ_SSNO = txtPatientSSNO.Text; if (cmbState.SelectedIndex != -1) { objLHRDAO.SZ_State = Convert.ToString(cmbState.SelectedItem.Value); } if (dtDateOfAppointment.Value != null) { dt = Convert.ToDateTime(dtDateOfAppointment.Value); objLHRDAO.SZ_Date_Of_Appointment = dt.ToString("MM/dd/yyyy"); } if (timeVisitTime.Value != null) { DateTime convertedDate = DateTime.Parse(timeVisitTime.Value.ToString()); timed = convertedDate.ToString("HH:mm"); try { string hr = convertedDate.ToString("HH"); string min = convertedDate.ToString("mm"); if (Convert.ToInt16(hr) < 12) { objLHRDAO.SZ_Visit_Time = hr + ":" + min + " AM"; } else { hr = Convert.ToString((Convert.ToInt32(hr) % 12)); objLHRDAO.SZ_Visit_Time = hr + ":" + min + " PM"; } } catch (Exception ex) { objLHRDAO.SZ_Visit_Time = timed + " AM"; } } if (dtDateOfAcci.Value != null) { dt = Convert.ToDateTime(dtDateOfAcci.Value); objLHRDAO.SZ_Date_Of_Accident = dt.ToString("MM/dd/yyyy"); } if (cmbModality.SelectedIndex != -1) { objLHRDAO.SZ_Modality = Convert.ToString(cmbModality.SelectedItem.Value); } if (cmdBookFacility.SelectedIndex != -1) { objLHRDAO.SZ_Book_Facility = Convert.ToString(cmdBookFacility.SelectedItem.Value); } objLHRDAO.SZ_Procedure_Code = txtProcedureCode.Text; objLHRDAO.SZ_Procedure_Desc = txtProcedureDesc.Text; objLHRDAO.Company_ID = CompanyID; objLHRDAO.User_ID = UserID; string status = objLHR.saveLHRData(objLHRDAO); if (status == "inserted") { usrMessage.PutMessage(GetLocalResourceObject("manualimport.visit.add.success").ToString()); usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage); usrMessage.Show(); } else { usrMessage.PutMessage(GetLocalResourceObject("manualimport.visit.add.error").ToString()); usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_ErrorMessage); usrMessage.Show(); } ClearControl(); }
public string saveLHRData(LHR_Visit_ImportDAO objLHR) { conn = new SqlConnection(strConn); ds = new DataSet(); bool manualImport = false; SqlTransaction tr; conn.Open(); tr = conn.BeginTransaction(); string strResult = ""; try { comm = new SqlCommand("sp_insert_lhr_import", conn); comm.CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimeOut"].ToString()); comm.CommandType = CommandType.StoredProcedure; comm.Transaction = tr; comm.Parameters.AddWithValue("@sz_First_Name", objLHR.SZ_First_Name); comm.Parameters.AddWithValue("@sz_Last_Name", objLHR.SZ_Last_Name); comm.Parameters.AddWithValue("@sz_Patient_ID", objLHR.SZ_Patient_ID); comm.Parameters.AddWithValue("@sz_Date_Of_Birth", objLHR.SZ_Date_Of_Birth); comm.Parameters.AddWithValue("@sz_Gender", objLHR.SZ_Gender); comm.Parameters.AddWithValue("@sz_Address", objLHR.SZ_Address); comm.Parameters.AddWithValue("@sz_Address2", objLHR.SZ_Address2); comm.Parameters.AddWithValue("@sz_City", objLHR.SZ_City); comm.Parameters.AddWithValue("@sz_State", objLHR.SZ_State); comm.Parameters.AddWithValue("@sz_Zip", objLHR.SZ_Zip); comm.Parameters.AddWithValue("@sz_Case_Type", objLHR.SZ_Case_Type); comm.Parameters.AddWithValue("@sz_SSNO", objLHR.SZ_SSNO); comm.Parameters.AddWithValue("@sz_Date_Of_Appointment", objLHR.SZ_Date_Of_Appointment); comm.Parameters.AddWithValue("@sz_Visit_Time", objLHR.SZ_Visit_Time); comm.Parameters.AddWithValue("@sz_Procedure_Code", objLHR.SZ_Procedure_Code); comm.Parameters.AddWithValue("@sz_Procedure_Desc", objLHR.SZ_Procedure_Desc); comm.Parameters.AddWithValue("@sz_Date_Of_Accident", objLHR.SZ_Date_Of_Accident); comm.Parameters.AddWithValue("@sz_Book_Facility", objLHR.SZ_Book_Facility); comm.Parameters.AddWithValue("@sz_Modality", objLHR.SZ_Modality); comm.Parameters.AddWithValue("@CaseID", objLHR.SZ_Case_ID); comm.Parameters.AddWithValue("@sz_Company_ID", objLHR.Company_ID); comm.Parameters.AddWithValue("@sz_User_ID", objLHR.User_ID); dr = comm.ExecuteReader(); while (dr.Read()) { strResult = dr[0].ToString(); } dr.Close(); if (strResult == "inserted") { comm = new SqlCommand("sp_get_data_to_import", conn); comm.CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimeOut"].ToString()); comm.CommandType = CommandType.StoredProcedure; comm.Transaction = tr; comm.Parameters.AddWithValue("@CaseID", objLHR.SZ_Case_ID); da = new SqlDataAdapter(comm); da.Fill(ds); ManualEntry.AddManualVisits objMan = new ManualEntry.AddManualVisits(); manualImport = objMan.ScanAndAddPatient(ds, objLHR.Company_ID); comm = new SqlCommand("sp_upadte_import_status", conn); comm.CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimeOut"].ToString()); comm.CommandType = CommandType.StoredProcedure; comm.Transaction = tr; comm.Parameters.AddWithValue("@sz_update_status", "Success"); comm.Parameters.AddWithValue("@CaseID", objLHR.SZ_Case_ID); comm.ExecuteNonQuery(); if (manualImport == false) { tr.Rollback(); } else { tr.Commit(); } } else { tr.Rollback(); } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); tr.Rollback(); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } return(strResult); }