private void tsmUpdateBarcode_Click(object sender, EventArgs e) { try { if (TResultDetail.CreateQuery().WHERE(TResultDetail.Columns.TestId, grdTestInfo.GetValue("Test_ID")).GetRecordCount() > 0) { Utility.ShowMsg("Đăng ký đã có kết quả. Không được sửa barcode !"); return; } frmInput_Update_Barcode oForm = new frmInput_Update_Barcode(); if (SysPara.AutoGenerateBarcode == 2) { oForm.vTestType_ID = Utility.Int32Dbnull(grdTestInfo.GetValue("TestType_ID")); } oForm.txtBarcode.Text = Utility.sDbnull(grdTestInfo.GetValue("Barcode")); oForm.txtTestType_Name.Text = Utility.sDbnull(grdTestInfo.GetValue("TestType_Name")); oForm.vPatient_ID = patientId; oForm.ShowDialog(); if (string.IsNullOrEmpty(oForm.txtBarcode.Text) | oForm.txtBarcode.Text == Utility.sDbnull(grdTestInfo.GetValue("Barcode"))) { return; } new Update(TTestInfo.Schema.Name).Set(TTestInfo.Columns.Barcode).EqualTo(oForm.txtBarcode.Text). Where(TTestInfo.Columns.TestId).IsEqualTo(Utility.Int32Dbnull(grdTestInfo.GetValue("Test_ID"))). Execute(); new Update(TRegList.Schema.Name).Set(TTestInfo.Columns.Barcode).EqualTo(oForm.txtBarcode.Text). Where(TRegList.Columns.TestId).IsEqualTo(Utility.Int32Dbnull(grdTestInfo.GetValue("Test_ID"))). Execute(); grdTestInfo.CurrentRow.Cells["Barcode"].Value = oForm.txtBarcode.Text; } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
private void tsmDelTestInfo_Click(object sender, EventArgs e) { try { if ( TResultDetail.CreateQuery().WHERE(TResultDetail.Columns.TestId, Utility.Int32Dbnull( grdTestInfo.GetValue(TTestInfo.Columns.TestId))). GetRecordCount() > 0) { Utility.ShowMsg("Đã có kết quả. Không được xóa !"); return; } if (Utility.AcceptQuestion("Xóa " + grdTestInfo.GetValue(TTestTypeList.Columns.TestTypeName), "Thông báo", true)) { new Delete().From(TTestInfo.Schema.Name).Where(TTestInfo.Columns.TestId). IsEqualTo(Utility.Int32Dbnull(grdTestInfo.GetValue("Test_ID"))).Execute(); new Delete().From(TRegList.Schema.Name).Where(TRegList.Columns.TestId). IsEqualTo(Utility.Int32Dbnull(grdTestInfo.GetValue("Test_ID"))).Execute(); grdTestInfo.CurrentRow.Delete(); grdTestInfo.UpdateData(); dtTestInfo.AcceptChanges(); } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
/// <summary> /// hàm thực hiện update UpdateResultDetail dữ liệu /// </summary> /// <param name="resultDetail"></param> /// <returns></returns> public void UpdateResultDetail(TResultDetail resultDetail) { int record = -1; Query _Query = TResultDetail.CreateQuery(); if (TResultDetail.FetchByID(resultDetail.TestDetailId) != null) { new Update(TResultDetail.Schema) .Set(TResultDetail.Columns.Barcode).EqualTo(resultDetail.Barcode) .Set(TResultDetail.Columns.ParaName).EqualTo(resultDetail.ParaName) .Set(TResultDetail.Columns.Note).EqualTo(resultDetail.Note) .Set(TResultDetail.Columns.PrintData).EqualTo(resultDetail.PrintData) .Set(TResultDetail.Columns.TestResult).EqualTo(resultDetail.TestResult) .Set(TResultDetail.Columns.TestId).EqualTo(resultDetail.TestId) .Set(TResultDetail.Columns.TestTypeId).EqualTo(resultDetail.TestTypeId) .Set(TResultDetail.Columns.PatientId).EqualTo(resultDetail.PatientId) .Set(TResultDetail.Columns.TestDate).EqualTo(resultDetail.TestDate) .Set(TResultDetail.Columns.TestSequence).EqualTo(resultDetail.TestSequence) .Set(TResultDetail.Columns.ParaStatus).EqualTo(resultDetail.ParaStatus) .Set(TResultDetail.Columns.UpdateNum).EqualTo(resultDetail.UpdateNum) .Set(TResultDetail.Columns.MeasureUnit).EqualTo(resultDetail.MeasureUnit) .Set(TResultDetail.Columns.NormalLevelW).EqualTo(resultDetail.NormalLevelW) .Set(TResultDetail.Columns.NormalLevel).EqualTo(resultDetail.NormalLevel) .Where(TResultDetail.Columns.TestDetailId).IsEqualTo(resultDetail.TestDetailId).Execute(); } }
private void grdPatientInfo_KeyPress(object sender, KeyPressEventArgs e) { try { if (grdPatientInfo.CurrentRow == null) { return; } int vTestResult_Id = Utility.Int32Dbnull(grdPatientInfo.GetValue("TestDetail_ID")); if (globalVariables.UserName == "ADMIN" || globalVariables.UserName == "LIS_ADMIN") { //Insert_Update_Result(); } else { if (grdPatientInfo.CurrentColumn.Key == "Test_Result" & grdPatientInfo.RootTable.Columns["Test_Result"].EditType != EditType.NoEdit & vTestResult_Id > 0) { if (TResultDetail.CreateQuery().WHERE(TResultDetail.Columns.TestDetailId, vTestResult_Id). AND(TResultDetail.Columns.ParaStatus, Comparison.GreaterThan, 0).GetRecordCount() > 0) { Utility.ShowMsg("Đã in kết quả. Không được sửa, Bạn hãy liên hệ với ADMIN để được trợ giúp!", "Thông Báo", MessageBoxIcon.Warning); e.Handled = true; } } } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
private void DeleteAllTestId(Int32 Test_ID) { try { if (!Utility.AcceptQuestion("Thực hiện xóa", "Thông báo", true)) { return; } Query myQuery; myQuery = TResultDetail.CreateQuery().WHERE(TTestInfo.Columns.TestId, Test_ID); myQuery.QueryType = QueryType.Delete; myQuery.Execute(); myQuery = TTestInfo.CreateQuery().WHERE(TTestInfo.Columns.TestId, Test_ID); myQuery.QueryType = QueryType.Delete; myQuery.Execute(); grdTestInfo.CurrentRow.Delete(); } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
private void grdTestResult_CellUpdated(object sender, ColumnActionEventArgs e) { try { if (grdTestResult.CurrentRow == null) { return; } if (Utility.Int32Dbnull(grdTestResult.GetValue("TestDetail_ID"), -1) > 0) { new Update(TResultDetail.Schema.Name).Set(TResultDetail.Columns.TestResult).EqualTo( grdTestResult.GetValue("Test_Result")).Where(TResultDetail.Columns.TestDetailId).IsEqualTo( Utility.Int32Dbnull(grdTestResult.GetValue("TestDetail_ID"), -1)).Execute(); } else { var obj = new TResultDetail(); if (string.IsNullOrEmpty(Utility.sDbnull(grdTestResult.GetValue("Para_Name")))) { Utility.ShowMsg("Tên thông số không được để trống"); return; } obj.TestId = Utility.Int32Dbnull(grdTestResult.GetValue("Test_ID"), -1); obj.PatientId = Utility.Int32Dbnull(grdTestResult.GetValue("Patient_ID"), -1); obj.TestTypeId = Utility.Int32Dbnull(grdTestResult.GetValue("TestType_ID"), -1); obj.TestDate = Utility.getSysDate(); obj.DataSequence = Utility.Int32Dbnull(grdTestResult.GetValue("Data_Sequence")); obj.TestResult = Utility.sDbnull(grdTestResult.GetValue("Test_Result")); obj.NormalLevel = Utility.sDbnull(grdTestResult.GetValue("Normal_Level")); obj.NormalLevelW = Utility.sDbnull(grdTestResult.GetValue("Normal_levelW")); obj.MeasureUnit = Utility.sDbnull(grdTestResult.GetValue("Measure_Unit")); obj.ParaName = Utility.sDbnull(grdTestResult.GetValue("Para_Name")); obj.TestDataId = Utility.sDbnull(grdTestResult.GetValue("TestData_ID")); obj.ParaStatus = 0; obj.PrintData = true; obj.Barcode = Utility.sDbnull(grdTestResult.GetValue("Barcode")); obj.UpdateNum = 0; obj.IsNew = true; obj.Save(); grdTestResult.CurrentRow.Cells["TestDetail_ID"].Value = Utility.Int32Dbnull(TResultDetail.CreateQuery(). WHERE(TResultDetail.Columns.PatientId, obj.PatientId). WHERE(TResultDetail.Columns.TestTypeId, obj.TestTypeId). GetMax(TResultDetail.Columns.TestDetailId), -1); } grdTestResult.UpdateData(); dtTestResult.AcceptChanges(); } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }
public ActionResult UpdateDataResultDetail(ref DataTable resultDetail, int v_TestInfo) { int TestResult_Id = -1; Query _Query = TResultDetail.CreateQuery(); try { using (var scope = new TransactionScope()) { using (var sp = new SharedDbConnectionScope()) { new Update(TTestInfo.Schema) .Set(TTestInfo.Columns.TestStatus).EqualTo(80) .Where(TTestInfo.Columns.TestId).IsEqualTo(v_TestInfo).Execute(); foreach (DataRow dr in resultDetail.Rows) { //if (dr["CHON"].ToString() == "1") //{ if (dr["IsNew"].ToString() == "1") { TResultDetail ObjResultDetail = CreateResultDetail(dr); if (ObjResultDetail != null) { ObjResultDetail.IsNew = true; ObjResultDetail.Save(); TestResult_Id = Convert.ToInt32(_Query.GetMax(TResultDetail.Columns.TestDetailId)); dr[TResultDetail.Columns.TestDetailId] = TestResult_Id; } //dr["IsNew"] = 0; } else { TResultDetail ObjResultDetail = CreateResultDetail(dr); UpdateResultDetail(ObjResultDetail); //} } } resultDetail.AcceptChanges(); } scope.Complete(); return(ActionResult.Success); } } catch (Exception exception) { return(ActionResult.Error); } }
//public static DataSet GetTestInfoByPatientInfo(int v_PatientId, string testTypeId) //{ // try // { // var ds = new DataSet(); // string strFormat = "dd/MM/yyyy"; // //string strFromDate = fromDate.ToString(strFormat); // //string strToDate = toDate.ToString(strFormat); // ds = SPs.SpGetTestInfoByPatientIDV2(v_PatientId, testTypeId).GetDataSet(); // return ds; // } // catch (Exception) // { // throw; // } //} //public static DataSet GetTestInfoByPatientInfo( string testTypeId) //{ // DataSet ds = new DataSet(); // ds = SPs.SpGetTestInfoByPatientID(testTypeId).GetDataSet(); // return ds; //} public static int InsertResultDetail(TResultDetail resultDetail) { int record = -1; Query _Query = TResultDetail.CreateQuery(); try { using (var scope = new TransactionScope()) { using (var sp = new SharedDbConnectionScope()) { resultDetail.IsNew = true; resultDetail.Save(); record = Convert.ToInt32(_Query.GetMax(TResultDetail.Columns.TestDetailId)); } scope.Complete(); } } catch (Exception exception) { record = -1; } return(record); }
private void grdPatientInfo_CellUpdated(object sender, Janus.Windows.GridEX.ColumnActionEventArgs e) { try { if (grdPatientInfo.CurrentRow.RowType != RowType.Record | grdPatientInfo.CurrentColumn.Key != "Test_Result") { return; } if (string.IsNullOrEmpty(Utility.sDbnull(grdPatientInfo.GetValue("TestData_ID")))) { return; } if (grdPatientInfo.CurrentRow == null) { return; } if (Utility.Int32Dbnull(grdPatientInfo.GetValue("TestDetail_ID"), -1) > 0) { new Update(TResultDetail.Schema.Name).Set(TResultDetail.Columns.ParaName) .EqualTo(Utility.sDbnull(grdPatientInfo.GetValue("Para_Name"))). Set(TResultDetail.Columns.TestResult).EqualTo(Utility.sDbnull(grdPatientInfo.GetValue("Test_Result"))). Where(TResultDetail.Columns.TestDetailId).IsEqualTo(Utility.Int32Dbnull(grdPatientInfo.GetValue("TestDetail_ID"), -1)). Execute(); } else { var obj = new TResultDetail(); obj.TestId = Utility.Int32Dbnull(grdPatientInfo.GetValue("Test_ID"), -1); obj.PatientId = Utility.Int32Dbnull(grdPatientInfo.GetValue("Patient_ID"), -1); obj.TestTypeId = Utility.Int32Dbnull(grdPatientInfo.GetValue("TestType_ID"), -1); obj.TestDate = DateTime.Now; obj.DataSequence = Utility.Int32Dbnull(grdPatientInfo.GetValue("Data_Sequence")); obj.TestResult = Utility.sDbnull(grdPatientInfo.GetValue("Test_Result")); obj.NormalLevel = Utility.sDbnull(grdPatientInfo.GetValue("Normal_Level")); obj.NormalLevelW = Utility.sDbnull(grdPatientInfo.GetValue("Normal_levelW")); obj.MeasureUnit = Utility.sDbnull(grdPatientInfo.GetValue("Measure_Unit")); obj.ParaName = Utility.sDbnull(grdPatientInfo.GetValue("Para_Name")); obj.TestDataId = Utility.sDbnull(grdPatientInfo.GetValue("TestData_ID")); obj.ParaStatus = 0; obj.PrintData = true; obj.Barcode = Utility.sDbnull(grdPatientInfo.GetValue("Barcode")); obj.UpdateNum = 0; obj.IsNew = true; obj.Save(); //grdPatientInfo.CurrentRow.Cells["TestDetail_ID"].Value = obj.TestDetailId; grdPatientInfo.CurrentRow.Cells["TestDetail_ID"].Value = Utility.Int32Dbnull(TResultDetail.CreateQuery(). WHERE(TResultDetail.Columns.PatientId, obj.PatientId). WHERE(TResultDetail.Columns.TestTypeId, obj.TestTypeId). GetMax(TResultDetail.Columns.TestDetailId), -1); grdPatientInfo.UpdateData(); dtPatientInfo.AcceptChanges(); } } catch (Exception ex) { Utility.ShowMsg(ex.Message); } }