private void OnDisplayPhieuChiList() { Result result = PhieuChiBus.GetPhieuChiList(_fromDate, _toDate); if (result.IsOK) { MethodInvoker method = delegate { ClearData(); DataTable dt = result.QueryResult as DataTable; dgPhieuChi.DataSource = result.QueryResult; lbKetQuaTimDuoc.Text = string.Format("Kết quả tìm được: {0}", dt.Rows.Count); }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuChiBus.GetPhieuChiList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuChiBus.GetPhieuChiList")); } }
private void OnSaveInfo() { try { MethodInvoker method = delegate { _phieuChi.NgayChi = dtpkNgayChi.Value; _phieuChi.SoTien = (double)numSoTien.Value; _phieuChi.DienGiai = txtGhiChu.Text; _phieuChi.Status = (byte)Status.Actived; if (_isNew) { _phieuChi.CreatedDate = DateTime.Now; _phieuChi.CreatedBy = Guid.Parse(Global.UserGUID); string soPhieuChi = GetGenerateCode(); if (soPhieuChi == string.Empty) { return; } _phieuChi.SoPhieuChi = soPhieuChi; } else { _phieuChi.SoPhieuChi = txtSoPhieuChi.Text; _phieuChi.UpdatedDate = DateTime.Now; _phieuChi.UpdatedBy = Guid.Parse(Global.UserGUID); } Result result = PhieuChiBus.InsertPhieuChi(_phieuChi); if (!result.IsOK) { MsgBox.Show(this.Text, result.GetErrorAsString("PhieuChiBus.InsertPhieuChi"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuChiBus.InsertPhieuChi")); 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 string GetGenerateCode() { Result result = PhieuChiBus.GetPhieuChiCount(); if (result.IsOK) { int count = Convert.ToInt32(result.QueryResult); return(Utility.GetCode("PC", count + 1, 7)); } else { MsgBox.Show(this.Text, result.GetErrorAsString("PhieuChiBus.GetPhieuChiCount"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuChiBus.GetPhieuChiCount")); return(string.Empty); } }
private void GenerateCode() { Cursor.Current = Cursors.WaitCursor; Result result = PhieuChiBus.GetPhieuChiCount(); if (result.IsOK) { int count = Convert.ToInt32(result.QueryResult); txtSoPhieuChi.Text = Utility.GetCode("PC", count + 1, 7); } else { MsgBox.Show(this.Text, result.GetErrorAsString("PhieuChiBus.GetPhieuChiCount"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuChiBus.GetPhieuChiCount")); } }
private void XoaPhieuChi() { List <string> deletedPhieuChiList = new List <string>(); List <DataRow> deletedRows = new List <DataRow>(); DataTable dt = dgPhieuChi.DataSource as DataTable; foreach (DataRow row in dt.Rows) { if (Boolean.Parse(row["Checked"].ToString())) { deletedPhieuChiList.Add(row["PhieuChiGUID"].ToString()); deletedRows.Add(row); } } if (deletedPhieuChiList.Count > 0) { if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những phiếu chi mà bạn đã đánh dấu ?") == DialogResult.Yes) { Result result = PhieuChiBus.DeletePhieuChi(deletedPhieuChiList); if (result.IsOK) { foreach (DataRow row in deletedRows) { dt.Rows.Remove(row); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuChiBus.DeletePhieuChi"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("PhieuChiBus.DeletePhieuChi")); } } } else { MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những phiếu chi cần xóa.", IconType.Information); } }