private void toolStripButton1_Click(object sender, EventArgs e)
 {
     Transf.TranferRequisition frm = new TranferRequisition(stock);
     frm.ShowDialog();
     if (frm.DialogResult == DialogResult.OK) {
         toolStripButton2_Click(sender,e);
     }
 }
Exemple #2
0
        public TranferAddReq(String type, String id, String tw, String qtyp, String qty,String gid,String price)
        {
            ID = id;
            Type = type;
            Qty = qty;
            InitializeComponent();

            Class.clsDatabase cls = null;
            DataTable dt = null;

            String sql = "select p.productid,p.productname,u.unitpackname,us.unitsalename from product p left join unitpack u on p.unitpackid = u.unitpackid " +
            "left join unitsale us on p.unitsaleid = us.unitsaleid where p.productid = '" + id + "'";
            try
            {
                String local = "select * from GrStockDetail where GrStockDetailId = '" + gid + "'";
                DataRow d = Class.DBConnString.clsDB.QueryDataTable(local).Rows[0];
                if (Class.DBConnString.clsDB.QueryDataTable(local).Rows.Count > 0)
                {
                    cls = new Class.clsDatabase(d["ip"].ToString(), d["db"].ToString(),
                    d["dbuser"].ToString(), d["dbpass"].ToString(), "");
                    dt = cls.QueryDataTable(sql);
                }
                else
                {
                    dt = Class.DBConnString.clsDB.QueryDataTable(sql);
                }
            }
            catch {
                if (Class.DBConnString.sDb == "SHOPFR")
                {
                    DBConnString.strConn = "Data Source=192.168.0.3;Initial Catalog=SHOP; Persist Security Info=True;User ID=KTCNET;Password=khu@9wbe";
                    DBConnString.sServer = "192.168.0.3";
                    DBConnString.clsDB = new clsDatabase(DBConnString.strConn, DBConnString.sServer);
                }
                dt = Class.DBConnString.clsDB.QueryDataTable(sql);
            }

            DataTable dtNew = dt;

            foreach (DataRow row in dtNew.Rows)
            {
                TxtProductId.Text = row["ProductId"].ToString();
                TxtProductName.Text = row["ProductName"].ToString();
                lblSale1.Text = row["UnitSaleName"].ToString();
                lblPack.Text = row["UnitPackName"].ToString();
            }

            this.Text = "หน้าจอเพิ่มรายการเบิกโอนสินค้า";
            if (Type == "1")
            {
                dgvWeight.ColumnCount = 3;
                TranferRequisition f = new TranferRequisition();
                f.SetDgvWeightH(tw, dgvWeight, Type);
                txtSale.Text = CellSum(1).ToString();
                txtWeight.Text = CellSum(2).ToString();
                if (Class.DBConnString.sDb != "SHOP" || Class.DBConnString.sDb != "SHOPFR")
                {
                    textBox1.Text = price;
                }
            }
            if (Type == "2")
            {
                dgvWeight.ColumnCount = 2;
                TranferRequisition f = new TranferRequisition();
                f.SetDgvWeightH(tw, dgvWeight, Type);
                txtSale.Text = CellSum(1).ToString();
                txtWeight.Text = "0";
                if (Class.DBConnString.sDb != "SHOP" || Class.DBConnString.sDb != "SHOPFR")
                {
                    textBox1.Text = price;
                }
            }
            if (Type == "3")
            {
                dgvWeight.ColumnCount = 2;
                txtPack.Text = qtyp;
                txtSale.Text = qty;
                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 (Class.DBConnString.sDb != "SHOP" || Class.DBConnString.sDb != "SHOPFR")
                {
                    textBox1.Text = price;
                }
            }
        }