Ejemplo n.º 1
0
        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);
            }
        }