private void btnDelete_Click(object sender, EventArgs e) { if (grvData.SelectedRowsCount < 1) { return; } try { string code = grvData.GetFocusedRowCellValue(colCode).ToString(); int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); int orderRequirePaidID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colOrderRequirePaidID)); if (MessageBox.Show("Bạn có chắc muốn xóa mã vụ việc [" + code + "]?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (id > 0) { PaymentTableItemBO.Instance.Delete(id); if (orderRequirePaidID > 0) { OrderRequirePaidModel paid = (OrderRequirePaidModel)OrderRequirePaidBO.Instance.FindByPK(orderRequirePaidID); paid.Status = 1; OrderRequirePaidBO.Instance.Update(paid); } ArrayList listOrder = OrdersBO.Instance.FindByAttribute("OrderCode", code); if (listOrder.Count > 0) { OrdersModel order = (OrdersModel)listOrder[0]; order.StatusTT = 1; OrdersBO.Instance.UpdateQLSX(order); } } grvData.DeleteSelectedRows(); } } catch (Exception) { } }
protected OrderRequirePaidFacade(OrderRequirePaidModel model) : base(model) { }
private void btnSave_Click(object sender, EventArgs e) { if (Order.OrderId == "") { return; } grvYC.FocusedRowHandle = -1; if (!validate()) { return; } Order.DeliveryCost = TextUtils.ToDecimal(txtDeliveryCost.EditValue); Order.DiffCost = TextUtils.ToDecimal(txtDiffCost.EditValue); Order.Description = txtDescription.Text.Trim(); Order.VAT = TextUtils.ToDecimal1(txtVAT.EditValue); Order.TotalNCC = TextUtils.ToDecimal(txtTotalNCC.EditValue); Order.IsTranferAfferVAT = chkIsTranferAfterVAT.Checked; //Order.PaymentDate = (DateTime?)dtpPayment.EditValue; //Order.RequirePaymentDate = (DateTime?)dtpRequireDate.EditValue; //Order.PaymentType = cboPaymentType.SelectedIndex; //Order.PayPercent = TextUtils.ToDecimal1(txtPayPercent.EditValue); OrdersBO.Instance.UpdateQLSX(Order); for (int i = 0; i < grvYC.RowCount; i++) { int status = TextUtils.ToInt(grvYC.GetFocusedRowCellValue(colStatus)); if (status > 0) { continue; } int id = TextUtils.ToInt(grvYC.GetRowCellValue(i, colID)); OrderRequirePaidModel model = new OrderRequirePaidModel(); if (id > 0) { model = (OrderRequirePaidModel)OrderRequirePaidBO.Instance.FindByPK(id); } model.OrderId = Order.OrderId; model.PayPercent = TextUtils.ToDecimal(grvYC.GetRowCellValue(i, colPayPercent)); model.RequirePaymentDate = TextUtils.ToDate2(grvYC.GetRowCellValue(i, colRequirePaymentDate)); model.TotalPay = TextUtils.ToDecimal(grvYC.GetRowCellValue(i, colTotalYC)); model.PaymentType = TextUtils.ToInt1(grvYC.GetRowCellValue(i, colPaymentType)); model.Status = TextUtils.ToInt(grvYC.GetRowCellValue(i, colStatus)); if (id > 0) { OrderRequirePaidBO.Instance.Update(model); } else { OrderRequirePaidBO.Instance.Insert(model); } } loadYC(); MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); if (this.LoadDataChange != null) { this.LoadDataChange(null, null); } }
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(); } }