Esempio n. 1
0
        /// <summary>
        /// 新增一条记录
        /// </summary>
        /// <param name="qcRecord">质检实体</param>
        /// <returns></returns>
        public static bool InsertOneICCardType(ICCardType qcICCardType)
        {
            bool rbool = true;

            using (DCCarManagementDataContext db = new DCCarManagementDataContext())
            {
                try
                {
                    rbool = LinQBaseDao.InsertOne(db, qcICCardType);
                }
                catch
                {
                    rbool = false;
                }
                finally { db.Connection.Close(); }
            }
            return(rbool);
        }
        /// <summary>
        /// “保 存” 按钮的单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //判断IC卡类型名称是否存在txtICCardType_Name
                if (LinQBaseDao.Query("select * from ICCardType where ICCardType_Name='" + txtICCardType_Name + "'").Tables[0].Rows.Count >= 1)
                {
                    PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "IC类型名称已存在!", txtICCardType_Name, this);
                    return;
                }
                if (LinQBaseDao.Query("select * from ICCardType where ICCardType_Value='" + txtICCardType_Value + "'").Tables[0].Rows.Count >= 1)
                {
                    PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "IC类型值已存在!", txtICCardType_Value, this);
                    return;
                }
                if (this.txtICCardType_Name.Text == "")
                {
                    PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "IC卡类型名称不能为空!", txtICCardType_Name, this);
                    return;
                }
                if (this.txtICCardType_Value.Text == "")
                {
                    PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "IC卡类型值不能为空!", txtICCardType_Value, this);
                    return;
                }
                if (!btnCheck())
                {
                    return;              // 去重复
                }
                var ICCardTypeadd = new ICCardType
                {
                    ICCardType_Name             = this.txtICCardType_Name.Text.Trim(),
                    ICCardType_State            = this.comboxICCardType_State.Text.Trim(),
                    ICCardType_Value            = this.txtICCardType_Value.Text.Trim(),
                    ICCardType_Description      = this.txtICCardType_Description.Text.Trim(),
                    ICCardType_Remark           = this.txtICCardType_Remark.Text.Trim(),
                    ICCardType_Permissions      = this.ICCardPermissions.Text,
                    ICCardType_PermissionsValue = strview
                };

                if (ICCardTypeDAL.InsertOneICCardType(ICCardTypeadd))
                {
                    MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    string strContent1 = "新增IC卡类型名称为: " + this.txtICCardType_Name.Text.Trim();
                    CommonalityEntity.WriteLogData("新增", strContent1, CommonalityEntity.USERNAME); //添加操作日志
                    Empty();                                                                       // 调用清空的方法
                }
                else
                {
                    MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch
            {
                CommonalityEntity.WriteTextLog("IC卡信息管理 btnSave_Click()");
            }
            finally
            {
                LogInfoLoad("");
            }
        }