Exemplo n.º 1
0
        private void ShowDgvProduct()
        {
            String a = "";
            String delQ = "";
            String whereQ = "";
            frmSentConsignmentNew frm = new frmSentConsignmentNew();
            String StrFind = TbxFind.Text.Trim();

            String sql = "select distinct CO_REQ_DETAIL.ProductId,PRODUCT.ProductName,CO_STOCK_OWN.Pack,UNITPACK.UnitPackName,CO_STOCK_OWN.Quantity," +
                "UNITSALE.UnitSaleName from CO_REQ_DETAIL inner join PRODUCT ON PRODUCT.ProductId=CO_REQ_DETAIL.ProductId inner join CO_REQ_HEAD " +
                "on CO_REQ_HEAD.CQHeadId=CO_REQ_DETAIL.CQHeadId inner join CO_STOCK_DETAIL on CO_STOCK_DETAIL.CQHeadId=CO_REQ_DETAIL.CQHeadId " +
                "inner join COSIGNMENT_STOCK_HEAD on COSIGNMENT_STOCK_HEAD.COHeadId=CO_STOCK_DETAIL.COHeadId left join CO_STOCK_OWN " +
                "on CO_STOCK_OWN.ProductId=CO_REQ_DETAIL.ProductId inner join UNITPACK ON UNITPACK.UnitPackId=PRODUCT.UnitPackId INNER JOIN UNITSALE " +
                "ON UNITSALE.UnitSaleId=PRODUCT.UnitSaleId " +
                "where COSIGNMENT_STOCK_HEAD.GrStockDetailId='" + strStock + "' " +
                "and CO_REQ_DETAIL.ProductId like '%" + StrFind + "%' " +
                "or PRODUCT.ProductName like '%" + StrFind + "%' " +
                "order by CO_REQ_DETAIL.ProductId asc";
            DgvProduct.DataSource = Class.DBConnString.clsDB.QueryDataTable(sql);
            formatDgvPo();

            //foreach (DataGridViewRow row in DgvProduct.Rows)
            //{
            //    foreach (var elm in list)
            //    {
            //        if (elm.Key == row.Cells[0].Value.ToString())
            //        {
            //        }
            //    }
            //}
            DataTable dtNew = Class.DBConnString.clsDB.QueryDataTable(sql);
            foreach (DataRow row in dtNew.Rows)
            {
                foreach (DataGridViewRow r in DgvProduct.Rows)
                {
                    if ((dtNew.Rows[r.Index][2].ToString() == "") && (dtNew.Rows[r.Index][4].ToString() == ""))
                    {
                        r.DefaultCellStyle.BackColor = Color.Peru;
                    }
                    else
                    {
                        r.DefaultCellStyle.BackColor = Color.SteelBlue;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public frmAddCO(String head, String price, String poDetailid, String Type, String tw, String d, String p, String s, Double sum, String dpu, String dist, String t)
        {
            head2 = head;
            poDetailid2 = poDetailid;
            strprice = price;
            InitializeComponent();
            String sql = "SELECT p.productid,p.productname,'' as numpack,up.UnitPackName,'' as numsale,us.UnitSaleName," +
                 "(SELECT TOP 1 rd.ReceiveDetailPriceUnit FROM dbo.RECEIVE_DETAIL rd INNER JOIN dbo.RECEIVE_HEAD rh " +
                 "ON rh.ReceiveHeadId = rd.ReceiveHeadId ORDER BY rh.ReceiveHeadDate desc) AS price,'' as w,'' as totalprice " +
                 "from PRODUCT p left join UNITPACK up on up.UnitPackId=p.UnitPackId left join UNITSALE us on us.UnitSaleId=p.UnitSaleId " +
                 "where p.productid='" + poDetailid2 + "'";

            DataTable dtNew = Class.DBConnString.clsDB.QueryDataTable(sql);

            String sql2 = "select * from COSIGNMENT_STOCK_DETAIL where COHeadId = '" + head + "'";

            DataTable dtNew2 = Class.DBConnString.clsDB.QueryDataTable(sql2);
            foreach (DataRow row in dtNew2.Rows)
            {
                txtPrice.Text = String.Format("{0:0,0.00}", Convert.ToDouble(row["CODetailPriceUnit"].ToString()));
            }

            foreach (DataRow row in dtNew.Rows)
            {
                TxtProductId.Text = row["productId"].ToString();
                TxtProductName.Text = row["productName"].ToString();
                //txtQReceive.Text = row["price"].ToString();

                if (price + "" != "")
                {
                    txtPrice.Text = String.Format("{0:0,0.00}", Convert.ToDouble(price));
                }
                //TxtPerDiscount.Text = row["DisText"].ToString();
                //Disper = Convert.ToDouble(row["DisPerUnit"]);
                //Discount = Convert.ToDouble(row["Dis"]);
                //DisperUnit.Text = Convert.ToDouble(row["DisPerUnit"]).ToString();
                //QuantityAll = Convert.ToDouble(row["q"]);
                //lblSale.Text = row["UnitSaleName"].ToString();
                lblSale1.Text = row["UnitSaleName"].ToString();
                lblPack.Text = row["UnitPackName"].ToString();
                //if (dist + "" != "")
                //{
                //    TxtPerDiscount.Text = dist;
                //}
            }

            this.Text = "หน้าจอเพิ่มรายการ";
            type = Type;
            if (Type == "1")
            {
                dgvWeight.ColumnCount = 3;
                frmSentConsignmentNew f = new frmSentConsignmentNew();
                f.SetDgvWeight(tw, dgvWeight, Type);
                txtSale.Text = CellSum(1).ToString();
                txtWeight.Text = CellSum(2).ToString();
            }
            if (Type == "2")
            {
                dgvWeight.ColumnCount = 2;
                frmSentConsignmentNew f = new frmSentConsignmentNew();
                f.SetDgvWeight(tw, dgvWeight, Type);
                txtSale.Text = CellSum(1).ToString();
                txtWeight.Text = "0";
            }
            if (Type == "3")
            {
                dgvWeight.ColumnCount = 2;
                txtPack.Text = p;
                txtSale.Text = s;
                dgvWeight.Visible = false;
                txtPack.Enabled = true; txtPack.BackColor = Color.White;
                txtSale.Enabled = true; txtSale.BackColor = Color.White;
                btnAdd.Enabled = false;
                btnDel.Enabled = false;
                txtRunPack.Enabled = false;
                txtWeight.Text = "0";
                txtPack.Focus();
                txtPack.SelectAll();
            }
            if (dist != "")
            {
                TxtPerDiscount.Text = String.Format("{0:0,0.00}", dist);
            }
            if (d != "")
            {
                TxtDiscount.Text = String.Format("{0:0,0.00}", d);
            }
            if (dpu != "")
            {
                DisperUnit.Text = String.Format("{0:0,0.00}", dpu);
            }
        }
Exemplo n.º 3
0
        private void ShowDgvProduct()
        {
            String a = "";
            String delQ = "";
            String whereQ = "";
            frmSentConsignmentNew frm = new frmSentConsignmentNew();
            String StrFind = TbxFind.Text.Trim();

            String sql = "SELECT DISTINCT TOP(100) CO_REQ_DETAIL.ProductId,PRODUCT.ProductName " +
                "FROM CO_REQ_DETAIL " +
                "INNER JOIN PRODUCT ON CO_REQ_DETAIL.ProductId=PRODUCT.ProductId " +
                "INNER JOIN CO_STOCK_DETAIL ON CO_STOCK_DETAIL.CQHeadId=CO_STOCK_DETAIL.CQHeadId " +
                "INNER JOIN COSIGNMENT_STOCK_HEAD ON COSIGNMENT_STOCK_HEAD.COHeadId=CO_STOCK_DETAIL.COHeadId " +
                "WHERE COSIGNMENT_STOCK_HEAD.GrStockDetailId='" + strStock + "' " +
                "AND ((PRODUCT.ProductId = '" + StrFind + "')" +
                "OR PRODUCT.ProductName like '%" + StrFind + "%' OR (";
            String[] arr = StrFind.Split(' ');
            sql += " PRODUCT.ProductName like '%" + arr[0] + "%' ";
            for (int i = 1; i < arr.Length; i++)
            {
                sql += " AND PRODUCT.ProductName like '%" + arr[i] + "%' ";
            }
            sql += " )";
            sql += " ) ";
            //DataSet ds = sqlquery(sql);
            //DataTable dt = ds.Tables[0];
            //DgvProduct.DataSource = dt;
            //FormatDgvPProduct();

            DgvProduct.DataSource = Class.DBConnString.clsDB.QueryDataTable(sql);
            formatDgvPo();
            foreach (DataGridViewRow row in DgvProduct.Rows)
            {
                foreach (var elm in list)
                {
                    if (elm.Key == row.Cells[0].Value.ToString())
                    {
                        //row.Cells[2].Value = Convert.ToDouble(row.Cells[2].Value) - elm.Value;
                    }
                }
                //row.Cells[2].Value = String.Format("{0:0.00}", row.Cells[2].Value.ToString());
                //row.Cells[4].Value = String.Format("{0:0.00}", row.Cells[4].Value.ToString());
            }
        }
Exemplo n.º 4
0
        /*แสดงใบเบิก*/
        private void ShowDgvProduct()
        {
            String a = "";
            String delQ = "";
            String whereQ = "";
            frmSentConsignmentNew frm = new frmSentConsignmentNew();
            String StrFind = TbxFind.Text.Trim();

            String sql = "select CO_REQ_HEAD.CQHeadId,CO_REQ_HEAD.CQHeadDate,GrStockDetail.GrStockDetailLName,CO_REQ_STATUS.COStatusName " +
                "from CO_REQ_HEAD inner join GrStockDetail on GrStockDetail.GrStockDetailId=CO_REQ_HEAD.GrStockDetailId " +
                "inner join CO_REQ_STATUS on CO_REQ_STATUS.COStatusId=CO_REQ_HEAD.COStatusId " +
                "where GrStockDetail.GrStockDetailId='" + Stock + "'and CO_REQ_HEAD.COStatusId='" + iSta + "' and CO_REQ_HEAD.ConfirmId=3 " +
                "and CO_REQ_HEAD.CQHeadId like '%" + StrFind + "%'";
            DgvProduct.DataSource = Class.DBConnString.clsDB.QueryDataTable(sql);
            formatDgvPo();
        }
        /*แสดงรายการสินค้า*/
        private void ShowDgvProduct()
        {
            String a = "";
            String delQ = "";
            String whereQ = "";
            frmSentConsignmentNew frm = new frmSentConsignmentNew();
            String StrFind = TbxFind.Text.Trim();

            String sql = "SELECT top(100) PRODUCT.ProductId,PRODUCT.ProductName,UNITPACK.UnitPackName,UNITSALE.UnitSaleName," +
                "isnull((select top 1 RECEIVE_DETAIL.ReceiveDetailPriceUnit from RECEIVE_DETAIL inner join RECEIVE_HEAD " +
                "on RECEIVE_HEAD.ReceiveHeadId=RECEIVE_DETAIL.ReceiveHeadId where PRODUCT.ProductId = RECEIVE_DETAIL.ProductId " +
                "order by RECEIVE_HEAD.ReceiveHeadDate desc),'0') AS price from PRODUCT left join UNITPACK on UNITPACK.UnitPackId=PRODUCT.UnitPackId " +
                "left join UNITSALE on UNITSALE.UnitSaleId=PRODUCT.UnitSaleId " +
                "where (PRODUCT.ProductId like '%" + StrFind + "%' or PRODUCT.ProductName like '%" + StrFind + "%') " +
                "and PRODUCT.Status is null " +
                "order by PRODUCT.ProductId asc";
            //String sql = "select * from product";
            DgvProduct.DataSource = Class.DBConnString.clsDB.QueryDataTable(sql);
            formatDgvPo();
            foreach (DataGridViewRow row in DgvProduct.Rows)
            {
                foreach (var elm in list)
                {
                    if (elm.Key == row.Cells[0].Value.ToString())
                    {
                        row.Cells[2].Value = Convert.ToDouble(row.Cells[2].Value) - elm.Value;
                    }
                }
                row.Cells[2].Value = String.Format("{0:0.00}", row.Cells[2].Value.ToString());
                row.Cells[4].Value = String.Format("{0:0.00}", row.Cells[4].Value.ToString());
            }
        }
Exemplo n.º 6
0
        /*แสดงรายการสินค้าที่อยู่คลังสินค้าฝาก*/
        private void ShowDgvProduct()
        {
            String a = "";
            String delQ = "";
            String whereQ = "";
            frmSentConsignmentNew frm = new frmSentConsignmentNew();
            String StrFind = TbxFind.Text.Trim();

            String sqlSelectLevel = "select isnull(CusTypeId,'1') from CUSTOMER where CustomerId='" + StrSup + "'";
            DataTable dtLevel = Class.DBConnString.clsDB.QueryDataTable(sqlSelectLevel);
            String CLevel = dtLevel.Rows[0][0].ToString();
            String strLevel = "Level" + CLevel + "";

            String sql = "select distinct CO_REQ_DETAIL.ProductId,PRODUCT.ProductName,UNITPACK.UnitPackName,UNITSALE.UnitSaleName," +
                "isnull((select top 1 SALE_DETAIL.SaleDetailPriceUnit from SALE_DETAIL inner join SALE_HEAD " +
                "on SALE_HEAD.SaleHeadId=SALE_DETAIL.SaleHeadId where PRODUCT.ProductId = SALE_DETAIL.ProductId " +
                "order by SALE_HEAD.SaleHeadDate desc),'0') as UnitPrice " +
                "from PRODUCT inner join CO_REQ_DETAIL " +
                "on CO_REQ_DETAIL.ProductId=PRODUCT.ProductId inner join UNITPACK on UNITPACK.UnitPackId=PRODUCT.UnitPackId inner join UNITSALE " +
                "on UNITSALE.UnitSaleId=PRODUCT.UnitSaleId " +
                "inner join CO_STOCK_DETAIL on CO_STOCK_DETAIL.CQHeadId=CO_REQ_DETAIL.CQHeadId " +
                "inner join COSIGNMENT_STOCK_HEAD on COSIGNMENT_STOCK_HEAD.COHeadId=CO_STOCK_DETAIL.COHeadId " +
                "where COSIGNMENT_STOCK_HEAD.COStatusId='1' " +
                "and CO_REQ_DETAIL.ProductId like '%" + StrFind + "%' " +
                " or PRODUCT.ProductName like '%" + StrFind + "%' " +
                "order by CO_REQ_DETAIL.ProductId asc";
            DgvProduct.DataSource = Class.DBConnString.clsDB.QueryDataTable(sql);
            formatDgvPo();
            foreach (DataGridViewRow row in DgvProduct.Rows)
            {
                foreach (var elm in list)
                {
                    if (elm.Key == row.Cells[0].Value.ToString())
                    {
                        row.Cells[2].Value = Convert.ToDouble(row.Cells[2].Value) - elm.Value;
                    }
                }
                row.Cells[2].Value = String.Format("{0:0.00}", row.Cells[2].Value.ToString());
                row.Cells[4].Value = String.Format("{0:0.00}", row.Cells[4].Value.ToString());
            }
        }
Exemplo n.º 7
0
        /*แสดงรายการสินค้า*/
        private void ShowDgvProduct()
        {
            String a = "";
            String delQ = "";
            String whereQ = "";
            frmSentConsignmentNew frm = new frmSentConsignmentNew();
            String StrFind = TbxFind.Text.Trim();

            String sql = "select distinct CO_REQ_DETAIL.ProductId,PRODUCT.ProductName,UNITPACK.UnitPackName,UNITSALE.UnitSaleName," +
                "CO_REQ_DETAIL.CQDetailPriceUnit from PRODUCT inner join CO_REQ_DETAIL " +
                "on CO_REQ_DETAIL.ProductId=PRODUCT.ProductId inner join UNITPACK on UNITPACK.UnitPackId=PRODUCT.UnitPackId inner join UNITSALE " +
                "on UNITSALE.UnitSaleId=PRODUCT.UnitSaleId " +
                "inner join CO_STOCK_DETAIL on CO_STOCK_DETAIL.CQHeadId=CO_REQ_DETAIL.CQHeadId " +
                "inner join COSIGNMENT_STOCK_HEAD on COSIGNMENT_STOCK_HEAD.COHeadId=CO_STOCK_DETAIL.COHeadId " +
                "where CO_REQ_DETAIL.ProductId like '%" + StrFind + "%' or PRODUCT.ProductName like '%" + StrFind + "%' order by CO_REQ_DETAIL.ProductId asc";
            DgvProduct.DataSource = Class.DBConnString.clsDB.QueryDataTable(sql);
            formatDgvPo();
            foreach (DataGridViewRow row in DgvProduct.Rows)
            {
                foreach (var elm in list)
                {
                    if (elm.Key == row.Cells[0].Value.ToString())
                    {
                        row.Cells[2].Value = Convert.ToDouble(row.Cells[2].Value) - elm.Value;
                    }
                }
                row.Cells[2].Value = String.Format("{0:0.00}", row.Cells[2].Value.ToString());
                row.Cells[4].Value = String.Format("{0:0.00}", row.Cells[4].Value.ToString());
            }
        }