private void OnDeletePhieuThu() { List <string> deletedPTThuocList = new List <string>(); List <DataRow> deletedRows = new List <DataRow>(); DataTable dt = dgPhieuThu.DataSource as DataTable; foreach (DataRow row in dt.Rows) { if (Boolean.Parse(row["Checked"].ToString())) { deletedRows.Add(row); } } if (deletedRows.Count > 0) { if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những phiếu thu mà bạn đã đánh dấu ?") == DialogResult.Yes) { List <string> noteList = new List <string>(); foreach (DataRow row in deletedRows) { string maPhieuThuThuoc = row["MaPhieuThuCapCuu"].ToString(); string phieuThuThuocGUID = row["PhieuThuCapCuuGUID"].ToString(); dlgLyDoXoa dlg = new dlgLyDoXoa(maPhieuThuThuoc, 0); if (dlg.ShowDialog(this) == DialogResult.OK) { noteList.Add(dlg.Notes); deletedPTThuocList.Add(phieuThuThuocGUID); } } if (deletedPTThuocList.Count > 0) { Result result = PhieuThuCapCuuBus.DeletePhieuThuCapCuu(deletedPTThuocList, noteList); if (result.IsOK) { foreach (DataRow row in deletedRows) { string phieuThuThuocGUID = row["PhieuThuCapCuuGUID"].ToString(); if (deletedPTThuocList.Contains(phieuThuThuocGUID)) { dt.Rows.Remove(row); } } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuCapCuuBus.DeletePhieuThuCapCuu"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuCapCuuBus.DeletePhieuThuCapCuu")); } } } } else { MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những phiếu thu cần xóa.", IconType.Information); } }
private void OnDisplayPhieuThuThuocList() { Result result = PhieuThuCapCuuBus.GetPhieuThuCapCuuList(_isFromDateToDate, _fromDate, _toDate, _tenBenhNhan, _type, _type2); if (result.IsOK) { MethodInvoker method = delegate { ClearData(); DataTable dt = result.QueryResult as DataTable; dgPhieuThu.DataSource = result.QueryResult; //HighlightExportedInvoice(); lbKetQuaTimDuoc.Text = string.Format("Kết quả tìm được: {0}", dt.Rows.Count); ShowTongTien(); }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuCapCuuBus.GetPhieuThuCapCuuList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuCapCuuBus.GetPhieuThuCapCuuList")); } }
private void dlgAddPhieuThuThuoc_FormClosing(object sender, FormClosingEventArgs e) { if (this.DialogResult == System.Windows.Forms.DialogResult.OK) { if (_isNew) { if (CheckInfo()) { SaveInfoAsThread(); } else { e.Cancel = true; } } else { Result result = PhieuThuCapCuuBus.CapNhatTrangThaiPhieuThu(_phieuThuCapCuu.PhieuThuCapCuuGUID.ToString(), chkDaXuatHD.Checked, chkDaThuTien.Checked, (byte)cboHinhThucThanhToan.SelectedIndex, txtGhiChu.Text); if (!result.IsOK) { MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuCapCuuBus.CapNhatTrangThaiPhieuThu"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuCapCuuBus.CapNhatTrangThaiPhieuThu")); e.Cancel = true; } else { _drPhieuThu["IsExported"] = chkDaXuatHD.Checked; _drPhieuThu["DaThuTien"] = chkDaThuTien.Checked; _drPhieuThu["HinhThucThanhToan"] = (byte)cboHinhThucThanhToan.SelectedIndex; _drPhieuThu["HinhThucThanhToanStr"] = cboHinhThucThanhToan.Text; _drPhieuThu["Notes"] = txtGhiChu.Text; } } } else { if (_isNew) { if (MsgBox.Question(this.Text, "Bạn có muốn lưu thông tin phiếu thu cấp cứu ?") == System.Windows.Forms.DialogResult.Yes) { if (CheckInfo()) { this.DialogResult = System.Windows.Forms.DialogResult.OK; SaveInfoAsThread(); } else { e.Cancel = true; } } } } }
private string GetGenerateCode() { Result result = PhieuThuCapCuuBus.GetPhieuThuCapCuuCount(); if (result.IsOK) { int count = Convert.ToInt32(result.QueryResult); return(Utility.GetCode("PTCC", count + 1, 7)); } else { MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuCapCuuBus.GetPhieuThuCapCuuCount"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuCapCuuBus.GetPhieuThuCapCuuCount")); return(string.Empty); } }
private void GenerateCode() { Cursor.Current = Cursors.WaitCursor; Result result = PhieuThuCapCuuBus.GetPhieuThuCapCuuCount(); if (result.IsOK) { int count = Convert.ToInt32(result.QueryResult); txtMaPhieuThu.Text = Utility.GetCode("PTCC", count + 1, 7); } else { MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuCapCuuBus.GetPhieuThuCapCuuCount"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuCapCuuBus.GetPhieuThuCapCuuCount")); } }
//public void HighlightExportedInvoice() //{ // foreach (DataGridViewRow row in dgPhieuThu.Rows) // { // DataRow dr = (row.DataBoundItem as DataRowView).Row; // bool isExported = Convert.ToBoolean(dr["IsExported"]); // if (isExported) // row.DefaultCellStyle.BackColor = Color.LightSeaGreen; // } //} private void ShowTongTien() { if (!chkTongTien.Checked) { chkTongTien.Text = "Tổng tiền:"; } else { Result result = PhieuThuCapCuuBus.GetTongTien(_isFromDateToDate, _fromDate, _toDate, _tenBenhNhan, _type, _type2); if (result.IsOK) { chkTongTien.Text = string.Format("Tổng tiền: {0:N0} VNĐ", result.QueryResult); } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuCapCuuBus.GetTongTien"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuCapCuuBus.GetTongTien")); } } }
private void OnGetChiTietPhieuThuCapCuu(string phieuThuCapCuuGUID) { Result result = PhieuThuCapCuuBus.GetChiTietPhieuThuCapCuu(phieuThuCapCuuGUID); if (result.IsOK) { dgChiTiet.DataSource = result.QueryResult; if (_isNew) { UpdateDataSourceDonGia(); } UpdateNgayHetHanVaSoLuongTon(); RefreshNo(); } else { MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuCapCuuBus.GetChiTietPhieuThuCapCuu"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuCapCuuBus.GetChiTietPhieuThuCapCuu")); } }
private void OnSaveInfo() { try { MethodInvoker method = delegate { _phieuThuCapCuu.MaPhieuThuCapCuu = txtMaPhieuThu.Text; _phieuThuCapCuu.ToaCapCuuGUID = Guid.Parse(cboMaToaCapCuu.SelectedValue.ToString()); _phieuThuCapCuu.NgayThu = dtpkNgayThu.Value; _phieuThuCapCuu.MaBenhNhan = txtMaBenhNhan.Text; _phieuThuCapCuu.TenBenhNhan = txtTenBenhNhan.Text; _phieuThuCapCuu.DiaChi = txtDiaChi.Text; _phieuThuCapCuu.TenCongTy = _tenCongTy; _phieuThuCapCuu.Status = (byte)Status.Actived; _phieuThuCapCuu.ChuaThuTien = !chkDaThuTien.Checked; _phieuThuCapCuu.Notes = txtGhiChu.Text; _phieuThuCapCuu.LyDoGiam = txtLyDoGiam.Text; _phieuThuCapCuu.HinhThucThanhToan = (byte)cboHinhThucThanhToan.SelectedIndex; if (_isNew) { _phieuThuCapCuu.CreatedDate = DateTime.Now; _phieuThuCapCuu.CreatedBy = Guid.Parse(Global.UserGUID); } List <ChiTietPhieuThuCapCuu> addedList = new List <ChiTietPhieuThuCapCuu>(); for (int i = 0; i < dgChiTiet.RowCount; i++) { DataGridViewRow row = dgChiTiet.Rows[i]; ChiTietPhieuThuCapCuu ctptcc = new ChiTietPhieuThuCapCuu(); ctptcc.CreatedDate = DateTime.Now; ctptcc.CreatedBy = Guid.Parse(Global.UserGUID); ctptcc.KhoCapCuuGUID = Guid.Parse(row.Cells["KhoCapCuuGUID"].Value.ToString()); ctptcc.DonGia = Convert.ToDouble(row.Cells["DonGia"].Value); if (row.Cells["SoLuong"].Value != null && row.Cells["SoLuong"].Value != DBNull.Value) { ctptcc.SoLuong = Convert.ToDouble(row.Cells["SoLuong"].Value); } else { ctptcc.SoLuong = 1; } if (row.Cells["Giam"].Value != null && row.Cells["Giam"].Value != DBNull.Value) { ctptcc.Giam = Convert.ToDouble(row.Cells["Giam"].Value); } else { ctptcc.Giam = 0; } double tienGiam = Math.Round(((double)ctptcc.SoLuong * (double)ctptcc.DonGia * (double)ctptcc.Giam) / (double)100); double thanhTien = (double)ctptcc.SoLuong * (double)ctptcc.DonGia - tienGiam; ctptcc.ThanhTien = thanhTien;//Convert.ToDouble(row.Cells["ThanhTien"].Value); ctptcc.Status = (byte)Status.Actived; addedList.Add(ctptcc); } string maPhieuThu = GetGenerateCode(); if (maPhieuThu == string.Empty) { return; } _phieuThuCapCuu.MaPhieuThuCapCuu = maPhieuThu; Result result = PhieuThuCapCuuBus.InsertPhieuThuCapCuu(_phieuThuCapCuu, addedList); if (!result.IsOK) { MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuCapCuuBus.InsertPhieuThuCapCuu"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuCapCuuBus.InsertPhieuThuCapCuu")); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } catch (Exception e) { MsgBox.Show(this.Text, e.Message, IconType.Error); Utility.WriteToTraceLog(e.Message); } }