private void btn_update_Click(object sender, EventArgs e) { InBound.Model.UnionCaChe ce = new InBound.Model.UnionCaChe(); try { ce.mainbelt = Convert.ToDecimal(txt_mainbelt.Text); ce.groupno = Convert.ToDecimal(txt_groupno.Text); ce.cachesize = Convert.ToDecimal(txt_cachesize.Text); ce.dispatchenum = Convert.ToDecimal(txt_dispatchenum.Text); ce.dispatchesize = Convert.ToDecimal(txt_dispatchesize.Text); } catch (Exception) { MessageBox.Show("信息输入格式不正确!"); return; } if (ce.cachesize > 280) { MessageBox.Show("输入的缓存量上限过大!"); return; } else if (ce.dispatchesize > ce.cachesize) { MessageBox.Show("每次订单数量超过缓存上限!"); return; } else if (ce.dispatchenum > ce.cachesize) { MessageBox.Show("空余缓存量超过缓存上限!"); return; } decimal states = 5; switch (cmb_state.SelectedItem.ToString()) { case "启用": states = 10; break; case "禁用": states = 0; break; } ce.state = states; DialogResult re = MessageBox.Show("确定修改 " + ce.mainbelt + "号主皮带上第 " + ce.groupno + "分拣组的信息?", "确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (re == DialogResult.OK) { if (UnionCacheServer.UpdateData(ce)) { MessageBox.Show("修改成功!"); dataGridView1.DataSource = UnionCacheServer.GetAllData(); } else { MessageBox.Show("修改失败!"); } } else { return; } }