private void btnSave_Click(object sender, EventArgs e) { try { bool isEnd; foreach (var key in dicCtrl.Keys) { if (dicCtrl[key]["num"].Enabled) { isEnd = IsEnd(dicCtrl[key]); if (key == 1) { if (!IsNotNull(dicCtrl[key])) { MessageBox.Show("请完善第1行数据!"); return; } } else { if (HasInput(dicCtrl[key])) { if (!IsNotNull(dicCtrl[key])) { MessageBox.Show("请完善第" + key + "行数据!"); return; } } } } } List <List <object> > list = new List <List <object> >(); foreach (var item in dicCtrl.Values) { if (item["num"].Enabled && !string.IsNullOrEmpty(item["num"].Text.Trim())) { if (checkInput(item)) { list.Add(new List <object> { item["num"].Text.Trim(), item["name"].Text.Trim(), item["length"].Text.Trim(), item["width"].Text.Trim(), (int)item["end"].Tag == 7 ? 1 : ((CheckBox)item["end"]).Checked ? 1 : 0 }); } else { return; } } } if (bll.SaveList(list, pid, parentForm.currentPlace.I_grade)) { parentForm.isAdd = true; MessageBox.Show("保存成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); Log.saveLog("设置货位成功!"); Close(); } else { MessageBox.Show("保存失败!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception) { MessageBox.Show("与数据库连接失败,请查看网络连接是否正常。如不能解决请与网络管理员联系!", "严重错误:", MessageBoxButtons.OK, MessageBoxIcon.Error); } }