/// <summary> /// “保存” 按钮的单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { try { if (this.txtPosition_Name.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "门岗名称不能为空!", txtPosition_Name, this); return; } int num = dgvPositionList.Rows.Count; int mgz = Convert.ToInt32(dgvPositionList.Rows[num - 1].Cells["Position_Value"].Value); txtPosition_Value.Text = "0" + (mgz + 1); int count = Convert.ToInt32(LinQBaseDao.GetSingle("select count(0) from Position").ToString()); if (count >= SystemClass.postionCount) { MessageBox.Show(this, "已超出可添加门岗上限!"); return; } if (!btnCheck()) { return; // 去重复 } var Positionadd = new Position { Position_Name = this.txtPosition_Name.Text.Trim(), Position_Value = this.txtPosition_Value.Text.Trim(), Position_State = this.cbxPosition_State.Text, Position_UserId = int.Parse(common.USERID), // 用户编号 Position_Add = this.txtPosition_ADD.Text.Trim(), Position_Phone = this.txtPosition_Phone.Text.Trim(), Position_CreatTime = Convert.ToDateTime(CommonalityEntity.GetServersTime().ToString()), Position_CameraValue = this.txtPosition_CameraValue.Text.Trim(), Position_Remark = this.txtPosition_Remark.Text.Trim() }; if (PositionDAL.InsertOneQCRecord(Positionadd)) { MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); string strContent1 = "门岗名称为:" + this.txtPosition_Name.Text.Trim();; CommonalityEntity.WriteLogData("新增", "新增 " + strContent1 + " 的信息", common.USERNAME);//添加日志); //重新查询门岗值的最大值 countID = PositionDAL.MaxID("select MAX(Position_Value) from Position"); txtPosition_Value.Text = "0" + (countID + 1); } else { MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch { common.WriteTextLog("门岗管理 btnSave_Click()"); } finally { LogInfoLoad(""); Empty(); } }