private void OnDisplayGhiNhanCongNoList() { Result result = GhiNhanTraNoBus.GetGhiNhanTraNoList(PhieuThuGUID, LoaiPT); if (result.IsOK) { MethodInvoker method = delegate { DataTable dt = result.QueryResult as DataTable; dgTraNo.DataSource = result.QueryResult; CalculateCongNo(); }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("GhiNhanTraNoBus.GetGhiNhanTraNoList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("GhiNhanTraNoBus.GetGhiNhanTraNoList")); } }
private double GetSoTienConNo() { //Get tổng tiền đã trả double tongTienTra = 0; Result result = GhiNhanTraNoBus.GetTongTienTraNo(_ghiNhanTraNo.GhiNhanTraNoGUID.ToString(), _phieuThuGUID, _loaiPT); if (result.IsOK) { tongTienTra = Convert.ToDouble(result.QueryResult); } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("GhiNhanTraNoBus.GetTongTienTraNo"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("GhiNhanTraNoBus.GetTongTienTraNo")); } //Get tổng tiền còn nợ double tongTienNo = 0; result = GhiNhanTraNoBus.GetTongTienPhieuThu(_phieuThuGUID, _loaiPT); if (result.IsOK) { tongTienNo = Convert.ToDouble(result.QueryResult); } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("GhiNhanTraNoBus.GetTongTienPhieuThu"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("GhiNhanTraNoBus.GetTongTienPhieuThu")); } tongTienNo = tongTienNo - tongTienTra; return(tongTienNo); }
private void OnSaveInfo() { try { MethodInvoker method = delegate { _ghiNhanTraNo.MaPhieuThuGUID = Guid.Parse(_phieuThuGUID); _ghiNhanTraNo.LoaiPT = (int)_loaiPT; _ghiNhanTraNo.NgayTra = dtpkNgayTra.Value; _ghiNhanTraNo.SoTien = (double)numSoTien.Value; _ghiNhanTraNo.GhiChu = txtGhiChu.Text; _ghiNhanTraNo.Status = (byte)Status.Actived; if (_isNew) { _ghiNhanTraNo.CreatedDate = DateTime.Now; _ghiNhanTraNo.CreatedBy = Guid.Parse(Global.UserGUID); } else { _ghiNhanTraNo.UpdatedDate = DateTime.Now; _ghiNhanTraNo.UpdatedBy = Guid.Parse(Global.UserGUID); } Result result = GhiNhanTraNoBus.InsertGhiNhanTraNo(_ghiNhanTraNo, _isDaTraDu, _phieuThuGUID, _loaiPT); if (!result.IsOK) { MsgBox.Show(this.Text, result.GetErrorAsString("GhiNhanTraNoBus.InsertGhiNhanTraNo"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("GhiNhanTraNoBus.InsertGhiNhanTraNo")); 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); } }
private void CalculateCongNo() { if (!DaThuTien) { //Get tổng tiền đã trả double tongTienTra = 0; Result result = GhiNhanTraNoBus.GetTongTienTraNo(string.Empty, PhieuThuGUID, LoaiPT); if (result.IsOK) { tongTienTra = Convert.ToDouble(result.QueryResult); } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("GhiNhanTraNoBus.GetTongTienTraNo"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("GhiNhanTraNoBus.GetTongTienTraNo")); } //Get tổng tiền còn nợ double tongTienNo = 0; result = GhiNhanTraNoBus.GetTongTienPhieuThu(PhieuThuGUID, LoaiPT); if (result.IsOK) { tongTienNo = Convert.ToDouble(result.QueryResult); } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("GhiNhanTraNoBus.GetTongTienPhieuThu"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("GhiNhanTraNoBus.GetTongTienPhieuThu")); } tongTienNo = tongTienNo - tongTienTra; lbConNo.Text = string.Format("Còn nợ: {0:N0} VNĐ", tongTienNo); } else { lbConNo.Text = "Còn nợ: 0 VNĐ"; } }
private void OnDelete() { List <string> keys = new List <string>(); DataTable dt = dgTraNo.DataSource as DataTable; foreach (DataRow row in dt.Rows) { if (Boolean.Parse(row["Checked"].ToString())) { keys.Add(row["GhiNhanTraNoGUID"].ToString()); } } if (keys.Count > 0) { if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những ghi nhận trả nợ mà bạn đã đánh dấu ?") == DialogResult.Yes) { Result result = GhiNhanTraNoBus.DeleteGhiNhanTraNo(keys, PhieuThuGUID, LoaiPT); if (result.IsOK) { IsDataChange = true; DaThuTien = false; DisplayAsThread(); } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("GhiNhanTraNoBus.DeleteGhiNhanTraNo"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("GhiNhanTraNoBus.DeleteGhiNhanTraNo")); } } } else { MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những ghi nhận trả nợ cần xóa.", IconType.Information); } }