/// <summary> /// Export Data To Excel. /// </summary> private void ExportExcelBtn_Click(object sender, EventArgs e) { try { if (GridLogs.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)); for (var i = 0; i < GridLogs.Count; i++) { var dr = data.NewRow(); dr["序号"] = i + 1; dr["日志时间"] = Common.GetDateTimeString(GridLogs[i].EventTime); dr["日志类型"] = ComUtility.GetLogTypeText(GridLogs[i].EventType); dr["触发对象"] = GridLogs[i].Operator; dr["触发来源"] = GridLogs[i].Source; dr["日志描述"] = GridLogs[i].Message; 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.LogManagerForm.ExportBtn.Click", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Export Data To Text. /// </summary> private void ExportBtn_Click(object sender, EventArgs e) { try { if (GridLogs.Count > 0) { var logText = new StringBuilder(); foreach (var log in GridLogs) { logText.AppendLine("======================================================================================="); logText.AppendLine(String.Format("日志编号: {0}", log.EventId)); logText.AppendLine(String.Format("日志时间: {0}", Common.GetDateTimeString(log.EventTime))); logText.AppendLine(String.Format("日志类型: {0}", ComUtility.GetLogTypeText(log.EventType))); logText.AppendLine(String.Format("触发对象: {0}", log.Operator)); logText.AppendLine(String.Format("触发来源: {0}", log.Source)); logText.AppendLine(String.Format("日志描述: {0}", log.Message)); logText.AppendLine(String.Format("详细信息: {0}", log.StackTrace)); logText.AppendLine(); } Common.ExportDataToText(null, "智能门禁管理系统 系统日志", logText.ToString()); } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.LogManagerForm.ExportBtn.Click", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Cards GridView CellValue Needed Event. /// </summary> private void CardsGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { try { if (e.RowIndex > GridCards.Count - 1) { return; } switch (CardsGridView.Columns[e.ColumnIndex].Name) { case "IDColumn": e.Value = e.RowIndex + 1; break; case "EIDColumn": e.Value = String.Format("{0} - {1}", GridCards[e.RowIndex].WorkerId, GridCards[e.RowIndex].WorkerName); break; case "CardSnColumn": e.Value = GridCards[e.RowIndex].CardSn; if (!String.IsNullOrWhiteSpace(SelectedCardSn) && SelectedCardSn.Equals(e.Value)) { CardsGridView.ClearSelection(); CardsGridView.Rows[e.RowIndex].Selected = true; SelectedCardSn = null; } break; case "DepNameColumn": e.Value = String.Format("{0} - {1}", GridCards[e.RowIndex].DepId, GridCards[e.RowIndex].DepName); break; case "CardTypeColumn": e.Value = ComUtility.GetCardTypeText(GridCards[e.RowIndex].CardType); break; case "BeginTimeColumn": e.Value = Common.GetDateTimeString(GridCards[e.RowIndex].BeginTime); break; case "BeginReasonColumn": e.Value = GridCards[e.RowIndex].BeginReason; break; case "CommentColumn": e.Value = GridCards[e.RowIndex].Comment; break; case "EnabledColumn": e.Value = GridCards[e.RowIndex].Enabled ? "启用" : "禁用"; break; default: break; } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.OrgCardManagerForm.CardsGridView.CellValueNeeded", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Card Auth GridView CellValue Needed Event. /// </summary> private void AuthGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { try { if (e.RowIndex > CurRecords.Count - 1) { return; } switch (AuthGridView.Columns[e.ColumnIndex].Name) { case "IDColumn": e.Value = e.RowIndex + 1; break; case "EIDColumn": e.Value = CurRecords[e.RowIndex].ID != null ? CurRecords[e.RowIndex].ID.WorkerId : String.Empty; break; case "NameColumn": e.Value = CurRecords[e.RowIndex].ID != null ? CurRecords[e.RowIndex].ID.WorkerName : String.Empty; break; case "DepNameColumn": e.Value = CurRecords[e.RowIndex].ID != null?String.Format("{0} - {1}", CurRecords[e.RowIndex].ID.DepId, CurRecords[e.RowIndex].ID.DepName) : String.Empty; break; case "CardSnColumn": e.Value = CurRecords[e.RowIndex].Value.CardSn; break; case "BeginTimeColumn": e.Value = Common.GetDateTimeString(CurRecords[e.RowIndex].Value.BeginTime); break; case "EndTimeColumn": e.Value = Common.GetDateTimeString(CurRecords[e.RowIndex].Value.EndTime); break; case "LimitColumn": e.Value = ComUtility.GetLimitIDText(CurRecords[e.RowIndex].Value.LimitId); break; case "LimitIndexColumn": e.Value = CurRecords[e.RowIndex].Value.LimitIndex == ComUtility.DefaultInt32 ? String.Empty : CurRecords[e.RowIndex].Value.LimitIndex.ToString(); break; case "EnabledColumn": e.Value = CurRecords[e.RowIndex].Value.Enabled ? "启用" : "禁用"; break; default: break; } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.CardAuthDetailDialog.AuthGridView.CellValueNeeded", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Alarm Menu Item Click Event. /// </summary> private void AlarmMenuItem2_Click(object sender, EventArgs e) { try { var data = new DataTable(); var colors = new Dictionary <Int32, Excel.Color>(); 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)); for (var i = 0; i < CurAlarms.Count; i++) { var dr = data.NewRow(); dr["序号"] = i + 1; dr["告警标识"] = CurAlarms[i].SerialNO.ToString(); dr["所属地区"] = CurAlarms[i].Area2Name; dr["所属县市"] = CurAlarms[i].Area3Name; dr["所属局站"] = CurAlarms[i].StaName; dr["所属设备"] = CurAlarms[i].DevName; dr["测点编号"] = CurAlarms[i].NodeID.ToString(); dr["测点名称"] = CurAlarms[i].NodeName; dr["告警描述"] = CurAlarms[i].AlarmDesc; dr["告警级别"] = ((Int32)CurAlarms[i].AlarmLevel).ToString(); dr["告警时间"] = Common.GetDateTimeString(CurAlarms[i].StartTime); dr["结束时间"] = Common.GetDateTimeString(CurAlarms[i].EndTime); dr["告警历时"] = Common.GetTimeInterval(CurAlarms[i].StartTime, CurAlarms[i].EndTime); dr["处理标识"] = Common.GetConfirmMarkingName(CurAlarms[i].ConfirmMarking); dr["处理时间"] = Common.GetDateTimeString(CurAlarms[i].ConfirmTime); dr["处理人员"] = CurAlarms[i].ConfirmName; data.Rows.Add(dr); if (AlarmMenuItem1.Checked) { colors[i] = Common.GetExcelAlarmColor(CurAlarms[i].AlarmLevel); } } 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, colors); } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.HisAlarmForm.AlarmMenuItem2.Click", 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); } }
/// <summary> /// Event GridView Cell Value Needed Event. /// </summary> private void EventGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { try { if (e.RowIndex > GridLogs.Count - 1) { return; } switch (EventGridView.Columns[e.ColumnIndex].Name) { case "IDColumn": e.Value = e.RowIndex + 1; break; case "EventIdColumn": e.Value = GridLogs[e.RowIndex].EventId; break; case "EventTimeColumn": e.Value = Common.GetDateTimeString(GridLogs[e.RowIndex].EventTime); break; case "EventTypeColumn": e.Value = ComUtility.GetLogTypeText(GridLogs[e.RowIndex].EventType); break; case "OperatorColumn": e.Value = GridLogs[e.RowIndex].Operator; break; case "SourceColumn": e.Value = GridLogs[e.RowIndex].Source; break; case "MessageColumn": e.Value = GridLogs[e.RowIndex].Message; break; case "StackTraceColumn": e.Value = GridLogs[e.RowIndex].StackTrace; break; default: break; } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.LogManagerForm.EventGridView.CellValueNeeded", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Cards GridView CellValue Needed Event. /// </summary> private void CardsGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { try { if (e.RowIndex > Cards.Count - 1) { return; } switch (CardsGridView.Columns[e.ColumnIndex].Name) { case "SIDColumn": e.Value = e.RowIndex + 1; break; case "SENameColumn": e.Value = String.Format("{0} - {1}", Cards[e.RowIndex].Value.EmpId, Cards[e.RowIndex].Value.EmpName); break; case "CardSnColumn": e.Value = Cards[e.RowIndex].ID.CardSn; if (ExistCards.ContainsKey(e.Value.ToString())) { CardsGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Salmon; } break; case "SDeptColumn": e.Value = String.Format("{0} - {1}", Cards[e.RowIndex].Value.DepId, Cards[e.RowIndex].Value.DepName); break; case "CardTypeColumn": e.Value = ComUtility.GetCardTypeText(Cards[e.RowIndex].ID.CardType); break; case "BeginTimeColumn": e.Value = Common.GetDateTimeString(Cards[e.RowIndex].ID.BeginTime); break; case "BeginReasonColumn": e.Value = Cards[e.RowIndex].ID.BeginReason; break; default: break; } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.BatchOrgCardsForm.CardsGridView.CellValueNeeded", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Record Menu Item Click Event. /// </summary> private void RecMenuItem1_Click(object sender, EventArgs e) { try { 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)); for (var i = 0; i < CurRecords.Count; i++) { var dr = data.NewRow(); dr["序号"] = i + 1; dr["所属地区"] = CurRecords[i].Device.Area2Name; dr["所属县市"] = CurRecords[i].Device.Area3Name; dr["所属局站"] = CurRecords[i].Device.StaName; dr["设备编号"] = CurRecords[i].Device.DevID.ToString(); dr["设备名称"] = CurRecords[i].Device.DevName; dr["刷卡描述"] = CurRecords[i].Remark; dr["刷卡卡号"] = CurRecords[i].CardSn; dr["刷卡时间"] = Common.GetDateTimeString(CurRecords[i].CardTime); dr["刷卡人员"] = CurRecords[i].Card != null?String.Format("{0} - {1}", CurRecords[i].Card.WorkerId, CurRecords[i].Card.WorkerName) : String.Empty; dr["人员类型"] = CurRecords[i].Card != null?ComUtility.GetWorkerTypeText(CurRecords[i].Card.WorkerType) : String.Empty; dr["所属部门"] = CurRecords[i].Card != null?String.Format("{0} - {1}", CurRecords[i].Card.DepId, CurRecords[i].Card.DepName) : String.Empty; 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.HisCardRecordsForm.RecMenuItem1.Click", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Export All Cards To Excel. /// </summary> private void ExportBtn_Click(object sender, EventArgs e) { try { if (GridCards.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)); for (var i = 0; i < GridCards.Count; i++) { var dr = data.NewRow(); dr["序号"] = i + 1; dr["持卡人"] = String.Format("{0} - {1}", GridCards[i].WorkerId, GridCards[i].WorkerName); dr["卡号"] = GridCards[i].CardSn; dr["所属部门"] = String.Format("{0} - {1}", GridCards[i].DepId, GridCards[i].DepName); dr["卡片类型"] = ComUtility.GetCardTypeText(GridCards[i].CardType); dr["发卡时间"] = Common.GetDateTimeString(GridCards[i].BeginTime); dr["发卡原因"] = GridCards[i].BeginReason; dr["备注"] = GridCards[i].Comment; dr["状态"] = GridCards[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.OrgCardManagerForm.ExportBtn.Click", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Record Menu Item Click Event. /// </summary> private void RecMenuItem1_Click(object sender, EventArgs e) { try { var data = new DataTable(); var colors = new Dictionary <Int32, Excel.Color>(); 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 < CurDevices.Count; i++) { var dr = data.NewRow(); dr["序号"] = i + 1; dr["地区"] = CurDevices[i].Area2Name; dr["县市"] = CurDevices[i].Area3Name; dr["局站"] = CurDevices[i].StaName; dr["设备编号"] = CurDevices[i].DevID.ToString(); dr["设备名称"] = CurDevices[i].DevName; data.Rows.Add(dr); } if (CurOrgEmp != null) { 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), CurOrgEmp.EmpId, CurOrgEmp.EmpName), data, colors); } else if (CurOutEmp != null) { 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), CurOutEmp.EmpId, CurOutEmp.EmpName), data, colors); } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.DevAuthDetailDialog.RecMenuItem1.Click", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Export Data To Excel. /// </summary> private void ExportBtn_Click(object sender, EventArgs e) { try { if (CurStations.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)); for (var i = 0; i < CurStations.Count; i++) { var dr = data.NewRow(); dr["序号"] = i + 1; dr["所属地区"] = CurStations[i].Area2Name; dr["所属县市"] = CurStations[i].Area3Name; dr["局站编号"] = CurStations[i].StaID; dr["局站名称"] = CurStations[i].StaName; dr["网格编号"] = CurStations[i].NetGridID; dr["网格名称"] = CurStations[i].NetGridName; data.Rows.Add(dr); } Common.ExportDataToExcel(null, "局站网格信息", String.Format("智能门禁管理系统 局站网格信息报表"), 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.GridGroupForm.ExportBtn.Click", 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> /// Records GridView CellValue Needed Event. /// </summary> private void HisCardGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { try { if (e.RowIndex > CurRecords.Count - 1) { return; } switch (HisCardGridView.Columns[e.ColumnIndex].Name) { case "HCIDColumn": e.Value = e.RowIndex + 1; break; case "HCRecIDColumn": e.Value = CurRecords[e.RowIndex].ID; break; case "HCArea2Column": e.Value = CurRecords[e.RowIndex].Device.Area2Name; break; case "HCArea3Column": e.Value = CurRecords[e.RowIndex].Device.Area3Name; break; case "HCStaNameColumn": e.Value = CurRecords[e.RowIndex].Device.StaName; break; case "HCDevIDColumn": e.Value = CurRecords[e.RowIndex].Device.DevID; break; case "HCDevNameColumn": e.Value = CurRecords[e.RowIndex].Device.DevName; break; case "HCDescColumn": e.Value = CurRecords[e.RowIndex].Remark; break; case "HCCardSnColumn": e.Value = CurRecords[e.RowIndex].CardSn; break; case "HCTimeColumn": e.Value = Common.GetDateTimeString(CurRecords[e.RowIndex].CardTime); break; case "HCWorkerColumn": e.Value = CurRecords[e.RowIndex].Card != null?String.Format("{0} - {1}", CurRecords[e.RowIndex].Card.WorkerId, CurRecords[e.RowIndex].Card.WorkerName) : String.Empty; break; case "HCWorkerTypeColumn": e.Value = CurRecords[e.RowIndex].Card != null?ComUtility.GetWorkerTypeText(CurRecords[e.RowIndex].Card.WorkerType) : String.Empty; break; case "HCDeptColumn": e.Value = CurRecords[e.RowIndex].Card != null?String.Format("{0} - {1}", CurRecords[e.RowIndex].Card.DepId, CurRecords[e.RowIndex].Card.DepName) : String.Empty; break; default: break; } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.HisCardRecordsForm.HisCardGridView.CellValueNeeded", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Export Data Button Click Event. /// </summary> private void BExportBtn_Click(object sender, EventArgs e) { try { var data = new Employee().ExportOutEmployees(Common.CurUser.Role.RoleID); 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.OrgEmployeeManagerForm.BExportBtn.Click", 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> /// Alarm GridView CellValue Needed Event. /// </summary> private void AlarmGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { try { if (e.RowIndex > CurAlarms.Count - 1) { return; } switch (AlarmGridView.Columns[e.ColumnIndex].Name) { case "AIDColumn": e.Value = e.RowIndex + 1; AlarmGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = AlarmMenuItem1.Checked ? Common.GetLevelColor(CurAlarms[e.RowIndex].AlarmLevel) : Color.White; break; case "SerialNOColumn": e.Value = CurAlarms[e.RowIndex].SerialNO; break; case "Area2Column": e.Value = CurAlarms[e.RowIndex].Area2Name; break; case "Area3Column": e.Value = CurAlarms[e.RowIndex].Area3Name; break; case "StaNameColumn": e.Value = CurAlarms[e.RowIndex].StaName; break; case "DevNameColumn": e.Value = CurAlarms[e.RowIndex].DevName; break; case "NodeIDColumn": e.Value = CurAlarms[e.RowIndex].NodeID; break; case "NodeNameColumn": e.Value = CurAlarms[e.RowIndex].NodeName; break; case "AlarmDescColumn": e.Value = CurAlarms[e.RowIndex].AlarmDesc; break; case "AlarmLevelColumn": e.Value = (Int32)CurAlarms[e.RowIndex].AlarmLevel; break; case "AlarmTimeColumn": e.Value = Common.GetDateTimeString(CurAlarms[e.RowIndex].StartTime); break; case "EndTimeColumn": e.Value = Common.GetDateTimeString(CurAlarms[e.RowIndex].EndTime); break; case "AlarmIntervalColumn": e.Value = Common.GetTimeInterval(CurAlarms[e.RowIndex].StartTime, CurAlarms[e.RowIndex].EndTime); break; case "ConfirmMarkingColumn": e.Value = Common.GetConfirmMarkingName(CurAlarms[e.RowIndex].ConfirmMarking); break; case "ConfirmTimeColumn": e.Value = Common.GetDateTimeString(CurAlarms[e.RowIndex].ConfirmTime); break; case "ConfirmNameColumn": e.Value = CurAlarms[e.RowIndex].ConfirmName; break; default: break; } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.HisAlarmForm.AlarmGridView.CellValueNeeded", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Export sub employees to excel. /// </summary> private void ExportBtn_Click(object sender, EventArgs e) { try { if (GridEmployees.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("Email", 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 < GridEmployees.Count; i++) { var dr = data.NewRow(); dr["序号"] = i + 1; dr["工号"] = GridEmployees[i].EmpId; dr["姓名"] = GridEmployees[i].EmpName; dr["性别"] = GridEmployees[i].Sex.Equals("M", StringComparison.CurrentCultureIgnoreCase) ? "男" : "女"; dr["身份证号"] = GridEmployees[i].CardId; dr["身份证住址"] = GridEmployees[i].CardAddress; dr["身份证签发机关"] = GridEmployees[i].CardIssue; dr["籍贯"] = GridEmployees[i].Hometown; dr["所属公司"] = GridEmployees[i].CompanyName; dr["所属项目"] = GridEmployees[i].ProjectName; dr["办公电话"] = GridEmployees[i].OfficePhone; dr["手机"] = GridEmployees[i].MobilePhone; dr["Email"] = GridEmployees[i].Email; dr["责任人"] = String.Format("{0} - {1}", GridEmployees[i].ParentEmpId, GridEmployees[i].ParentEmpName); dr["所属部门"] = String.Format("{0} - {1}", GridEmployees[i].DepId, GridEmployees[i].DepName); dr["备注"] = GridEmployees[i].Comment; dr["状态"] = GridEmployees[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.OutEmployeeManagerForm.ExportBtn.Click", 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)); 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> /// Export roles to excel. /// </summary> private void ExportBtn_Click(object sender, EventArgs e) { try { if (GridDepartments.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)); for (var i = 0; i < GridDepartments.Count; i++) { var dr = data.NewRow(); dr["序号"] = i + 1; dr["部门编号"] = GridDepartments[i].DepId; dr["部门名称"] = GridDepartments[i].DepName; dr["备注"] = GridDepartments[i].Comment; dr["状态"] = GridDepartments[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.DepartmentManagerForm.ExportBtn.Click", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Auth GridView CellValue Needed Event. /// </summary> private void AuthGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { try { if (e.RowIndex > TotalRecords.Count - 1) { return; } switch (AuthGridView.Columns[e.ColumnIndex].Name) { case "IDColumn": e.Value = e.RowIndex + 1; break; case "EIDColumn": e.Value = TotalRecords[e.RowIndex].Value3.WorkerId; break; case "NameColumn": e.Value = TotalRecords[e.RowIndex].Value3.WorkerName; break; case "DeptNameColumn": e.Value = String.Format("{0} - {1}", TotalRecords[e.RowIndex].Value3.DepId, TotalRecords[e.RowIndex].Value3.DepName); break; case "CardSnColumn": e.Value = TotalRecords[e.RowIndex].Value3.CardSn; break; case "DevIDColumn": e.Value = TotalRecords[e.RowIndex].Value1.DevID; break; case "DevNameColumn": e.Value = GetDeviceRemark(TotalRecords[e.RowIndex].Value1); break; case "BeginTimeColumn": e.Value = Common.GetDateTimeString(TotalRecords[e.RowIndex].Value2.BeginTime); break; case "EndTimeColumn": e.Value = Common.GetDateTimeString(TotalRecords[e.RowIndex].Value2.EndTime); break; case "LimitColumn": e.Value = ComUtility.GetLimitIDText(TotalRecords[e.RowIndex].Value2.LimitId); break; case "LimitIndexColumn": e.Value = TotalRecords[e.RowIndex].Value2.LimitIndex == ComUtility.DefaultInt32 ? String.Empty : TotalRecords[e.RowIndex].Value2.LimitIndex.ToString(); break; case "EnabledColumn": e.Value = TotalRecords[e.RowIndex].Value2.Enabled ? "启用" : "禁用"; break; default: break; } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.BitchUpdateEndTimeForm.AuthGridView.CellValueNeeded", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }