コード例 #1
0
ファイル: SaveCardForm.cs プロジェクト: radtek/AccessSystem
 /// <summary>
 /// Class Constructor
 /// </summary>
 public SaveCardForm(EnmSaveBehavior Behavior, CardInfo Card)
 {
     InitializeComponent();
     CurBehavior = Behavior;
     CardEntity  = new Card();
     CurCard     = new CardInfo();
     OriCard     = Card;
     Common.CopyObjectValues(OriCard, CurCard);
     Text = Behavior == EnmSaveBehavior.Add ? "新增持卡信息" : "编辑持卡信息";
 }
コード例 #2
0
 /// <summary>
 /// Class Constructor
 /// </summary>
 public SaveDepartmentForm(EnmSaveBehavior Behavior, DepartmentInfo Dept)
 {
     InitializeComponent();
     DeptEntity  = new Department();
     CurBehavior = Behavior;
     CurDept     = new DepartmentInfo();
     OriDept     = Dept;
     Common.CopyObjectValues(OriDept, CurDept);
     Text = Behavior == EnmSaveBehavior.Add ? "新增部门信息" : "编辑部门信息";
 }
コード例 #3
0
 /// <summary>
 /// Class Constructor
 /// </summary>
 public SaveOrgEmployeeForm(EnmSaveBehavior Behavior, OrgEmployeeInfo Employee)
 {
     InitializeComponent();
     CurBehavior = Behavior;
     EmpEntity   = new Employee();
     CurEmployee = new OrgEmployeeInfo();
     OriEmployee = Employee;
     Common.CopyObjectValues(OriEmployee, CurEmployee);
     Text = Behavior == EnmSaveBehavior.Add ? "新增员工信息" : "编辑员工信息";
 }
コード例 #4
0
ファイル: SaveUserForm.cs プロジェクト: radtek/AccessSystem
 /// <summary>
 /// Class Constructor
 /// </summary>
 public SaveUserForm(EnmSaveBehavior Behavior, UserInfo User)
 {
     InitializeComponent();
     MemberShipEntity = new MemberShip();
     CurBehavior      = Behavior;
     CurUser          = new UserInfo();
     OriUser          = User;
     Common.CopyObjectValues(OriUser, CurUser);
     Text = Behavior == EnmSaveBehavior.Add ? "新增用户信息" : "编辑用户信息";
 }
コード例 #5
0
 /// <summary>
 /// Class Constructor
 /// </summary>
 public SaveCardAuthForm(EnmSaveBehavior Behavior, CardInfo Card, CardAuthInfo CardAuth, List <CardInfo> Cards, List <DepartmentInfo> Departments, List <OrgEmployeeInfo> OrgEmployees, List <OutEmployeeInfo> OutEmployees)
 {
     InitializeComponent();
     CardAuthEntity = new CardAuth();
     CurBehavior    = Behavior;
     CurCardAuth    = new CardAuthInfo();
     OriCardAuth    = CardAuth;
     CurCard        = Card;
     Common.CopyObjectValues(OriCardAuth, CurCardAuth);
     CurCards        = Cards;
     CurDepartments  = Departments;
     CurOrgEmployees = OrgEmployees;
     CurOutEmployees = OutEmployees;
     CurExistsCards  = new Dictionary <String, Int32>();
     Text            = Behavior == EnmSaveBehavior.Add ? "新增授权信息" : "编辑授权信息";
 }
コード例 #6
0
 /// <summary>
 /// Class Constructor
 /// </summary>
 public SaveCardDevAuthForm(EnmSaveBehavior Behavior, List <CardAuthInfo> CardAuth, List <NodeLevelInfo> Nodes)
 {
     InitializeComponent();
     CardAuthEntity = new CardAuth();
     CurBehavior    = Behavior;
     OriCardAuth    = CardAuth;
     CurCardAuth    = new List <CardAuthInfo>();
     CurNodes       = Nodes;
     foreach (var oc in OriCardAuth)
     {
         var newCardAuth = new CardAuthInfo();
         Common.CopyObjectValues(oc, newCardAuth);
         CurCardAuth.Add(newCardAuth);
     }
     Text           = Behavior == EnmSaveBehavior.Add ? "新增授权信息" : "编辑授权信息";
     CurExistsNodes = new Dictionary <Int32, String>();
 }
コード例 #7
0
ファイル: SaveRoleForm.cs プロジェクト: radtek/AccessSystem
        /// <summary>
        /// Class Constructor
        /// </summary>
        public SaveRoleForm(EnmSaveBehavior Behavior, RoleInfo Role)
        {
            InitializeComponent();
            AuthorizationsTreeView                  = new TreeView();
            AuthorizationsTreeView.CheckBoxes       = true;
            AuthorizationsTreeView.Dock             = DockStyle.Fill;
            AuthorizationsTreeView.ImageKey         = "Default";
            AuthorizationsTreeView.ImageList        = TreeImages;
            AuthorizationsTreeView.SelectedImageKey = "Default";
            AuthorizationsTreeView.ContextMenuStrip = TreeViewContextMenuStrip1;
            AuthorizationsTreeView.HideSelection    = false;
            AuthorizationsTreeView.AfterCheck      += new System.Windows.Forms.TreeViewEventHandler(authorizationsTreeView_AfterCheck);

            NodesTreeView                  = new TreeView();
            NodesTreeView.CheckBoxes       = true;
            NodesTreeView.Dock             = DockStyle.Fill;
            NodesTreeView.ImageKey         = "Default";
            NodesTreeView.ImageList        = TreeImages;
            NodesTreeView.SelectedImageKey = "Default";
            NodesTreeView.ContextMenuStrip = TreeViewContextMenuStrip2;
            NodesTreeView.HideSelection    = false;
            NodesTreeView.AfterCheck      += new System.Windows.Forms.TreeViewEventHandler(nodesTreeView_AfterCheck);

            DepartmentTreeView                  = new TreeView();
            DepartmentTreeView.CheckBoxes       = true;
            DepartmentTreeView.Dock             = DockStyle.Fill;
            DepartmentTreeView.ImageKey         = "Default";
            DepartmentTreeView.ImageList        = TreeImages;
            DepartmentTreeView.SelectedImageKey = "Default";
            DepartmentTreeView.ContextMenuStrip = TreeViewContextMenuStrip3;
            DepartmentTreeView.HideSelection    = false;
            DepartmentTreeView.AfterCheck      += new System.Windows.Forms.TreeViewEventHandler(departmentTreeView_AfterCheck);

            MemberShipEntity = new MemberShip();
            CurBehavior      = Behavior;
            CurRole          = new RoleInfo();
            OriRole          = Role;
            Common.CopyObjectValues(OriRole, CurRole);
            Text = Behavior == EnmSaveBehavior.Add ? "新增角色权限" : "编辑角色权限";
        }
コード例 #8
0
        /// <summary>
        /// Save Department.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                if (String.IsNullOrWhiteSpace(DepIDTB.Text))
                {
                    DepIDTB.Focus();
                    MessageBox.Show("部门编码不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (String.IsNullOrWhiteSpace(DepNameTB.Text))
                {
                    DepNameTB.Focus();
                    MessageBox.Show("部门名称不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (CurBehavior == EnmSaveBehavior.Add && DeptEntity.ExistDepartment(DepIDTB.Text.Trim()))
                {
                    DepIDTB.Focus();
                    MessageBox.Show("部门已存在", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (ParentDeptCB.Checked)
                {
                    CurDept.LastDepId = "0";
                }
                if (String.IsNullOrWhiteSpace(CurDept.LastDepId))
                {
                    LastDeptTB.Clear();
                    CurDept.LastDepId = String.Empty;
                    MessageBox.Show("请选择上级部门", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (CurBehavior == EnmSaveBehavior.Edit && CurDept.DepId.Equals(CurDept.LastDepId, StringComparison.CurrentCultureIgnoreCase))
                {
                    LastDeptTB.Clear();
                    CurDept.LastDepId = String.Empty;
                    MessageBox.Show("当前部门不能作为其上级部门", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                CurDept.DepId   = DepIDTB.Text.Trim();
                CurDept.DepName = DepNameTB.Text.Trim();
                //CurDept.LastDepId = null;
                CurDept.Comment = DepCommentTB.Text.Trim();
                CurDept.Enabled = EnabledCB.Checked;
                var result = Common.ShowWait(() => {
                    DeptEntity.SaveDepartments(new List <DepartmentInfo> {
                        CurDept
                    });
                    if (CurBehavior == EnmSaveBehavior.Add)
                    {
                        Common.CurUser.Role.Departments.Add(CurDept);
                    }
                }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                if (result == DialogResult.OK)
                {
                    Common.CopyObjectValues(CurDept, OriDept);
                    Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveDepartmentForm.SaveBtn.Click", String.Format("{0}部门:[{1},{2}]", CurBehavior == EnmSaveBehavior.Add ? "新增" : "更新", CurDept.DepId, CurDept.DepName), null);
                    MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveDepartmentForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #9
0
        /// <summary>
        /// Save Employee.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                if (String.IsNullOrWhiteSpace(EmpIDTB.Text) ||
                    String.IsNullOrWhiteSpace(EmpNameTB.Text) ||
                    String.IsNullOrWhiteSpace(MobilePhoneTB.Text) ||
                    String.IsNullOrWhiteSpace(EmailTB.Text))
                {
                    if (String.IsNullOrWhiteSpace(EmailTB.Text))
                    {
                        EmailTB.BackColor = Color.MistyRose;
                        EmailTB.Focus();
                    }
                    if (String.IsNullOrWhiteSpace(MobilePhoneTB.Text))
                    {
                        MobilePhoneTB.BackColor = Color.MistyRose;
                        MobilePhoneTB.Focus();
                    }
                    if (String.IsNullOrWhiteSpace(EmpNameTB.Text))
                    {
                        EmpNameTB.BackColor = Color.MistyRose;
                        EmpNameTB.Focus();
                    }
                    if (String.IsNullOrWhiteSpace(EmpIDTB.Text))
                    {
                        EmpIDTB.BackColor = Color.MistyRose;
                        EmpIDTB.Focus();
                    }

                    MessageBox.Show("请输入必填项(红色标示区域)", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (CurBehavior == EnmSaveBehavior.Add && EmpEntity.ExistOrgEmployee(EmpIDTB.Text.Trim()))
                {
                    EmpIDTB.BackColor = Color.MistyRose;
                    EmpIDTB.Focus();
                    MessageBox.Show("工号已存在", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (String.IsNullOrWhiteSpace(CurEmployee.DepId))
                {
                    DeptTB.Clear();
                    CurEmployee.DepId   = String.Empty;
                    CurEmployee.DepName = String.Empty;
                    MessageBox.Show("请选择所属部门", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                CurEmployee.EmpId       = EmpIDTB.Text.Trim();
                CurEmployee.EmpType     = ComUtility.DBNullWorkerTypeHandler(EmpTypeCB.SelectedValue);
                CurEmployee.EmpName     = EmpNameTB.Text.Trim();
                CurEmployee.EnglishName = EmpEnglishNameTB.Text.Trim();
                CurEmployee.Sex         = SexMRB.Checked ? "M" : "F";
                CurEmployee.CardId      = CardIDTB.Text.Trim();
                CurEmployee.Hometown    = HometownTB.Text.Trim();
                CurEmployee.BirthDay    = BirthDayDTP.Value;
                CurEmployee.Marriage    = ComUtility.DBNullMarriageTypeHandler(MarriageTypeCB.SelectedValue);
                CurEmployee.HomeAddress = HomeAddressTB.Text.Trim();
                CurEmployee.HomePhone   = HomePhoneTB.Text.Trim();
                CurEmployee.EntryDay    = EntryDayDTP.Value;
                CurEmployee.PositiveDay = PositiveDayDTP.Value;
                //CurEmployee.DepId = null;
                //CurEmployee.DepName = null;
                CurEmployee.DutyName    = DutyNameTB.Text.Trim();
                CurEmployee.OfficePhone = OfficePhoneTB.Text.Trim();
                CurEmployee.MobilePhone = MobilePhoneTB.Text.Trim();
                CurEmployee.Email       = EmailTB.Text.Trim();
                CurEmployee.Comment     = RemarkTB.Text.Trim();
                //CurEmployee.Photo = null;
                CurEmployee.PhotoLayout       = (int)PhotoPanel.BackgroundImageLayout;
                CurEmployee.Enabled           = !EmpStatusCB.Checked;
                CurEmployee.ResignationDate   = CurEmployee.Enabled ? ComUtility.DefaultDateTime : ResignationDateDTP.Value;
                CurEmployee.ResignationRemark = CurEmployee.Enabled ? ComUtility.DefaultString : ResignationRemarkTB.Text.Trim();

                var result = Common.ShowWait(() => {
                    EmpEntity.SaveOrgEmployees(new List <OrgEmployeeInfo> {
                        CurEmployee
                    });
                }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                if (result == DialogResult.OK)
                {
                    Common.CopyObjectValues(CurEmployee, OriEmployee);
                    Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveEmployeeForm.SaveBtn.Click", String.Format("{0}员工:[{1},{2}]", CurBehavior == EnmSaveBehavior.Add ? "新增" : "更新", CurEmployee.EmpId, CurEmployee.EmpName), null);
                    MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveEmployeeForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #10
0
        /// <summary>
        /// Save Button Click Event.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                var target = new CardAuthInfo();
                target.BeginTime = BeginTimeDTP.Value;
                target.EndTime   = EndTimeDTP.Value;
                target.Password  = PwdCB.Text.Trim();
                target.Enabled   = EnabledCB.Checked;
                var limitId = (Int32)LimitTypeCB.SelectedValue;
                switch ((EnmLimitID)limitId)
                {
                case EnmLimitID.TQ:
                    target.LimitId    = EnmLimitID.TQ;
                    target.LimitIndex = ComUtility.DefaultInt32;
                    break;

                case EnmLimitID.WTMG:
                    target.LimitId    = EnmLimitID.WTMG;
                    target.LimitIndex = Convert.ToInt32(LimitIndexCB.SelectedValue);
                    break;

                case EnmLimitID.DTM:
                    target.LimitId    = EnmLimitID.DTM;
                    target.LimitIndex = Convert.ToInt32(LimitIndexCB.SelectedValue);
                    break;
                }

                var SaveCardAuth = new List <CardAuthInfo>();
                if (CurBehavior == EnmSaveBehavior.Add)
                {
                    var Devices = new List <Int32>();
                    CheckDevTreeView(DeviceTreeView.Nodes, Devices);
                    if (Devices.Count == 0)
                    {
                        MessageBox.Show("请勾选需要授权的设备", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    var Cards = new List <String>();
                    CheckCardsTreeView(CardsTreeView.Nodes, Cards);
                    if (Cards.Count == 0)
                    {
                        MessageBox.Show("请勾选需要授权的卡片", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    foreach (var dev in Devices)
                    {
                        foreach (var card in Cards)
                        {
                            var ca = new CardAuthInfo();
                            ca.CardSn     = card;
                            ca.DevId      = dev;
                            ca.LimitId    = target.LimitId;
                            ca.LimitIndex = target.LimitIndex;
                            ca.BeginTime  = target.BeginTime;
                            ca.EndTime    = target.EndTime;
                            ca.Password   = target.Password;
                            ca.Enabled    = target.Enabled;
                            SaveCardAuth.Add(ca);
                        }
                    }
                }
                else
                {
                    foreach (var ca in CurCardAuth)
                    {
                        ca.LimitId    = target.LimitId;
                        ca.LimitIndex = target.LimitIndex;
                        ca.BeginTime  = target.BeginTime;
                        ca.EndTime    = target.EndTime;
                        ca.Password   = target.Password;
                        ca.Enabled    = target.Enabled;
                    }
                    SaveCardAuth.AddRange(CurCardAuth);
                }

                var IsSync = SyncCB.Checked;
                var result = Common.ShowWait(() => {
                    CardAuthEntity.SaveCardAuth(SaveCardAuth, IsSync);
                }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                if (result == DialogResult.OK)
                {
                    foreach (var ca in SaveCardAuth)
                    {
                        Common.WriteLog(DateTime.Now, CurBehavior == EnmSaveBehavior.Add ? EnmMsgType.Authin : EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveCardDevAuthForm.SaveBtn.Click", String.Format("{0}卡片授权[设备:{1} 卡号:{2}]", CurBehavior == EnmSaveBehavior.Add ? "新增" : "更新", ca.DevId, ca.CardSn), null);
                    }

                    if (CurBehavior == EnmSaveBehavior.Edit)
                    {
                        foreach (var cc in CurCardAuth)
                        {
                            var OriCA = OriCardAuth.Find(oc => oc.CardSn.Equals(cc.CardSn) && oc.DevId == cc.DevId);
                            if (OriCA != null)
                            {
                                Common.CopyObjectValues(cc, OriCA);
                            }
                        }
                    }
                    MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveCardDevAuthForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #11
0
        /// <summary>
        /// Save Out Employee.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                if (String.IsNullOrWhiteSpace(EmpIDTB.Text) ||
                    String.IsNullOrWhiteSpace(EmpNameTB.Text) ||
                    String.IsNullOrWhiteSpace(MobilePhoneTB.Text) ||
                    String.IsNullOrWhiteSpace(EmailTB.Text))
                {
                    if (String.IsNullOrWhiteSpace(EmailTB.Text))
                    {
                        EmailTB.BackColor = Color.MistyRose;
                        EmailTB.Focus();
                    }
                    if (String.IsNullOrWhiteSpace(MobilePhoneTB.Text))
                    {
                        MobilePhoneTB.BackColor = Color.MistyRose;
                        MobilePhoneTB.Focus();
                    }
                    if (String.IsNullOrWhiteSpace(EmpNameTB.Text))
                    {
                        EmpNameTB.BackColor = Color.MistyRose;
                        EmpNameTB.Focus();
                    }
                    if (String.IsNullOrWhiteSpace(EmpIDTB.Text))
                    {
                        EmpIDTB.BackColor = Color.MistyRose;
                        EmpIDTB.Focus();
                    }

                    MessageBox.Show("请输入必填项(红色标示区域)", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (CurBehavior == EnmSaveBehavior.Add && EmpEntity.ExistOutEmployee(EmpIDTB.Text.Trim()))
                {
                    EmpIDTB.BackColor = Color.MistyRose;
                    EmpIDTB.Focus();
                    MessageBox.Show("工号已存在", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (String.IsNullOrWhiteSpace(CurEmployee.ParentEmpId))
                {
                    PEmpNameTB.Clear();
                    CurEmployee.DepId         = String.Empty;
                    CurEmployee.DepName       = String.Empty;
                    CurEmployee.ParentEmpId   = String.Empty;
                    CurEmployee.ParentEmpName = String.Empty;
                    MessageBox.Show("请选择外协人员的责任人", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                CurEmployee.EmpId       = EmpIDTB.Text.Trim();
                CurEmployee.EmpName     = EmpNameTB.Text.Trim();
                CurEmployee.Sex         = SexMRB.Checked ? "M" : "F";
                CurEmployee.Hometown    = HometownTB.Text.Trim();
                CurEmployee.CardId      = CardIDTB.Text.Trim();
                CurEmployee.CardIssue   = CardIssueTB.Text.Trim();
                CurEmployee.CardAddress = CardAddressTB.Text.Trim();
                CurEmployee.CompanyName = CompanyNameTB.Text.Trim();
                CurEmployee.ProjectName = ProjectNameTB.Text.Trim();
                CurEmployee.OfficePhone = OfficePhoneTB.Text.Trim();
                CurEmployee.MobilePhone = MobilePhoneTB.Text.Trim();
                CurEmployee.Email       = EmailTB.Text.Trim();
                //CurEmployee.ParentEmpName = null;
                CurEmployee.Enabled = EmpStatusCB.Checked;
                CurEmployee.Comment = RemarkTB.Text.Trim();
                //CurEmployee.Photo = null;
                CurEmployee.PhotoLayout = (int)PhotoPanel.BackgroundImageLayout;

                var result = Common.ShowWait(() => {
                    EmpEntity.SaveOutEmployees(new List <OutEmployeeInfo> {
                        CurEmployee
                    });
                }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                if (result == DialogResult.OK)
                {
                    Common.CopyObjectValues(CurEmployee, OriEmployee);
                    Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveOutEmployeeForm.SaveBtn.Click", String.Format("{0}外协人员:[{1},{2}]", CurBehavior == EnmSaveBehavior.Add ? "新增" : "更新", CurEmployee.EmpId, CurEmployee.EmpName), null);
                    MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveOutEmployeeForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #12
0
ファイル: SaveUserForm.cs プロジェクト: radtek/AccessSystem
        /// <summary>
        /// Save User.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                if (String.IsNullOrWhiteSpace(UserNameTB.Text))
                {
                    UserNameTB.Focus();
                    MessageBox.Show("用户名不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                var UserName = UserNameTB.Text.Trim();
                if (CurBehavior == EnmSaveBehavior.Add || (CurBehavior == EnmSaveBehavior.Edit && !CurUser.UserName.Equals(UserName, StringComparison.CurrentCultureIgnoreCase)))
                {
                    if (MemberShipEntity.UserExists(UserName))
                    {
                        UserNameTB.Focus();
                        MessageBox.Show("用户名已存在", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                if (CurBehavior == EnmSaveBehavior.Add || (CurBehavior == EnmSaveBehavior.Edit && UserPasswordCB.Checked))
                {
                    if (String.IsNullOrWhiteSpace(UserPasswordTB.Text))
                    {
                        UserPasswordTB.Focus();
                        MessageBox.Show("密码不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    if (!UserPasswordTB.Text.Equals(UserCPasswordTB.Text))
                    {
                        UserPasswordTB.Focus();
                        MessageBox.Show("两次输入密码不一致", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                if (!String.IsNullOrWhiteSpace(UserMobileTB.Text) && !Regex.IsMatch(UserMobileTB.Text.Trim(), @"^1[358][0-9]{9}$", RegexOptions.IgnoreCase))
                {
                    UserMobileTB.Focus();
                    MessageBox.Show("请输入正确的手机号码", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!String.IsNullOrWhiteSpace(UserEmailTB.Text) && !Regex.IsMatch(UserEmailTB.Text.Trim(), @"^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$", RegexOptions.IgnoreCase))
                {
                    UserEmailTB.Focus();
                    MessageBox.Show("请输入正确的Email", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!NeverCB.Checked && UserLimitDTP.Value <= DateTime.Now)
                {
                    UserLimitDTP.Focus();
                    MessageBox.Show("用户有效日期无效,请选择大于当前时间的有效日期。", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (CurBehavior == EnmSaveBehavior.Add)
                {
                    CurUser.Role.RoleID                = (Guid)UserRoleCB.SelectedValue;
                    CurUser.Role.RoleName              = UserRoleCB.Text;
                    CurUser.UserName                   = UserNameTB.Text.Trim();
                    CurUser.RemarkName                 = UserRemarkNameTB.Text.Trim();
                    CurUser.Password                   = MemberShipEntity.EncodePassword(UserPasswordTB.Text.Trim(), CurUser.PasswordFormat, CurUser.PasswordSalt);
                    CurUser.MobilePhone                = UserMobileTB.Text.Trim();
                    CurUser.Email                      = UserEmailTB.Text.Trim();
                    CurUser.CreateDate                 = DateTime.Now;
                    CurUser.LimitDate                  = NeverCB.Checked ? new DateTime(2099, 12, 31) : UserLimitDTP.Value;
                    CurUser.LastLoginDate              = ComUtility.DefaultDateTime;
                    CurUser.LastPasswordChangedDate    = ComUtility.DefaultDateTime;
                    CurUser.FailedPasswordAttemptCount = 0;
                    CurUser.IsLockedOut                = false;
                    CurUser.LastLockoutDate            = ComUtility.DefaultDateTime;
                    CurUser.Comment                    = UserCommentTB.Text.Trim();
                    CurUser.Enabled                    = UserStatusCB.Checked;

                    var result = Common.ShowWait(() => {
                        MemberShipEntity.CreateUser(CurUser);
                    }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                    if (result == DialogResult.OK)
                    {
                        Common.CopyObjectValues(CurUser, OriUser);
                        Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveUserForm.SaveBtn.Click", String.Format("新增用户:[{0}]", CurUser.UserName), null);
                        MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        DialogResult = System.Windows.Forms.DialogResult.OK;
                    }
                    else
                    {
                        MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else if (CurBehavior == EnmSaveBehavior.Edit)
                {
                    var IsChangePwd = UserPasswordCB.Checked;
                    if (!IsChangePwd || MessageBox.Show("您确定要重置用户密码吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                    {
                        CurUser.Role.RoleID   = (Guid)UserRoleCB.SelectedValue;
                        CurUser.Role.RoleName = UserRoleCB.Text;
                        CurUser.UserName      = UserNameTB.Text.Trim();
                        CurUser.RemarkName    = UserRemarkNameTB.Text.Trim();
                        if (IsChangePwd)
                        {
                            CurUser.PasswordFormat          = EnmPasswordFormat.Hashed;
                            CurUser.PasswordSalt            = MemberShipEntity.GenerateSalt();
                            CurUser.Password                = MemberShipEntity.EncodePassword(UserPasswordTB.Text.Trim(), CurUser.PasswordFormat, CurUser.PasswordSalt);
                            CurUser.LastPasswordChangedDate = DateTime.Now;
                        }
                        CurUser.MobilePhone = UserMobileTB.Text.Trim();
                        CurUser.Email       = UserEmailTB.Text.Trim();
                        CurUser.LimitDate   = NeverCB.Checked ? new DateTime(2099, 12, 31) : UserLimitDTP.Value;
                        CurUser.Comment     = UserCommentTB.Text.Trim();
                        CurUser.Enabled     = UserStatusCB.Checked;

                        var result = Common.ShowWait(() => {
                            MemberShipEntity.SaveUser(CurUser);
                            if (IsChangePwd)
                            {
                                MemberShipEntity.ChangePassword(CurUser);
                            }
                        }, default(string), "正在保存,请稍后...", default(int), default(int));

                        if (result == DialogResult.OK)
                        {
                            Common.CopyObjectValues(CurUser, OriUser);
                            Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveUserForm.SaveBtn.Click", String.Format("更新用户:[{0}]", CurUser.UserName), null);
                            MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            DialogResult = System.Windows.Forms.DialogResult.OK;
                        }
                        else
                        {
                            MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveUserForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #13
0
ファイル: SaveCardForm.cs プロジェクト: radtek/AccessSystem
        /// <summary>
        /// Save Card.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                if (String.IsNullOrWhiteSpace(CurCard.WorkerId))
                {
                    EmpNameTB.Clear();
                    CurCard.DepId      = String.Empty;
                    CurCard.DepName    = String.Empty;
                    CurCard.WorkerId   = String.Empty;
                    CurCard.WorkerName = String.Empty;
                    MessageBox.Show("请选择持卡员工", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (String.IsNullOrWhiteSpace(CardSnTB.Text))
                {
                    CardSnTB.Focus();
                    MessageBox.Show("请输入卡号", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (CurBehavior == EnmSaveBehavior.Add && CardEntity.ExistCard(CardSnTB.Text.Trim()))
                {
                    CardSnTB.Focus();
                    MessageBox.Show("卡号已存在", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                //CurCard.WorkerId = null;
                //CurCard.WorkerType = null;
                //CurCard.WorkerName = null;
                //CurCard.DepId = null;
                //CurCard.DepName = null;
                CurCard.CardSn      = CardSnTB.Text.Trim();
                CurCard.CardType    = ComUtility.DBNullCardTypeHandler(CardTypeCB.SelectedValue);
                CurCard.UID         = String.IsNullOrWhiteSpace(CardUIDTB.Text) ? "00000000" : CardUIDTB.Text.Trim().PadLeft(8, '0');
                CurCard.Pwd         = String.IsNullOrWhiteSpace(CardPwdTB.Text) ? "0000" : CardPwdTB.Text.Trim().PadLeft(4, '0');
                CurCard.BeginTime   = BeginTimeDTP.Value;
                CurCard.BeginReason = Convert.ToInt32(BeginReasonCB.SelectedValue) == 0 ? BeginReasonTB.Text.Trim() : BeginReasonCB.Text;
                CurCard.Comment     = CommentTB.Text.Trim();
                CurCard.Enabled     = EnabledCB.Checked;
                var result = Common.ShowWait(() => {
                    CardEntity.SaveCards(new List <CardInfo> {
                        CurCard
                    });
                }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                if (result == DialogResult.OK)
                {
                    Common.CopyObjectValues(CurCard, OriCard);
                    Common.WriteLog(DateTime.Now, CurBehavior == EnmSaveBehavior.Add ? EnmMsgType.Cardin : EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveCardForm.SaveBtn.Click", String.Format("{0}卡片:[{1} - {2},{3}]", CurBehavior == EnmSaveBehavior.Add ? "新增" : "更新", CurCard.CardSn, CurCard.WorkerId, CurCard.WorkerName), null);
                    MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveCardForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #14
0
ファイル: SaveRoleForm.cs プロジェクト: radtek/AccessSystem
        /// <summary>
        /// Save Role.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                if (String.IsNullOrWhiteSpace(RoleIDTB.Text))
                {
                    MessageBox.Show("角色标识不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (String.IsNullOrWhiteSpace(RoleNameTB.Text))
                {
                    MessageBox.Show("角色名称不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                var RoleName = RoleNameTB.Text.Trim();
                if (CurBehavior == EnmSaveBehavior.Add || (CurBehavior == EnmSaveBehavior.Edit && !CurRole.RoleName.Equals(RoleName, StringComparison.CurrentCultureIgnoreCase)))
                {
                    if (MemberShipEntity.RoleExists(RoleName))
                    {
                        MessageBox.Show("角色已存在", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                CurRole.RoleName = RoleNameTB.Text.Trim();
                CurRole.Comment  = RoleCommentTB.Text.Trim();
                CurRole.Enabled  = EnabledCB.Checked;
                CurRole.Authorizations.Clear();
                CheckAuthorizationsTreeView(AuthorizationsTreeView.Nodes, 0, CurRole.Authorizations);
                if (CurRole.Authorizations.Count == 0)
                {
                    MessageBox.Show("操作权限未授权", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    RoleTabControl.SelectedIndex = 0;
                    return;
                }

                var sortIndex = 0;
                CurRole.Nodes.Clear();
                CheckNodesTreeView(NodesTreeView.Nodes, 0, ref sortIndex, CurRole.Nodes);
                if (CurRole.Nodes.Count == 0)
                {
                    MessageBox.Show("设备权限未授权", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    RoleTabControl.SelectedIndex = 1;
                    return;
                }

                CurRole.Departments.Clear();
                CheckDepartmentsTreeView(DepartmentTreeView.Nodes, "0", CurRole.Departments);
                if (CurRole.Departments.Count == 0)
                {
                    MessageBox.Show("部门权限未授权", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    RoleTabControl.SelectedIndex = 2;
                    return;
                }

                var result = Common.ShowWait(() => {
                    CurRole.LastRoleID = Common.CurUser.Role.RoleID;
                    MemberShipEntity.SaveRoles(new List <RoleInfo> {
                        CurRole
                    });
                    if (CurBehavior == EnmSaveBehavior.Edit)
                    {
                        MemberShipEntity.VerifyRoles(new List <RoleInfo> {
                            CurRole
                        });
                    }
                }, default(string), "正在保存,请稍后...", default(int), default(int));

                if (result == DialogResult.OK)
                {
                    Common.CopyObjectValues(CurRole, OriRole);
                    Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveRoleForm.SaveBtn.Click", String.Format("{0}角色:[{1}]", CurBehavior == EnmSaveBehavior.Add ? "新增" : "更新", CurRole.RoleName), null);
                    MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveRoleForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }