using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace WCS { public partial class Form1 : Form { public Form1() { InitializeComponent(); } MySqlHelper mysql = new MySqlHelper(); private void button4_Click(object sender, EventArgs e) { new Thread((ThreadStart)delegate { lock ("ssss") { try { int str1 = 0; //双伸为货位生成规则,默认生成货位后 更改入库顺序 string P = "";//排 string L = "";//列 string C = "";//层 int kk = 0; string locationId = ""; string decId = "2"; string instand = ""; string outStand = ""; for (int i = 1; i <= int.Parse(this.txtP.Text.Trim()); i++) { for (int j = 1; j <= int.Parse(this.txtL.Text.Trim()); j++) { P = i.ToString("00") + "-" + j.ToString("00"); for (int k = 1; k <= int.Parse(this.txtC.Text.Trim()); k++) { for (int s = 1; s <= int.Parse(this.textBox4.Text.Trim()); s++) { L = P + "-" + k.ToString("00") + "-" + s; kk++; addText(L); locationId = L.Trim(); int size = 0; string sqlStr = ""; sqlStr = "insert into t_base_storage_area_location(LOCATION_ID,STORAGE_ID,SORT,STATUS,decId,`row`,cln,layer,depth) " + "values('" + locationId + "','LTK01'," + str1 + ",'0','" + decId + "','" + i.ToString("00") + "','" + j.ToString("00") + "','" + k.ToString("00") + "','" + s + "')"; //str1 = str1 + 4; // sqlStr = "insert into t_base_storage_area_location(LOCATION_ID,PY_NAME,STORAGE_ID,LOCATION_LONG," + //"LOCATION_WIDTH,LOCATION_HEIGHT,VOLUME,HASVOLUME,BEARWEIGHT,SORT,STATUS,OPERATEDATE,decId,instand,outStand,row,cln,layer) " // + "values('" + locationId + "','" + locationId + "','LTK01',0,0," + size + ",1,1,0," + kk + "," // + "0,GETDATE(),'1','" + instand + "','" + outStand + "','" + i.ToString("00") + "','" + j.ToString("00") + "','" + k.ToString("00") + "')"; mysql.ExecuteNonQuery(sqlStr); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }).Start(); } delegate void addTextCallback(string text); #region 文本框界面显示函数 public void addText(string str) { if (this.txtMessage.InvokeRequired)//为了多线程间控件的安全调用 { addTextCallback ad = new addTextCallback(addText); this.Invoke(ad, new object[] { str }); } else { txtMessage.Text += DateTime.Now.ToString() + ":" + str + "\r\n"; this.txtMessage.Focus(); this.txtMessage.Select(this.txtMessage.TextLength, 0); this.txtMessage.ScrollToCaret(); } } #endregion private void button3_Click(object sender, EventArgs e) { new Thread((ThreadStart)delegate { lock ("ssss") { try { //010101 1 //010102 5 //010103 9 //010201 //010202 //010203 //010301 //010302 //010303 //020101 3 //020102 7 //020103 11 //020201 //020202 //020203 //020301 //020302 //020303 //030101 2 //030102 6 //030103 10 //030201 //030202 //030203 //030301 //030302 //030303 //040101 4 //040102 8 //040103 12 //040201 //040202 //040203 //040301 //040302 //040303 //050900101 顺序:1 //051000101 顺序:2 //051200101 顺序:3 //051100101 顺序:4 //050900102 顺序:5 //051000102 顺序:6 //051200102 顺序:7 //051100102 顺序:8 int P = 1; //排 int L = 1; //列 int C = 1; //岑 int sort = 0; string locationId = ""; int k = int.Parse(this.textBox2.Text.Trim());// K对应1,2,3,4,顺序, 更新第几排的顺序,P值需要 手动更改第几排 for (P = int.Parse(this.textBox3.Text.Trim()); P <= int.Parse(this.textBox3.Text.Trim()); P++) { for (L = 1; L <= int.Parse(this.txtL.Text.Trim()); L++) { for (C = 1; C <= int.Parse(this.txtC.Text.Trim()); C++) { for (int s = 1; s <= int.Parse(this.textBox4.Text.Trim()); s++) { locationId = P.ToString("00") + "-" + L.ToString("00") + "-" + C.ToString("00") + "-" + s; addText(locationId + " 顺序:" + k.ToString()); string sqlStr = "update t_base_storage_area_location set sort=" + k + " where LOCATION_ID='" + locationId + "'"; int row = mysql.ExecuteNonQuery( sqlStr); k = k + 2; } } } } textBox2.Text = Convert.ToString(int.Parse(textBox2.Text) + 1); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }).Start(); } private void button5_Click(object sender, EventArgs e) { } private void Form1_Load(object sender, EventArgs e) { } } }