Beispiel #1
0
        /// <summary>
        /// 删除操作员
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            int rowHandle = gridView1.FocusedRowHandle;

            if (rowHandle >= 0)
            {
                if (gridView1.GetRowCellValue(rowHandle, "UC001").ToString() == App_Const.ROOT_ID)
                {
                    XtraMessageBox.Show("系统内置用户,不能删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (XtraMessageBox.Show("确认要删除当前用户吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string s_uc001 = gridView1.GetRowCellValue(rowHandle, "UC001").ToString();
                    UC01   uc01    = unitOfWork1.GetObjectByKey <UC01>(s_uc001);
                    try
                    {
                        uc01.STATUS = '0';
                        uc01.Save();
                        unitOfWork1.CommitChanges();

                        XtraMessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.RefreshData();
                    }
                    catch (Exception ee)
                    {
                        unitOfWork1.RollbackTransaction();
                        LogUtils.Error(ee.Message);
                        XtraMessageBox.Show(ee.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Beispiel #2
0
        private void sb_ok_Click(object sender, EventArgs e)
        {
            //数据校验
            string s_uc002   = txtedit_uc002.Text;
            string s_uc003   = txtedit_uc003.Text;
            string s_uc004   = txtedit_pwd.Text;
            string s_uc004_2 = txtedit_pwd2.Text;

            if (String.IsNullOrEmpty(s_uc002))
            {
                txtedit_uc002.ErrorImageOptions.Alignment = ErrorIconAlignment.MiddleRight;
                txtedit_uc002.ErrorText = "用户登录代码必须输入!";
                txtedit_uc002.Focus();
                return;
            }

            if (String.IsNullOrEmpty(s_uc003))
            {
                txtedit_uc003.ErrorImageOptions.Alignment = ErrorIconAlignment.MiddleRight;
                txtedit_uc003.ErrorText = "用户姓名必须输入!";
                txtedit_uc003.Focus();
                return;
            }

            if (action == "add")
            {
                if (String.IsNullOrEmpty(s_uc004))
                {
                    txtedit_pwd.ErrorImageOptions.Alignment = ErrorIconAlignment.MiddleRight;
                    txtedit_pwd.ErrorText = "密码必须输入!";
                    txtedit_pwd.Focus();
                    return;
                }
                else if (!String.Equals(s_uc004, s_uc004_2))
                {
                    txtedit_pwd2.ErrorImageOptions.Alignment = ErrorIconAlignment.MiddleRight;
                    txtedit_pwd2.ErrorText = "密码不一致!";
                    txtedit_pwd2.Focus();
                    return;
                }
            }

            /////////// 保存过程  ////////
            if (action == "add")
            {
                uc01        = new UC01(unitOfWork1);
                uc01.UC001  = MiscAction.GetEntityPK("UC01");
                uc01.STATUS = '1';
                uc01.UC004  = SecurityTool.EncryptWithMD5(s_uc004);
            }
            uc01.UC002 = s_uc002;
            uc01.UC003 = s_uc003;

            try
            {
                ///unitOfWork1.BeginTransaction();
                uc01.Save();

                SqlHelper.ExecuteNonQuery("delete from ur_mapper where uc001 = :uc001", new string[] { "uc001" }, new string[] { uc01.UC001 });

                foreach (RO01 r in clbx_roles.CheckedItems)
                {
                    UR_MAPPER mapper = new UR_MAPPER(unitOfWork1);
                    mapper.UM001 = MiscAction.GetEntityPK("MAPPER");
                    mapper.UC001 = uc01.UC001;
                    mapper.RO001 = r.RO001;
                    mapper.Save();
                }

                unitOfWork1.CommitChanges();
                XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ee)
            {
                unitOfWork1.RollbackTransaction();
                LogUtils.Error(ee.Message);
                XtraMessageBox.Show(ee.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }