private void dgXetNghiem_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (e.ColumnIndex != 5) { return; } if (e.RowIndex < 0) { return; } try { double soTien = Convert.ToDouble(e.FormattedValue); if (soTien != _currentSoTien) { _tongTien = _tongTien - _currentSoTien + soTien; UpdateTongTien(_tongTien); DataRow row = (dgXetNghiem.Rows[e.RowIndex].DataBoundItem as DataRowView).Row; string key = row["ThucHienXetNghiemGUID"].ToString(); Result result = ThucHienXetNghiemBus.UpdateGiaDichVuXetNghiem(key, soTien); if (!result.IsOK) { MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThucHienXetNghiemBus.UpdateGiaDichVuXetNghiem"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("ThucHienXetNghiemBus.UpdateGiaDichVuXetNghiem")); } } } catch { e.Cancel = true; } }
private void OnDelete() { List <string> keyList = new List <string>(); DataTable dt = dgXetNghiem.DataSource as DataTable; foreach (DataRow row in dt.Rows) { if (Boolean.Parse(row["Checked"].ToString())) { keyList.Add(row["ThucHienXetNghiemGUID"].ToString()); } } if (keyList.Count > 0) { if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những dịch vụ xét nghiệm mà bạn đã đánh dấu ?") == DialogResult.Yes) { Result result = ThucHienXetNghiemBus.DeleteDichVuXetNghiem(keyList); if (result.IsOK) { InitData(); DisplayAsThread(); } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThucHienXetNghiemBus.DeleteDichVuXetNghiem"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("ThucHienXetNghiemBus.DeleteDichVuXetNghiem")); } } } else { MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những dịch vụ xét nghiệm cần xóa.", IconType.Information); } }
private void OnDisplayDichVuXetNghiemList() { Result result = ThucHienXetNghiemBus.GetDichVuXetNghiemList(_tuNgay, _denNgay, _tenCongTy, _tenKhachHang, _tenDichVu); if (result.IsOK) { MethodInvoker method = delegate { ClearData(); DataTable dt = result.QueryResult as DataTable; dgXetNghiem.DataSource = result.QueryResult; lbKetQuaTimDuoc.Text = string.Format("Kết quả tìm được: {0}", dt.Rows.Count); result = ThucHienXetNghiemBus.GetTongTien(_tuNgay, _denNgay, _tenCongTy, _tenKhachHang, _tenDichVu); if (result.IsOK) { _tongTien = Convert.ToDouble(result.QueryResult); UpdateTongTien(_tongTien); } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThucHienXetNghiemBus.GetTongTien"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("ThucHienXetNghiemBus.GetTongTien")); } }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThucHienXetNghiemBus.GetDichVuXetNghiemList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("ThucHienXetNghiemBus.GetDichVuXetNghiemList")); } }
public void InitData() { string tenCongTy = cboTenCongTy.Text; string tenKhachHang = cboTenKhachHang.Text; string tenDichVu = cboTenDichVu.Text; DataTable dt = cboTenCongTy.DataSource as DataTable; if (dt != null) { dt.Rows.Clear(); dt.Clear(); dt = null; } dt = cboTenKhachHang.DataSource as DataTable; if (dt != null) { dt.Rows.Clear(); dt.Clear(); dt = null; } dt = cboTenDichVu.DataSource as DataTable; if (dt != null) { dt.Rows.Clear(); dt.Clear(); dt = null; } Result result = ThucHienXetNghiemBus.GetDanhSachCongTy(); if (result.IsOK) { dt = result.QueryResult as DataTable; DataRow newRow = dt.NewRow(); newRow[0] = string.Empty; dt.Rows.InsertAt(newRow, 0); cboTenCongTy.DataSource = dt; cboTenCongTy.DisplayMember = "TenCongTy"; cboTenCongTy.ValueMember = "TenCongTy"; cboTenCongTy.Text = tenCongTy; } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThucHienXetNghiemBus.GetDanhSachCongTy"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("ThucHienXetNghiemBus.GetDanhSachCongTy")); return; } result = ThucHienXetNghiemBus.GetDanhSachKhachHang(); if (result.IsOK) { dt = result.QueryResult as DataTable; DataRow newRow = dt.NewRow(); newRow[0] = string.Empty; dt.Rows.InsertAt(newRow, 0); cboTenKhachHang.DataSource = dt; cboTenKhachHang.DisplayMember = "TenKhachHang"; cboTenKhachHang.ValueMember = "TenKhachHang"; cboTenKhachHang.Text = tenKhachHang; } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThucHienXetNghiemBus.GetDanhSachKhachHang"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("ThucHienXetNghiemBus.GetDanhSachKhachHang")); return; } result = ThucHienXetNghiemBus.GetDanhSachDichVu(); if (result.IsOK) { dt = result.QueryResult as DataTable; DataRow newRow = dt.NewRow(); newRow[0] = string.Empty; dt.Rows.InsertAt(newRow, 0); cboTenDichVu.DataSource = dt; cboTenDichVu.DisplayMember = "TenDichVu"; cboTenDichVu.ValueMember = "TenDichVu"; cboTenDichVu.Text = tenDichVu; } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThucHienXetNghiemBus.GetDanhSachDichVu"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("ThucHienXetNghiemBus.GetDanhSachDichVu")); return; } }
private void OnImportExcel(string fileName) { int row = 7; try { IWorkbook book = SpreadsheetGear.Factory.GetWorkbook(fileName); if (book.Worksheets.Count <= 0) { return; } IWorksheet workSheet = book.Worksheets[0]; string msg = "Nhập dữ liệu từ Excel hoàn tất." + System.Environment.NewLine; if (!CheckTemplate(workSheet, ref msg)) { MsgBox.Show(Application.ProductName, msg, IconType.Information); return; } while (true) { IRange range = workSheet.Cells[string.Format("B{0}", row)]; if (range.Value == null || range.Value.ToString().Trim() == string.Empty || range.Value.ToString().Trim().ToLower() == "tổng") { break; } DateTime ngayThucHien = Convert.ToDateTime(workSheet.Cells[string.Format("D{0}", row)].Text); string tenCongTy = workSheet.Cells[string.Format("E{0}", row)].Value.ToString().Trim(); string tenKhachHang = workSheet.Cells[string.Format("F{0}", row)].Value.ToString().Trim(); string tenDichVu = workSheet.Cells[string.Format("I{0}", row)].Value.ToString().Trim(); double soTien = Convert.ToDouble(workSheet.Cells[string.Format("J{0}", row)].Value); ThucHienXetNghiem thxn = new ThucHienXetNghiem(); thxn.NgayThucHien = ngayThucHien; thxn.TenCongTy = tenCongTy; thxn.TenKhachHang = tenKhachHang; thxn.TenDichVu = tenDichVu; thxn.SoTien = soTien; thxn.SourcePath = fileName; Result result = ThucHienXetNghiemBus.InsertDichVuXetNghiem(thxn); if (!result.IsOK) { MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThucHienXetNghiemBus.InsertDichVuXetNghiem"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("ThucHienXetNghiemBus.InsertDichVuXetNghiem")); return; } row++; } MsgBox.Show(Application.ProductName, msg, IconType.Information); InitData(); DisplayAsThread(); } catch (Exception ex) { MsgBox.Show(Application.ProductName, ex.Message, IconType.Error); Utility.WriteToTraceLog(ex.Message); } }