private void RefreshDataForEditDoc() { //زمانی که کاربر مشخص نشده باشد if (comboBoxUsers.SelectedValue == null) { this.radGridView.DataSource = new List <NjitSoftware.UserLogView>(); return; } if (Njit.Program.Controls.DateControl.CompareDate(dateFromTextBox.Text, dateToTextBox.Text) == Njit.Program.Controls.DateControl.CheckDateResult.Error) { this.radGridView.DataSource = new List <NjitSoftware.UserLogView>(); return; } Model.Common.ArchiveCommonDataClassesDataContext dc = new Model.Common.ArchiveCommonDataClassesDataContext(Setting.Sql.ThisProgram.DatabaseConnection.ConnectionString); IQueryable <Model.Common.UserLog> data; if (((int)comboBoxUsers.SelectedValue == -1)) { data = dc.UserLogs.Select(t => t); } else { var des = Setting.User.ThisProgram.GetUserLogCryptoService((int)comboBoxUsers.SelectedValue); data = dc.UserLogs.Where(t => t.UserCode == (int)comboBoxUsers.SelectedValue && t.OperationPlaceCode == des.EncryptToBase64(((short)Setting.User.UserOparatesPlaceNames.لاگیری_سند_و_پرونده).ToString())).Select(t => t).OrderByDescending(q => q.ID); } List <Report> userLogs = new List <Report>(); List <Report> userLogs2 = new List <Report>(); Dictionary <int, string> dicPersonnel = new Dictionary <int, string>(); int i = 0; foreach (var item in data) { try { NjitSoftware.UserLogView log = Setting.User.ThisProgram.GetUserLogView(item); if (GetOperation(log.Operation).Contains("ویرایش اطلاعات سند")) { i++; Report r = new Report(); r.ID = i; r.Date1 = log.Date; r.Description1 = log.Description; r.FullName = log.UserFullName; r.Operation1 = GetOperation(log.Operation); r.Time1 = log.Time; r.IP = log.IPAddress; //if (log.Unit != null) //{ // userlog.Unit = GetUnit(userlog.Unit); // r.ArchiveName = ListArchive.FirstOrDefault(q => q.Key.ToString() == log.ArchiveID).Value; r.PerssonelNumber = log.OperationCode; dicPersonnel.Add(i, r.PerssonelNumber); userLogs.Add(r); } } catch (System.Security.Cryptography.CryptographicException) { PersianMessageBox.Show(this, "داده نامعتبر پیدا شد"); } } foreach (var item in userLogs) { if (userLogs2.Any()) { if (!userLogs2.Exists(q => q.PerssonelNumber == item.PerssonelNumber)) { Report r = new Report(); r = item; r.Description1 = "به تعداد:" + dicPersonnel.Count(q => q.Value == item.PerssonelNumber); userLogs2.Add(r); } } else { Report r = new Report(); r = item; r.Description1 = "به تعداد:" + dicPersonnel.Count(q => q.Value == item.PerssonelNumber); userLogs2.Add(r); } } switch (Njit.Program.Controls.DateControl.CompareDate(dateFromTextBox.Text, dateToTextBox.Text)) { case Njit.Program.Controls.DateControl.CheckDateResult.Both: this.radGridView.DataSource = userLogs2.Where(t => t.Date1.CompareTo(dateFromTextBox.Text) >= 0 && t.Date1.CompareTo(dateToTextBox.Text) <= 0); break; case Njit.Program.Controls.DateControl.CheckDateResult.Date1: this.radGridView.DataSource = userLogs2.Where(t => t.Date1.CompareTo(dateFromTextBox.Text) >= 0); break; case Njit.Program.Controls.DateControl.CheckDateResult.Date2: this.radGridView.DataSource = userLogs2.Where(t => t.Date1.CompareTo(dateToTextBox.Text) <= 0); break; case Njit.Program.Controls.DateControl.CheckDateResult.Error: return; case Njit.Program.Controls.DateControl.CheckDateResult.Free: this.radGridView.DataSource = userLogs2; break; } //radGridView.BestFitColumnsSmart(); }
public override void RefreshData() { base.RefreshData(); if (comboBoxUsers.SelectedValue == null) { this.userLogBindingSource.DataSource = new List <NjitSoftware.UserLogView>(); return; } if (Njit.Program.Controls.DateControl.CompareDate(dateFromTextBox.Text, dateToTextBox.Text) == Njit.Program.Controls.DateControl.CheckDateResult.Error) { this.userLogBindingSource.DataSource = new List <NjitSoftware.UserLogView>(); return; } Model.Common.ArchiveCommonDataClassesDataContext dc = new Model.Common.ArchiveCommonDataClassesDataContext(Setting.Sql.ThisProgram.DatabaseConnection.ConnectionString); IQueryable <Model.Common.UserLog> data; if (((int)comboBoxUsers.SelectedValue == -1)) { data = dc.UserLogs.Select(t => t); } else { data = dc.UserLogs.Where(t => t.UserCode == (int)comboBoxUsers.SelectedValue).Select(t => t).OrderByDescending(q => q.ID); } List <NjitSoftware.UserLogView> userLogs = new List <NjitSoftware.UserLogView>(); int index = 0; foreach (var item in data) { try { NjitSoftware.UserLogView userlog = Setting.User.ThisProgram.GetUserLogView(item); userlog.Radif = ++index; userlog.Operation = GetOperation(userlog.Operation); if (userlog.Unit != null) { userlog.Unit = GetUnit(userlog.Unit); if (userlog.Unit == GetUnit((Convert.ToInt32(Setting.User.UserOparatesPlaceNames.لاگیری_سند_و_پرونده)).ToString())) { continue; } } userlog.ArchiveID = ListArchive.FirstOrDefault(q => q.Key.ToString() == userlog.ArchiveID).Value; userLogs.Add(userlog); } catch (System.Security.Cryptography.CryptographicException) { PersianMessageBox.Show(this, "داده نامعتبر پیدا شد"); } } switch (Njit.Program.Controls.DateControl.CompareDate(dateFromTextBox.Text, dateToTextBox.Text)) { case Njit.Program.Controls.DateControl.CheckDateResult.Both: this.userLogBindingSource.DataSource = userLogs.Where(t => t.Date.CompareTo(dateFromTextBox.Text) >= 0 && t.Date.CompareTo(dateToTextBox.Text) <= 0); break; case Njit.Program.Controls.DateControl.CheckDateResult.Date1: this.userLogBindingSource.DataSource = userLogs.Where(t => t.Date.CompareTo(dateFromTextBox.Text) >= 0); break; case Njit.Program.Controls.DateControl.CheckDateResult.Date2: this.userLogBindingSource.DataSource = userLogs.Where(t => t.Date.CompareTo(dateToTextBox.Text) <= 0); break; case Njit.Program.Controls.DateControl.CheckDateResult.Error: return; case Njit.Program.Controls.DateControl.CheckDateResult.Free: this.userLogBindingSource.DataSource = userLogs; break; } radGridView.BestFitColumnsSmart(); radGridView.ClipboardCopyMode = Telerik.WinControls.UI.GridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText; }