private void bỏXácNhậnĐãThanhToánToolStripMenuItem_Click(object sender, EventArgs e) { foreach (int i in grvData.GetSelectedRows()) { if (i < 0) { continue; } int iD = TextUtils.ToInt(grvData.GetRowCellValue(i, colID)); PaymentTableItemModel model = (PaymentTableItemModel)PaymentTableItemBO.Instance.FindByPK(iD); if (!model.IsPaid) { model.IsPaid = false; PaymentTableItemBO.Instance.Update(model); grvData.SetRowCellValue(i, colIsPaid, false); } } //long id = TextUtils.ToInt64(grvData.GetFocusedRowCellValue(colID)); //PaymentTableItemModel item = new PaymentTableItemModel(); //if (id > 0) //{ // item = (PaymentTableItemModel)PaymentTableItemBO.Instance.FindByPK(id); // item.IsPaid = false; // PaymentTableItemBO.Instance.Update(item); // grvData.SetFocusedRowCellValue(colIsPaid, false); //} //else //{ // MessageBox.Show("Bạn phải Ghi lại dữ liệu trước khi xác nhận.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); // return; //} }
private void bỏDuyệtToolStripMenuItem_Click(object sender, EventArgs e) { foreach (int i in grvData.GetSelectedRows()) { if (i < 0) { continue; } int iD = TextUtils.ToInt(grvData.GetRowCellValue(i, colID)); PaymentTableItemModel model = (PaymentTableItemModel)PaymentTableItemBO.Instance.FindByPK(iD); if (model.IsApproved) { model.IsApproved = false; PaymentTableItemBO.Instance.Update(model); grvData.SetRowCellValue(i, colIsApproved, false); } } }
private void btnVouchers_Click(object sender, EventArgs e) { long id = TextUtils.ToInt64(grvData.GetFocusedRowCellValue(colID)); PaymentTableItemModel item = new PaymentTableItemModel(); if (id > 0) { item = (PaymentTableItemModel)PaymentTableItemBO.Instance.FindByPK(id); } else { MessageBox.Show("Bạn phải Ghi lại dữ liệu trước khi thêm chứng từ nợ.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } frmVouchers frm = new frmVouchers(); frm.PaymentTableItem = item; frm.Show(); }
private void btnAdd_Click(object sender, EventArgs e) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); decimal tm = 0; decimal ck = 0; PaymentTableModel PaymentTable = new PaymentTableModel(); PaymentTable.IsDeleted = false; PaymentTable.Note = ""; PaymentTable.Number = loadNumber(); //PaymentTable.TotalTM = TextUtils.ToDecimal(colTM.SummaryItem.SummaryValue); //PaymentTable.TotalCK = TextUtils.ToDecimal(colCK.SummaryItem.SummaryValue); PaymentTable.UpdatedBy = Global.AppUserName; PaymentTable.UpdatedDate = DateTime.Now; PaymentTable.CreatedBy = Global.AppUserName; PaymentTable.CreatedDate = DateTime.Now; PaymentTable.ID = (long)pt.Insert(PaymentTable); grvData.FocusedRowHandle = -1; for (int i = 0; i < grvData.RowCount; i++) { if (i < 0) { continue; } bool check = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colCheck)); if (!check) { continue; } long iD = TextUtils.ToInt64(grvData.GetRowCellValue(i, colID)); PaymentTableItemModel model = (PaymentTableItemModel)PaymentTableItemBO.Instance.FindByPK(iD); PaymentTableModel pay = (PaymentTableModel)PaymentTableBO.Instance.FindByPK(model.PaymentTableID); pay.TotalTM -= model.TotalCash; pay.TotalCK -= model.TotalCK; pt.Update(pay); model.PaymentTableID = PaymentTable.ID; pt.Update(model); tm += model.TotalCash; ck += model.TotalCK; } pt.CommitTransaction(); PaymentTable.TotalTM = tm; PaymentTable.TotalCK = ck; PaymentTableItemBO.Instance.Update(PaymentTable); loadItems(); }
private void btnSave_Click(object sender, EventArgs e) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { if (!ValidateForm()) { return; } grvData.FocusedRowHandle = -1; PaymentTable.IsDeleted = false; PaymentTable.Note = ""; PaymentTable.Number = txtNumber.Text.Trim(); PaymentTable.TotalTM = TextUtils.ToDecimal(colTM.SummaryItem.SummaryValue); PaymentTable.TotalCK = TextUtils.ToDecimal(colCK.SummaryItem.SummaryValue); PaymentTable.UpdatedBy = Global.AppUserName; PaymentTable.UpdatedDate = DateTime.Now; if (PaymentTable.ID == 0) { PaymentTable.CreatedBy = Global.AppUserName; PaymentTable.CreatedDate = DateTime.Now; PaymentTable.ID = (long)pt.Insert(PaymentTable); } else { pt.Update(PaymentTable); } for (int i = 0; i < grvData.RowCount; i++) { string code = TextUtils.ToString(grvData.GetRowCellValue(i, colCode)); if (code == "") { continue; } long id = TextUtils.ToInt64(grvData.GetRowCellValue(i, colID)); PaymentTableItemModel item = new PaymentTableItemModel(); if (id > 0) { item = (PaymentTableItemModel)PaymentTableItemBO.Instance.FindByPK(id); } item.Code = code; item.Content = TextUtils.ToString(grvData.GetRowCellValue(i, colContent)); item.ContentCheck = TextUtils.ToString(grvData.GetRowCellValue(i, colContentCheck)); item.Target = TextUtils.ToString(grvData.GetRowCellValue(i, colTarget)); item.Name = TextUtils.ToString(grvData.GetRowCellValue(i, colName)); item.Note = TextUtils.ToString(grvData.GetRowCellValue(i, colNote)); item.PaymentTableID = PaymentTable.ID; item.IsCash = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsTM)); item.Total = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colTotal)); item.TotalTH = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colTotalTH)); item.DeliveryCost = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colDeliveryCost)); item.DiffCost = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colDiffCost)); item.PercentPay = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colPercentPay)); item.TotalCash = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colTM)); item.TotalCK = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colCK)); item.UserId = TextUtils.ToString(grvData.GetRowCellValue(i, colOrderUserId)); item.CompanyID = TextUtils.ToInt(grvData.GetRowCellValue(i, colCompany)); item.DepartmentId = TextUtils.ToString(grvData.GetRowCellValue(i, colDepartment)); item.ProjectId = TextUtils.ToString(grvData.GetRowCellValue(i, colProject)); item.CostID = TextUtils.ToInt(grvData.GetRowCellValue(i, colCost)); item.CountProject = TextUtils.ToInt(grvData.GetRowCellValue(i, colCountProject)); item.VAT = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colVAT)); item.ContractStatus = TextUtils.ToInt1(grvData.GetRowCellValue(i, colContractStatus)); item.InvoiceStatus = TextUtils.ToInt1(grvData.GetRowCellValue(i, colInvoiceStatus)); item.IsPO = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsPO)); item.IsCongNo = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsCongNo)); item.IsCuongVe = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsCuongVe)); item.IsGDD = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsGĐĐ)); item.IsTTGH = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsTTGH)); item.IsVV_DA_NCC = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsVV_DA_NCC)); if (id > 0) { pt.Update(item); } else { pt.Insert(item); } ArrayList listOrder = OrdersBO.Instance.FindByAttribute("OrderCode", item.Code); if (listOrder.Count > 0) { OrdersModel order = (OrdersModel)listOrder[0]; order.StatusTT = 2; pt.UpdateQLSX(order); } } pt.CommitTransaction(); loadItems(); _isSaved = true; MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); if (this.LoadDataChange != null) { this.LoadDataChange(null, null); } } catch (Exception ex) { MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pt.CloseConnection(); } }
private void btnCreateBKTT_Click(object sender, EventArgs e) { grvYC.FocusedRowHandle = -1; DataTable dtYC = (DataTable)grdYC.DataSource; DataRow[] drsYC = dtYC.Select("Check = 1"); if (drsYC.Length == 0) { return; } ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { PaymentTableModel PaymentTable = new PaymentTableModel(); PaymentTable.IsDeleted = false; PaymentTable.Number = loadNumber(PaymentTable); //PaymentTable.TotalTM = TextUtils.ToDecimal(colTM.SummaryItem.SummaryValue); //PaymentTable.TotalCK = TextUtils.ToDecimal(colCK.SummaryItem.SummaryValue); PaymentTable.UpdatedBy = Global.AppUserName; PaymentTable.UpdatedDate = DateTime.Now; PaymentTable.CreatedBy = Global.AppUserName; PaymentTable.CreatedDate = DateTime.Now; PaymentTable.ID = (long)pt.Insert(PaymentTable); int count = 0; foreach (DataRow row in drsYC) { PaymentTableItemModel item = new PaymentTableItemModel(); item.Code = TextUtils.ToString(row["OrderCode"]); item.Target = TextUtils.ToString(row["Project"]); item.Name = TextUtils.ToString(row["SupplierName"]); item.Total = TextUtils.ToDecimal(row["TienThanhToan"]); item.TotalTH = TextUtils.ToDecimal(row["TotalPrice"]); item.DeliveryCost = TextUtils.ToDecimal(row["DeliveryCost"]); item.DiffCost = TextUtils.ToDecimal(row["DiffCost"]); item.UserId = TextUtils.ToString(row["UserId"]); //item.ProjectId = TextUtils.ToString(row["Project"]); item.VAT = TextUtils.ToDecimal(row["VAT"]); item.OrderRequirePaidID = TextUtils.ToInt(row["ID"]); item.PaymentTableID = PaymentTable.ID; item.IsCash = TextUtils.ToInt(row["PaymentType"]) == 1 ? true : false; item.PercentPay = TextUtils.ToDecimal(row["PayPercent"]); item.TotalCash = item.IsCash ? TextUtils.ToDecimal(row["TotalPay"]) : 0; item.TotalCK = item.IsCash ? 0 : TextUtils.ToDecimal(row["TotalPay"]); pt.Insert(item); OrdersModel order = (OrdersModel)OrdersBO.Instance.FindByAttribute("OrderId", TextUtils.ToString(row["OrderId"]))[0]; order.StatusTT = 2; pt.UpdateQLSX(order); OrderRequirePaidModel paid = (OrderRequirePaidModel)OrderRequirePaidBO.Instance.FindByPK(TextUtils.ToInt(row["ID"])); paid.Status = 2; pt.Update(paid); count++; } if (count > 0) { pt.CommitTransaction(); MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); loadData(); PaymentTableModel model = (PaymentTableModel)PaymentTableBO.Instance.FindByAttribute("Number", PaymentTable.Number)[0]; frmPaymentTableItem frm = new frmPaymentTableItem(); frm.PaymentTable = model; frm.Show(); } } catch (Exception ex) { MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pt.CloseConnection(); } }
protected PaymentTableItemFacade(PaymentTableItemModel model) : base(model) { }