Esempio n. 1
0
        /// <summary>
        /// 删除按钮双击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_delete_Click(object sender, EventArgs e)
        {
            try
            {
                string strmessagebox = "";
                string strlog        = "";
                if (btn_delete.Enabled)
                {
                    btn_delete.Enabled = false;
                }

                if (MessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    if (JudgeCarTypeUseMethod())//判断要删除的管控信息是否正在使用
                    {
                        Expression <Func <ControlInfo, bool> > fun = n => list.Contains(common.GetInt(n.ControlInfo_ID));
                        if (ControlInfoDAL.DeleteToMany(fun))
                        {
                            strmessagebox = "成功删除管控信息";
                            list.Clear();
                            strlog = String.Format("删除管控信息:{0}", strControlInfo_Name);
                            CommonalityEntity.WriteLogData("删除", strlog, CommonalityEntity.USERNAME);
                        }
                        else
                        {
                            strmessagebox = "删除管控信息失败";
                        }
                    }
                    else
                    {
                        strmessagebox = "该管控信息正在使用不能删除";
                    }
                }

                if (strmessagebox != "")
                {
                    MessageBox.Show(strmessagebox, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            {
                CommonalityEntity.WriteTextLog("ControlInfoForm.btn_delete_Click()");
            }
            finally
            {
                btn_delete.Enabled = true;

                InitMenu();//更新
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 保存按钮双击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Preservation_Click(object sender, EventArgs e)
        {
            try
            {
                if (!NullHandleMethod())
                {
                    return;                     //查重
                }
                string strControlInfo_Name    = txt_ControlInfo_Name.Text.Trim();
                string strControlInfo_Value   = txt_ControlInfo_Value.Text.Trim();
                string strControlInfo_State   = cob_ControlInfo_State.Text.Trim();
                string strControlInfo_Content = txt_ControlInfo_Content.Text.Trim();
                string strControlInfo_Remark  = txt_ControlInfo_Remark.Text.Trim();
                string strControlInfo_Rule    = txt_ControlInfo_Rule.Text.Trim();
                string strControlInfo_IDValue = txt_ControlInfo_IDValue.Text.Trim();
                string strmessagebox          = "";
                string strlog = "";
                if (btn_Preservation.Enabled)
                {
                    btn_Preservation.Enabled = false;
                }

                if (btn_Empty.Text == "清  空")
                {
                    ControlInfo ci = new ControlInfo();
                    ci.ControlInfo_Name    = strControlInfo_Name;
                    ci.ControlInfo_Value   = strControlInfo_Value;
                    ci.ControlInfo_State   = strControlInfo_State;
                    ci.ControlInfo_Content = strControlInfo_Content;
                    ci.ControlInfo_Remark  = strControlInfo_Remark;
                    ci.ControlInfo_Rule    = strControlInfo_Rule;
                    ci.ControlInfo_IDValue = strControlInfo_IDValue;

                    //ci.ControlInfo_Type = comboxType.SelectedValue.ToString();//用管控信息实际值
                    ci.ControlInfo_Type = comboxType.Text;//用管控信息类型名称

                    if (intControlInfo_HeightID > 0)
                    {
                        ci.ControlInfo_HeightID = intControlInfo_HeightID;
                    }
                    if (ControlInfoDAL.InsertOneQCRecord(ci))
                    {
                        strlog                  = String.Format("添加管控信息:'{0}'", txt_ControlInfo_Name.Text.Trim());
                        strmessagebox           = "添加管控信息成功";
                        intControlInfo_HeightID = 0;
                        CommonalityEntity.WriteLogData("新增", strlog, CommonalityEntity.USERNAME);
                        ClearMethod();
                    }
                    else
                    {
                        strmessagebox = "添加管控信息失败";
                    }
                }
                else
                {
                    Expression <Func <ControlInfo, bool> > fun = n => n.ControlInfo_ID == intControlInfo_ID;
                    Action <ControlInfo> action = n =>
                    {
                        n.ControlInfo_Value   = strControlInfo_Value;
                        n.ControlInfo_State   = strControlInfo_State;
                        n.ControlInfo_Content = strControlInfo_Content;
                        n.ControlInfo_Remark  = strControlInfo_Remark;
                        n.ControlInfo_Rule    = strControlInfo_Rule;
                        n.ControlInfo_IDValue = strControlInfo_IDValue;
                        //ci.ControlInfo_Type = comboxType.SelectedValue.ToString();//用管控信息实际值
                        n.ControlInfo_Type = comboxType.Text;//用管控信息类型名称
                    };
                    if (ControlInfoDAL.Update(fun, action))
                    {
                        strlog            = String.Format("修改管控信息:'{0}'", txt_ControlInfo_Name.Text.Trim());
                        strmessagebox     = "管控信息修改成功";
                        intControlInfo_ID = 0;
                        CommonalityEntity.WriteLogData("修改", strlog, CommonalityEntity.USERNAME);
                        ClearMethod();
                        txt_ControlInfo_Name.ReadOnly = false;
                        btn_Empty.Text = "清 空";
                        InitMenu();//更新
                    }
                    else
                    {
                        strmessagebox = "管控信息修改失败";
                    }
                }

                if (strmessagebox != "")
                {
                    MessageBox.Show(strmessagebox, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            {
                CommonalityEntity.WriteTextLog("ControlInfoForm.btn_Preservation_Click()");
            }
            finally
            {
                btn_Preservation.Enabled = true;
            }
        }