public Settings(MyGroupList screen1Group, MyGroupList screen2Group, MyScreenParam screen1Param, MyScreenParam screen2Param) { InitializeComponent(); this.screen1Group = screen1Group; this.screen2Group = screen2Group; this.screen1Param = screen1Param; this.screen2Param = screen2Param; InitializeRoleGroupTab(); }
private void AreaMonitor(ScreenParam screenParam, MyGroupList myGroupList) { string sql = ""; DataTable dataTable = null; string time = DateTime.Now.ToString("HH:mm:ss"); string date = DateTime.Now.ToString("yyyy-MM-dd"); bool updateFlag = false; if (screenParam.DutyNoFormat.Equals(ScreenParam.dutyPrefix)) { updateFlag = true; } else { int result = DateTime.Compare(Convert.ToDateTime(time), Convert.ToDateTime(screenParam.UpdateTime)); if (result >= 0 && !date.Equals(screenParam.DutyDate)) { updateFlag = true; } } if (updateFlag) { string year = "'" + DateTime.Now.ToString("yyyy-MM") + "'"; sql = String.Format("select * from IO_LeaderDuty where M_Month={0:G} and M_Date={1:D}", year, Convert.ToInt32(DateTime.Now.ToString("dd"))); string name = ""; SqlParameter[] paras = null; dataTable = SqlHelper.ExecuteDataTable(sql, paras); foreach (DataRow dt in dataTable.Rows) { name = dt["M_Name"].ToString(); } screenParam.DutyNoFormat = ScreenParam.dutyPrefix + name + " " + screenParam.DutyNo; if (name.Length > 0) { screenParam.DutyDate = date; } } SqlParameter[] param = null; //查询当前刷卡 sql = "SELECT top 1 A.*,B.Base_PerID,B.Base_PerNo,B.Base_PerName,C.Base_RoleName FROM AcvB_AccessLog A," + " General_Personnel B,General_Role C,General_Group D " + " where A.Base_PerID=B.Base_PerID and B.Base_RoleID=C.Base_RoleID and B.Base_GroupID=D.Base_GroupID" + " and A.Device_ID in(" + myGroupList.DevicesFormat + ")" + " order by A.Access_DateTime desc"; //System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); //stopwatch.Start(); // 开始监视代码 dataTable = SqlHelper.ExecuteDataTable(sql, param); string inOutRecord = ""; foreach (DataRow dt in dataTable.Rows) { if (dt["InOutFlag"].ToString().Equals("0")) { inOutRecord = "进闸"; } else { inOutRecord = "出闸"; } inOutRecord = "当前刷卡: " + dt["Base_PerName"].ToString() + " 工号" + dt["Base_PerNo"].ToString(); } //screenParam.PersonRecord = inOutRecord; //stopwatch.Stop(); // 停止监视 //TimeSpan timeSpan = stopwatch.Elapsed; // 获取总时间 //Console.WriteLine("seconds:" + timeSpan.TotalSeconds); param = new SqlParameter[3];//参数化有问题,暂时用字符串连接代替 param[0] = new SqlParameter("@deviceList", myGroupList.DevicesFormat); param[1] = new SqlParameter("@groupIdLen", SqlDbType.Int, 4) { Value = 5 }; param[2] = new SqlParameter("@groupId", screenParam.GroupId); sql = "select F.Base_RoleID,Max(G.Base_RoleName) as Base_RoleName,count(E.Base_PerID) as PerCount from" + " (select top 500000 a.* from AcvB_AccessLog a where ISNULL(Base_PerID,'''')<>'''' and Device_ID in(" + myGroupList.DevicesFormat + ")" + " and a.Access_DateTime=(select MAX(Access_DateTime) from AcvB_AccessLog" + " where Base_PerID=a.Base_PerID and isnull(Reserved,'''')='''' )" + " order by Base_PerID) E, General_Personnel F,General_Role G,General_Group H" + " where E.Base_PerID=F.Base_PerID and F.Base_RoleID=G.Base_RoleID and F.Base_GroupID=H.Base_GroupID" //+ " and SUBSTRING(H.Base_AuthID,1,@groupIdLen) = @groupId" + " and E.InOutFlag='0' and E.Card_Status='1'" + " group by F.Base_RoleID"; dataTable = SqlHelper.ExecuteDataTable(sql, param); screenParam.ResetRoleDefaultTotal(); foreach (DataRow dt in dataTable.Rows) { string role_id = dt["Base_RoleID"].ToString(); int count = dt.Field <int>("PerCount"); screenParam.SetRoleTotal(role_id, count); } screenParam.ShowRoleStatistics(); screenParam.GenerateFile(); }
private void screen2Radio_Checked(object sender, RoutedEventArgs e) { this.mainGrid.DataContext = myScreen2Param.ScreenParam; screenParamUse = myScreen2Param.ScreenParam; screenGroupUse = screen2Group; }
private void InitializeScreenGroup() { screen1Group = new MyGroupList("Devs"); screen2Group = new MyGroupList("Devs2"); }