예제 #1
0
        void loadProductOfProject(string projectCode)
        {
            try
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang load danh sách module..."))
                {
                    string[] paraName  = new string[1];
                    object[] paraValue = new object[1];
                    paraName[0] = "@ProjectCode"; paraValue[0] = projectCode;
                    DataTable dt = TPA.Business.SuppliersBO.Instance.LoadDataFromSP("spGetProductOfProject", "Source", paraName, paraValue);

                    _dtBaoGia.Rows.Clear();
                    _dtBaoGia.Merge(dt);

                    if (chkGetPriceVT.Checked)
                    {
                        foreach (DataRow dr in _dtBaoGia.Rows)
                        {
                            string code = TextUtils.ToString(dr["ModuleCode"]);
                            if (code == "")
                            {
                                continue;
                            }
                            decimal price = TextUtils.GetPrice(code, true);

                            //dr["VAT"] = 5m;
                            //dr["Qty"] = 1m;
                            dr["PriceVT"]  = price;
                            dr["TotalVT"]  = price;
                            dr["PriceTPA"] = price;
                            dr["TotalTPA"] = price;
                        }
                    }

                    grdData.DataSource = _dtBaoGia;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        private void cboModule_EditValueChanged(object sender, EventArgs e)
        {
            string code = TextUtils.ToString(grvCboModule.GetFocusedRowCellValue(colCode));
            string name = TextUtils.ToString(grvCboModule.GetFocusedRowCellValue(colName));

            txtModuleCode.Text = code;
            txtModuleName.Text = name;

            if (chkGetPriceVT.Checked)
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang load giá vật tư..."))
                {
                    try
                    {
                        txtPriceVT.EditValue = TextUtils.GetPrice(code, true);
                    }
                    catch
                    {
                    }
                }
            }
        }
예제 #3
0
        private void btnAddModule_Click(object sender, EventArgs e)
        {
            frmListModules frm = new frmListModules();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang thêm module..."))
                {
                    foreach (DataRow r in frm.dtSeleted.Rows)
                    {
                        string code = TextUtils.ToString(r["Code"]);
                        if (code == "")
                        {
                            continue;
                        }
                        DataRow[] drs = _dtDMVT.Select("Code = '" + code + "'");
                        if (drs.Length > 0)
                        {
                            continue;
                        }

                        decimal price = TextUtils.GetPrice(code, true);

                        DataRow dr = _dtDMVT.NewRow();
                        dr["Code"]       = TextUtils.ToString(r["Code"]);
                        dr["Name"]       = TextUtils.ToString(r["Name"]);
                        dr["Hang"]       = TextUtils.ToString(r["Hang"]);
                        dr["Unit"]       = "Bộ";
                        dr["Price"]      = price;
                        dr["TotalPrice"] = price;
                        dr["Qty"]        = 1;
                        dr["SolutionID"] = TextUtils.ToInt(Solution.ID);
                        _dtDMVT.Rows.Add(dr);
                    }
                }
            }
        }
예제 #4
0
        private void lấyGiáChoModuleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang load giá cho module..."))
            {
                foreach (int i in grvData.GetSelectedRows())
                {
                    string code = TextUtils.ToString(grvData.GetRowCellValue(i, colModuleCode));
                    if (!code.StartsWith("TPAD."))
                    {
                        continue;
                    }
                    decimal price       = TextUtils.GetPrice(code, true);
                    int     costGroupID = TextUtils.ToInt(grvData.GetRowCellValue(i, colCostGroupID));
                    decimal qty         = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colQty));
                    string  priceType   = TextUtils.ToString(grvData.GetRowCellValue(i, colPriceType));

                    decimal totalVT  = qty * price;
                    decimal priceTPA = 0;

                    if (priceType.ToUpper() == "SX")
                    {
                        priceTPA = GetCostSX(costGroupID, price);
                    }
                    else
                    {
                        priceTPA = GetCostTM(costGroupID, price);
                    }
                    decimal totalTPA = priceTPA * qty;

                    grvData.SetRowCellValue(i, colPriceVT, price);
                    grvData.SetRowCellValue(i, colPriceDT, price);
                    grvData.SetRowCellValue(i, colTotalVT, totalVT);
                    grvData.SetRowCellValue(i, colPriceTPA, priceTPA);
                    grvData.SetRowCellValue(i, colTotalTPA, totalTPA);
                }
            }
        }
예제 #5
0
        private void btnAddModule_Click(object sender, EventArgs e)
        {
            frmListModules frm = new frmListModules();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang thêm module..."))
                {
                    foreach (DataRow r in frm.dtSeleted.Rows)
                    {
                        string code = TextUtils.ToString(r["Code"]);
                        if (code == "")
                        {
                            continue;
                        }
                        DataRow[] drs = _dtVT.Select("Code = '" + code + "'");
                        if (drs.Length > 0)
                        {
                            continue;
                        }

                        decimal price = TextUtils.GetPrice(code, true);

                        int deliveryTime = -1;
                        if (code.StartsWith("PCB."))
                        {
                            //string sqlM = "SELECT top 1 * FROM  vGetPriceOfPart with(nolock)"
                            //        + " WHERE Price > 1 AND replace(replace([PartsCode],'/','#'),')','#') = '"
                            //        + "TPAT." + code.Substring(4, 7) + "'"
                            //        + " ORDER BY DateAboutF DESC";
                            //DataTable dtPrice = LibQLSX.Select(sqlM);

                            string    sqlM    = "exec spGetPriceOfPart 'TPAT." + code.Substring(4, 7) + "'";
                            DataTable dtPrice = LibQLSX.Select(sqlM);

                            deliveryTime = TextUtils.ToInt(dtPrice.Rows[0]["DeliveryTime"]);
                        }

                        DataRow dr = _dtVT.NewRow();
                        dr["Code"]  = TextUtils.ToString(r["Code"]);
                        dr["Name"]  = TextUtils.ToString(r["Name"]);
                        dr["Hang"]  = TextUtils.ToString(r["Hang"]);
                        dr["Unit"]  = "Bộ";
                        dr["Price"] = price.ToString("n0");
                        dr["Total"] = price.ToString("n0");
                        dr["Qty"]   = 1;

                        if (deliveryTime != -1)
                        {
                            dr["Time"] = deliveryTime;

                            DateTime dateP       = TextUtils.ToDate1(txtDateP.Text);
                            int      dateCurrent = TextUtils.ToInt(dr["Time"]);
                            if (dateCurrent < 0)
                            {
                                dr["Status"] = "Không đạt";
                            }
                            else
                            {
                                DateTime dateVT = DateTime.Now.AddDays(dateCurrent);
                                if (dateVT.Date <= dateP.Date)
                                {
                                    dr["Status"] = "Đạt";
                                }
                                else
                                {
                                    dr["Status"] = "Không đạt";
                                }
                            }
                        }

                        _dtVT.Rows.Add(dr);
                    }

                    txtTotalM.Text = TextUtils.ToDecimal(colMaTotal.SummaryItem.SummaryValue).ToString("n0");
                }
            }
        }