Esempio n. 1
0
        private void btnAddPK_Click(object sender, EventArgs e)
        {
            frmListMaterial frm = new frmListMaterial();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                //dtMaterial = frm.dtAll;
                //grdVT.DataSource = dtMaterial;
                foreach (DataRow r in frm.dtAll.Rows)
                {
                    string code = TextUtils.ToString(r["Code"]);
                    if (code == "")
                    {
                        continue;
                    }
                    DataRow[] drs = dtPK.Select("Code = '" + code + "'");
                    if (drs.Length > 0)
                    {
                        continue;
                    }

                    DataRow dr = dtPK.NewRow();
                    dr["Code"] = r["Code"].ToString();
                    dr["Name"] = r["Name"].ToString();
                    dr["Qty"]  = 1;
                    dtPK.Rows.Add(dr);
                }
            }
        }
Esempio n. 2
0
        private void btnAddVT_Click(object sender, EventArgs e)
        {
            frmListMaterial frm = new frmListMaterial();

            frm.dtAll = _dtMaterial.Copy();
            if (frm.ShowDialog() == DialogResult.OK)
            {
                _dtMaterial = frm.dtAll;
                foreach (DataRow row in _dtMaterial.Rows)
                {
                    string    code = TextUtils.ToString(row["Code"]);
                    DataRow[] drs  = _dtListMaterial.Select("Code = '" + code + "'");
                    if (drs.Length == 0)
                    {
                        DataRow dr = _dtListMaterial.NewRow();
                        dr["Code"]   = TextUtils.ToString(row["Code"]);
                        dr["Name"]   = TextUtils.ToString(row["Name"]);
                        dr["Hang"]   = TextUtils.ToString(row["Hang"]);
                        dr["Unit"]   = TextUtils.ToString(row["Unit"]);
                        dr["Qty"]    = TextUtils.ToDecimal(row["Qty"]);
                        dr["TonKho"] = TextUtils.ToDecimal(row["TonKho"]);
                        _dtListMaterial.Rows.Add(dr);
                    }
                }
                //grdVT.DataSource = _dtListMaterial;
            }
        }
Esempio n. 3
0
        private void btnAddVT_Click(object sender, EventArgs e)
        {
            frmListMaterial frm = new frmListMaterial();

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

                        //string sqlM = "SELECT top 1 * FROM  vGetPriceOfPart with(nolock)"
                        //                + " WHERE Price > 1 AND replace(replace([PartsCode],'/','#'),')','#') = '"
                        //                + code.Replace(" ", "").Replace("/", "#").Replace(")", "#") + "'"
                        //                + " ORDER BY DateAboutF DESC";
                        //DataTable dtPrice = LibQLSX.Select(sqlM);

                        string    sqlM    = "exec spGetPriceOfPart '" + code.Replace(" ", "").Replace("/", "#").Replace(")", "#") + "'";
                        DataTable dtPrice = LibQLSX.Select(sqlM);

                        DataRow dr = _dtDMVT.NewRow();
                        dr["Code"]       = r["Code"].ToString();
                        dr["Name"]       = r["Name"].ToString();
                        dr["Hang"]       = r["Hang"].ToString();
                        dr["Unit"]       = r["Unit"].ToString();
                        dr["QtyTon"]     = tonKho;
                        dr["SolutionID"] = TextUtils.ToInt(Solution.ID);
                        if (dtPrice.Rows.Count > 0)
                        {
                            dr["Price"] = TextUtils.ToDecimal(dtPrice.Rows[0]["Price"]).ToString("n0");
                        }
                        else
                        {
                            dr["Price"] = TextUtils.ToDecimal(r["Price"]).ToString("n0");
                        }
                        dr["TotalPrice"] = TextUtils.ToDecimal(dr["Price"]).ToString("n0");
                        dr["Qty"]        = 1;
                        _dtDMVT.Rows.Add(dr);
                    }
                }
            }
        }
Esempio n. 4
0
        private void btnAddVT_Click(object sender, EventArgs e)
        {
            frmListMaterial frm = new frmListMaterial();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                foreach (DataRow row in frm.dtAll.Rows)
                {
                    DataRow[] rows = dtMaterial.Select("Code = '" + row["Code"].ToString() + "'");
                    if (rows.Count() > 0)
                    {
                        continue;
                    }

                    DataRow dr = dtMaterial.NewRow();
                    dr["ID"]        = 0;
                    dr["ProductID"] = Product.ID;
                    dr["Code"]      = row["Code"].ToString();
                    dr["Name"]      = row["Name"].ToString();
                    dr["Qty"]       = 1;
                    dr["Hang"]      = row["Hang"].ToString();
                    dr["Type"]      = 1;
                    //if (row["Code"].ToString().StartsWith("TPAD"))
                    //{
                    //    DataTable dt = TextUtils.Select("SELECT ISNULL(MAX(Version), 0) FROM dbo.ModuleVersion WHERE (ModuleCode = '" + row["Code"].ToString() + "')");
                    //    dr["CVersion"] = dt.Rows.Count > 0 ? dt.Rows[0][0].ToString() : "0";
                    //    dr["NVersion"] = dr["CVersion"];
                    //}
                    //else
                    //{
                    //    dr["CVersion"] = "0";
                    //    dr["NVersion"] = "0";
                    //}
                    dr["CVersion"] = row["CVersion"].ToString();
                    dr["NVersion"] = row["NVersion"].ToString();
                    dtMaterial.Rows.Add(dr);

                    //dtMaterial.Rows.Add(0, BaiThucHanh.ID, row["Code"].ToString(), row["Name"].ToString(), 1, row["Hang"].ToString(), 1);
                }

                grdVT.DataSource = dtMaterial;
            }
        }
Esempio n. 5
0
        private void btnAddVT_Click(object sender, EventArgs e)
        {
            frmListMaterial frm = new frmListMaterial();

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

                        //string sqlM = "SELECT top 1 * FROM  vGetPriceOfPart with(nolock)"
                        //                + " WHERE Price > 1 AND replace(replace([PartsCode],'/','#'),')','#') = '"
                        //                + code.Replace(" ", "").Replace("/", "#").Replace(")", "#") + "'"
                        //                + " ORDER BY DateAboutF DESC";
                        //DataTable dtPrice = LibQLSX.Select(sqlM);

                        string    sqlM    = "exec spGetPriceOfPart '" + code.Replace(" ", "").Replace("/", "#").Replace(")", "#") + "'";
                        DataTable dtPrice = LibQLSX.Select(sqlM);

                        DataRow dr = _dtVT.NewRow();
                        dr["Code"]         = r["Code"].ToString();
                        dr["Name"]         = r["Name"].ToString();
                        dr["Hang"]         = r["Hang"].ToString();
                        dr["Unit"]         = r["Unit"].ToString();
                        dr["TonKho"]       = tonKho;
                        dr["DeliveryTime"] = TextUtils.ToInt(dtPrice.Rows[0]["DeliveryTime"]);

                        if (dtPrice.Rows.Count > 0)
                        {
                            dr["Price"] = TextUtils.ToDecimal(dtPrice.Rows[0]["Price"]).ToString("n0");
                            if (tonKho >= 1)
                            {
                                dr["Time"] = 1;
                            }
                            else
                            {
                                dr["Time"] = TextUtils.ToInt(dtPrice.Rows[0]["DeliveryTime"]);
                            }

                            DateTime dateP       = TextUtils.ToDate1(txtDateP.Text);
                            int      dateCurrent = TextUtils.ToInt(dr["Time"]);
                            if (dateCurrent < 0)
                            {
                                dr["Description"] = "Chưa phát sinh mua bán";
                            }
                            else
                            {
                                DateTime dateVT = DateTime.Now.AddDays(dateCurrent);
                                if (dateVT.Date <= dateP.Date)
                                {
                                    dr["Status"] = "Đạt";
                                }
                                else
                                {
                                    dr["Status"] = "Không đạt";
                                }
                            }
                        }
                        else
                        {
                            dr["Price"]       = TextUtils.ToDecimal(r["Price"]).ToString("n0");
                            dr["Description"] = "Chưa phát sinh mua bán";
                        }
                        dr["Total"] = TextUtils.ToDecimal(dr["Price"]).ToString("n0");

                        dr["Qty"] = 1;
                        _dtVT.Rows.Add(dr);
                    }
                    txtTotalM.Text = TextUtils.ToDecimal(colMaTotal.SummaryItem.SummaryValue).ToString("n0");
                    txtDateM.Text  = TextUtils.ToDecimal(colMaTime.SummaryItem.SummaryValue).ToString("n0");
                }
            }
        }