public static bool UpdThongSo(PSDanhMucThongSoXN thongSo) { var db = new BioDAL(); return(db.UpdThongSo(thongSo)); }
private void gridView_thongso_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { try { GridView view = sender as GridView; int rowfocus = e.RowHandle; if (string.IsNullOrEmpty(Convert.ToString(view.GetRowCellValue(rowfocus, col_IDThongSoXN)))) { e.Valid = false; view.SetColumnError(col_IDThongSoXN, "Mã thông số xét nghiệm không được để trống!"); } if (string.IsNullOrEmpty(Convert.ToString(view.GetRowCellValue(rowfocus, col_TenThongSo)))) { e.Valid = false; view.SetColumnError(col_TenThongSo, "Tên thông số xét nghiệm không được để trống!"); } if (string.IsNullOrEmpty(Convert.ToString(view.GetRowCellValue(rowfocus, col_MaNhom)))) { e.Valid = false; view.SetColumnError(col_MaNhom, "Mã nhóm không được để trống!"); } if (e.Valid) { PSDanhMucThongSoXN thongSo = new PSDanhMucThongSoXN(); if (string.IsNullOrEmpty(gridView_thongso.GetRowCellValue(e.RowHandle, "RowIDThongSo").ToString())) { thongSo.RowIDThongSo = 0; } else { thongSo.RowIDThongSo = Convert.ToInt32(gridView_thongso.GetRowCellValue(e.RowHandle, "RowIDThongSo").ToString()); } thongSo.IDThongSoXN = gridView_thongso.GetRowCellValue(e.RowHandle, "IDThongSoXN").ToString(); thongSo.TenThongSo = gridView_thongso.GetRowCellValue(e.RowHandle, "TenThongSo").ToString(); if (!string.IsNullOrEmpty(gridView_thongso.GetRowCellValue(e.RowHandle, "GiaTriMinNu").ToString())) { thongSo.GiaTriMinNu = Convert.ToDouble(gridView_thongso.GetRowCellValue(e.RowHandle, "GiaTriMinNu").ToString()); } else { thongSo.GiaTriMinNu = 0; } if (!string.IsNullOrEmpty(gridView_thongso.GetRowCellValue(e.RowHandle, "GiaTriMaxNu").ToString())) { thongSo.GiaTriMaxNu = Convert.ToDouble(gridView_thongso.GetRowCellValue(e.RowHandle, "GiaTriMaxNu").ToString()); } else { thongSo.GiaTriMaxNu = 0; } thongSo.GiaTriTrungBinhNu = gridView_thongso.GetRowCellValue(e.RowHandle, "GiaTriTrungBinhNu").ToString(); thongSo.GiaTriMacDinh = gridView_thongso.GetRowCellValue(e.RowHandle, "GiaTriMacDinh").ToString(); if (!string.IsNullOrEmpty(gridView_thongso.GetRowCellValue(e.RowHandle, "GiaTriMinNam").ToString())) { thongSo.GiaTriMinNam = Convert.ToDouble(gridView_thongso.GetRowCellValue(e.RowHandle, "GiaTriMinNam").ToString()); } else { thongSo.GiaTriMinNam = 0; } if (!string.IsNullOrEmpty(gridView_thongso.GetRowCellValue(e.RowHandle, "GiaTriMaxNam").ToString())) { thongSo.GiaTriMaxNam = Convert.ToDouble(gridView_thongso.GetRowCellValue(e.RowHandle, "GiaTriMaxNam").ToString()); } else { thongSo.GiaTriMaxNam = 0; } thongSo.GiaTriTrungBinhNam = gridView_thongso.GetRowCellValue(e.RowHandle, "GiaTriTrungBinhNam").ToString(); thongSo.MaNhom = Convert.ToByte(gridView_thongso.GetRowCellValue(e.RowHandle, "MaNhom").ToString()); if (!string.IsNullOrEmpty(gridView_thongso.GetRowCellValue(e.RowHandle, "Stt").ToString())) { thongSo.Stt = Convert.ToByte(gridView_thongso.GetRowCellValue(e.RowHandle, "Stt").ToString()); } else { thongSo.Stt = 0; } thongSo.GiaTri = gridView_thongso.GetRowCellValue(e.RowHandle, "GiaTri").ToString(); thongSo.DonViTinh = gridView_thongso.GetRowCellValue(e.RowHandle, "DonViTinh").ToString(); if (string.IsNullOrEmpty(gridView_thongso.GetRowCellValue(e.RowHandle, "isLocked").ToString())) { thongSo.isLocked = false; } else { thongSo.isLocked = Convert.ToBoolean(gridView_thongso.GetRowCellValue(e.RowHandle, "isLocked").ToString()); } if (e.RowHandle < 0) { if (!BioBLL.CheckExistThongSo(thongSo.IDThongSoXN)) { XtraMessageBox.Show("Đã tồn tại mã thông số xét nghiệm!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error); this.gridControl_thongso.DataSource = BioBLL.GetListThongSoXN(); return; } if (BioBLL.InsThongSoXN(thongSo)) { XtraMessageBox.Show("Thêm mới thông số xét nghiệm thành công!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("Thêm mới thông số xét nghiệm thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (BioBLL.GetThongSoXNById(Convert.ToInt32(thongSo.RowIDThongSo)).IDThongSoXN != thongSo.IDThongSoXN) { if (!BioBLL.CheckExistThongSo(thongSo.IDThongSoXN)) { XtraMessageBox.Show("Đã tồn tại mã thông số xét nghiệm!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error); this.gridControl_thongso.DataSource = BioBLL.GetListThongSoXN(); return; } } if (BioBLL.UpdThongSo(thongSo)) { XtraMessageBox.Show("Cập nhật thông số xét nghiệm thành công!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("Cập nhật thông số xét nghiệm thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error); } } this.gridControl_thongso.DataSource = BioBLL.GetListThongSoXN(); } } catch (Exception ex) { XtraMessageBox.Show("Thao tác thất bại thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error); this.gridControl_thongso.DataSource = BioBLL.GetListThongSoXN(); } }
public static bool InsThongSoXN(PSDanhMucThongSoXN thongSo) { var db = new BioDAL(); return(db.InsThongSoXN(thongSo)); }
public static PsReponse UpdateDMThongSo(List <PSDanhMucThongSoXN> Clm) { PsReponse res = new PsReponse(); try { ProcessDataSync cn = new ProcessDataSync(); db = cn.db; db.Connection.Open(); db.Transaction = db.Connection.BeginTransaction(); foreach (var cl in Clm) { var kyt = db.PSDanhMucThongSoXNs.FirstOrDefault(p => p.IDThongSoXN == cl.IDThongSoXN); if (kyt != null) { kyt.DonViTinh = cl.DonViTinh; kyt.GiaTri = cl.GiaTri; kyt.GiaTriMacDinh = cl.GiaTriMacDinh; kyt.GiaTriMaxNam = cl.GiaTriMaxNam; kyt.GiaTriMaxNu = cl.GiaTriMaxNu; kyt.GiaTriMinNam = cl.GiaTriMinNam; kyt.GiaTriMinNu = cl.GiaTriMinNu; kyt.GiaTriTrungBinhNam = cl.GiaTriTrungBinhNam; kyt.GiaTriTrungBinhNu = cl.GiaTriTrungBinhNu; kyt.MaDonViTinh = cl.MaDonViTinh; kyt.MaNhom = kyt.MaNhom; kyt.Stt = cl.Stt; kyt.TenThongSo = cl.TenThongSo; db.SubmitChanges(); } else { PSDanhMucThongSoXN kyth = new PSDanhMucThongSoXN(); kyth.DonViTinh = cl.DonViTinh; kyth.GiaTri = cl.GiaTri; kyth.GiaTriMacDinh = cl.GiaTriMacDinh; kyth.GiaTriMaxNam = cl.GiaTriMaxNam; kyth.GiaTriMaxNu = cl.GiaTriMaxNu; kyth.GiaTriMinNam = cl.GiaTriMinNam; kyth.GiaTriMinNu = cl.GiaTriMinNu; kyth.GiaTriTrungBinhNam = cl.GiaTriTrungBinhNam; kyth.GiaTriTrungBinhNu = cl.GiaTriTrungBinhNu; kyth.MaDonViTinh = cl.MaDonViTinh; kyth.MaNhom = kyt.MaNhom; kyth.Stt = cl.Stt; kyth.TenThongSo = cl.TenThongSo; kyth.IDThongSoXN = cl.IDThongSoXN; db.PSDanhMucThongSoXNs.InsertOnSubmit(kyth); db.SubmitChanges(); } } db.Transaction.Commit(); db.Connection.Close(); res.Result = true; } catch (Exception ex) { db.Transaction.Rollback(); db.Connection.Close(); res.Result = false; res.StringError = ex.ToString(); } return(res); }