/// <summary> /// Menu Item Click Event. /// </summary> private void RecMenuItem1_Click(object sender, EventArgs e) { try { if (CurRecords.Count > 0) { var data = new DataTable(); data.Columns.Add("序号", typeof(String)); data.Columns.Add("工号", typeof(String)); data.Columns.Add("姓名", typeof(String)); data.Columns.Add("部门", typeof(String)); data.Columns.Add("卡号", typeof(String)); data.Columns.Add("开始日期", typeof(String)); data.Columns.Add("结束日期", typeof(String)); data.Columns.Add("权限类型", typeof(String)); data.Columns.Add("权限分组", typeof(String)); data.Columns.Add("状态", typeof(String)); for (var i = 0; i < CurRecords.Count; i++) { var dr = data.NewRow(); dr["序号"] = i + 1; dr["工号"] = CurRecords[i].ID != null ? CurRecords[i].ID.WorkerId : String.Empty; dr["姓名"] = CurRecords[i].ID != null ? CurRecords[i].ID.WorkerName : String.Empty; dr["部门"] = CurRecords[i].ID != null?String.Format("{0} - {1}", CurRecords[i].ID.DepId, CurRecords[i].ID.DepName) : String.Empty; dr["卡号"] = CurRecords[i].Value.CardSn; dr["开始日期"] = Common.GetDateString(CurRecords[i].Value.BeginTime); dr["结束日期"] = Common.GetDateString(CurRecords[i].Value.EndTime); dr["权限类型"] = ComUtility.GetLimitIDText(CurRecords[i].Value.LimitId); dr["权限分组"] = CurRecords[i].Value.LimitIndex == ComUtility.DefaultInt32 ? String.Empty : CurRecords[i].Value.LimitIndex.ToString(); dr["状态"] = CurRecords[i].Value.Enabled ? "启用" : "禁用"; data.Rows.Add(dr); } Common.ExportDataToExcel(null, "设备授权信息", "智能门禁管理系统 设备授权信息报表", String.Format("操作员:{0}{1} 日期:{2} 设备:{3} - {4}", Common.CurUser.UserName, String.IsNullOrWhiteSpace(Common.CurUser.RemarkName) ? String.Empty : String.Format("({0})", Common.CurUser.RemarkName), Common.GetDateTimeString(DateTime.Now), CurDevice.DevID, String.Format("{0}>{1}>{2}>{3}", CurDevice.Area2Name, CurDevice.Area3Name, CurDevice.StaName, CurDevice.DevName)), data); } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.CardAuthDetailDialog.RecMenuItem1.Click", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Register software. /// </summary> private void okBtn_Click(object sender, EventArgs e) { try { if (String.IsNullOrWhiteSpace(registerCode.Text)) { registerCode.Focus(); MessageBox.Show("注册码不能为空,请输入注册码。", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var lcode = registerCode.Text.Trim(); Common.CheckLicense(lcode); if (Common.LicenseStatus == EnmLicenseStatus.Licensed) { Common.CurApplication.AppLicense = lcode; var registryEntity = new RegistryDatabase(); registryEntity.SaveSystemApplication(Common.CurApplication); var sb = new StringBuilder(); sb.AppendLine("软件注册成功!"); sb.AppendLine(); sb.AppendFormat("用户: {0}{1}", Common.CurLicense.Name, Environment.NewLine); sb.AppendFormat("公司: {0}{1}", Common.CurLicense.Company, Environment.NewLine); sb.AppendFormat("Email: {0}{1}", Common.CurLicense.Email, Environment.NewLine); sb.AppendFormat("有效期: {0}", new DateTime(2099, 12, 31).Equals(Common.CurLicense.Expiration) ? "永不过期" : Common.GetDateString(Common.CurLicense.Expiration)); Common.WriteLog(DateTime.Now, EnmMsgType.Warning, "System", "Delta.MPS.AccessSystem.RegisterForm", sb.ToString().Replace(Environment.NewLine, " "), null); MessageBox.Show(sb.ToString(), "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } else if (Common.LicenseStatus == EnmLicenseStatus.Expired) { MessageBox.Show("注册码已过期,注册失败。", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("无效的注册码,注册失败。", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.RegisterForm", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Menu Item Click Event. /// </summary> private void RecMenuItem1_Click(object sender, EventArgs e) { try { if (CurRecords.Count > 0) { var data = new DataTable(); data.Columns.Add("序号", typeof(String)); data.Columns.Add("工号", typeof(String)); data.Columns.Add("姓名", typeof(String)); data.Columns.Add("类别", typeof(String)); data.Columns.Add("英文名", typeof(String)); data.Columns.Add("性别", typeof(String)); data.Columns.Add("身份证号", typeof(String)); data.Columns.Add("籍贯", typeof(String)); data.Columns.Add("出生日期", typeof(String)); data.Columns.Add("婚姻状况", typeof(String)); data.Columns.Add("家庭地址", typeof(String)); data.Columns.Add("家庭电话", typeof(String)); data.Columns.Add("入职日期", typeof(String)); data.Columns.Add("转正日期", typeof(String)); data.Columns.Add("部门名称", typeof(String)); data.Columns.Add("职务", typeof(String)); data.Columns.Add("办公电话", typeof(String)); data.Columns.Add("手机", typeof(String)); data.Columns.Add("Email", typeof(String)); data.Columns.Add("备注", typeof(String)); data.Columns.Add("状态", typeof(String)); data.Columns.Add("离职日期", typeof(String)); data.Columns.Add("离职原因", typeof(String)); data.Columns.Add("关联卡片", typeof(String)); data.Columns.Add("授权设备", typeof(String)); for (var i = 0; i < CurRecords.Count; i++) { var dr = data.NewRow(); dr["序号"] = i + 1; dr["工号"] = CurRecords[i].Value1.EmpId; dr["姓名"] = CurRecords[i].Value1.EmpName; dr["类别"] = ComUtility.GetWorkerTypeText(CurRecords[i].Value1.EmpType); dr["英文名"] = CurRecords[i].Value1.EnglishName; dr["性别"] = CurRecords[i].Value1.Sex.Equals("M", StringComparison.CurrentCultureIgnoreCase) ? "男" : "女"; dr["身份证号"] = CurRecords[i].Value1.CardId; dr["籍贯"] = CurRecords[i].Value1.Hometown; dr["出生日期"] = Common.GetDateString(CurRecords[i].Value1.BirthDay); dr["婚姻状况"] = ComUtility.GetMarriageTypeText(CurRecords[i].Value1.Marriage); dr["家庭地址"] = CurRecords[i].Value1.HomeAddress; dr["家庭电话"] = CurRecords[i].Value1.HomePhone; dr["入职日期"] = Common.GetDateString(CurRecords[i].Value1.EntryDay); dr["转正日期"] = Common.GetDateString(CurRecords[i].Value1.PositiveDay); dr["部门名称"] = String.Format("{0} - {1}", CurRecords[i].Value1.DepId, CurRecords[i].Value1.DepName); dr["职务"] = CurRecords[i].Value1.DutyName; dr["办公电话"] = CurRecords[i].Value1.OfficePhone; dr["手机"] = CurRecords[i].Value1.MobilePhone; dr["Email"] = CurRecords[i].Value1.Email; dr["备注"] = CurRecords[i].Value1.Comment; dr["状态"] = CurRecords[i].Value1.Enabled ? "在职" : "离职"; dr["离职日期"] = Common.GetDateString(CurRecords[i].Value1.ResignationDate); dr["离职原因"] = CurRecords[i].Value1.ResignationRemark; dr["关联卡片"] = CurRecords[i].Value2 != null ? CurRecords[i].Value2.CardSn : String.Empty; dr["授权设备"] = CurRecords[i].Value3.ToString(); data.Rows.Add(dr); } Common.ExportDataToExcel(null, "员工信息", "智能门禁管理系统 员工信息报表", String.Format("操作员:{0}{1} 日期:{2}", Common.CurUser.UserName, String.IsNullOrWhiteSpace(Common.CurUser.RemarkName) ? String.Empty : String.Format("({0})", Common.CurUser.RemarkName), Common.GetDateTimeString(DateTime.Now)), data); } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.OrgEmployeeReportForm.RecMenuItem1.Click", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Employees GridView Cell Value Needed Event. /// </summary> private void EmpGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { try { if (e.RowIndex > CurRecords.Count - 1) { return; } switch (EmpGridView.Columns[e.ColumnIndex].Name) { case "IDColumn": e.Value = e.RowIndex + 1; break; case "EIDColumn": e.Value = CurRecords[e.RowIndex].Value1.EmpId; break; case "NameColumn": e.Value = CurRecords[e.RowIndex].Value1.EmpName; break; case "TypeColumn": e.Value = ComUtility.GetWorkerTypeText(CurRecords[e.RowIndex].Value1.EmpType); break; case "EnglishNameColumn": e.Value = CurRecords[e.RowIndex].Value1.EnglishName; break; case "SexColumn": e.Value = CurRecords[e.RowIndex].Value1.Sex.Equals("M", StringComparison.CurrentCultureIgnoreCase) ? "男" : "女"; break; case "CardIDColumn": e.Value = CurRecords[e.RowIndex].Value1.CardId; break; case "HometownColumn": e.Value = CurRecords[e.RowIndex].Value1.Hometown; break; case "BirthDayColumn": e.Value = Common.GetDateString(CurRecords[e.RowIndex].Value1.BirthDay); break; case "MarriageColumn": e.Value = ComUtility.GetMarriageTypeText(CurRecords[e.RowIndex].Value1.Marriage); break; case "HomeAddressColumn": e.Value = CurRecords[e.RowIndex].Value1.HomeAddress; break; case "HomePhoneColumn": e.Value = CurRecords[e.RowIndex].Value1.HomePhone; break; case "EntryDayColumn": e.Value = Common.GetDateString(CurRecords[e.RowIndex].Value1.EntryDay); break; case "PositiveDayColumn": e.Value = Common.GetDateString(CurRecords[e.RowIndex].Value1.PositiveDay); break; case "DepNameColumn": e.Value = String.Format("{0} - {1}", CurRecords[e.RowIndex].Value1.DepId, CurRecords[e.RowIndex].Value1.DepName); break; case "DutyNameColumn": e.Value = CurRecords[e.RowIndex].Value1.DutyName; break; case "OfficePhoneColumn": e.Value = CurRecords[e.RowIndex].Value1.OfficePhone; break; case "MobilePhoneColumn": e.Value = CurRecords[e.RowIndex].Value1.MobilePhone; break; case "EmailColumn": e.Value = CurRecords[e.RowIndex].Value1.Email; break; case "CommentColumn": e.Value = CurRecords[e.RowIndex].Value1.Comment; break; case "EnabledColumn": e.Value = CurRecords[e.RowIndex].Value1.Enabled ? "在职" : "离职"; break; case "ResignationDateColumn": e.Value = Common.GetDateString(CurRecords[e.RowIndex].Value1.ResignationDate); break; case "ResignationRemarkColumn": e.Value = CurRecords[e.RowIndex].Value1.ResignationRemark; break; case "CardSnColumn": e.Value = CurRecords[e.RowIndex].Value2 != null ? CurRecords[e.RowIndex].Value2.CardSn : String.Empty; break; case "CardAuthColumn": e.Value = CurRecords[e.RowIndex].Value3; break; default: break; } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.OrgEmployeeReportForm.EmpGridView.CellValueNeeded", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// User GridView CellValue Needed Event. /// </summary> private void UserGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { try { if (e.RowIndex > GridUsers.Count - 1) { return; } switch (UserGridView.Columns[e.ColumnIndex].Name) { case "IDColumn": e.Value = e.RowIndex + 1; break; case "LockedOutColumn": e.Value = GridUsers[e.RowIndex].IsLockedOut ? "解锁" : String.Empty; break; case "UIDColumn": e.Value = GridUsers[e.RowIndex].UserID; break; case "NameColumn": e.Value = GridUsers[e.RowIndex].UserName; break; case "RoleNameColumn": e.Value = GridUsers[e.RowIndex].Role.RoleName; break; case "RemarkNameColumn": e.Value = GridUsers[e.RowIndex].RemarkName; break; case "CommentColumn": e.Value = GridUsers[e.RowIndex].Comment; break; case "MobilePhoneColumn": e.Value = GridUsers[e.RowIndex].MobilePhone; break; case "EmailColumn": e.Value = GridUsers[e.RowIndex].Email; break; case "CreateDateColumn": e.Value = Common.GetDateTimeString(GridUsers[e.RowIndex].CreateDate); break; case "LimitDateColumn": if (GridUsers[e.RowIndex].LimitDate < DateTime.Today) { e.Value = String.Format("{0}({1})", Common.GetDateString(GridUsers[e.RowIndex].LimitDate), "已过期"); UserGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.ForeColor = Color.Red; } else if (GridUsers[e.RowIndex].LimitDate.Equals(new DateTime(2099, 12, 31))) { e.Value = "永不过期"; } else { e.Value = Common.GetDateString(GridUsers[e.RowIndex].LimitDate); } break; case "LastLoginDateColumn": e.Value = Common.GetDateTimeString(GridUsers[e.RowIndex].LastLoginDate); break; case "LastPasswordChangedDateColumn": e.Value = Common.GetDateTimeString(GridUsers[e.RowIndex].LastPasswordChangedDate); break; case "IsLockedOutColumn": e.Value = GridUsers[e.RowIndex].IsLockedOut ? "锁定" : "正常"; break; case "LastLockoutDateColumn": e.Value = Common.GetDateTimeString(GridUsers[e.RowIndex].LastLockoutDate); break; case "EnableColumn": e.Value = GridUsers[e.RowIndex].Enabled ? "启用" : "禁用"; break; default: break; } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.UserManagerForm.UserGridView.CellValueNeeded", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Export users to excel. /// </summary> private void ExportBtn_Click(object sender, EventArgs e) { try { if (GridUsers.Count > 0) { var data = new DataTable(); data.Columns.Add("序号", typeof(String)); data.Columns.Add("用户标识", typeof(String)); data.Columns.Add("用户名称", typeof(String)); data.Columns.Add("备注名称", typeof(String)); data.Columns.Add("用户描述", typeof(String)); data.Columns.Add("所属角色", typeof(String)); data.Columns.Add("手机", typeof(String)); data.Columns.Add("Email", typeof(String)); data.Columns.Add("创建时间", typeof(String)); data.Columns.Add("有效日期", typeof(String)); data.Columns.Add("最后登录时间", typeof(String)); data.Columns.Add("修改密码时间", typeof(String)); if (Common.IsCheckFailedPasswordAttemptCount) { data.Columns.Add("锁定状态", typeof(String)); data.Columns.Add("锁定时间", typeof(String)); } data.Columns.Add("状态", typeof(String)); for (var i = 0; i < GridUsers.Count; i++) { var dr = data.NewRow(); dr["序号"] = i + 1; dr["用户标识"] = GridUsers[i].UserID.ToString().ToUpper(); dr["用户名称"] = GridUsers[i].UserName; dr["备注名称"] = GridUsers[i].RemarkName; dr["用户描述"] = GridUsers[i].Comment; dr["所属角色"] = GridUsers[i].Role.RoleName; dr["手机"] = GridUsers[i].MobilePhone; dr["Email"] = GridUsers[i].Email; dr["创建时间"] = Common.GetDateTimeString(GridUsers[i].CreateDate); dr["有效日期"] = GridUsers[i].LimitDate.Equals(new DateTime(2099, 12, 31)) ? "永不过期" : Common.GetDateString(GridUsers[i].LimitDate); dr["最后登录时间"] = Common.GetDateTimeString(GridUsers[i].LastLoginDate); dr["修改密码时间"] = Common.GetDateTimeString(GridUsers[i].LastPasswordChangedDate); if (Common.IsCheckFailedPasswordAttemptCount) { dr["锁定状态"] = GridUsers[i].IsLockedOut ? "锁定" : "正常"; dr["锁定时间"] = Common.GetDateTimeString(GridUsers[i].LastLockoutDate); } dr["状态"] = GridUsers[i].Enabled ? "启用" : "禁用"; data.Rows.Add(dr); } Common.ExportDataToExcel(null, "用户信息", "智能门禁管理系统 系统用户报表", String.Format("操作员:{0}{1} 日期:{2}", Common.CurUser.UserName, String.IsNullOrWhiteSpace(Common.CurUser.RemarkName) ? String.Empty : String.Format("({0})", Common.CurUser.RemarkName), Common.GetDateTimeString(DateTime.Now)), data); } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.UserManagerForm", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void registerLbl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { if (!Common.IsCheckLicense) { return; } if (Common.LicenseStatus == EnmLicenseStatus.Licensed) { var sb = new StringBuilder(); sb.AppendLine("软件授权信息"); sb.AppendLine(); sb.AppendFormat("用户: {0}{1}", Common.CurLicense.Name, Environment.NewLine); sb.AppendFormat("公司: {0}{1}", Common.CurLicense.Company, Environment.NewLine); sb.AppendFormat("Email: {0}{1}", Common.CurLicense.Email, Environment.NewLine); sb.AppendFormat("有效期: {0}", new DateTime(2099, 12, 31).Equals(Common.CurLicense.Expiration) ? "永不过期" : Common.GetDateString(Common.CurLicense.Expiration)); MessageBox.Show(sb.ToString(), "授权信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Common.LicenseStatus == EnmLicenseStatus.Expired) { var sb = new StringBuilder(); sb.AppendLine(String.Format("软件已过期,请重新注册。", Common.CurLicense.Expiration)); sb.AppendLine(); sb.AppendFormat("用户: {0}{1}", Common.CurLicense.Name, Environment.NewLine); sb.AppendFormat("公司: {0}{1}", Common.CurLicense.Company, Environment.NewLine); sb.AppendFormat("Email: {0}{1}", Common.CurLicense.Email, Environment.NewLine); sb.AppendFormat("有效期: {0}", new DateTime(2099, 12, 31).Equals(Common.CurLicense.Expiration) ? "永不过期" : Common.GetDateString(Common.CurLicense.Expiration)); MessageBox.Show(sb.ToString(), "授权信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (Common.LicenseStatus == EnmLicenseStatus.Evaluation) { MessageBox.Show(String.Format("软件为试用版,离试用期结束还有{0}天。", Common.CurApplication.AppFirstTime.AddDays(30).Subtract(Common.CurApplication.AppLastTime).Days), "授权信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show(String.Format("软件试用期已到,请注册后使用。", Common.CurApplication.AppFirstTime.AddDays(30).Subtract(Common.CurApplication.AppLastTime).Days), "授权信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.AboutForm", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <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); } }