Esempio n. 1
0
 /*ปุ่มเพิ่มใบรับสินค้าตามใบสั่งซื้อ*/
 private void addReceive_Click(object sender, EventArgs e)
 {
     receive.FrmNewReceive frm = new FrmNewReceive();
     //frm.MdiParent = this.MdiParent;
     frm.ShowDialog();
     //frm.WindowState = FormWindowState.Maximized;
     if (frm.DialogResult == DialogResult.OK) {
         FindSearch();
     }
 }
Esempio n. 2
0
        //public frmAddReceive(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;
        //    InitializeComponent();
        //    String sql = "SELECT pod.PurchaseOrderDetailId,pod.ProductId, CASE when pod.ProductId = '0000000000-00' then pod.ProductNameWait " +
        //                "ELSE p.ProductName END AS ProductName ,(pod.Quantity) as q," +
        //                "CASE when ISNULL((SELECT sum(ReceiveDetailQuantity) FROM Receive_Detail Where PurchaseOrderDetailId = " + poDetailid + " And ReceiveHeadId = " + head + "),0) != 0 " +
        //                "THEN pod.Quantity -((select isnull(sum(ReceiveDetailQuantity),0) FROM Receive_Detail " +
        //                "Where PurchaseOrderDetailId = " + poDetailid + ") - (SELECT isnull(sum(ReceiveDetailQuantity),0) FROM Receive_Detail " +
        //                "Where PurchaseOrderDetailId = " + poDetailid + " And ReceiveHeadId = " + head + ")) - " + sum + " " +
        //                "ELSE " +
        //                "pod.Quantity -((select isnull(sum(ReceiveDetailQuantity),0) FROM Receive_Detail Where PurchaseOrderDetailId = " + poDetailid + ") - 0) END as Quantity , " +
        //                    "'' AS Qpack,up.UnitPackName,'' AS Qsale,us.UnitSaleName,pod.PricePerUnit,pod.DisText,isnull(pod.DisPerUnit,0) as DisPerUnit, " +
        //                    "pod.Dis,'' AS Total,po.PurchaseOrderId " +
        //                    "from PurchaseOrderDetail pod INNER JOIN PRODUCT p " +
        //                    "ON pod.ProductId = p.ProductId INNER JOIN UNITPACK up " +
        //                    "ON p.UnitPackId = up.UnitPackId INNER JOIN UNITSALE us " +
        //                    "ON p.UnitSaleId = us.UnitSaleId INNER JOIN PurchaseOrder po " +
        //                    "ON po.PurchaseOrderId = pod.PurchaseOrderId " +
        //                    "where pod.PurchaseOrderDetailId = " + poDetailid;
        //    DataTable dtNew = Class.DBConnString.clsDB.QueryDataTable(sql);
        //    String sql2 = "select * from receive_detail where ReceiveHeadId = '" + head + "' and PurchaseOrderDetailId = " + poDetailid;
        //    DataTable dtNew2 = Class.DBConnString.clsDB.QueryDataTable(sql2);
        //    foreach (DataRow row in dtNew2.Rows)
        //    {
        //        txtPrice.Text = String.Format("{0:0,0.00}",Convert.ToDouble(row["ReceiveDetailPriceUnit"].ToString()));
        //    }
        //    foreach (DataRow row in dtNew.Rows)
        //    {
        //        TxtProductId.Text = row["ProductId"].ToString();
        //        TxtProductName.Text = row["ProductName"].ToString();
        //        txtQReceive.Text = row["Quantity"].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 = lblSale.Text;
        //        lblPack.Text = row["UnitPackName"].ToString();
        //        if (dist + "" != "") {
        //            TxtPerDiscount.Text = dist;
        //        }
        //    }
        //    this.Text = "หน้าจอเพิ่มรายการรับสินค้า";
        //    type = Type;
        //    if (Type == "1")
        //    {
        //        dgvWeight.ColumnCount = 3;
        //        FrmNewReceive f = new FrmNewReceive();
        //        f.SetDgvWeight(tw, dgvWeight, Type);
        //        txtSale.Text = CellSum(1).ToString();
        //        txtWeight.Text = CellSum(2).ToString();
        //    }
        //    if (Type == "2")
        //    {
        //        dgvWeight.ColumnCount = 2;
        //        FrmNewReceive f = new FrmNewReceive();
        //        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 (d != "")
        //    {
        //        TxtDiscount.Text = String.Format("{0:0,0.00}",d);
        //    }
        //    if (dpu != "") {
        //        DisperUnit.Text = String.Format("{0:0,0.00}",dpu);
        //    }
        //    txtTrans.Text = String.Format("{0:0,0.00}", t);
        //}
        public frmAddReceive(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;
            InitializeComponent();

            String sql = "SELECT pod.PurchaseOrderDetailId,pod.ProductId, CASE when pod.ProductId = '0000000000-00' then pod.ProductNameWait " +
                        "ELSE p.ProductName END AS ProductName ,(pod.Quantity) as q," +
                        "CASE when ISNULL((SELECT sum(ReceiveDetailQuantity) FROM Receive_Detail Where PurchaseOrderDetailId = " + poDetailid + " And ReceiveHeadId = " + head + "),0) "+
                        "+ ISNULL((SELECT sum(OutsideStockDetail_Quantity) FROM OUTSIDE_STOCK_DETAIL Where PurchaseOrderDetailId = " + poDetailid + " And OutsideStockHeadId = " + head + "),0) " +
                        " != 0 " +
                        "THEN pod.Quantity -(((select isnull(sum(ReceiveDetailQuantity),0) FROM Receive_Detail " +
                        "Where PurchaseOrderDetailId = " + poDetailid + ") - (SELECT isnull(sum(ReceiveDetailQuantity),0) FROM Receive_Detail " +
                        "Where PurchaseOrderDetailId = " + poDetailid + " And ReceiveHeadId = " + head + ")) + "+
                        "((select isnull(sum(OutsideStockDetail_Quantity),0) FROM OUTSIDE_STOCK_DETAIL " +
                        "Where PurchaseOrderDetailId = " + poDetailid + ") - (SELECT isnull(sum(OutsideStockDetail_Quantity),0) FROM OUTSIDE_STOCK_DETAIL " +
                        "Where PurchaseOrderDetailId = " + poDetailid + " And OutsideStockHeadId = " + head + "))" +
                        ") - " + sum + " " +
                        "ELSE " +
                        "pod.Quantity -(((select isnull(sum(ReceiveDetailQuantity),0) FROM Receive_Detail Where PurchaseOrderDetailId = " + poDetailid + ") - 0) +  "+
                        "((select isnull(sum(OutsideStockDetail_Quantity),0) FROM OUTSIDE_STOCK_DETAIL Where PurchaseOrderDetailId = " + poDetailid + ") - 0) " +
                        ") END as Quantity , " +
                            "'' AS Qpack,up.UnitPackName,'' AS Qsale,us.UnitSaleName,pod.PricePerUnit,pod.DisText,isnull(pod.DisPerUnit,0) as DisPerUnit, " +
                            "pod.Dis,'' AS Total,po.PurchaseOrderId " +
                            "from PurchaseOrderDetail pod INNER JOIN PRODUCT p " +
                            "ON pod.ProductId = p.ProductId INNER JOIN UNITPACK up " +
                            "ON p.UnitPackId = up.UnitPackId INNER JOIN UNITSALE us " +
                            "ON p.UnitSaleId = us.UnitSaleId INNER JOIN PurchaseOrder po " +
                            "ON po.PurchaseOrderId = pod.PurchaseOrderId " +
                            "where pod.PurchaseOrderDetailId = " + poDetailid;
            DataTable dtNew = Class.DBConnString.clsDB.QueryDataTable(sql);

            String sql2 = "select * from receive_detail where ReceiveHeadId = '" + head + "' and PurchaseOrderDetailId = " + poDetailid;

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

            foreach (DataRow row in dtNew.Rows)
            {
                TxtProductId.Text = row["ProductId"].ToString();
                TxtProductName.Text = row["ProductName"].ToString();
                txtQReceive.Text = Convert.ToDouble(row["Quantity"]).ToString("#,##0.00");

                if (price + "" != "")
                {
                    txtPrice.Text = String.Format("{0:0,0.000000}", 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 = lblSale.Text;
                lblPack.Text = row["UnitPackName"].ToString();
                if (dist + "" != "")
                {
                    TxtPerDiscount.Text = dist;
                }
            }

            this.Text = "หน้าจอเพิ่มรายการรับสินค้า";
            type = Type;
            if (Type == "1")
            {
                dgvWeight.ColumnCount = 3;
                FrmNewReceive f = new FrmNewReceive();
                f.SetDgvWeight(tw, dgvWeight, Type);
                txtSale.Text = CellSum(1).ToString();
                txtWeight.Text = CellSum(2).ToString();
            }
            if (Type == "2")
            {
                dgvWeight.ColumnCount = 2;
                FrmNewReceive f = new FrmNewReceive();
                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 (d != "")
            {
                TxtDiscount.Text = String.Format("{0:0,0.00}", d);
            }
            if (dpu != "")
            {
                DisperUnit.Text = String.Format("{0:0,0.00}", dpu);
            }
            txtTrans.Text = String.Format("{0:0,0.00}", t);
        }
Esempio n. 3
0
 private void NewrecieveMenu_Click(object sender, EventArgs e)
 {
     receive.FrmNewReceive frmNewRecieve = new receive.FrmNewReceive();
     frmNewRecieve.MdiParent = this;
     frmNewRecieve.Show();
     frmNewRecieve.WindowState = FormWindowState.Maximized;
 }