コード例 #1
0
        /// <summary>
        /// 删除选中行数据的方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbtnDelPosition()
        {
            try
            {
                int j = 0;
                if (dgvPositionList.SelectedRows.Count > 0)//选中删除
                {
                    if (MessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        //选中数量
                        int    count = dgvPositionList.SelectedRows.Count;
                        string id    = "";
                        //遍历
                        for (int i = 0; i < count; i++)
                        {
                            int position_id = int.Parse(this.dgvPositionList.SelectedRows[i].Cells["Position_ID"].Value.ToString());
                            Expression <Func <Position, bool> > funuserinfo = n => n.Position_ID == position_id;
                            string strContent = LinQBaseDao.GetSingle("select Position_Name from Position where Position_ID=" + position_id).ToString();
                            if (PositionDAL.DeleteToMany(funuserinfo))
                            {
                                j++;
                                CommonalityEntity.WriteLogData("删除", "删除门岗名称为:" + strContent + " 的信息", common.USERNAME);//添加日志
                            }
                        }
                        if (j == 0)
                        {
                            MessageBox.Show("删除失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            MessageBox.Show("成功删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            //重新查询门岗值的最大值
                            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("门岗管理 tbtnDelPosition()+");
            }
            finally
            {
                LogInfoLoad("");
            }
        }
コード例 #2
0
        /// <summary>
        /// 门岗加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PositionFrom_Load(object sender, EventArgs e)
        {
            userContext();
            btnUpdate.Enabled = false;
            btnSelect_Click(btnSelect, null);  // 调用查询条件执行查询
            BindPosition();
            BindSearchPosition();
            mf = new MainForm();
            LoadData();
            this.cbxPosition_State.Text = "启动";
            this.txtPositionUserID.Text = common.NAME;

            countID = PositionDAL.MaxID("select MAX(Position_Value) from Position");
            txtPosition_Value.Text = "0" + (countID + 1);
        }
コード例 #3
0
        /// <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();
            }
        }