public ManageExpensesListViewModel() { this.DateBegin = new DateTime(DateTime.Now.Year, 1, 1, 0, 0, 0, 0); this.DateEnd = new DateTime(DateTime.Now.Year, 12, 31, 23, 59, 59, 999); this.Dat1 = DateBegin.ToString("MM/dd/yyyy"); this.Dat2 = DateEnd.ToString("MM/dd/yyyy"); }
/// <summary> /// Serves as the hash function. /// </summary> /// <returns>Event object hash.</returns> public override int GetHashCode() { unchecked { var hashCode = Id; hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ DateBegin.GetHashCode(); hashCode = (hashCode * 397) ^ DateEnd.GetHashCode(); return(hashCode); } }
private void ButtonDateSelect_Click(object sender, RoutedEventArgs e) { string param = (sender as Button).Tag.ToString(); if (param.Equals("EquateEndDateToBeginDate")) { DateEnd = DateBegin; } else if (param.Equals("SetDatesToCurrentDay")) { DateBegin = DateTime.Now; DateEnd = DateBegin; } else if (param.Equals("SetDatesToCurrentWeek")) { DateEnd = DateTime.Now; int dayOfWeek = (int)DateEnd.DayOfWeek; if (dayOfWeek == 0) { dayOfWeek = 7; } DateBegin = DateEnd.AddDays(-1 * (dayOfWeek - 1)); } else if (param.Equals("SetDatesToCurrentMonth")) { DateBegin = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); DateEnd = DateBegin.AddDays(DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month) - 1); } else if (param.Equals("SetDatesToCurrentYear")) { DateBegin = new DateTime(DateTime.Now.Year, 1, 1); DateEnd = new DateTime(DateTime.Now.Year, 12, DateTime.DaysInMonth(DateTime.Now.Year, 12)); } else if (param.Equals("GoToPreviousMonth")) { DateEnd = new DateTime(DateBegin.Year, DateBegin.Month, 1).AddDays(-1); DateBegin = DateEnd.AddDays(-1 * (DateTime.DaysInMonth(DateEnd.Year, DateEnd.Month) - 1)); } else if (param.Equals("GoToPreviousDay")) { DateBegin = DateBegin.AddDays(-1); DateEnd = DateBegin; } else if (param.Equals("GoToNextDay")) { DateBegin = DateBegin.AddDays(1); DateEnd = DateBegin; } else if (param.Equals("GoToNextMonth")) { DateBegin = new DateTime(DateBegin.Year, DateBegin.Month, DateTime.DaysInMonth(DateBegin.Year, DateBegin.Month)).AddDays(1); DateEnd = DateBegin.AddDays((DateTime.DaysInMonth(DateBegin.Year, DateBegin.Month) - 1)); } }
public ManageExpensesListViewModel(User user, string dat1, string dat2) : base() { First_Name = user.First_Name; Last_Name = user.Last_Name; Email = user.Email; this.DateBegin = Convert.ToDateTime(dat1); this.DateEnd = Convert.ToDateTime(dat2); this.Dat1 = DateBegin.ToString("MM/dd/yyyy"); this.Dat2 = DateEnd.ToString("MM/dd/yyyy"); UserId = user.UserId; }
/// <summary> /// Determines whether the specified event is equal to the current event. /// </summary> /// <param name="other">Event to equal.</param> /// <returns>True if the specified event is equal to the current event; otherwise, false.</returns> public bool Equals(Event other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Id == other.Id && string.Equals(Name, other.Name) && DateBegin.Equals(other.DateBegin) && DateEnd.Equals(other.DateEnd)); }
protected override void OnInitialize() { base.OnInitialize(); DbReloadToken .Merge(DateBegin.Changed()) .Merge(DateEnd.Changed()) .Merge(SupplierCostBegin.Changed()) .Merge(SupplierCostEnd.Changed()) .Merge(RetailCostBegin.Changed()) .Merge(RetailCostEnd.Changed()) .SelectMany(_ => RxQuery(LoadItems)) .Subscribe(Items); }
/// <summary> /// Returns true if SessionRequest instances are equal /// </summary> /// <param name="other">Instance of SessionRequest to be compared</param> /// <returns>Boolean</returns> public bool Equals(SessionRequest other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( CreatorEmail == other.CreatorEmail || CreatorEmail != null && CreatorEmail.Equals(other.CreatorEmail) ) && ( Title == other.Title || Title != null && Title.Equals(other.Title) ) && ( Description == other.Description || Description != null && Description.Equals(other.Description) ) && ( DateBegin == other.DateBegin || DateBegin != null && DateBegin.Equals(other.DateBegin) ) && ( DateEnd == other.DateEnd || DateEnd != null && DateEnd.Equals(other.DateEnd) ) && ( TimeZone == other.TimeZone || TimeZone != null && TimeZone.Equals(other.TimeZone) ) && ( SessionId == other.SessionId || SessionId != null && SessionId.Equals(other.SessionId) )); }
public MainWindow() { InitializeComponent(); InsuranceCompanies.AddRange(insuranceCompaniesJID.Keys); DateBegin = DateTime.Now.Date.AddDays(DateTime.Now.Day * -1); DateEnd = DateBegin; DateBegin = DateBegin.AddDays((DateBegin.Day - 1) * -1); IsCheckedLoadTypeTreatmentsDetails = true; DataContext = this; //Loaded += (s, e) => { // if (Debugger.IsAttached) { // SelectedFile = @"C:\Users\nn-admin\Desktop\PL шаблон.xlsx"; // IsCheckedLoadTypeProfitAndLoss = true; // ReadSheetNames(); // } //}; Closing += (s, e) => { if ((bwReadFile != null && bwReadFile.IsBusy) || (bwLoadToDb != null && bwLoadToDb.IsBusy)) { if (MessageBox.Show( this, "Текущие операции еще не завершены" + Environment.NewLine + "Данные могут быть потеряны" + Environment.NewLine + "Вы уверены, что хотите завершить работу?", string.Empty, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { e.Cancel = true; } } }; timerWorkIndicator = new DispatcherTimer(); timerWorkIndicator.Interval = TimeSpan.FromMilliseconds(300); timerWorkIndicator.Tick += (s, e) => { UpdateProgress(string.Empty, true); }; }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (CreatorEmail != null) { hashCode = hashCode * 59 + CreatorEmail.GetHashCode(); } if (Title != null) { hashCode = hashCode * 59 + Title.GetHashCode(); } if (Description != null) { hashCode = hashCode * 59 + Description.GetHashCode(); } if (DateBegin != null) { hashCode = hashCode * 59 + DateBegin.GetHashCode(); } if (DateEnd != null) { hashCode = hashCode * 59 + DateEnd.GetHashCode(); } if (TimeZone != null) { hashCode = hashCode * 59 + TimeZone.GetHashCode(); } if (SessionId != null) { hashCode = hashCode * 59 + SessionId.GetHashCode(); } return(hashCode); } }
public EmployeeReportViewModel GetData() { var result = new EmployeeReportViewModel(); var span = DateEnd - DateBegin; int countDays = span.Days; result.MyColumns = new List <string>(); for (int i = 0; i < countDays; i++) { result.MyColumns.Add(DateBegin.AddDays(i).ToShortDateString()); } var timesheetsInterval = _tabelContext.Timesheets.Include("Employee") .Include("Project") .Where(ts => ts.Date >= DateBegin && ts.Date < DateEnd); var neededData = timesheetsInterval.Select(ts => new { EmployeeName = ts.Employee.Name, ProjectName = ts.Project.Name, ProjectCode = ts.Project.Code, Rate = ts.Employee.Rate, ts.Project.WorkObject, ts.Hours, ts.Date }); List <DateTime> reportDays = new List <DateTime>(); for (int i = 0; i < countDays; i++) { reportDays.Add(DateBegin.AddDays(i)); } var allEmployees = neededData.Select(data => data.EmployeeName).Distinct(); var employeeProjectDict = new Dictionary <string, List <string> >(); foreach (var employee in allEmployees) { employeeProjectDict[employee] = neededData.Where(data => data.EmployeeName == employee).Select(data => data.ProjectName).Distinct().ToList(); } //Заполняем тут данные о сотрудниках и проектах List <ErReportEmployee> reportEmployee = new List <ErReportEmployee>(); foreach (var employeeProject in employeeProjectDict) { var newReportEmploy = new ErReportEmployee { EmployeeName = employeeProject.Key, ReportProject = new List <ErReportProject>() }; foreach (var project in employeeProject.Value) { newReportEmploy.ReportProject.Add(new ErReportProject() { ProjectName = project, ProjectCode = neededData.Where(data => data.ProjectName == project).Select(data => data.ProjectCode).FirstOrDefault() }); } newReportEmploy.SetBeginAndEndDate(DateBegin, DateEnd); reportEmployee.Add(newReportEmploy); } //Записываем данные о часах foreach (var employee in reportEmployee) { foreach (var project in employee.ReportProject) { var workingHours = neededData.Where( data => data.EmployeeName == employee.EmployeeName && data.ProjectName == project.ProjectName) .Select(data => new { WorkDate = data.Date, WorkHour = data.Hours, data.WorkObject, }).ToList(); project.WorkObject = workingHours.First().WorkObject; foreach (var workingHour in workingHours) { var roundedDate = new DateTime(workingHour.WorkDate.Year, workingHour.WorkDate.Month, workingHour.WorkDate.Day); project.Hours[roundedDate] = workingHour.WorkHour; } } } //Записываем данные о зарплате foreach (var employee in reportEmployee) { //var employees = reportEmployee.Where(data => data.EmployeeName == employee.EmployeeName); employee.Rate = neededData.Where(data => data.EmployeeName == employee.EmployeeName) .Select(data => data.Rate) .FirstOrDefault(); } //Переделываем в формат грида result.Rows = new List <ErEmployeeViewModel>(); var totalHoursDict = new Dictionary <DateTime, int>(); var totalMoney = 0.0; for (int i = 0; i < countDays; i++) { totalHoursDict[DateBegin.AddDays(i)] = 0; } foreach (var reportEmploy in reportEmployee) { var hoursDict = new Dictionary <DateTime, int>(); for (int i = 0; i < countDays; i++) { hoursDict[DateBegin.AddDays(i)] = 0; } foreach (var reportProject in reportEmploy.ReportProject) { var newEmployee = new ErEmployeeViewModel { Name = reportEmploy.EmployeeName, Rate = reportEmploy.Rate, Project = reportProject.ProjectName, ProjectCode = reportProject.ProjectCode, WorkObject = reportProject.WorkObject, Hours = reportProject.Hours.Values.ToList() }; result.Rows.Add(newEmployee); totalMoney += newEmployee.Money; foreach (var hour in reportProject.Hours) { if (!hoursDict.ContainsKey(hour.Key)) { hoursDict[hour.Key] = 0; } hoursDict[hour.Key] += hour.Value; if (!totalHoursDict.ContainsKey(hour.Key)) { totalHoursDict[hour.Key] = 0; } totalHoursDict[hour.Key] += hour.Value; } } result.Rows.Add(new ErEmployeeViewModel { Hours = hoursDict.Values.ToList(), Name = reportEmploy.EmployeeName + " Итого", //Project = "По всем проектам", //WorkObject = "По всем объектам", Rate = reportEmploy.Rate }); } result.Rows = result.Rows.OrderBy(row => row.Name).ThenBy(then => then.ProjectCode).ToList(); result.Employees = allEmployees.ToList(); result.Employees.Insert(0, "Все"); //result.Rows.Add(new ErEmployeeViewModel(totalMoney) //{ // Hours = totalHoursDict.Values.ToList(), // Name = "Итого", // // Project = "По всем проектам" //}); if (!string.IsNullOrEmpty(EmployeeFilter) && EmployeeFilter != "Все") { result.Rows.RemoveAll(item => item.Name != EmployeeFilter); } return(result); }
public void LoadDisabilitySheetList(BackgroundWorker bworker, bool updateOpened = false) { this.bworker = bworker; if (updateOpened) { bworker.ReportProgress((int)progressCurrent, "Получение информации по больничным листам со статусом 'ЭЛН открыт'"); } else { bworker.ReportProgress((int)progressCurrent, "Получения информации о больничных листах за период: " + DateBegin.ToShortDateString() + " - " + DateEnd.ToShortDateString()); } double iteration = (DateEnd - DateBegin).TotalDays + 1; double progressStep = 30.0d / iteration; bworker.ReportProgress((int)progressCurrent, "Создание подключения к сервису ФСС"); FssWsdlService.FileOperationsLnClient client = new FssWsdlService.FileOperationsLnClient(); ServiceBehavior behavior = new ServiceBehavior(new ServiceClientInspector()); client.Endpoint.EndpointBehaviors.Add(behavior); if (!updateOpened) { string daysLoadedFolder = Path.Combine(Logging.ASSEMBLY_DIRECTORY, "DaysLoaded"); string daysLoadedPath = Path.Combine(Directory.GetCurrentDirectory(), daysLoadedFolder); if (!Directory.Exists(daysLoadedPath)) { Directory.CreateDirectory(daysLoadedPath); } for (DateTime date = DateBegin; date <= DateEnd; date = date.AddDays(1)) { InsertDelimiterToBworker(); bworker.ReportProgress((int)progressCurrent, "Запрос списка больничных от: " + date.ToShortDateString()); string dayFile = Path.Combine(daysLoadedPath, date.ToString("yyyy_MM_dd")); if (File.Exists(dayFile)) { bworker.ReportProgress((int)progressCurrent, "Данный день был выгружен ранее, пропуск"); continue; } for (int i = 0; i < 10; i++) { if (i > 0) { bworker.ReportProgress((int)progressCurrent, "Попытка: " + (i + 1)); } try { client.getLNListByDate(date, ogrn); File.Create(dayFile); break; } catch (Exception e) { Thread.Sleep(1000); if (i == 9) { bworker.ReportProgress((int)progressCurrent, "!!! Ошибка: " + e.Message); } } } progressCurrent += progressStep; } } progressStep = 60.0d / (double)DisabilitySheets.Count; int currentItem = 1; foreach (ItemDisabilitySheet item in DisabilitySheets.Values) { InsertDelimiterToBworker(); for (int i = 0; i < 10; i++) { string attempt = string.Empty; if (i > 0) { attempt = ", попытка: " + (i + 1); } bworker.ReportProgress((int)progressCurrent, "Запрос детализации по листу: " + item.LN_CODE + attempt + " (" + currentItem++ + " / " + DisabilitySheets.Count + ")"); try { client.getLNData(ogrn, item.LN_CODE.ToString(), item.SNILS); break; } catch (Exception e) { Thread.Sleep(1000); if (i == 9) { bworker.ReportProgress((int)progressCurrent, "!!! Ошибка: " + e.Message); } } } progressCurrent += progressStep; } InsertDelimiterToBworker(); bworker.ReportProgress(90, "Получено больничных листов: " + DisabilitySheets.Count); InsertDelimiterToBworker(); return; }
public ProjectReportViewModel GetData() { var result = new ProjectReportViewModel(); var span = DateEnd - DateBegin; int countDays = span.Days; result.MyColumns = new List <string>(); for (int i = 0; i < countDays; i++) { result.MyColumns.Add(DateBegin.AddDays(i).ToShortDateString()); } var timesheetsInterval = _tabelContext.Timesheets.Include("Employee") .Include("Project") .Where(ts => ts.Date >= DateBegin && ts.Date < DateEnd); var neededData = timesheetsInterval.Select(ts => new { EmployeeName = ts.Employee.Name, ProjectName = ts.Project.Name, ProjectCode = ts.Project.Code, Rate = ts.Employee.Rate, ts.Project.WorkObject, ts.Hours, ts.Date }); List <DateTime> reportDays = new List <DateTime>(); for (int i = 0; i < countDays; i++) { reportDays.Add(DateBegin.AddDays(i)); } var allProjects = neededData.Select(data => data.ProjectCode).Distinct(); var projectEmployeeDict = new Dictionary <string, List <string> >(); //у этого проекта такие то сотрудники foreach (var project in allProjects) { projectEmployeeDict[project] = neededData.Where(data => data.ProjectCode == project).Select(data => data.EmployeeName).Distinct().ToList(); } //Заполняем тут данные о сотрудниках и проектах List <PrReportProject> reportProject = new List <PrReportProject>(); foreach (var projectEmployee in projectEmployeeDict) { var newReportProject = new PrReportProject { // ProjectName = projectEmployee.Key, ProjectCode = projectEmployee.Key, ReportEmployee = new List <PrReportEmployee>() }; foreach (var employee in projectEmployee.Value) { newReportProject.ReportEmployee.Add(new PrReportEmployee() { EmployeeName = employee }); } newReportProject.SetBeginAndEndDate(DateBegin, DateEnd); reportProject.Add(newReportProject); } //Записываем данные о часах foreach (var project in reportProject) { foreach (var employee in project.ReportEmployee) { var workingHours = neededData.Where( data => data.EmployeeName == employee.EmployeeName && data.ProjectCode == project.ProjectCode) .Select(data => new { WorkDate = data.Date, WorkHour = data.Hours, data.WorkObject, data.ProjectCode }).ToList(); project.WorkObject = workingHours.First().WorkObject; project.ProjectCode = workingHours.First().ProjectCode; foreach (var workingHour in workingHours) { var roundedDate = new DateTime(workingHour.WorkDate.Year, workingHour.WorkDate.Month, workingHour.WorkDate.Day); employee.Hours[roundedDate] = workingHour.WorkHour; } } } //Записываем данные о зарплате НЕДОДЕЛКА foreach (var project in reportProject) { foreach (var employee in project.ReportEmployee) { employee.Rate = neededData.Where(data => data.EmployeeName == employee.EmployeeName) .Select(data => data.Rate) .FirstOrDefault(); } } //Переделываем в формат грида result.Rows = new List <PrProjectViewModel>(); var totalHoursDict = new Dictionary <DateTime, int>(); var totalMoney = 0.0; for (int i = 0; i < countDays; i++) { totalHoursDict[DateBegin.AddDays(i)] = 0; } foreach (var reportPrj in reportProject) { var hoursDict = new Dictionary <DateTime, int>(); var neededProject = neededData.FirstOrDefault(data => data.ProjectCode == reportPrj.ProjectCode); if (neededProject != null) { reportPrj.ProjectName = neededProject.ProjectName; } for (int i = 0; i < countDays; i++) { hoursDict[DateBegin.AddDays(i)] = 0; } double projectMoney = 0; foreach (var reportEmploy in reportPrj.ReportEmployee) { var newEmployee = new PrProjectViewModel { Name = reportEmploy.EmployeeName, Rate = reportEmploy.Rate, ProjectName = reportPrj.ProjectName, WorkObject = reportPrj.WorkObject, ProjectCode = reportPrj.ProjectCode, Hours = reportEmploy.Hours.Values.ToList() }; result.Rows.Add(newEmployee); totalMoney += newEmployee.Money; foreach (var hour in reportEmploy.Hours) { if (!hoursDict.ContainsKey(hour.Key)) { hoursDict[hour.Key] = 0; } hoursDict[hour.Key] += hour.Value; if (!totalHoursDict.ContainsKey(hour.Key)) { totalHoursDict[hour.Key] = 0; } totalHoursDict[hour.Key] += hour.Value; } projectMoney += newEmployee.Money; } result.Rows = result.Rows.OrderBy(row => row.ProjectCode).ToList(); result.Rows.Add(new PrProjectViewModel(projectMoney) { Hours = hoursDict.Values.ToList(), ProjectCode = reportPrj.ProjectCode + " Итого", ProjectName = reportPrj.ProjectName + " Итого", // Rate = reportPrj.Rate НЕДОДЕЛКА }); } result.Projects = allProjects.ToList(); result.Projects.Insert(0, "Все"); if (!string.IsNullOrEmpty(ProjectFilter) && ProjectFilter != "Все") { result.Rows.RemoveAll(item => item.ProjectCode != ProjectFilter); } return(result); }
public EditEntitlementModel() { DateBegin = DateTime.Now.Date; DateEnd = DateBegin.AddDays(1).Date; }
public void Action(object parameter) { string param = parameter.ToString(); if (param.Equals("CheckDbConnection")) { CheckDbConnection(); } else if (param.Equals("SaveConfig")) { SaveConfiguration(); } else if (param.Equals("CheckMailSettings")) { CheckMailServer(); } else if (param.Equals("EquateEndDateToBeginDate")) { DateEnd = DateBegin; } else if (param.Equals("SetDatesToCurrentDay")) { DateBegin = DateTime.Now; DateEnd = DateBegin; } else if (param.Equals("SetDatesToCurrentWeek")) { DateEnd = DateTime.Now; int dayOfWeek = (int)DateEnd.DayOfWeek; if (dayOfWeek == 0) { dayOfWeek = 7; } DateBegin = DateEnd.AddDays(-1 * (dayOfWeek - 1)); } else if (param.Equals("SetDatesToCurrentMonth")) { DateBegin = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); DateEnd = DateBegin.AddDays(DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month) - 1); } else if (param.Equals("SetDatesToCurrentYear")) { DateBegin = new DateTime(DateTime.Now.Year, 1, 1); DateEnd = new DateTime(DateTime.Now.Year, 12, DateTime.DaysInMonth(DateTime.Now.Year, 12)); } else if (param.Equals("GoToPreviousMonth")) { DateEnd = new DateTime(DateBegin.Year, DateBegin.Month, 1).AddDays(-1); DateBegin = DateEnd.AddDays(-1 * (DateTime.DaysInMonth(DateEnd.Year, DateEnd.Month) - 1)); } else if (param.Equals("GoToPreviousDay")) { DateBegin = DateBegin.AddDays(-1); DateEnd = DateBegin; } else if (param.Equals("GoToNextDay")) { DateBegin = DateBegin.AddDays(1); DateEnd = DateBegin; } else if (param.Equals("GoToNextMonth")) { DateBegin = new DateTime(DateBegin.Year, DateBegin.Month, DateTime.DaysInMonth(DateBegin.Year, DateBegin.Month)).AddDays(1); DateEnd = DateBegin.AddDays((DateTime.DaysInMonth(DateBegin.Year, DateBegin.Month) - 1)); } }