Ejemplo n.º 1
0
        private void btn_out_Click(object sender, EventArgs e)
        {
            int    sum         = int.Parse(textBox1.Text) - int.Parse(tb_count.Text);
            string houseNumber = "";
            int    list        = 0;
            int    blank       = 0;
            int    floor       = 0;
            //加料入库
            var    db        = new DBAccess_MySql("MySql");
            string outString = "";

            if (btn_out.Text == "入库")
            {
                if (sum == 0)
                {
                    sql = "UPDATE house_data SET have_number = " + sum + " WHERE house_number = '" + cb_houseNumber.Text + "' AND goods_code = '" + cb_suppliesName.Text + "' AND goods_name = '" + cb_specification.Text + "'";
                    db.ExecSql(sql, out outString);

                    sql = "DELETE FROM house_data WHERE have_number = " + 0;
                    db.ExecSql(sql, out outString);
                    list  = int.Parse((cb_houseNumber.Text).Substring(0, 2));
                    blank = int.Parse((cb_houseNumber.Text).Substring(2, 2));
                    floor = int.Parse((cb_houseNumber.Text).Substring(4, 2));
                    WriteSRM.WriteSrmData(btn_out.Text, 2, list, blank, floor);
                    btn_out.Text          = "出库";
                    cb_houseNumber.Text   = "";
                    cb_specification.Text = "";
                    cb_suppliesName.Text  = "";
                    textBox1.Text         = "";
                }
                else
                {
                    sql = "UPDATE house_data SET have_number = " + sum + " WHERE house_number = '" + cb_houseNumber.Text + "' AND goods_code = '" + cb_suppliesName.Text + "' AND goods_name = '" + cb_specification.Text + "'";
                    var rlt = db.ExecSql(sql, out outString);
                    list  = int.Parse((cb_houseNumber.Text).Substring(0, 2));
                    blank = int.Parse((cb_houseNumber.Text).Substring(2, 2));
                    floor = int.Parse((cb_houseNumber.Text).Substring(4, 2));
                    WriteSRM.WriteSrmData(btn_out.Text, 2, list, blank, floor);
                    btn_out.Text          = "出库";
                    cb_houseNumber.Text   = "";
                    cb_specification.Text = "";
                    cb_suppliesName.Text  = "";
                    textBox1.Text         = "";
                }
            }
            else
            {
                DataTable dt;
                sql = "SELECT house_number,list,blank,floor FROM house_info WHERE house_number = '" + cb_houseNumber.Text + "'";
                var rlt1 = db.QuerySQL_ToTable(sql, out dt, out outString);
                if (dt == null || dt.Rows.Count <= 0)
                {
                    return;
                }
                houseNumber = dt.Rows[0]["house_number"].ToString();
                list        = int.Parse(dt.Rows[0]["list"].ToString());
                blank       = int.Parse(dt.Rows[0]["blank"].ToString());
                floor       = int.Parse(dt.Rows[0]["floor"].ToString());
                WriteSRM.WriteSrmData(btn_out.Text, 2, list, blank, floor);
                btn_out.Text = "入库";
            }
            update_houseData();
        }
Ejemplo n.º 2
0
        private void btn_Add_Click(object sender, EventArgs e)
        {
            int sum = 0;

            if (textBox1.Text == "")
            {
                sum = int.Parse("0") + int.Parse(tb_count.Text);
            }
            else
            {
                sum = int.Parse(textBox1.Text) + int.Parse(tb_count.Text);
            }

            string houseNumber = "";
            int    list        = 0;
            int    blank       = 0;
            int    floor       = 0;
            //加料入库
            var       db        = new DBAccess_MySql("MySql");
            string    outString = "";
            DataTable dt;

            sql = "SELECT * FROM house_data WHERE house_number = '" + cb_houseNumber.Text + "' AND goods_code = '" + cb_suppliesName.Text + "' AND goods_name = '" + cb_specification.Text + "'";
            var    rlt3 = db.QuerySQL_ToTable(sql, out dt, out outString);
            string str  = "";

            foreach (DataRow dr in dt.Rows)
            {
                str = dr["house_number"].ToString();
            }

            if (str != "")
            {
                if (btn_Add.Text == "入库")
                {
                    sql = "UPDATE house_data SET have_number = " + sum + " WHERE house_number = '" + cb_houseNumber.Text + "' AND goods_code = '" + cb_suppliesName.Text + "' AND goods_name = '" + cb_specification.Text + "'";
                    var rlt = db.ExecSql(sql, out outString);
                    list  = int.Parse((cb_houseNumber.Text).Substring(0, 2));
                    blank = int.Parse((cb_houseNumber.Text).Substring(2, 2));
                    floor = int.Parse((cb_houseNumber.Text).Substring(4, 2));
                    WriteSRM.WriteSrmData(btn_Add.Text, 2, list, blank, floor);
                    btn_Add.Text          = "出库";
                    cb_houseNumber.Text   = "";
                    cb_specification.Text = "";
                    cb_suppliesName.Text  = "";
                    textBox1.Text         = "";
                }
                else
                {
                    sql = "SELECT house_number,list,blank,floor FROM house_info WHERE house_number = '" + cb_houseNumber.Text + "'";
                    var rlt1 = db.QuerySQL_ToTable(sql, out dt, out outString);
                    if (dt == null || dt.Rows.Count <= 0)
                    {
                        return;
                    }
                    houseNumber = dt.Rows[0]["house_number"].ToString();
                    list        = int.Parse(dt.Rows[0]["list"].ToString());
                    blank       = int.Parse(dt.Rows[0]["blank"].ToString());
                    floor       = int.Parse(dt.Rows[0]["floor"].ToString());
                    WriteSRM.WriteSrmData(btn_Add.Text, 2, list, blank, floor);
                    btn_Add.Text = "入库";
                }
            }
            else
            {
                if (btn_Add.Text == "入库")
                {
                    //跟新货位状态
                    sql = "INSERT INTO house_data(house_number,goods_name,goods_code,have_number,in_house_time) VALUES('" + cb_houseNumber.Text + "','" + cb_suppliesName.Text + "','" + cb_specification.Text + "'," + int.Parse(tb_count.Text) + ",SYSDATE())";
                    var rlt2 = db.ExecSql(sql, out outString);
                }

                sql = "SELECT house_number,list,blank,floor FROM house_info WHERE house_number = '" + cb_houseNumber.Text + "'";
                var rlt1 = db.QuerySQL_ToTable(sql, out dt, out outString);
                if (dt == null || dt.Rows.Count <= 0)
                {
                    return;
                }
                houseNumber = dt.Rows[0]["house_number"].ToString();
                list        = int.Parse(dt.Rows[0]["list"].ToString());
                blank       = int.Parse(dt.Rows[0]["blank"].ToString());
                floor       = int.Parse(dt.Rows[0]["floor"].ToString());
                WriteSRM.WriteSrmData(btn_Add.Text, 2, list, blank, floor);
                btn_Add.Text = "入库";
            }
            update_houseData();
        }