public No35_NoMethodOverloadingExtensionMethod() { //目的: //①名前空間を変えて同名の拡張メソッドを定義しない //概要: //-------------------------------------------------------------------------------------- //名前空間を変えて同じ名前の拡張メソッドを作成することで、 //使用する名前空間を変えると様々なバージョンの拡張メソッドを定義できると考えられるがこれは間違い //実装者が名前空間を変えると振る舞いが変わるとは思わないのである //悪い例 //usingする名前空間によってresultの値が変わる var emp = new Employee() { Salary = 100 }; var result = emp.Format(); //そもそも拡張メソッドはその型に存在しているのが自然なメソッドであるべきである //上記のメソッドは、Employeeを利用したい実装者側の都合のため、Employeeを利用する別の型に実装すべきである //良い例 var result1 = EmployeeReport.FormatAsText(emp); var result2 = EmployeeReport.FormatAsXml(emp); }
public EmployeeReport GetEmployeeReport(string lastName) { var timeLogs = _timesheetRepository.GetTimeLogs(lastName); var employee = _authService.GetEmployee(lastName); decimal bill; int hours = 0; foreach (var log in timeLogs) { hours += log.WorkingTimeHours; } bill = hours / 160 * employee.Salary; var result = new EmployeeReport { LastName = lastName, TimeLogs = timeLogs.ToList(), Bill = bill, StartTime = timeLogs.Select(t => t.Date).Min(), EndTime = timeLogs.Select(t => t.Date).Max(), TotalHours = timeLogs.Sum(x => x.WorkingTimeHours) }; return(result); }
public List <EmployeeReport> GenerateReport() { SqlConnection conn = new SqlConnection(); conn.ConnectionString = ConnectionHelper.getConnectionString(); conn.Open(); using (conn) { SqlCommand command = new SqlCommand("SP_EmployeeReport", conn); command.CommandType = System.Data.CommandType.StoredProcedure; SqlDataReader reader = command.ExecuteReader(); List <EmployeeReport> reportList = new List <EmployeeReport>(); while (reader.Read()) { EmployeeReport report = new EmployeeReport(); report.EmpID = Convert.ToInt32(reader["EmpID"]); report.FirstName = Convert.ToString(reader["FirstName"]); report.LastName = Convert.ToString(reader["LastName"]); report.TotalHours = Convert.ToDouble(reader["TotalHoursWorked"]); reportList.Add(report); } return(reportList); } }
private static EmployeeReport ToEmployeeReport(EmployeeEntity employee, DateTime?beginDate = null, DateTime?endDate = null) { var actualBeginDate = beginDate ?? DateTime.MinValue; var actualEndDate = endDate ?? DateTime.MaxValue; var employeeReport = new EmployeeReport { Employee = employee.ToEmployeeModel(), TimeRecords = employee.TimeRecords .Where(i => actualBeginDate <= i.Date && i.Date <= actualEndDate) .Select(timeRecord => timeRecord.ToTimeRecord()) .ToArray(), Resources = employee.SoldResources .Select(i => i.SoldResource) .Select(resource => resource.ToResourceModel(beginDate, endDate)) .ToArray(), ProjectResources = employee.SoldResources.Select(resource => new ProjectResource { ProjectName = resource.SoldResource.Project.Name, Resource = resource.SoldResource.ToResourceModel(beginDate, endDate) }) }; employeeReport.TakenTime = employeeReport.ProjectResources.Sum(i => i.Resource.TakenTime); employeeReport.TakenMoney = employeeReport.ProjectResources.Sum(i => i.Resource.TakenMoney); return(employeeReport); }
public IActionResult GetEmployeeReport() { EmployeeReport report = new EmployeeReport(); report.generatedReport(_env.WebRootPath); return(Ok(new { msg = "Report Generated" })); }
private EmployeeReport ReadToTransactionforMonth(IDataReader aReader) { EmployeeReport aTransaction = new EmployeeReport(); try { aTransaction.SalaryDate = Convert.ToDateTime(aReader["date"]); } catch (Exception) { } try { aTransaction.SalaryAmount = Convert.ToDouble(aReader["amount"]); } catch (Exception) { } try { aTransaction.EmployeeName = (aReader["employee_name"]).ToString(); } catch (Exception) { } return(aTransaction); }
public static IEnumerable <EmployeeReport> GenerateReport(IEnumerable <PaymentModel> payments) { Dictionary <int, Dictionary <PayPeriod, EmployeeReport> > employees = new Dictionary <int, Dictionary <PayPeriod, EmployeeReport> >(); foreach (var payment in payments) { if (!employees.ContainsKey(payment.EmployeeId)) { employees.Add(payment.EmployeeId, new Dictionary <PayPeriod, EmployeeReport>()); } var employeePaymentPeriods = employees[payment.EmployeeId]; var payPeriod = PayPeriod.FindPayPeriod(payment.Date); var salary = PayScale.Payments[payment.JobGroup] * payment.HoursWorked; if (!employeePaymentPeriods.ContainsKey(payPeriod)) { employeePaymentPeriods.Add(payPeriod, new EmployeeReport { EmployeeID = payment.EmployeeId, PayPeriod = payPeriod }); } employeePaymentPeriods[payPeriod].AmountPaid += salary; employeePaymentPeriods[payPeriod].HoursWorked += payment.HoursWorked; } var reports = new List <EmployeeReport>(); foreach (var employee in employees.Values) { foreach (var report in employee.Values.OrderBy(x => x.PayPeriod)) { if (report.HoursWorked > OVERTIME_HOURS) { var overTimeReport = new EmployeeReport { EmployeeID = payment.EmployeeId, PayPeriod = payPeriod }; overTimeReport.HoursWorked = report.HoursWorked - OVERTIME_HOURS; overTimeReport.AmountPaid = overTimeReport.HoursWorked * OVERTIME * PayScale.Payments[report.JobGroup]; reports.Add(overTimeReport); report.HoursWorked = (double)OVERTIME; report.AmountPaid = report.HoursWorked * PayScale.Payments[report.JobGroup]; reports.Add(report); } else { reports.Add(report); } } } return(reports); }
private List <Employee> ProcessSelectedEmployeeReportFile(string path) { if (File.Exists(path)) { var employeeReportContents = new EmployeeReport(path); return(employeeReportContents.Scan()); } MessageBox.Show("Whoops! We can't find a file located at '" + path + "'"); return(new List <Employee>()); }
public async Task <IActionResult> GetReportEmployee([FromQuery] EmployeeReport employeeReport) { var result = await repo.GetEmployeeReport(employeeReport); if (result != null) { return(Ok(result)); } return(BadRequest("Error in saving employee")); }
public IHttpActionResult GetEmployeeReport() { try { EmployeeReport report = new EmployeeReport(); report.getEmpReport(); return(Ok("employee report generated")); } catch (Exception ex) { return(BadRequest("Call Report Generation failed - " + ex.Message)); } }
public IHttpActionResult GetEmployeeReport() { try { EmployeeReport rep = new EmployeeReport(); rep.doIt(); return(Ok("report generated")); } catch (Exception e) { //Trace.WriteLine("Error " + e.Message); return(BadRequest("Retrieve failed - Couldn't generate report" + e.Message)); } }
public IHttpActionResult GetEmloyeeReport() { try { EmployeeReport rep = new EmployeeReport(); rep.doIt(); return(Ok("employee report generated")); } catch (Exception ex) { Trace.WriteLine("error" + ex.Message); return(BadRequest("Retrived failed - Couldn't generate sample report")); } }
public EmployeeReport GetEmployeeReport(string lastName) { var employee = _employeeRepository.GetEmployee(lastName); var timeLogs = _timesheetRepository.GetTimeLogs(employee.LastName); if (timeLogs.Length == 0 || timeLogs == null) { return(new EmployeeReport { Bill = 0m, TotalHours = 0, LastName = employee.LastName }); } decimal bill = 0m; var totalHours = timeLogs.Sum(x => x.WorkingHours); var workingHoursGroupByDay = timeLogs .GroupBy(x => x.Date.ToShortDateString()); foreach (var workingLogsPerDay in workingHoursGroupByDay) { int dayHours = workingLogsPerDay.Sum(x => x.WorkingHours); if (dayHours > MAX_WORKING_HOURS_IN_DAY) { var overtimeHours = dayHours - MAX_WORKING_HOURS_IN_DAY; bill += MAX_WORKING_HOURS_IN_DAY * employee.Salary / MAX_WORKING_HOURS_IN_MONTH; bill += overtimeHours * employee.Salary * OVERTIME_MULTIPLIER / MAX_WORKING_HOURS_IN_MONTH; } else { bill += dayHours * employee.Salary / MAX_WORKING_HOURS_IN_MONTH; } } var result = new EmployeeReport { LastName = employee.LastName, TimeLogs = timeLogs.ToList(), TotalHours = totalHours, Bill = bill }; return(result); }
public bool AddReport(EmployeeReport _report) { lock (this.syncRoot) { if (this.items.ContainsKey(_report.Time)) { this.items.Add(_report.Time, _report); return(true); } else { return(false); } } }
//计算年度累计薪水 private decimal countSalary(EmployeeReport employeereport) { var payrolls = from p in db.PayRolls where p.EmployeeName == User.Identity.Name select p; decimal totalsalary = 0; foreach (PayRoll p in payrolls) { if (p.PayDate.Year == employeereport.EndDate.Year && DateTime.Compare(p.PayDate, employeereport.EndDate) <= 0) { totalsalary += p.Salary; } } return(totalsalary); }
//计算累计工时 private int countHour(EmployeeReport employeereport) { var timecards = from t in db.Timecards where t.EmployeeName == User.Identity.Name && t.isSubmitted != null select t; int totalhour = 0; foreach (Timecard t in timecards) { if (DateTime.Compare(t.Date, employeereport.StartDate) >= 0 && DateTime.Compare(t.Date, employeereport.EndDate) <= 0) { totalhour += t.Hours; } } return(totalhour); }
public ActionResult Index([Bind(Include = "ReportType,StartDate,EndDate,Chargenumber")] EmployeeReport employeereport) { var ChargeNumList = new List <string>(); var ChargeNumQry = from d in db.ChargeNumbers orderby d.ID select d.chargenumber; ChargeNumList.AddRange(ChargeNumQry.Distinct()); ViewBag.ChargeNumList = new SelectList(ChargeNumList); if (employeereport.ReportType == EMreporttype.TOTALHOUR)//累计工时 { employeereport.TotalHour = countHour(employeereport); employeereport.Name = getName(); EMPLOYEEREPORT = employeereport; return(RedirectToAction("HourReport")); } else if (employeereport.ReportType == EMreporttype.YEARtoDATE)//累计薪水 { employeereport.Salary = countSalary(employeereport); employeereport.Year = employeereport.EndDate.Year; employeereport.Name = getName(); EMPLOYEEREPORT = employeereport; return(RedirectToAction("SalaryReport")); } else if (employeereport.ReportType == EMreporttype.HOURSforPROJECT)//项目累计时间 { if (employeereport.Chargenumber == null) { Response.Write("<script>alert('请选择项目编号!')</script>"); return(View(employeereport)); } employeereport.TotalHour = countHoursForProject(employeereport); employeereport.Name = getName(); EMPLOYEEREPORT = employeereport; return(RedirectToAction("HoursForProject"));; } else//剩余假期 { employeereport.Vacation = countVacation(); employeereport.Name = getName(); EMPLOYEEREPORT = employeereport; return(RedirectToAction("Vacation"));; } }
public void AddReport(DateTime date, string name, string position, int time, string comment) { string note = $"{date.ToShortDateString()},{name},{time},{comment}"; switch (position) { case "руководитель": ManagerReport.Add(note); break; case "сотрудник": EmployeeReport.Add(note); break; case "фрилансер": FreelancerReport.Add(note); break; } }
// Get existing employees public async Task <IEnumerable <Employee> > GetEmployeeReport(EmployeeReport employeeReport = null) { if (employeeReport.Status == "status") { var resultAll = context.Employees.Where(j => j.IsCreated >= employeeReport.StartDate && j.IsCreated <= employeeReport.FinishDate); return(resultAll); } var result = await context.Employees.Where(j => j.Status == employeeReport.Status && j.IsCreated >= employeeReport.StartDate && j.IsCreated <= employeeReport.FinishDate ).ToListAsync(); return(result); }
private XtraReport CreateReport(string reportEntry) { if (reportEntry.Contains("Parameter")) { XtraReport report = new EmployeeReport(); DevExpress.XtraReports.Parameters.Parameter param = new DevExpress.XtraReports.Parameters.Parameter() { Name = "parameterDepartment", Type = typeof(string), Value = "Management" }; param.Description = "Department"; report.Parameters.Add(param); report.RequestParameters = false; return(report); } else { return(new EmployeeReport()); } }
private void lbEmpID_SelectedIndexChanged(object sender, EventArgs e) { EmployeeReport empReport = (EmployeeReport)lbEmpID.SelectedValue; int ID = empReport.EmpID; EmpHourController controller = new EmpHourController(); HourResult result = controller.GetHours(ID); if (result.status == ResultEnum.Success) { var bindingList = new BindingList <WorkingHour>(result.hours); var source = new BindingSource(bindingList, null); txtTotal.Text = empReport.TotalHours.ToString(); dataGridView2.DataSource = source; dataGridView2.Columns[1].Visible = false; } else { MessageBox.Show("Failed To generate Employee Data. Please Contact Admin"); } }
public List <EmployeeReport> EmployeeTransactionReportBydateForMonth(DateTime fromDate, DateTime toDate) { List <EmployeeReport> aTransactions = new List <EmployeeReport>(); try { this.OpenConnection(); string sqlComm = string.Format(SqlQueries.GetQuery(Query.EmployeeTransactionReportBydate), fromDate, toDate); IDataReader aReader = this.ExecuteReader(sqlComm); if (aReader != null) { while (aReader.Read()) { EmployeeReport aTransaction = new EmployeeReport(); aTransaction = ReadToTransactionforMonth(aReader); aTransactions.Add(aTransaction); } } } catch (Exception) { } return(aTransactions); }
public void WithEmployee(EmployeeReport employee) { _employee = employee; }
public async static Task <DashboardInfo> Generate() { var res = new DashboardInfo(); var employeeModel = (await MetadataToModelConverter.GetEntityModelByModelAsync("Employee")); var businessTripModel = (await MetadataToModelConverter.GetEntityModelByModelAsync(DocumentTypes.BusinessTrip)); var CompensationModel = (await MetadataToModelConverter.GetEntityModelByModelAsync(DocumentTypes.Compensation)); if (DWKitRuntime.Security.CheckPermission("Dashboard", "ViewCompanyInfo")) { Filter notDraft = Filter.And.NotIn(WorkflowReport.DraftStates, "State"); res.BusinessTripCount = await Document.GetDocumentTypeCountAsync(DocumentTypes.BusinessTrip, notDraft); res.SickLeaveCount = await Document.GetDocumentTypeCountAsync(DocumentTypes.SickLeave, notDraft); res.VacationCount = await Document.GetDocumentTypeCountAsync(DocumentTypes.Vacation, notDraft); res.CompensationCount = await Document.GetDocumentTypeCountAsync(DocumentTypes.Compensation, notDraft); res.RecruitmentCount = await Document.GetDocumentTypeCountAsync(DocumentTypes.Recruitment, notDraft); res.EmployeeReport = await EmployeeReport.GenerateForDashboard(DateTime.Now.AddMonths(-5), DateTime.Now); } if (DWKitRuntime.Security.CurrentUser != null) { #region For Users Guid id = DWKitRuntime.Security.CurrentUser.Id; Filter userBusinessTripFilter = DocumentTypes.GetFilter(DocumentTypes.BusinessTrip).NotIn(WorkflowReport.DraftStates, "State").LikeRightLeft(id.ToString(), "Employees"); var trips = await businessTripModel.GetAsync(userBusinessTripFilter, Order.StartAsc("DateStart")); Filter userCompenstationFilter = DocumentTypes.GetFilter(DocumentTypes.Compensation).NotIn(WorkflowReport.DraftStates, "State").Equal(id, "EmployeeId"); var Compensations = await CompensationModel.GetAsync(userCompenstationFilter); res.UserBusinessTripExpenses = 0; res.UserBusinessTripExpensesApproved = 0; foreach (dynamic trip in trips) { if (trip.Amount == null || trip.Amount == 0) { continue; } if (WorkflowReport.FinalStates.Contains(trip.State)) { res.UserBusinessTripExpensesApproved += (decimal)trip.Amount; } else { res.UserBusinessTripExpenses += (decimal)trip.Amount; } } res.UserCompensationAmount = 0; res.UserCompensationAmountApproved = 0; foreach (dynamic c in Compensations) { if (c.Amount == null || c.Amount == 0) { continue; } if (WorkflowReport.FinalStates.Contains(c.State)) { res.UserCompensationAmountApproved += (decimal)c.Amount; } else { res.UserCompensationAmount += (decimal)c.Amount; } } res.UserBusinessTrips = trips.Where(c => ((dynamic)c).DateEnd > DateTime.Now).Select(c => c.ToDictionary(true)).ToList(); #endregion } return(res); }
public IEnumerable<EmployeeReport> GetByExample(EmployeeReport example) { return Employees.Where(x => x.Id == example.Id); }
private string encryptkey = "Oyea"; //密钥 #region 执行“目录”控件中的项操作 /// <summary> /// 执行“目录”控件中的项操作 /// </summary> /// <param name="control">控件类型</param> /// <param name="form">所属窗体</param> public void ShowForm(ToolStripMenuItem control, Form form) { switch (control.Tag.ToString()) { case "1": EmployeeInfo employee = new EmployeeInfo(); employee.MdiParent = form; employee.StartPosition = FormStartPosition.CenterScreen; employee.Show(); break; case "2": CompanyInfo company = new CompanyInfo(); company.MdiParent = form; company.StartPosition = FormStartPosition.CenterScreen; company.Show(); break; case "3": Login login = new Login(); login.StartPosition = FormStartPosition.CenterScreen; login.ShowDialog(); form.Dispose(); //释放窗体资源 break; case "5": GoodsIn goodsin = new GoodsIn(); goodsin.MdiParent = form; goodsin.StartPosition = FormStartPosition.CenterScreen; goodsin.Show(); break; case "6": ReGoods regoods = new ReGoods(); regoods.MdiParent = form; regoods.StartPosition = FormStartPosition.CenterScreen; regoods.Show(); break; case "7": GoodsFind stockfind = new GoodsFind(); stockfind.MdiParent = form; stockfind.StartPosition = FormStartPosition.CenterScreen; stockfind.Show(); break; case "8": s sellgoods = new s(); sellgoods.MdiParent = form; sellgoods.StartPosition = FormStartPosition.CenterScreen; sellgoods.Show(); break; case "9": CustomerReGoods customerregoods = new CustomerReGoods(); customerregoods.MdiParent = form; customerregoods.StartPosition = FormStartPosition.CenterScreen; customerregoods.Show(); break; case "10": SellFind sellfind = new SellFind(); sellfind.MdiParent = form; sellfind.StartPosition = FormStartPosition.CenterScreen; sellfind.Show(); break; case "11": ChangeGoods changegoods = new ChangeGoods(); changegoods.MdiParent = form; changegoods.StartPosition = FormStartPosition.CenterScreen; changegoods.Show(); break; case "12": StockAlarm stockalarm = new StockAlarm(); stockalarm.MdiParent = form; stockalarm.StartPosition = FormStartPosition.CenterScreen; stockalarm.Show(); break; case "13": StockFind stockfindall = new StockFind(); stockfindall.MdiParent = form; stockfindall.StartPosition = FormStartPosition.CenterScreen; stockfindall.Show(); break; case "14": EmployeeReport employeereport = new EmployeeReport(); employeereport.MdiParent = form; employeereport.StartPosition = FormStartPosition.CenterScreen; employeereport.Show(); break; case "15": CompanyReport companyreport = new CompanyReport(); companyreport.MdiParent = form; companyreport.StartPosition = FormStartPosition.CenterScreen; companyreport.Show(); break; case "16": GoodsInReport goodsinreport = new GoodsInReport(); goodsinreport.MdiParent = form; goodsinreport.StartPosition = FormStartPosition.CenterScreen; goodsinreport.Show(); break; case "17": GoodsInAnalysisReport sellgodsreport = new GoodsInAnalysisReport(); sellgodsreport.MdiParent = form; sellgodsreport.StartPosition = FormStartPosition.CenterScreen; sellgodsreport.Show(); break; case "18": EmployeeSellReport employeesellreport = new EmployeeSellReport(); employeesellreport.MdiParent = form; employeesellreport.StartPosition = FormStartPosition.CenterScreen; employeesellreport.Show(); break; case "19": GoodsInAnalysisReport goodsinana = new GoodsInAnalysisReport(); goodsinana.MdiParent = form; goodsinana.StartPosition = FormStartPosition.CenterScreen; goodsinana.Show(); break; case "20": SellGoodsAnalysisReport sellana = new SellGoodsAnalysisReport(); sellana.MdiParent = form; sellana.StartPosition = FormStartPosition.CenterScreen; sellana.Show(); break; case "21": SetPopedom setpopedom = new SetPopedom(); setpopedom.MdiParent = form; setpopedom.StartPosition = FormStartPosition.CenterScreen; setpopedom.Show(); break; case "22": ChangePwd changepwd = new ChangePwd(); changepwd.MdiParent = form; changepwd.StartPosition = FormStartPosition.CenterScreen; changepwd.Show(); break; case "23": BakData bakdata = new BakData(); bakdata.MdiParent = form; bakdata.StartPosition = FormStartPosition.CenterScreen; bakdata.Show(); break; case "24": ReBakData rebakdata = new ReBakData(); rebakdata.MdiParent = form; rebakdata.StartPosition = FormStartPosition.CenterScreen; rebakdata.Show(); break; case "25": SysUser sysuser = new SysUser(); sysuser.MdiParent = form; sysuser.StartPosition = FormStartPosition.CenterScreen; sysuser.Show(); break; case "30": CustomerInfo customer = new CustomerInfo(); customer.MdiParent = form; customer.StartPosition = FormStartPosition.CenterScreen; customer.Show(); break; case "31": EmployeeSellAnalysisReport sell = new EmployeeSellAnalysisReport(); sell.MdiParent = form; sell.StartPosition = FormStartPosition.CenterScreen; sell.Show(); break; default: break; } }
public void Save(EmployeeReport employee) { Employees.Add(employee); }