private void MerchandiseQuery_Load(object sender, EventArgs e) { update_houseData(); //tb_specification.ReadOnly = true; System.Data.DataTable dt; var db = new DBAccess_MySql("MySql"); string outString = ""; sql = "SELECT * FROM config_unit"; var rlt1 = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr = dt.Rows[0]; string s = dr[0].ToString(); string name = dr[0].ToString(); if (name == "S") { btnBinding.Visible = true; btn_cancel.Visible = true; btn_updata.Visible = true; } else { btnBinding.Visible = false; btn_cancel.Visible = false; btn_updata.Visible = false; } }
//出库过账 public void OutAccount(int s_FrLine, int s_FrGrids, int s_FrTiers, int s_ToStand) { string houseNumber = "0" + s_FrLine + "0" + s_FrGrids + "0" + s_FrTiers; var db = new DBAccess_MySql("MySql"); string outString = ""; DataTable dt; string sql; sql = "SELECT goods_id,goods_code,goods_name FROM goods_info WHERE goods_style = '" + houseNumber + "'"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr = dt.Rows[0]; string goods_id = dr[0].ToString(); string goods_code = dr[1].ToString(); string goods_name = dr[2].ToString(); //跟新货位状态 sql = "UPDATE house_info SET house_state = 'N' WHERE house_number = '" + houseNumber + "'"; db.ExecSql(sql, out outString); //删除库存表数据 sql = "DELETE FROM house_data WHERE house_number = '" + houseNumber + "'"; db.ExecSql(sql, out outString); sql = "UPDATE order_info SET order_state = 3 WHERE order_state = 1 LIMIT 1"; db.ExecSql(sql, out outString); }
private void btn_updata_Click(object sender, EventArgs e) { System.Data.DataTable dt; if (MessageBox.Show("名称:" + tb_suppliesName.Text + " 规格:" + tb_specification.Text + " 高度:" + tb_sort.Text, "确定修改!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { var db = new DBAccess_MySql("MySql"); string outString = ""; sql = "UPDATE goods_info SET goods_code = '" + tb_specification.Text + "',goods_name = '" + tb_suppliesName.Text + "' WHERE goods_id = " + label7.Text + ""; db.ExecSql(sql, out outString); try { sql = "SELECT goods_code,goods_name,goods_style FROM goods_info WHERE goods_id = " + label7.Text + ""; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr = dt.Rows[0]; string goods_code = dr[0].ToString(); string goods_name = dr[1].ToString(); string goods_style = dr[2].ToString(); sql = "UPDATE house_data SET goods_code = '" + goods_name + "',goods_name = '" + goods_code + "' WHERE house_number = '" + goods_style + "'"; db.ExecSql(sql, out outString); } catch { } } update_houseData(); }
//入库过账 public void InAccount(int s_FrStand, int s_ToLine, int s_ToGrid, int s_ToTier) { string houseNumber = "0" + s_ToLine + "0" + s_ToGrid + "0" + s_ToTier; var db = new DBAccess_MySql("MySql"); string outString = ""; DataTable dt; string sql; sql = "SELECT goods_id,goods_code,goods_name FROM goods_info WHERE goods_style = '" + houseNumber + "'"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr = dt.Rows[0]; string goods_id = dr[0].ToString(); string goods_code = dr[1].ToString(); string goods_name = dr[2].ToString(); //跟新货位状态 sql = "UPDATE house_info SET house_state = 'O' WHERE house_number = '" + houseNumber + "'"; db.ExecSql(sql, out outString); //更新库存数据 sql = "INSERT INTO house_data(house_number,goods_code,goods_name,have_number,in_house_time) VALUES('" + houseNumber + "','" + goods_name + "','" + goods_code + "'," + 1 + ",SYSDATE())"; db.ExecSql(sql, out outString); sql = "UPDATE order_info SET order_state = 3 WHERE order_state = 1 LIMIT 1"; db.ExecSql(sql, out outString); }
//故障过账 public void Fault() { #region 指令过账 var db = new DBAccess_MySql("MySql"); string outString = ""; DataTable dt; string sql; sql = "SELECT order_user,order_id,order_style FROM order_info WHERE order_state = 1 LIMIT 1"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr = dt.Rows[0]; string order_user = dr[0].ToString(); string orderid = dr[1].ToString(); string orderstyle = dr[2].ToString(); sql = "SELECT goods_code,goods_name,goods_style FROM goods_info WHERE goods_id = " + int.Parse(order_user) + ""; var rlt1 = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr1 = dt.Rows[0]; string goods_code = dr1[0].ToString(); string goods_name = dr1[1].ToString(); string goods_style = dr1[2].ToString(); if (orderstyle == "1")//入库 { ////跟新货位状态 sql = "UPDATE house_info SET house_state = 'N' WHERE house_number = '" + goods_style + "'"; db.ExecSql(sql, out outString); sql = "UPDATE order_info SET order_state = 2 WHERE order_id = " + int.Parse(orderid) + ""; db.ExecSql(sql, out outString); } if (orderstyle == "2")//出库 { ////跟新货位状态 sql = "UPDATE house_info SET house_state = 'S' WHERE house_number = '" + goods_style + "'"; db.ExecSql(sql, out outString); //更新库存数据 sql = "INSERT INTO house_data(house_number,goods_code,goods_name,have_number,in_house_time) VALUES('" + goods_style + "','" + goods_name + "','" + goods_code + "'," + 1 + ",SYSDATE())"; db.ExecSql(sql, out outString); sql = "UPDATE order_info SET order_state = 2 WHERE order_id = " + int.Parse(orderid) + ""; db.ExecSql(sql, out outString); } #endregion }
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { DataTable dt; string sql; try { //tb_houseNumber.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); //string s = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); var db = new DBAccess_MySql("MySql"); string outString = ""; //sql = "SELECT goods_code FROM goods_info WHERE goods_style = '"+ tb_houseNumber.Text + "'"; //var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); //DataRow dr = dt.Rows[0]; //string goods_code = dr[0].ToString(); //tb_sort.Text = goods_code; string housenumber; housenumber = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); if (housenumber != "0") { tb_houseNumber.Text = housenumber; } else { tb_houseNumber.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); } sql = "SELECT goods_code FROM goods_info WHERE goods_style = '" + tb_houseNumber.Text + "'"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr = dt.Rows[0]; string goods_code = dr[0].ToString(); tb_sort.Text = goods_code; string state = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); string style = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); if (state == "3") { tb_state.Text = "完成"; } if (state == "2") { tb_state.Text = "未完成"; } if (style == "1") { tb_style.Text = "入库"; } if (style == "2") { tb_style.Text = "出库"; } } catch { } }
private void comboBox1_DropDown(object sender, EventArgs e) { var db = new DBAccess_MySql("MySql"); dataGridView1.Columns.Clear(); sql = "SELECT user_code FROM user_info"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); comboBox1.DataSource = dt; comboBox1.DisplayMember = "user_code"; }
private void UserMaintain_Load(object sender, EventArgs e) { DataTable dt; var db = new DBAccess_MySql("MySql"); string outString = ""; sql = "SELECT * FROM config_unit"; var rlt1 = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr = dt.Rows[0]; string s = dr[0].ToString(); lb_S.Text = dr[0].ToString(); }
private void seleteGoodsData(string sql) { DataTable dt; var db = new DBAccess_MySql("MySql"); dataGridView1.Columns.Clear(); string outString = ""; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); dataGridView1.DataSource = dt; dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LightBlue; dataGridView1.Columns[0].HeaderText = "物料编号"; dataGridView1.Columns[1].HeaderText = "物料名称"; dataGridView1.Columns[2].HeaderText = "物料规格"; dataGridView1.Columns[3].HeaderText = "库位编号"; }
private void comboBox1_DropDown(object sender, EventArgs e) { DataTable dt; var db = new DBAccess_MySql("MySql"); dataGridView1.Columns.Clear(); string outString = ""; sql = "SELECT house_number FROM house_info WHERE house_state = 'N'"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); comboBox1.DataSource = dt; comboBox1.DisplayMember = "house_number"; comboBox1.Text = ""; update_goodInfo(); }
private void cb_houseNumber_DropDown(object sender, EventArgs e) { DataTable dt; var db = new DBAccess_MySql("MySql"); dataGridView1.Columns.Clear(); string outString = ""; sql = "SELECT house_number FROM house_info"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); cb_houseNumber.DataSource = dt; cb_houseNumber.DisplayMember = "house_number"; cb_houseNumber.Text = ""; update_houseData(); }
public void update_goodInfo() { DataTable dt; var db = new DBAccess_MySql("MySql"); dataGridView1.Columns.Clear(); string outString = ""; sql = "SELECT gi.goods_id,gi.goods_name,gi.goods_code,gi.goods_style FROM goods_info gi,house_info hi WHERE gi.goods_style = hi.house_number AND hi.house_state = 'N'"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); dataGridView1.DataSource = dt; dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LightBlue; dataGridView1.Columns[0].HeaderText = "物料编号"; dataGridView1.Columns[1].HeaderText = "物料名称"; dataGridView1.Columns[2].HeaderText = "物料规格"; dataGridView1.Columns[3].HeaderText = "库位编号"; }
//查询库存数据 private void seleteData(string sql) { DataTable dt; var db = new DBAccess_MySql("MySql"); dataGridView1.Columns.Clear(); string outString = ""; //sql = "SELECT house_number,goods_code,goods_name,in_house_time,have_number FROM house_data"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); dataGridView1.DataSource = dt; dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LightBlue; dataGridView1.Columns[0].HeaderText = "库位编号"; dataGridView1.Columns[1].HeaderText = "物料名称"; dataGridView1.Columns[2].HeaderText = "物料规格"; dataGridView1.Columns[3].HeaderText = "创建时间"; dataGridView1.Columns[4].HeaderText = "物料数量"; }
private string SelectState(string name) { try { System.Data.DataTable dt; var db = new DBAccess_MySql("MySql"); string outString = ""; sql = "SELECT house_state FROM house_info WHERE house_number = '" + name + "'"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr = dt.Rows[0]; string state = dr[0].ToString(); return(state); } catch { return(name); } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { var db = new DBAccess_MySql("MySql"); sql = "SELECT id,user_code,user_name,pass_word FROM user_info WHERE user_code = '" + comboBox1.Text + "'"; db.QuerySQL_ToTable(sql, out dt, out outString); if (dt == null || dt.Rows.Count <= 0) { return; } string id = dt.Rows[0]["id"].ToString(); string user_code = dt.Rows[0]["user_code"].ToString(); string user_name = dt.Rows[0]["user_name"].ToString(); string pass_word = dt.Rows[0]["pass_word"].ToString(); lab_id.Text = id; textBox2.Text = user_name; textBox3.Text = pass_word; }
public void update_goodInfo() { DataTable dt; var db = new DBAccess_MySql("MySql"); dataGridView1.Columns.Clear(); string outString = ""; sql = "SELECT goods_id,goods_name,goods_code,goods_height,modify_time FROM goods_info"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); dataGridView1.DataSource = dt; dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LightBlue; dataGridView1.Columns[0].HeaderText = "物料编号"; dataGridView1.Columns[1].HeaderText = "物料名称"; dataGridView1.Columns[2].HeaderText = "物料规格"; dataGridView1.Columns[3].HeaderText = "物料高度"; dataGridView1.Columns[4].HeaderText = "创建时间"; }
public void update_houseData() { DataTable dt; var db = new DBAccess_MySql("MySql"); dataGridView1.Columns.Clear(); string outString = ""; //sql = "SELECT * FROM doc_info"; sql = "SELECT order_id,order_state,order_style,house_from,house_to,order_time FROM order_info WHERE order_state = 3 OR order_state = 2 ORDER BY order_id DESC LIMIT 500"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); dataGridView1.DataSource = dt; dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LightBlue; dataGridView1.Columns[0].HeaderText = "指令编号"; dataGridView1.Columns[1].HeaderText = "指令状态"; dataGridView1.Columns[2].HeaderText = "指令类型"; dataGridView1.Columns[3].HeaderText = "库位编号"; dataGridView1.Columns[4].HeaderText = "库位编号"; dataGridView1.Columns[5].HeaderText = "时间日期"; }
private void cb_houseNumber_DropDown(object sender, EventArgs e) { try { System.Data.DataTable dt; var db = new DBAccess_MySql("MySql"); string outString = ""; //sql = "SELECT bf_h_to_h,house_number,house_state,house_style FROM house_info WHERE bf_h_to_h = '" + tb_sort.Text + "' AND house_style LIKE '%" + (tb_suppliesName.Text).Substring(1, 1) + "%' AND house_state = 'N' AND before_change = 'N'"; sql = "SELECT bf_h_to_h,house_number,house_state,house_style FROM house_info WHERE before_change = 'N' OR before_change = 'B' "; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr = dt.Rows[0]; string house_number = dr[1].ToString(); string house_state = dr[2].ToString(); cb_houseNumber.DataSource = dt; cb_houseNumber.DisplayMember = "house_number"; } catch { MessageBox.Show("请填入物料信息!"); } }
public void update_houseData() { System.Data.DataTable dt; var db = new DBAccess_MySql("MySql"); dataGridView1.Columns.Clear(); string outString = ""; sql = "SELECT goods_id,goods_name,goods_code,goods_height,goods_style,modify_time FROM goods_info"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); dataGridView1.DataSource = dt; dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LightBlue; //dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Blue; //dataGridView1.DefaultCellStyle.SelectionBackColor = Color.LightYellow; dataGridView1.Columns[0].HeaderText = "物料编号"; dataGridView1.Columns[1].HeaderText = "物料名称"; dataGridView1.Columns[2].HeaderText = "物料规格"; dataGridView1.Columns[3].HeaderText = "物料高度"; dataGridView1.Columns[4].HeaderText = "库位号"; dataGridView1.Columns[5].HeaderText = "创建时间"; }
public void update_orderInfo() { DataTable dt; var db = new DBAccess_MySql("MySql"); dataGridView1.Columns.Clear(); string outString = ""; sql = "SELECT order_id,order_state,order_style,station_from,station_to,house_from,house_to,order_user,order_time FROM order_info WHERE order_state = 0 or order_state = 1"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); dataGridView1.DataSource = dt; dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LightBlue; dataGridView1.Columns[0].HeaderText = "命令编号"; dataGridView1.Columns[1].HeaderText = "命令状态"; dataGridView1.Columns[2].HeaderText = "命令类别"; dataGridView1.Columns[3].HeaderText = "站号来源"; dataGridView1.Columns[4].HeaderText = "站号目的"; dataGridView1.Columns[5].HeaderText = "库位来源"; dataGridView1.Columns[6].HeaderText = "库位目的"; dataGridView1.Columns[7].HeaderText = "物料编号"; dataGridView1.Columns[8].HeaderText = "创建时间"; }
//判断当前指令0 public int OrderInfo() { try { var db = new DBAccess_MySql("MySql"); string outString = ""; DataTable dt; string sql; sql = "SELECT order_user,order_id,order_style,order_state FROM order_info WHERE order_state = 0 LIMIT 1"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr = dt.Rows[0]; string order_user = dr[0].ToString(); string orderid = dr[1].ToString(); string orderstyle = dr[2].ToString(); string order_state = dr[3].ToString(); return(int.Parse(order_state)); } catch { return(1); } }
//PLC写入指令 public string Write() { try { int list = 0; int blank = 0; int floor = 0; string str = null; var db = new DBAccess_MySql("MySql"); string outString = ""; DataTable dt; string sql; sql = "SELECT order_user,order_id,order_style FROM order_info WHERE order_state = 0 LIMIT 1"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr = dt.Rows[0]; string order_user = dr[0].ToString(); string orderid = dr[1].ToString(); string orderstyle = dr[2].ToString(); if (orderstyle == "1") { str = "入库"; } if (orderstyle == "2") { str = "出库"; } #region 入库 if (str == "入库") { //指令过账 sql = "SELECT goods_code,goods_name,goods_style FROM goods_info WHERE goods_id = " + int.Parse(order_user) + ""; var rlt1 = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr1 = dt.Rows[0]; string goods_code = dr1[0].ToString(); string goods_name = dr1[1].ToString(); string goods_style = dr1[2].ToString(); sql = "SELECT house_number,line,list,blank,floor FROM house_info WHERE house_state = 'I' and house_number = '" + goods_style + "'"; db.QuerySQL_ToTable(sql, out dt, out outString); if (dt == null || dt.Rows.Count <= 0) { return("S"); } list = int.Parse(dt.Rows[0]["list"].ToString()); blank = int.Parse(dt.Rows[0]["blank"].ToString()); floor = int.Parse(dt.Rows[0]["floor"].ToString()); if (orderstyle == "1")//下达入库 { //////跟新货位状态 //sql = "UPDATE house_info SET house_state = 'S' WHERE house_number = '" + goods_style + "'"; //db.ExecSql(sql, out outString); ////删除 //sql = "UPDATE order_info SET order_state = 3 WHERE order_id = " + int.Parse(orderid) + ""; //db.ExecSql(sql, out outString); foreach (var s in PLCSystem_SRM.Dic_SRM_Request) { s.Value.s_serial = 1; s.Value.s_pattern = 2; if (goods_name == "端拾器") { s.Value.s_FrStand = 1; } if (goods_name == "检具") { s.Value.s_FrStand = 2; } s.Value.s_FrLine = 0; s.Value.s_FrGrid = 0; s.Value.s_FrTier = 0; s.Value.s_ToStand = 0; s.Value.s_ToLine = (ushort)list; s.Value.s_ToGrid = (ushort)blank; s.Value.s_ToTier = (ushort)floor; //s.Value.s_execute_signal = 0; break; } } if (orderstyle == "2")//下达出库 { ////删除物料库存 //////跟新货位状态 //sql = "UPDATE house_info SET house_state = 'N' WHERE house_number = '" + goods_style + "'"; //db.ExecSql(sql, out outString); ////删除 //sql = "DELETE FROM house_data WHERE house_number = '" + goods_style + "'"; //db.ExecSql(sql, out outString); //sql = "UPDATE order_info SET order_state = 3 WHERE order_id = " + int.Parse(orderid) + ""; //db.ExecSql(sql, out outString); foreach (var s in PLCSystem_SRM.Dic_SRM_Request) { s.Value.s_serial = 1; s.Value.s_pattern = 1; s.Value.s_FrStand = 0; s.Value.s_FrLine = (ushort)list; s.Value.s_FrGrid = (ushort)blank; s.Value.s_FrTier = (ushort)floor; if (goods_name == "端拾器") { s.Value.s_ToStand = 1; } if (goods_name == "检具") { s.Value.s_ToStand = 2; } s.Value.s_ToLine = 0; s.Value.s_ToGrid = 0; s.Value.s_ToTier = 0; //s.Value.s_execute_signal = 0; break; } } } #endregion #region 出库 if (str == "出库") { //指令过账 sql = "SELECT goods_code,goods_name,goods_style FROM goods_info WHERE goods_id = " + int.Parse(order_user) + ""; var rlt1 = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr1 = dt.Rows[0]; string goods_code = dr1[0].ToString(); string goods_name = dr1[1].ToString(); string goods_style = dr1[2].ToString(); sql = "SELECT house_number,line,list,blank,floor FROM house_info WHERE house_state = 'O' and house_number = '" + goods_style + "'"; db.QuerySQL_ToTable(sql, out dt, out outString); if (dt == null || dt.Rows.Count <= 0) { return("S"); } list = int.Parse(dt.Rows[0]["list"].ToString()); blank = int.Parse(dt.Rows[0]["blank"].ToString()); floor = int.Parse(dt.Rows[0]["floor"].ToString()); if (orderstyle == "1")//写入 入库指令 { //////跟新货位状态 //sql = "UPDATE house_info SET house_state = 'S' WHERE house_number = '" + goods_style + "'"; //db.ExecSql(sql, out outString); ////删除 //sql = "UPDATE order_info SET order_state = 3 WHERE order_id = " + int.Parse(orderid) + ""; //db.ExecSql(sql, out outString); foreach (var s in PLCSystem_SRM.Dic_SRM_Request) { s.Value.s_serial = 1; s.Value.s_pattern = 2; if (goods_name == "端拾器") { s.Value.s_FrStand = 1; } if (goods_name == "检具") { s.Value.s_FrStand = 2; } s.Value.s_FrLine = 0; s.Value.s_FrGrid = 0; s.Value.s_FrTier = 0; s.Value.s_ToStand = 0; s.Value.s_ToLine = (ushort)list; s.Value.s_ToGrid = (ushort)blank; s.Value.s_ToTier = (ushort)floor; //s.Value.s_execute_signal = 0; break; } } if (orderstyle == "2")//写入 出库指令 { ////删除物料库存 //////跟新货位状态 //sql = "UPDATE house_info SET house_state = 'N' WHERE house_number = '" + goods_style + "'"; //db.ExecSql(sql, out outString); ////删除 //sql = "DELETE FROM house_data WHERE house_number = '" + goods_style + "'"; //db.ExecSql(sql, out outString); //sql = "UPDATE order_info SET order_state = 3 WHERE order_id = " + int.Parse(orderid) + ""; //db.ExecSql(sql, out outString); foreach (var s in PLCSystem_SRM.Dic_SRM_Request) { s.Value.s_serial = 1; s.Value.s_pattern = 1; s.Value.s_FrStand = 0; s.Value.s_FrLine = (ushort)list; s.Value.s_FrGrid = (ushort)blank; s.Value.s_FrTier = (ushort)floor; if (goods_name == "端拾器") { s.Value.s_ToStand = 1; } if (goods_name == "检具") { s.Value.s_ToStand = 2; } s.Value.s_ToLine = 0; s.Value.s_ToGrid = 0; s.Value.s_ToTier = 0; //s.Value.s_execute_signal = 0; break; } } } #endregion return("S"); } catch { return("N"); } }
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(); }
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(); }
private void btnAlter_Click(object sender, EventArgs e) { var db = new DBAccess_MySql("MySql"); string outString = ""; DataTable dt; //执行中不能强制过账 if (tb_suppliesName.Text == "0") { //获取数据指令数据 sql = "SELECT order_id,order_state,order_style,station_from,station_to,house_from,house_to,order_user,order_time FROM order_info WHERE order_id = " + int.Parse(tb_goodsid.Text) + ""; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr = dt.Rows[0]; string order_state = dr[1].ToString(); string order_style = dr[2].ToString(); string station_from = dr[3].ToString(); string station_to = dr[4].ToString(); string house_from = dr[5].ToString(); string house_to = dr[6].ToString(); string order_user = dr[7].ToString(); //分解物料 sql = "SELECT goods_code,goods_name,goods_style FROM goods_info WHERE goods_id = " + int.Parse(order_user) + ""; db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dd = dt.Rows[0]; string goods_code = dd[0].ToString(); string goods_name = dd[1].ToString(); string goods_style = dd[2].ToString(); if (order_style == "1")//入库 order_state = 3 完成 order_state = 2 未完成 { ////跟新货位状态 sql = "UPDATE house_info SET house_state = 'S' WHERE house_number = '" + goods_style + "'"; db.ExecSql(sql, out outString); //更新库存数据 sql = "INSERT INTO house_data(house_number,goods_code,goods_name,have_number,in_house_time) VALUES('" + goods_style + "','" + goods_name + "','" + goods_code + "'," + 1 + ",SYSDATE())"; db.ExecSql(sql, out outString); //修改 sql = "UPDATE order_info SET order_state = 3 WHERE order_id = " + int.Parse(tb_goodsid.Text) + ""; db.ExecSql(sql, out outString); ////完成后生成历史清单 //sql = "INSERT INTO doc_info(doc_id,doc_style,send_user,rec_user,doc_time) VALUES('" + int.Parse(tb_goodsid.Text) + "','" + goods_style + "','完成','入库',SYSDATE())"; //db.ExecSql(sql, out outString); } if (order_style == "2")//出库 { ////跟新货位状态 sql = "UPDATE house_info SET house_state = 'N' WHERE house_number = '" + house_to + "'"; db.ExecSql(sql, out outString); //修改 sql = "DELETE FROM house_data WHERE house_number = '" + house_to + "'"; db.ExecSql(sql, out outString); sql = "UPDATE order_info SET order_state = 3 WHERE order_id = " + int.Parse(tb_goodsid.Text) + ""; db.ExecSql(sql, out outString); ////完成后生成历史清单 //sql = "INSERT INTO doc_info(doc_id,doc_style,send_user,rec_user,doc_time) VALUES('" + int.Parse(tb_goodsid.Text) + "','" + house_to + "','完成','出库',SYSDATE())"; //db.ExecSql(sql, out outString); } } else { MessageBox.Show("不满足强制过账条件,运行中!"); } update_orderInfo(); }
private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("库位编号:" + tb_sort.Text + " 物料名称:" + tb_suppliesName.Text + " 物料规格:" + tb_specification.Text, "确认入库!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { #region //创建入库预约 try { DataTable dt; var db = new DBAccess_MySql("MySql"); dataGridView1.Columns.Clear(); string outString = ""; string houseNumber = ""; int line = 0; int list = 0; int blank = 0; int floor = 0; sql = "SELECT house_number,line,list,blank,floor FROM house_info WHERE house_state = 'N' and house_number = '" + tb_sort.Text + "'"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); if (dt == null || dt.Rows.Count <= 0) { return; } houseNumber = dt.Rows[0]["house_number"].ToString(); line = int.Parse(dt.Rows[0]["line"].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()); //foreach (var s in PLCSystem_SRM.Dic_SRM_Request) //{ // s.Value.s_serial = 1; // s.Value.s_pattern = 2; // if (tb_suppliesName.Text == "端拾器") // { // s.Value.s_FrStand = 1; // } // if (tb_suppliesName.Text == "检具") // { // s.Value.s_FrStand = 2; // } // s.Value.s_FrLine = 0; // s.Value.s_FrGrid = 0; // s.Value.s_FrTier = 0; // s.Value.s_ToStand = 0; // s.Value.s_ToLine = (ushort)list; // s.Value.s_ToGrid = (ushort)blank; // s.Value.s_ToTier = (ushort)floor; // s.Value.s_execute_signal = 0; // //break; //} ////跟新货位状态 //sql = "UPDATE house_info SET house_state = 'S' WHERE house_number = '" + houseNumber + "'"; //rlt = db.ExecSql(sql, out outString); ////更新库存数据 //sql = "INSERT INTO house_data(house_number,goods_code,goods_name,have_number,in_house_time) VALUES('" + houseNumber + "','" + tb_suppliesName.Text + "','" + tb_specification.Text + "'," + int.Parse(textBox1.Text) + ",SYSDATE())"; //rlt = db.ExecSql(sql, out outString); //update_goodInfo(); //comboBox1.Text = ""; sql = "INSERT INTO order_info(order_state,order_style,station_from,station_to,house_from,house_to,order_user,order_time) VALUES(0,1,1,0,'" + tb_sort.Text + "','0'," + int.Parse(lbID.Text) + ",SYSDATE())"; db.ExecSql(sql, out outString); //string str = @"Server=PLCWMSDBCONNECT;Database=PLCWMSDB;User ID=sa;Password=123456"; //SqlConnection conn = new SqlConnection(str); //SqlCommand cmd = conn.CreateCommand(); //cmd.CommandText = "INSERT INTO dbo.Filtering(FilLocId) values(@FilLocId)"; //cmd.Parameters.Add(new SqlParameter("@FilLocId", LocId)); //conn.Open(); //cmd.ExecuteNonQuery(); //conn.Close(); sql = "UPDATE house_info SET house_state = 'I' WHERE house_number = '" + tb_sort.Text + "'"; db.ExecSql(sql, out outString); } catch { MessageBox.Show("操作不正确!"); } update_goodInfo(); #endregion } else { return; } }
private void button2_Click(object sender, EventArgs e) { //创建入库预约 try { DataTable dt; var db = new DBAccess_MySql("MySql"); dataGridView1.Columns.Clear(); string outString = ""; string houseNumber = ""; int line = 0; int list = 0; int blank = 0; int floor = 0; sql = "SELECT house_number,line,list,blank,floor FROM house_info WHERE house_number = '" + comboBox1.Text + "'"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); if (dt == null || dt.Rows.Count <= 0) { return; } houseNumber = dt.Rows[0]["house_number"].ToString(); line = int.Parse(dt.Rows[0]["line"].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()); foreach (var s in PLCSystem_SRM.Dic_SRM_Request) { SRM_Respone cr = null; PLCSystem_SRM.Dic_SRM_Res.TryGetValue(s.Key, out cr); //if (button1.Text == "入库") //{ // cr.s_FrPattern = 2; //} //if (button1.Text == "出库") //{ // cr.s_FrPattern = 1; //} //cr.s_ToStand = 0; //cr.s_FrLine = 0; //cr.s_FrGrid = 0; //cr.s_FrTier = 0; //cr.s_FrStand = 2; //cr.s_ToLine = (ushort)list; //cr.s_ToGrid = (ushort)blank; //cr.s_ToTier = (ushort)floor; //cr.s_Execute = 1; //cr.s_Fault = 1; break; } //跟新货位状态 sql = "UPDATE house_info SET house_state = 'S' WHERE house_number = '" + houseNumber + "'"; rlt = db.ExecSql(sql, out outString); //更新库存数据 sql = "INSERT INTO house_data(house_number,goods_code,goods_name,have_number,in_house_time) VALUES('" + houseNumber + "','" + tb_suppliesName.Text + "','" + tb_specification.Text + "'," + int.Parse(textBox1.Text) + ",SYSDATE())"; rlt = db.ExecSql(sql, out outString); update_goodInfo(); comboBox1.Text = ""; } catch { MessageBox.Show("操作不正确!"); } }
//清除过账 public void ClearAccount() { try { string str = null; var db = new DBAccess_MySql("MySql"); string outString = ""; DataTable dt; string sql; sql = "SELECT order_user,order_id,order_style FROM order_info WHERE order_state = 1 LIMIT 1"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr = dt.Rows[0]; string order_user = dr[0].ToString(); string orderid = dr[1].ToString(); string orderstyle = dr[2].ToString(); if (orderstyle == "1") { str = "入库"; } if (orderstyle == "2") { str = "出库"; } #region 入库过账 if (str == "入库") { sql = "SELECT goods_code,goods_name,goods_style FROM goods_info WHERE goods_id = " + int.Parse(order_user) + ""; var rlt1 = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr1 = dt.Rows[0]; string goods_code = dr1[0].ToString(); string goods_name = dr1[1].ToString(); string goods_style = dr1[2].ToString(); if (orderstyle == "1")//入库 { //跟新货位状态 sql = "UPDATE house_info SET house_state = 'S' WHERE house_number = '" + goods_style + "'"; db.ExecSql(sql, out outString); //修改指令 sql = "UPDATE order_info SET order_state = 3 WHERE order_id = " + int.Parse(orderid) + ""; db.ExecSql(sql, out outString); //插入数据到库存表 sql = "INSERT INTO house_data(house_number,goods_code,goods_name,have_number,in_house_time) VALUES('" + goods_style + "','" + goods_name + "','" + goods_code + "'," + 1 + ",SYSDATE())"; db.ExecSql(sql, out outString); } if (orderstyle == "2")//出库 { //跟新货位状态 sql = "UPDATE house_info SET house_state = 'N' WHERE house_number = '" + goods_style + "'"; db.ExecSql(sql, out outString); //删除库存表数据 sql = "DELETE FROM house_data WHERE house_number = '" + goods_style + "'"; db.ExecSql(sql, out outString); //修改指令状态 sql = "UPDATE order_info SET order_state = 3 WHERE order_id = " + int.Parse(orderid) + ""; db.ExecSql(sql, out outString); } } #endregion #region 出库过账 if (str == "出库") { sql = "SELECT goods_code,goods_name,goods_style FROM goods_info WHERE goods_id = " + int.Parse(order_user) + ""; var rlt1 = db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dr1 = dt.Rows[0]; string goods_code = dr1[0].ToString(); string goods_name = dr1[1].ToString(); string goods_style = dr1[2].ToString(); if (orderstyle == "1")//入库 { //跟新货位状态 sql = "UPDATE house_info SET house_state = 'S' WHERE house_number = '" + goods_style + "'"; db.ExecSql(sql, out outString); //更新排队指令 sql = "UPDATE order_info SET order_state = 3 WHERE order_id = " + int.Parse(orderid) + ""; db.ExecSql(sql, out outString); } if (orderstyle == "2")//出库 { //跟新货位状态 sql = "UPDATE house_info SET house_state = 'N' WHERE house_number = '" + goods_style + "'"; db.ExecSql(sql, out outString); //删除 sql = "DELETE FROM house_data WHERE house_number = '" + goods_style + "'"; db.ExecSql(sql, out outString); sql = "UPDATE order_info SET order_state = 3 WHERE order_id = " + int.Parse(orderid) + ""; db.ExecSql(sql, out outString); } } #endregion } catch { } }
private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("库位编号:" + tb_sort.Text + " 物料名称:" + tb_suppliesName.Text + " 物料规格:" + tb_specification.Text, "确认出库!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { #region //创建出库预约 try { DataTable dt; var db = new DBAccess_MySql("MySql"); dataGridView1.Columns.Clear(); string outString = ""; string houseNumber = ""; int line = 0; int list = 0; int blank = 0; int floor = 0; sql = "SELECT house_number,line,list,blank,floor FROM house_info WHERE house_number = '" + tb_sort.Text + "'"; var rlt = db.QuerySQL_ToTable(sql, out dt, out outString); if (dt == null || dt.Rows.Count <= 0) { return; } houseNumber = dt.Rows[0]["house_number"].ToString(); line = int.Parse(dt.Rows[0]["line"].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()); //foreach (var s in PLCSystem_SRM.Dic_SRM_Request) //{ // s.Value.s_serial = 1; // s.Value.s_pattern = 1; // s.Value.s_FrStand = 0; // s.Value.s_FrLine = (ushort)list; // s.Value.s_FrGrid = (ushort)blank; // s.Value.s_FrTier = (ushort)floor; // if (tb_suppliesName.Text == "端拾器") // { // s.Value.s_ToStand = 1; // } // if (tb_suppliesName.Text == "检具") // { // s.Value.s_ToStand = 2; // } // s.Value.s_ToLine = 0; // s.Value.s_ToGrid = 0; // s.Value.s_ToTier = 0; // s.Value.s_execute_signal = 0; // //break; //} sql = "SELECT goods_id FROM goods_info WHERE goods_name = '" + tb_suppliesName.Text + "' AND goods_code = '" + tb_specification.Text + "'"; db.QuerySQL_ToTable(sql, out dt, out outString); DataRow dd = dt.Rows[0]; string id = dd[0].ToString(); sql = "INSERT INTO order_info(order_state,order_style,station_from,station_to,house_from,house_to,order_user,order_time) VALUES(0,2,1,0,'0','" + tb_sort.Text + "'," + int.Parse(id) + ",SYSDATE())"; db.ExecSql(sql, out outString); sql = "UPDATE house_info SET house_state = 'O' WHERE house_number = '" + tb_sort.Text + "'"; db.ExecSql(sql, out outString); //删除 sql = "DELETE FROM house_data WHERE house_number = '" + tb_sort.Text + "'"; db.ExecSql(sql, out outString); update_houseInfo(); } catch { MessageBox.Show("存在操作错误!"); } #endregion } else { return; } }