private void OnDisplayInvoiceList() { Result result = HoaDonThuocBus.GetHoaDonThuocList(_fromDate, _toDate, _tenBenhNhan, _tenDonVi, _maSoThue, _type); if (result.IsOK) { MethodInvoker method = delegate { ClearData(); dgInvoice.DataSource = result.QueryResult; }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("HoaDonThuocBus.GetHoaDonThuocList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("HoaDonThuocBus.GetHoaDonThuocList")); } }
private bool CheckInfo() { DataTable dt = dgSoHoaDon.DataSource as DataTable; if (dt == null || dt.Rows.Count <= 0) { MsgBox.Show(this.Text, "Vui lòng phát sinh số hóa đơn.", IconType.Information); return(false); } foreach (DataRow row in dt.Rows) { int soHoaDon = Convert.ToInt32(row["SoHoaDon"]); string code = Utility.GetCode(string.Empty, soHoaDon, 7); Result result = HoaDonThuocBus.CheckHoaDonThuocExistCode(Convert.ToInt32(code), _fromDate, _toDate); if (result.Error.Code == ErrorCode.EXIST || result.Error.Code == ErrorCode.NOT_EXIST) { if (result.Error.Code == ErrorCode.EXIST) { MsgBox.Show(this.Text, "Số hóa đơn này đã được xuất rồi. Vui lòng phát sinh lại.", IconType.Information); return(false); } } else { MsgBox.Show(this.Text, result.GetErrorAsString("HoaDonThuocBus.CheckHoaDonThuocExistCode"), IconType.Error); return(false); } } return(true); }
private void OnDeleteInvoice() { List <string> deletedInvoiceList = new List <string>(); List <DataRow> deletedRows = new List <DataRow>(); DataTable dt = dgInvoice.DataSource as DataTable; foreach (DataRow row in dt.Rows) { if (Boolean.Parse(row["Checked"].ToString())) { //deletedInvoiceList.Add(row["HoaDonThuocGUID"].ToString()); deletedRows.Add(row); } } if (deletedRows.Count > 0) { if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những hóa đơn mà bạn đã đánh dấu ?") == DialogResult.Yes) { List <string> noteList = new List <string>(); foreach (DataRow row in deletedRows) { string soHoaDon = row["SoHoaDon"].ToString(); string hoaDonThuocGUID = row["HoaDonThuocGUID"].ToString(); dlgLyDoXoa dlg = new dlgLyDoXoa(soHoaDon, 1); if (dlg.ShowDialog(this) == DialogResult.OK) { noteList.Add(dlg.Notes); deletedInvoiceList.Add(hoaDonThuocGUID); } } if (deletedInvoiceList.Count > 0) { Result result = HoaDonThuocBus.DeleteHoaDonThuoc(deletedInvoiceList, noteList); if (result.IsOK) { foreach (DataRow row in deletedRows) { string hoaDonThuocGUID = row["HoaDonThuocGUID"].ToString(); if (deletedInvoiceList.Contains(hoaDonThuocGUID)) { dt.Rows.Remove(row); } } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("HoaDonThuocBus.DeleteHoaDonThuoc"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("HoaDonThuocBus.DeleteHoaDonThuoc")); } } } } else { MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những hóa đơn cần xóa.", IconType.Information); } }