Beispiel #1
0
        private void cboOrder_EditValueChanged(object sender, EventArgs e)
        {
            string orderId = TextUtils.ToString(grvCboOrder.GetFocusedRowCellValue(colOrderID));

            if (orderId == "")
            {
                return;
            }

            cboUser.EditValue          = null;
            cboSupplier.EditValue      = null;
            cboNguoiPhuTrach.EditValue = null;

            txtCode.Text = TextUtils.ToString(grvCboOrder.GetFocusedRowCellValue(colOrderCode));
            txtName.Text = TextUtils.ToString(grvCboOrder.GetFocusedRowCellValue(colOrderSupplierName));

            DataTable     dtProject   = LibQLSX.Select("select * from vGetProjectWithOrder with(nolock) where OrderId = '" + orderId + "'");
            List <string> listProject = new List <string>();

            foreach (DataRow row in dtProject.Rows)
            {
                string projectCode = TextUtils.ToString(row["ProjectCode"]) == "" ? "Mua vật tư sản xuất chung" : TextUtils.ToString(row["ProjectCode"]);
                if (!listProject.Contains(projectCode))
                {
                    listProject.Add(projectCode);
                }
            }

            cboNguoiPhuTrach.EditValue = TextUtils.ToString(grvCboOrder.GetFocusedRowCellValue(colOrderUserId));
            txtTarget.Text             = TextUtils.ArrayToString(" ,", listProject.ToArray());
        }
Beispiel #2
0
        private void cboOrder_EditValueChanged(object sender, EventArgs e)
        {
            string orderId = TextUtils.ToString(grvCboOrder.GetFocusedRowCellValue(colOrderID));

            if (orderId == "")
            {
                return;
            }

            _type         = 0;
            _countProject = 0;

            cboUser.EditValue          = null;
            cboSupplier.EditValue      = null;
            cboNguoiPhuTrach.EditValue = null;

            txtCode.Text = TextUtils.ToString(grvCboOrder.GetFocusedRowCellValue(colOrderCode));
            txtName.Text = TextUtils.ToString(grvCboOrder.GetFocusedRowCellValue(colOrderSupplierName));

            DataTable dtPrice = loadPartOfOrder(txtCode.Text);

            decimal totalTransfer = TextUtils.ToDecimal(LibIE.ExcuteScalar("SELECT * FROM V_XNTC_VUVIEC WHERE (C_MA = '"
                                                                           + txtCode.Text.Trim() + "') AND (FK_TKCO LIKE '111%' OR FK_TKCO LIKE '112%') AND (FK_TKNO LIKE '331%') and C_KHACHHANG_MA = '"
                                                                           + TextUtils.ToString(grvCboOrder.GetFocusedRowCellValue(colOrderSupplierCode)) + "'"));

            decimal totalPrice = TextUtils.ToDecimal(dtPrice.Compute("Sum(TotalPrice)", ""));

            txtTotalTH.EditValue  = totalPrice;
            txtDiffCost.EditValue = TextUtils.ToDecimal(grvCboOrder.GetFocusedRowCellValue(colOrderDiffCost));

            //Tính lại công thức lấy tổng tiền PO = tiền hàng + vat + chi phí vận chuyển 10/03/2018
            decimal deliveryNew = TextUtils.ToDecimal(
                LibQLSX.ExcuteScalar("select isnull(sum(isnull(Amount,0) ),0) FROM [dbo].vTransport where [OrderId]='" + orderId + "'")
                );

            txtDeliveryCost.EditValue = deliveryNew;

            txtVAT.EditValue = TextUtils.ToDecimal(grvCboOrder.GetFocusedRowCellValue(colOrderVAT));
            decimal total = (TextUtils.ToDecimal(txtTotalTH.EditValue) + TextUtils.ToDecimal(txtDiffCost.EditValue) + TextUtils.ToDecimal(txtDeliveryCost.EditValue));

            total = total + (TextUtils.ToDecimal(txtVAT.EditValue) * total / 100);
            txtTotal.EditValue = total;

            txtTotalTransfer.EditValue = totalTransfer;
            txtTotalRest.EditValue     = TextUtils.ToDecimal(txtTotal.EditValue) - TextUtils.ToDecimal(txtTotalTransfer.EditValue);

            txtPercentPay.Text = "100";
            chkTM.Checked      = true;

            txtTM.EditValue = TextUtils.ToDecimal(txtTotal.EditValue) * TextUtils.ToDecimal(txtPercentPay.EditValue) / 100;
            txtCK.EditValue = 0;

            DataTable     dtProject   = LibQLSX.Select("select * from vGetProjectWithOrder with(nolock) where OrderId = '" + orderId + "'");
            List <string> listProject = new List <string>();

            foreach (DataRow row in dtProject.Rows)
            {
                string projectCode = TextUtils.ToString(row["ProjectCode"]) == "" ? "Mua vật tư sản xuất chung" : TextUtils.ToString(row["ProjectCode"]);
                if (!listProject.Contains(projectCode))
                {
                    listProject.Add(projectCode);
                    _countProject++;
                }
            }

            cboNguoiPhuTrach.EditValue = TextUtils.ToString(grvCboOrder.GetFocusedRowCellValue(colOrderUserId));
            txtTarget.Text             = TextUtils.ArrayToString(" ,", listProject.ToArray());
        }