using Pms.UserEvent.Model; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace PMSUI.UI.库位状态显示 { public partial class EditWareHouseMsg : Form { public EditWareHouseMsg() { InitializeComponent(); } private enum NullFull { 空 = 0, 满 = 1, } public string StationNum = string.Empty; private void findData() { StringBuilder sb = new StringBuilder(); sb.Append($" SELECT "); sb.Append($" * "); sb.Append($" from "); sb.Append($" UpStation"); sb.Append($" where "); sb.Append($" StationNum='{StationNum}' "); DataTable dt = ConDataBase.reDt(sb.ToString()); if (dt != null && dt.Rows != null && dt.Rows.Count > 0) { txt_StationNum.Text = dt.Rows[0]["StationNum"].ToString(); int StationValue = int.Parse(dt.Rows[0]["StationValue"].ToString()); switch (StationValue) { case 0: { cbx_StationValue.Text = NullFull.空.ToString().Trim(); break; } case 1: { cbx_StationValue.Text = NullFull.满.ToString().Trim(); break; } } cbx_Sel.Text = dt.Rows[0]["StationSelect"].ToString(); } } private void button1_Click(object sender, EventArgs e) { int index = cbx_Sel.SelectedIndex; if (index < 0) { MessageBox.Show("库位顺序不可为空!"); return; } int StationValue = 0; switch (cbx_StationValue.Text.Trim()) { case "空": { StationValue = (int)NullFull.空; break; } case "满": { StationValue = (int)NullFull.满; break; } } StringBuilder sb = new StringBuilder(); sb.Append($" update "); sb.Append($" UpStation"); sb.Append($" set "); sb.Append($" StationNum='{txt_StationNum.Text.Trim()}', "); sb.Append($" StationValue={StationValue}, "); sb.Append($" StationSelect={cbx_Sel.Text.Trim()} "); sb.Append($" where "); sb.Append($" StationNum='{StationNum}' "); int flag = ConDataBase.sqlNonQuery(sb.ToString()); if (flag > 0) { MessageBox.Show($"状态信息更新成功!"); findData(); } } private void EditWareHouseMsg_Load(object sender, EventArgs e) { findData(); } } }