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 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); } }