Esempio n. 1
0
        /// <summary>
        /// Form Shown Event.
        /// </summary>
        private void SaveStaGridForm_Shown(object sender, EventArgs e)
        {
            try {
                SaveBtn.Enabled = false;
                var TempTreeView = new TreeView();
                var result       = Common.ShowWait(() => {
                    BindStationToTreeView(TempTreeView);
                });

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    StaTreeView.Nodes.Clear();
                    foreach (TreeNode tn in TempTreeView.Nodes)
                    {
                        StaTreeView.Nodes.Add((TreeNode)tn.Clone());
                    }

                    if (StaTreeView.Nodes.Count > 0)
                    {
                        var root = StaTreeView.Nodes[0];
                        StaTreeView.SelectedNode = root;
                        root.Expand();
                    }
                    SaveBtn.Enabled = true;
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveStaGridForm.Shown", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Delete All Cards.
        /// </summary>
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            try {
                if (CardsGridView.Rows.Count > 0)
                {
                    if (MessageBox.Show("您确定要全部删除吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                    {
                        var result = Common.ShowWait(() => {
                            CardEntity.DeleteCards(GridCards);
                        }, default(String), "正在删除,请稍后...", default(Int32), default(Int32));

                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            foreach (var gc in GridCards)
                            {
                                Cards.Remove(gc);
                                Common.WriteLog(DateTime.Now, EnmMsgType.Cardout, Common.CurUser.UserName, "Delta.MPS.AccessSystem.OrgCardManagerForm.DeleteBtn.Click", String.Format("删除卡片:[{0} - {1},{2}]", gc.CardSn, gc.WorkerId, gc.WorkerName), null);
                            }
                            GridCards.Clear();
                            CardsGridView.Rows.Clear();
                        }
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.OrgCardManagerForm.DeleteBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Delete Users.
        /// </summary>
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            try {
                var dUsers = GridUsers.FindAll(u => u.UserID != Common.CurUser.UserID);
                if (dUsers.Count > 0)
                {
                    if (MessageBox.Show("您确定要全部删除吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                    {
                        var result = Common.ShowWait(() => {
                            MemberShipEntity.DeleteUsers(dUsers.Select(u => u.UserID).ToList());
                        }, default(String), "正在删除,请稍后...", default(Int32), default(Int32));

                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            foreach (var du in dUsers)
                            {
                                Users.Remove(du);
                                Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.UserManagerForm.DeleteBtn.Click", String.Format("删除用户:[{0}]", du.UserName), null);
                            }

                            BindUsersToGridView();
                        }
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.UserManagerForm.DeleteBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Delete Employees.
        /// </summary>
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            try {
                if (EmpGridView.Rows.Count > 0)
                {
                    if (MessageBox.Show("您确定要全部删除吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                    {
                        var result = Common.ShowWait(() => {
                            EmpEntity.DeleteOutEmployees(GridEmployees);
                        }, default(String), "正在删除,请稍后...", default(Int32), default(Int32));

                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            foreach (var ge in GridEmployees)
                            {
                                OutEmployees.Remove(ge);
                                Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.OutEmployeeManagerForm.DeleteBtn.Click", String.Format("删除外协人员:[{0},{1}]", ge.EmpId, ge.EmpName), null);
                            }
                            GridEmployees.Clear();
                            EmpGridView.Rows.Clear();
                        }
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.OutEmployeeManagerForm.DeleteBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Form Shown Event.
        /// </summary>
        private void OutEmployeeManagerForm_Shown(object sender, EventArgs e)
        {
            try {
                BindSearchType();
                var TempTreeView = new TreeView();
                var result       = Common.ShowWait(() => {
                    Departments  = Common.CurUser.Role.Departments;
                    OrgEmployees = EmpEntity.GetOrgEmployees(Common.CurUser.Role.RoleID);
                    OutEmployees = EmpEntity.GetOutEmployees(Common.CurUser.Role.RoleID);
                    BindEmployeesToTreeView(TempTreeView);
                });

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    EmpTreeView.Nodes.Clear();
                    foreach (TreeNode tn in TempTreeView.Nodes)
                    {
                        EmpTreeView.Nodes.Add((TreeNode)tn.Clone());
                    }

                    if (EmpTreeView.Nodes.Count > 0)
                    {
                        var root = EmpTreeView.Nodes[0];
                        EmpTreeView.SelectedNode = root;
                        root.Expand();
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.OutEmployeeManagerForm.Shown", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Clear Database Logs.
        /// </summary>
        private void ClearBtn1_Click(object sender, EventArgs e)
        {
            try {
                var beginDate   = BeginDateDTP1.Value;
                var endDate     = EndDateDTP1.Value;
                var logType     = (Int32)LogTypeCB1.SelectedValue;
                var logTypeName = LogTypeCB1.Text;
                if (DateTime.Today.Subtract(new DateTime(beginDate.Year, beginDate.Month, beginDate.Day)).Days < 30 ||
                    DateTime.Today.Subtract(new DateTime(endDate.Year, endDate.Month, endDate.Day)).Days < 30)
                {
                    MessageBox.Show("仅能清理30天前的日志记录", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (MessageBox.Show("您确定要清理日志记录吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                {
                    var result = Common.ShowWait(() => {
                        new Log().ClearDBLog(beginDate, endDate, logType);
                    }, default(String), "正在清理,请稍后...", default(Int32), default(Int32));

                    if (result == DialogResult.OK)
                    {
                        Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.ClearDataForm.ClearBtn1.Click", String.Format("清理日志记录[开始日期:{0} 结束日期:{1} 日志类型:{2}]", Common.GetDateString(beginDate), Common.GetDateString(endDate), logTypeName), null);
                        MessageBox.Show("数据清理完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("数据清理失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.ClearDataForm.ClearBtn1.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Employee GridView CellContent Click Event.
        /// </summary>
        private void EmpGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try {
                if (e.RowIndex == -1 || e.ColumnIndex == -1)
                {
                    return;
                }
                var key = (String)EmpGridView.Rows[e.RowIndex].Cells["EIDColumn"].Value;
                var obj = GridEmployees.Find(d => d.EmpId.Equals(key, StringComparison.CurrentCultureIgnoreCase));
                if (obj == null)
                {
                    MessageBox.Show("未找到相关数据项", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                switch (EmpGridView.Columns[e.ColumnIndex].Name)
                {
                case "DeleteColumn":
                    if (EmpEntity.ExistOutEmployeesInOrgEmployees(key))
                    {
                        MessageBox.Show(String.Format("员工[{0},{1}]下已分配外协人员,无法执行删除操作。", obj.EmpId, obj.EmpName), "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    if (MessageBox.Show(String.Format("员工[{0},{1}]将被删除,您确定要删除吗?", obj.EmpId, obj.EmpName), "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                    {
                        var result = Common.ShowWait(() => {
                            EmpEntity.DeleteOrgEmployees(new List <OrgEmployeeInfo>()
                            {
                                obj
                            });
                        }, default(String), "正在删除,请稍后...", default(Int32), default(Int32));

                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            Employees.Remove(obj);
                            GridEmployees.Remove(obj);
                            EmpGridView.Rows.RemoveAt(e.RowIndex);
                            Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.OrgEmployeeManagerForm.EmpGridView.CellContentClick", String.Format("删除员工:[{0},{1}]", obj.EmpId, obj.EmpName), null);
                        }
                    }
                    break;

                case "EditColumn":
                    if (new SaveOrgEmployeeForm(EnmSaveBehavior.Edit, obj).ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                    {
                        EmpGridView.InvalidateRow(e.RowIndex);
                    }
                    break;

                default:
                    break;
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.OrgEmployeeManagerForm.EmpGridView.CellContentClick", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Copy Button1 Click Event.
        /// </summary>
        private void CopyBtn1_Click(object sender, EventArgs e)
        {
            try {
                var source = new List <Int32>();
                if (SourceTreeView1.SelectedNode != null)
                {
                    var tag = (IDValuePair <Int32, EnmNodeType>)SourceTreeView1.SelectedNode.Tag;
                    if (tag != null && tag.Value == EnmNodeType.Dev)
                    {
                        source.Add(tag.ID);
                    }
                }

                if (source.Count == 0)
                {
                    MessageBox.Show("请选择源授权设备", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                var target = new List <Int32>();
                CheckDevTreeView(TargetTreeView1.Nodes, target);
                if (target.Count == 0)
                {
                    MessageBox.Show("请勾选目的授权设备", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (MessageBox.Show(String.Format("源设备[{0}]权限将被复制,您确定要复制吗?", source[0]), "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                {
                    var result = Common.ShowWait(() => {
                        CardAuthEntity.CopyAuthByDev(source, target, DeleteOriAuthCB.Checked);
                    }, default(String), "正在复制,请稍后...", default(Int32), default(Int32));

                    if (result == DialogResult.OK)
                    {
                        foreach (var s in source)
                        {
                            foreach (var t in target)
                            {
                                Common.WriteLog(DateTime.Now, EnmMsgType.Authin, Common.CurUser.UserName, "Delta.MPS.AccessSystem.CopyAuthForm.CopyBtn1.Click", String.Format("权限复制:设备[{0}] --> 设备[{1}]", s, t), null);
                            }
                        }

                        MessageBox.Show("权限复制完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("权限复制失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.CopyAuthForm.CopyBtn1.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Cancel All CardAuth Button Click.
        /// </summary>
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            try {
                var Devices = new List <Int32>();
                CheckDevTreeView(DevTreeView.Nodes, Devices);
                if (Devices.Count == 0)
                {
                    MessageBox.Show("请勾选需要撤权的设备", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

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

                if (MessageBox.Show("您确定要执行批量撤权操作吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                {
                    var DelCardAuth = new List <IDValuePair <Int32, String> >();
                    foreach (var dev in Devices)
                    {
                        foreach (var card in Cards)
                        {
                            DelCardAuth.Add(new IDValuePair <Int32, String>(dev, card));
                        }
                    }

                    var result = Common.ShowWait(() => {
                        CardAuthEntity.DeleteCardAuth(DelCardAuth);
                    }, default(String), "正在撤权,请稍后...", default(Int32), default(Int32), 1800);

                    if (result == DialogResult.OK)
                    {
                        foreach (var ca in DelCardAuth)
                        {
                            Common.WriteLog(DateTime.Now, EnmMsgType.Authout, Common.CurUser.UserName, "Delta.MPS.AccessSystem.BatchCancelCardAuthForm.DeleteBtn.Click", String.Format("删除卡片授权[设备:{0} 卡号:{1}]", ca.ID, ca.Value), 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.BatchCancelCardAuthForm.DeleteBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Form Shown Event.
        /// </summary>
        private void BatchCancelCardAuthForm_Shown(object sender, EventArgs e)
        {
            try {
                DeleteBtn.Enabled = false;
                var DevTempTreeView  = new TreeView();
                var CardTempTreeView = new TreeView();
                var result           = Common.ShowWait(() => {
                    BindDeviceToTreeView(DevTempTreeView);

                    if (CurWorkerType == EnmWorkerType.WXRY)
                    {
                        BindOutCardsToTreeView(CardTempTreeView);
                    }
                    else
                    {
                        BindOrgCardsToTreeView(CardTempTreeView);
                    }
                });

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    DevTreeView.Nodes.Clear();
                    foreach (TreeNode tn in DevTempTreeView.Nodes)
                    {
                        DevTreeView.Nodes.Add((TreeNode)tn.Clone());
                    }

                    CardTreeView.Nodes.Clear();
                    foreach (TreeNode tn in CardTempTreeView.Nodes)
                    {
                        CardTreeView.Nodes.Add((TreeNode)tn.Clone());
                    }

                    if (DevTreeView.Nodes.Count > 0)
                    {
                        var root = DevTreeView.Nodes[0];
                        DevTreeView.SelectedNode = root;
                        root.Expand();
                    }

                    if (CardTreeView.Nodes.Count > 0)
                    {
                        var root = CardTreeView.Nodes[0];
                        CardTreeView.SelectedNode = root;
                        root.Expand();
                    }
                    DeleteBtn.Enabled = true;
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.BatchCancelCardAuthForm.Shown", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Delete All Departments.
        /// </summary>
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            try {
                if (DeptGridView.Rows.Count > 0)
                {
                    if (MessageBox.Show("您确定要全部删除吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                    {
                        var adDept = new Dictionary <String, DepartmentInfo>();
                        foreach (var dd in GridDepartments)
                        {
                            if (DeptEntity.ExistEmployeesInDepartment(dd.DepId))
                            {
                                MessageBox.Show(String.Format("部门[{0},{1}]下存在员工,无法执行删除操作。", dd.DepId, dd.DepName), "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return;
                            }
                            adDept[dd.DepId] = dd;

                            var SubDept = new List <DepartmentInfo>();
                            FindSubDeptRecursion(dd.DepId, SubDept);
                            foreach (var sd in SubDept)
                            {
                                if (DeptEntity.ExistEmployeesInDepartment(sd.DepId))
                                {
                                    MessageBox.Show(String.Format("部门[{0},{1}]的子部门[{2},{3}]下存在员工,无法执行删除操作。", dd.DepId, dd.DepName, sd.DepId, sd.DepName), "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    return;
                                }
                                adDept[sd.DepId] = sd;
                            }
                        }

                        var result = Common.ShowWait(() => {
                            DeptEntity.DeleteDepartments(adDept.Select(sd => sd.Value.DepId).ToList());
                        }, default(String), "正在删除,请稍后...", default(Int32), default(Int32));

                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            foreach (var gr in adDept)
                            {
                                Departments.Remove(gr.Value);
                                Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.DepartmentManagerForm.DeleteBtn.Click", String.Format("删除部门:[{0},{1}]", gr.Value.DepId, gr.Value.DepName), null);
                            }

                            BindDepartmentsToTreeView();
                        }
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.DepartmentManagerForm.DeleteBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Save Cards.
        /// </summary>
        private void OKBtn_Click(object sender, EventArgs e)
        {
            try {
                if (CardsGridView.Rows.Count == 0)
                {
                    Cards.Clear();
                    MessageBox.Show("无发卡记录", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                ExistCards.Clear();
                foreach (var c in Cards)
                {
                    if (CardEntity.ExistCard(c.ID.CardSn))
                    {
                        ExistCards[c.ID.CardSn] = c.ID;
                    }
                }

                if (ExistCards.Count > 0)
                {
                    BindCardsToGridView();
                    CardsGridView.ClearSelection();
                    MessageBox.Show("卡号已注册,请对红色标记的记录重新读卡。", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                var result = Common.ShowWait(() => {
                    CardEntity.SaveCards(Cards.Select(c => c.ID).ToList());
                }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                if (result == DialogResult.OK)
                {
                    foreach (var c in Cards)
                    {
                        Common.WriteLog(DateTime.Now, EnmMsgType.Cardin, Common.CurUser.UserName, "Delta.MPS.AccessSystem.BatchOrgCardsForm.OKBtn.Click", String.Format("新增卡片:[{0} - {1},{2}]", c.ID.CardSn, c.ID.WorkerId, c.ID.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.BatchOrgCardsForm.OKBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Delete Selected Employees.
        /// </summary>
        private void OpMenuItem1_Click(object sender, EventArgs e)
        {
            try {
                if (EmpGridView.SelectedRows.Count > 0)
                {
                    var adEmps = new Dictionary <Int32, OrgEmployeeInfo>();
                    foreach (DataGridViewRow row in EmpGridView.SelectedRows)
                    {
                        var key = (String)row.Cells["EIDColumn"].Value;
                        var obj = GridEmployees.Find(ge => ge.EmpId.Equals(key, StringComparison.CurrentCultureIgnoreCase));
                        if (obj != null)
                        {
                            if (EmpEntity.ExistOutEmployeesInOrgEmployees(obj.EmpId))
                            {
                                MessageBox.Show(String.Format("员工[{0},{1}]下已分配外协人员,无法执行删除操作。", obj.EmpId, obj.EmpName), "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return;
                            }

                            adEmps[row.Index] = obj;
                        }
                    }

                    if (adEmps.Count > 0)
                    {
                        if (MessageBox.Show("选中员工将被删除,您确定要删除吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                        {
                            var result = Common.ShowWait(() => {
                                EmpEntity.DeleteOrgEmployees(adEmps.Select(ad => ad.Value).ToList());
                            }, default(String), "正在删除,请稍后...", default(Int32), default(Int32));

                            if (result == System.Windows.Forms.DialogResult.OK)
                            {
                                foreach (var ae in adEmps)
                                {
                                    Employees.Remove(ae.Value);
                                    GridEmployees.Remove(ae.Value);
                                    EmpGridView.Rows.RemoveAt(ae.Key);
                                    Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.OrgEmployeeManagerForm.OpMenuItem1.Click", String.Format("删除员工:[{0},{1}]", ae.Value.EmpId, ae.Value.EmpName), null);
                                }
                            }
                        }
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.OrgEmployeeManagerForm.OpMenuItem1.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Grid Group GridView CellContent Click Event.
        /// </summary>
        private void GridGroupGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try {
                if (e.RowIndex == -1 || e.ColumnIndex == -1)
                {
                    return;
                }
                var key = (Int32)GridGroupGridView.Rows[e.RowIndex].Cells["StaIDColumn"].Value;
                var obj = CurStations.Find(d => d.StaID == key);
                if (obj == null)
                {
                    MessageBox.Show("未找到相关数据项", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                switch (GridGroupGridView.Columns[e.ColumnIndex].Name)
                {
                case "DeleteColumn":
                    if (MessageBox.Show("您确定要删除吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                    {
                        var result = Common.ShowWait(() => {
                            new Grid().DeleteStaGrid(new List <Int32>()
                            {
                                obj.StaID
                            });
                        }, default(String), "正在删除,请稍后...", default(Int32), default(Int32));

                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            CurStations.Remove(obj);
                            GridGroupGridView.Rows.RemoveAt(e.RowIndex);
                        }
                    }
                    break;

                default:
                    break;
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.GridGroupForm.GridGroupGridView.CellContentClick", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Delete Selected Cards.
        /// </summary>
        private void OpMenuItem1_Click(object sender, EventArgs e)
        {
            try {
                if (CardsGridView.SelectedRows.Count > 0)
                {
                    var adEmps = new Dictionary <Int32, CardInfo>();
                    foreach (DataGridViewRow row in CardsGridView.SelectedRows)
                    {
                        var key = (String)row.Cells["CardSnColumn"].Value;
                        var obj = GridCards.Find(gc => gc.CardSn.Equals(key));
                        if (obj != null)
                        {
                            adEmps[row.Index] = obj;
                        }
                    }

                    if (adEmps.Count > 0)
                    {
                        if (MessageBox.Show("选中卡片将被删除,您确定要删除吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                        {
                            var result = Common.ShowWait(() => {
                                CardEntity.DeleteCards(adEmps.Select(ad => ad.Value).ToList());
                            }, default(String), "正在删除,请稍后...", default(Int32), default(Int32));

                            if (result == System.Windows.Forms.DialogResult.OK)
                            {
                                foreach (var ae in adEmps)
                                {
                                    Cards.Remove(ae.Value);
                                    GridCards.Remove(ae.Value);
                                    CardsGridView.Rows.RemoveAt(ae.Key);
                                    Common.WriteLog(DateTime.Now, EnmMsgType.Cardout, Common.CurUser.UserName, "Delta.MPS.AccessSystem.OrgCardManagerForm.OpMenuItem1.Click", String.Format("删除卡片:[{0} - {1},{2}]", ae.Value.CardSn, ae.Value.WorkerId, ae.Value.WorkerName), null);
                                }
                            }
                        }
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.OrgCardManagerForm.OpMenuItem1.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Save Button Click Event.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                if (ExcelDataTable == null || ExcelDataTable.Rows.Count == 0)
                {
                    MessageBox.Show("无数据记录", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (MessageBox.Show("您确定要保存吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                {
                    var result = Common.ShowWait(() => {
                        switch (ImportType)
                        {
                        case EnmImportType.Org:
                            new Employee().ImportOrgEmployees(ExcelDataTable);
                            break;

                        case EnmImportType.Out:
                            new Employee().ImportOutEmployees(ExcelDataTable);
                            break;

                        default:
                            break;
                        }
                    }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                    if (result == DialogResult.OK)
                    {
                        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.ImportDataForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Delete Selected Users.
        /// </summary>
        private void OpMenuItem1_Click(object sender, EventArgs e)
        {
            try {
                if (UserGridView.SelectedRows.Count > 0)
                {
                    var dUsers = new Dictionary <Int32, UserInfo>();
                    foreach (DataGridViewRow row in UserGridView.SelectedRows)
                    {
                        var key = (Guid)row.Cells["UIDColumn"].Value;
                        var obj = GridUsers.Find(r => r.UserID == key);
                        if (obj != null && obj.UserID != Common.CurUser.UserID)
                        {
                            dUsers[row.Index] = obj;
                        }
                    }

                    if (dUsers.Count > 0)
                    {
                        if (MessageBox.Show("选中用户将被删除,您确定要删除吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                        {
                            var result = Common.ShowWait(() => {
                                MemberShipEntity.DeleteUsers(dUsers.Select(dr => dr.Value.UserID).ToList());
                            }, default(String), "正在删除,请稍后...", default(Int32), default(Int32));

                            if (result == System.Windows.Forms.DialogResult.OK)
                            {
                                foreach (var du in dUsers)
                                {
                                    Users.Remove(du.Value);
                                    GridUsers.Remove(du.Value);
                                    UserGridView.Rows.RemoveAt(du.Key);
                                    Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.UserManagerForm.OpMenuItem1.Click", String.Format("删除用户:[{0}]", du.Value.UserName), null);
                                }
                            }
                        }
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.UserManagerForm.OpMenuItem1.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Delete Employees.
        /// </summary>
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            try {
                if (EmpGridView.Rows.Count > 0)
                {
                    var adEmps = new Dictionary <String, OrgEmployeeInfo>();
                    foreach (var ge in GridEmployees)
                    {
                        if (EmpEntity.ExistOutEmployeesInOrgEmployees(ge.EmpId))
                        {
                            MessageBox.Show(String.Format("员工[{0},{1}]下已分配外协人员,无法执行删除操作。", ge.EmpId, ge.EmpName), "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                        adEmps[ge.EmpId] = ge;
                    }

                    if (MessageBox.Show("您确定要全部删除吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                    {
                        var result = Common.ShowWait(() => {
                            EmpEntity.DeleteOrgEmployees(adEmps.Select(ad => ad.Value).ToList());
                        }, default(String), "正在删除,请稍后...", default(Int32), default(Int32));

                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            GridEmployees.Clear();
                            EmpGridView.Rows.Clear();
                            foreach (var ad in adEmps)
                            {
                                Employees.Remove(ad.Value);
                                Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.OrgEmployeeManagerForm.DeleteBtn.Click", String.Format("删除员工:[{0},{1}]", ad.Value.EmpId, ad.Value.EmpName), null);
                            }
                        }
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.OrgEmployeeManagerForm.DeleteBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Delete Stations From Grid.
        /// </summary>
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            try {
                if (GridGroupGridView.Rows.Count > 0)
                {
                    if (MessageBox.Show("您确定要全部删除吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                    {
                        var result = Common.ShowWait(() => {
                            new Grid().DeleteStaGrid(CurStations.Select(s => s.StaID).ToList());
                        }, default(String), "正在删除,请稍后...", default(Int32), default(Int32));

                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            CurStations.Clear();
                            GridGroupGridView.Rows.Clear();
                        }
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.GridGroupForm.DeleteBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Delete Selected Stations.
        /// </summary>
        private void OpMenuItem1_Click(object sender, EventArgs e)
        {
            try {
                if (GridGroupGridView.Rows.Count > 0)
                {
                    var adEmps = new Dictionary <Int32, StaInfo>();
                    foreach (DataGridViewRow row in GridGroupGridView.SelectedRows)
                    {
                        var key = (Int32)row.Cells["StaIDColumn"].Value;
                        var obj = CurStations.Find(s => s.StaID == key);
                        if (obj != null)
                        {
                            adEmps[row.Index] = obj;
                        }
                    }

                    if (adEmps.Count > 0)
                    {
                        if (MessageBox.Show("选中局站将被删除,您确定要删除吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                        {
                            var result = Common.ShowWait(() => {
                                new Grid().DeleteStaGrid(adEmps.Select(s => s.Value.StaID).ToList());
                            }, default(String), "正在删除,请稍后...", default(Int32), default(Int32));

                            foreach (var ae in adEmps)
                            {
                                CurStations.Remove(ae.Value);
                                GridGroupGridView.Rows.RemoveAt(ae.Key);
                            }
                        }
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.GridGroupForm.DeleteBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Delete All Roles.
        /// </summary>
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            try {
                if (RoleGridView.Rows.Count > 0)
                {
                    if (MessageBox.Show("您确定要全部删除吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                    {
                        foreach (var gr in GridRoles)
                        {
                            if (MemberShipEntity.RoleUserExists(gr.RoleID))
                            {
                                MessageBox.Show(String.Format("角色[{0}]下存在用户,无法执行删除操作。", gr.RoleName), "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return;
                            }
                        }

                        var result = Common.ShowWait(() => {
                            MemberShipEntity.DelRoles(GridRoles);
                        }, default(string), "正在删除,请稍后...", default(int), default(int));

                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            foreach (var gr in GridRoles)
                            {
                                Roles.Remove(gr);
                                Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.RoleManagerForm.DeleteBtn.Click", String.Format("删除角色:[{0}]", gr.RoleName), null);
                            }

                            BindRolesToTreeView();
                        }
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.RoleManagerForm.DeleteBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Save Station Grid.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                var Stations = new List <Int32>();
                CheckStaTreeView(StaTreeView.Nodes, Stations);

                var result = Common.ShowWait(() => {
                    new Grid().UpdateStaGrid(CurGrid.ID, Stations);
                }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                if (result == DialogResult.OK)
                {
                    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.SaveStaGridForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 23
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);
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Department GridView CellContent Click Event.
        /// </summary>
        private void DeptGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try {
                if (e.RowIndex == -1 || e.ColumnIndex == -1)
                {
                    return;
                }
                var key = (String)DeptGridView.Rows[e.RowIndex].Cells["DIDColumn"].Value;
                var obj = GridDepartments.Find(d => d.DepId.Equals(key, StringComparison.CurrentCultureIgnoreCase));
                if (obj == null)
                {
                    MessageBox.Show("未找到相关数据项", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                switch (DeptGridView.Columns[e.ColumnIndex].Name)
                {
                case "DeleteColumn":
                    if (DeptEntity.ExistEmployeesInDepartment(obj.DepId))
                    {
                        MessageBox.Show(String.Format("部门[{0},{1}]下存在员工,无法执行删除操作。", obj.DepId, obj.DepName), "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    var SubDept = new List <DepartmentInfo>();
                    FindSubDeptRecursion(obj.DepId, SubDept);
                    foreach (var sd in SubDept)
                    {
                        if (DeptEntity.ExistEmployeesInDepartment(sd.DepId))
                        {
                            MessageBox.Show(String.Format("其子部门[{0},{1}]下存在员工,无法执行删除操作。", sd.DepId, sd.DepName), "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                    }

                    if (MessageBox.Show(String.Format("部门[{0},{1}]{2}将被删除,您确定要删除吗?", obj.DepId, obj.DepName, SubDept.Count > 0 ? "及其子部门" : String.Empty), "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                    {
                        var result = Common.ShowWait(() => {
                            SubDept.Add(obj);
                            DeptEntity.DeleteDepartments(SubDept.Select(sd => sd.DepId).ToList());
                        }, default(String), "正在删除,请稍后...", default(Int32), default(Int32));

                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            foreach (var sr in SubDept)
                            {
                                Departments.Remove(sr);
                                Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.DepartmentManagerForm.DeptGridView.CellContentClick", String.Format("删除部门:[{0},{1}]", sr.DepId, sr.DepName), null);
                            }

                            BindDepartmentsToTreeView();
                        }
                    }
                    break;

                case "EditColumn":
                    if (new SaveDepartmentForm(EnmSaveBehavior.Edit, obj).ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                    {
                        BindDepartmentsToTreeView();
                    }
                    break;

                default:
                    break;
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.DepartmentManagerForm.DeptGridView.CellContentClick", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 25
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);
            }
        }
Esempio n. 26
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);
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Query Button Click Event.
        /// </summary>
        private void QueryBtn_Click(object sender, EventArgs e)
        {
            try {
                CurRecords.Clear();
                EmpGridView.Rows.Clear();

                var departments = new List <String>();
                foreach (IDValuePair <String, String> dt in DeptLB.Items)
                {
                    departments.Add(dt.ID);
                }

                var cardType   = (Int32)CardTypeCB.SelectedValue;
                var queryIndex = (Int32)QueryTypeCB.SelectedValue;
                var queryText  = QueryTypeTB.Text;

                var result = Common.ShowWait(() => {
                    var employees = new Employee().GetOrgEmployees(Common.CurUser.Role.RoleID);
                    var cardAuths = new CardAuth().GetCardAuthCount();
                    var cards     = from c in Common.CurUser.Role.Cards
                                    join ca in cardAuths on c.CardSn equals ca.ID into tp
                                    from ta in tp.DefaultIfEmpty()
                                    where c.WorkerType != EnmWorkerType.WXRY
                                    select new {
                        Card = c,
                        Auth = ta
                    };

                    CurRecords = (from emp in employees
                                  join dep in departments on emp.DepId equals dep
                                  join c in cards on emp.EmpId equals c.Card.WorkerId into tp
                                  from tc in tp.DefaultIfEmpty()
                                  where cardType == 0 || (cardType == 1 && tc != null) || (cardType == 2 && tc == null)
                                  orderby emp.EmpId
                                  select new ValuesPair <OrgEmployeeInfo, CardInfo, Int32, object, object> {
                        Value1 = emp,
                        Value2 = tc != null ? tc.Card : null,
                        Value3 = tc != null && tc.Auth != null ? tc.Auth.Value : 0,
                        Value4 = null,
                        Value5 = null
                    }).ToList();

                    if (!String.IsNullOrWhiteSpace(queryText))
                    {
                        var filters = queryText.Split(new String[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                        switch (queryIndex)
                        {
                        case 0:
                            CurRecords = CurRecords.FindAll(rec => {
                                foreach (var f in filters)
                                {
                                    if (rec.Value1.EmpId.Contains(f.Trim()))
                                    {
                                        return(true);
                                    }
                                }
                                return(false);
                            });
                            break;

                        case 1:
                            CurRecords = CurRecords.FindAll(rec => {
                                foreach (var f in filters)
                                {
                                    if (rec.Value1.EmpName.Equals(f.Trim(), StringComparison.CurrentCultureIgnoreCase))
                                    {
                                        return(true);
                                    }
                                }
                                return(false);
                            });
                            break;

                        case 2:
                            CurRecords = CurRecords.FindAll(rec => {
                                if (rec.Value2 == null)
                                {
                                    return(false);
                                }
                                foreach (var f in filters)
                                {
                                    if (rec.Value2.CardSn.Contains(f.Trim()))
                                    {
                                        return(true);
                                    }
                                }
                                return(false);
                            });
                            break;

                        default:
                            break;
                        }
                    }
                }, default(string), "正在查询,请稍后...", default(int), default(int));

                if (result == DialogResult.OK)
                {
                    EmpGridView.RowCount = CurRecords.Count;
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.OrgEmployeeReportForm.DeptBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Form Shown Event
        /// </summary>
        private void SaveCardDevAuthForm_Shown(object sender, EventArgs e)
        {
            try {
                SaveBtn.Enabled = false;
                if (CurBehavior == EnmSaveBehavior.Null || CurCardAuth.Count == 0)
                {
                    MessageBox.Show("非法的构造参数", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    DialogResult = System.Windows.Forms.DialogResult.Abort;
                    return;
                }

                BindLimitTypeCombobox();
                DeviceTreeView.CheckBoxes = CardsTreeView.CheckBoxes = CurBehavior == EnmSaveBehavior.Add;
                var cardSn = String.Empty;
                foreach (var ca in CurCardAuth)
                {
                    cardSn                     = ca.CardSn;
                    BeginTimeDTP.Value         = ca.BeginTime;
                    EndTimeDTP.Value           = ca.EndTime;
                    LimitTypeCB.SelectedValue  = (Int32)ca.LimitId;
                    LimitIndexCB.SelectedValue = ca.LimitIndex;
                    PwdCB.Text                 = ca.Password;
                    EnabledCB.Checked          = ca.Enabled;
                }

                var DevTempTreeView  = new TreeView();
                var CardTempTreeView = new TreeView();
                var result           = Common.ShowWait(() => {
                    CurExistsNodes = CardAuthEntity.GetCardAuthDevs(cardSn);
                    BindDeviceToTreeView(DevTempTreeView);
                    BindCardsToTreeView(CardTempTreeView);
                });

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    DeviceTreeView.Nodes.Clear();
                    foreach (TreeNode tn in DevTempTreeView.Nodes)
                    {
                        DeviceTreeView.Nodes.Add((TreeNode)tn.Clone());
                    }

                    CardsTreeView.Nodes.Clear();
                    foreach (TreeNode tn in CardTempTreeView.Nodes)
                    {
                        CardsTreeView.Nodes.Add((TreeNode)tn.Clone());
                    }

                    if (DeviceTreeView.Nodes.Count > 0)
                    {
                        var root = DeviceTreeView.Nodes[0];
                        DeviceTreeView.SelectedNode = root;
                        if (CurBehavior == EnmSaveBehavior.Add)
                        {
                            root.Expand();
                        }
                        else
                        {
                            root.ExpandAll();
                        }
                    }
                    SaveBtn.Enabled = true;
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveCardDevAuthForm.Shown", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 29
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);
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Query Button Click Event.
        /// </summary>
        private void QueryBtn_Click(object sender, EventArgs e)
        {
            try {
                CurRecords.Clear();
                CardCountGridView.Rows.Clear();

                var area2Index = Area2NameCB.SelectedIndex;
                var area2Text  = Area2NameCB.Text.ToLower().Trim();
                var area2Value = Area2NameCB.SelectedValue != null ? (Int32)Area2NameCB.SelectedValue : -1;

                var area3Index = Area3NameCB.SelectedIndex;
                var area3Text  = Area3NameCB.Text.ToLower().Trim();
                var area3Value = Area3NameCB.SelectedValue != null ? (Int32)Area3NameCB.SelectedValue : -1;

                var staIndex = StaNameCB.SelectedIndex;
                var staText  = StaNameCB.Text.ToLower().Trim();
                var staValue = StaNameCB.SelectedValue != null ? (Int32)StaNameCB.SelectedValue : -1;

                var devIndex = DevNameCB.SelectedIndex;
                var devText  = DevNameCB.Text.ToLower().Trim();
                var devValue = DevNameCB.SelectedValue != null ? (Int32)DevNameCB.SelectedValue : -1;

                var beginTime = BeginFromTime.Value;
                var endTime   = BeginToTime.Value;

                var queryIndex = (Int32)QueryTypeCB.SelectedValue;
                var queryText  = QueryTypeTB.Text;

                var result = Common.ShowWait(() => {
                    var tpRecords = new Card().GetHisCardRecords(beginTime, endTime);
                    if (tpRecords != null && tpRecords.Count > 0)
                    {
                        var devices = Common.CurUser.Role.Devices.Values.ToList();
                        if (area2Index == -1)
                        {
                            devices = devices.FindAll(rec => rec.Area2Name.ToLower().Contains(area2Text));
                        }

                        if (area2Index > 0)
                        {
                            devices = devices.FindAll(rec => rec.Area2ID == area2Value);
                        }

                        if (area3Index == -1)
                        {
                            devices = devices.FindAll(rec => rec.Area3Name.ToLower().Contains(area3Text));
                        }

                        if (area3Index > 0)
                        {
                            devices = devices.FindAll(rec => rec.Area3ID == area3Value);
                        }

                        if (staIndex == -1)
                        {
                            devices = devices.FindAll(rec => rec.StaName.ToLower().Contains(staText));
                        }

                        if (staIndex > 0)
                        {
                            devices = devices.FindAll(rec => rec.StaID == staValue);
                        }

                        if (devIndex == -1)
                        {
                            devices = devices.FindAll(rec => rec.DevName.ToLower().Contains(devText));
                        }

                        if (devIndex > 0)
                        {
                            devices = devices.FindAll(rec => rec.DevID == devValue);
                        }

                        var cards = Common.CurUser.Role.Cards;
                        if (!String.IsNullOrWhiteSpace(queryText))
                        {
                            var filters = queryText.Split(new String[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                            switch (queryIndex)
                            {
                            case 0:
                                cards = cards.FindAll(rec => {
                                    if (String.IsNullOrWhiteSpace(rec.CardSn))
                                    {
                                        return(false);
                                    }
                                    foreach (var f in filters)
                                    {
                                        if (rec.CardSn.Contains(f.Trim()))
                                        {
                                            return(true);
                                        }
                                    }
                                    return(false);
                                });
                                break;

                            case 1:
                                cards = cards.FindAll(rec => {
                                    if (String.IsNullOrWhiteSpace(rec.WorkerId))
                                    {
                                        return(false);
                                    }
                                    foreach (var f in filters)
                                    {
                                        if (rec.WorkerId.Contains(f.Trim()))
                                        {
                                            return(true);
                                        }
                                    }
                                    return(false);
                                });
                                break;

                            case 2:
                                cards = cards.FindAll(rec => {
                                    if (String.IsNullOrWhiteSpace(rec.WorkerName))
                                    {
                                        return(false);
                                    }
                                    foreach (var f in filters)
                                    {
                                        if (rec.WorkerName.Equals(f.Trim(), StringComparison.CurrentCultureIgnoreCase))
                                        {
                                            return(true);
                                        }
                                    }
                                    return(false);
                                });
                                break;

                            default:
                                break;
                            }
                        }

                        var gpRecords = from rec in tpRecords
                                        group rec by new { rec.DevID, rec.CardSn } into g
                        select new {
                            DevID  = g.Key.DevID,
                            CardSn = g.Key.CardSn,
                            Cnt    = g.ToList()
                        };

                        CurRecords = (from rec in gpRecords
                                      join dev in devices on rec.DevID equals dev.DevID
                                      join card in cards on rec.CardSn equals card.CardSn
                                      orderby card.CardSn, dev.DevID
                                      select new ValuesPair <DeviceInfo, CardInfo, List <CardRecordInfo>, object, object> {
                            Value1 = dev,
                            Value2 = card,
                            Value3 = rec.Cnt,
                            Value4 = null,
                            Value5 = null
                        }).ToList();
                    }
                }, default(string), "正在查询,请稍后...", default(int), default(int));

                if (result == DialogResult.OK)
                {
                    CardCountGridView.RowCount = CurRecords.Count;
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.CardRecordsCountForm.QueryBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }