private void button2_Click(object sender, EventArgs e) { var emp = advanceDeductionDataGridView.DataSource; List <DL.AdvanceDeduction> viewSalarySheets = (List <DL.AdvanceDeduction>)emp; DateTime From = dateTimePicker1.Value; int id = Convert.ToInt32(comboBox4.SelectedValue); DL.Section section = db.Sections.Find(id); SalaryReportParameter salaryReportParameter = new SalaryReportParameter(); salaryReportParameter.Unit = section.Department.Unit.Name; salaryReportParameter.Department = section.Department.Name; salaryReportParameter.Section = section.Name; salaryReportParameter.Date = DateTime.Now; using (AdvancedeductionCrystalReport salaryCrystalReport = new AdvancedeductionCrystalReport(salaryReportParameter, viewSalarySheets)) { salaryCrystalReport.ShowDialog(); } }
private void button1_Click(object sender, EventArgs e) { DateTime From = dateTimePicker1.Value; int id = Convert.ToInt32(comboBox4.SelectedValue); List <Employee> employeesALL = db.Employees.Where(a => a.SectionId == id).ToList(); List <Employee> employees = employeesALL.Where(a => a.IsActive(From)).ToList(); PopulateGrid(employees); DL.Section section = db.Sections.Find(id); label5.Text = "U: " + section.Department.Unit.Name + "; D: " + section.Department.Name + "; S: " + section.Name; }
private void button1_Click(object sender, EventArgs e) { DateTime dateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); int id = Convert.ToInt32(comboBox4.SelectedValue); List <DL.Loan> loans = db.Loans.Where(a => a.Employee.SectionId == id).ToList(); List <DL.Loan> currentLone = loans.Where(a => a.IsLoanPaid(dateTime)).ToList(); List <ViewLoan> viewLoans = GetLoanList(currentLone, dateTime); viewLoanDataGridView.DataSource = null; viewLoanDataGridView.DataSource = viewLoans; DL.Section section = db.Sections.Find(id); label5.Text = "Unit:" + section.Department.Unit.Name + ", Department:" + section.Department.Name + ", Section:" + section.Name; }
private void employeesDataGridView_CellContentClick(object sender, EventArgs e) { try { var emp = employeesDataGridView.CurrentRow; Employee emp2 = (Employee)emp.DataBoundItem; Employee employee = db.Employees.Find(emp2.Id); if (employee.SectionId != null) { DL.Section section = db.Sections.Find(employee.SectionId); LoadCompany(); //comboBox1.SelectedItem = section.Department.Unit.Company.Name; ////LoadCombobox2(); //comboBox2.SelectedItem = section.Department.Unit.Name; //comboBox3.SelectedItem = section.Department.Name; //sectionIdComboBox.SelectedValue = section.Id; comboBox1.SelectedText = section.Department.Unit.Company.Name; comboBox1.SelectedValue = section.Department.Unit.Company.Id; comboBox2.SelectedText = section.Department.Unit.Name; comboBox2.SelectedValue = section.Department.Unit.Id; comboBox3.SelectedText = section.Department.Name; comboBox3.SelectedValue = section.Department.Id; sectionIdComboBox.SelectedText = section.Name; sectionIdComboBox.SelectedValue = section.Id; //Display image } else { LoadCompany(); } pictureBox1.Image = null; pictureBox1.Image = new Bitmap(employee.ImagePath); checkBox1.Checked = false; } catch (Exception) { } }
private void LoadCascadingDropDown() { checkBox4.Checked = false; try { var emp = employeesDataGridView.CurrentRow; Employee emp2 = (Employee)emp.DataBoundItem; Employee employee = db.Employees.Find(emp2.Id); //Is Active Status if (!employee.IsActive(DateTime.Now)) { inActiveCheckBox.Checked = true; List <InActiveHistory> inActiveHistories = db.InActiveHistories.Where(a => a.EmployeeId == employee.Id).OrderBy(a => a.From).ToList(); inActiveDateTimePicker.Value = inActiveHistories[inActiveHistories.Count - 1].From; } else { inActiveCheckBox.Checked = false; inActiveDateTimePicker.Value = DateTime.Now; } DL.Section section = db.Sections.Find(employee.SectionId); comboBox10.SelectedText = section.Department.Unit.Company.Name; comboBox10.SelectedValue = section.Department.Unit.Company.Id; comboBox9.SelectedText = section.Department.Unit.Name; comboBox9.SelectedValue = section.Department.Unit.Id; comboBox8.SelectedText = section.Department.Name; comboBox8.SelectedValue = section.Department.Id; comboBox7.SelectedText = section.Name; comboBox7.SelectedValue = section.Id; //Image Load pictureBox2.Image = null; pictureBox2.Image = new Bitmap(employee.ImagePath); checkBox4.Checked = false; } catch (Exception Ex) { } }
private void button5_Click(object sender, EventArgs e) { var emp = viewOTDataGridView1.DataSource; List <ViewOT> viewSalarySheets = (List <ViewOT>)emp; DateTime From = dateTimePicker1.Value; DateTime Loop = new DateTime(From.Year, From.Month, 1); int id = Convert.ToInt32(comboBox4.SelectedValue); DL.Section section = db.Sections.Find(id); SalaryReportParameter salaryReportParameter = new SalaryReportParameter(); salaryReportParameter.Unit = section.Department.Unit.Name; salaryReportParameter.Department = section.Department.Name; salaryReportParameter.Section = section.Name; salaryReportParameter.Date = From; do { salaryReportParameter.Days = salaryReportParameter.Days + 1; if (Loop.DayOfWeek.ToString() == "Friday") { salaryReportParameter.Weekend = salaryReportParameter.Weekend + 1; } var Holiday = db.Holidays.FirstOrDefault(a => a.DepartmentId == section.DepartmentId && a.From <= Loop && a.To >= Loop); if (Holiday != null) { salaryReportParameter.Holiday = salaryReportParameter.Holiday + 1; } Loop = Loop.AddDays(1); } while (Loop.Month == From.Month); using (OTPaymentCrystalComReport salaryCrystalReport = new OTPaymentCrystalComReport(salaryReportParameter, viewSalarySheets)) { salaryCrystalReport.ShowDialog(); } }
private void button5_Click(object sender, EventArgs e) { var emp = viewBonusDataGridView.DataSource; List <DL.ViewBonus> viewSalarySheets = (List <ViewBonus>)emp; int bonusId = Convert.ToInt32(comboBox1.SelectedValue); Bonus bonus = db.Bonus.Find(bonusId); DateTime To = bonus.Date; DateTime From = To.AddYears(-1); int id = Convert.ToInt32(comboBox3.SelectedValue); DL.Department department = db.Departments.Find(id); int id2 = Convert.ToInt32(comboBox4.SelectedValue); DL.Section section = db.Sections.Find(id2); BonusCrystalPar salaryReportParameter = new BonusCrystalPar(); salaryReportParameter.Unit = department.Unit.Name; salaryReportParameter.Department = department.Name; salaryReportParameter.Section = section.Name; salaryReportParameter.Date = DateTime.Now; salaryReportParameter.BonusDate = bonus.Date; salaryReportParameter.Festival = bonus.Reason; // Calculate Company Wise List <Employee> employeesALL = db.Employees.Where(a => a.Section.Department.Unit.CompanyId == department.Unit.CompanyId).ToList(); List <Employee> employees = employeesALL.Where(a => a.IsActive(To) && a.IsEdited == true).ToList(); try { List <ViewBonus> viewSalarySheetsCompany = GetList(employees); salaryReportParameter.CTE = viewSalarySheetsCompany.Sum(a => a.Bonus).ToString(); salaryReportParameter.UTE = viewSalarySheetsCompany.Where(a => a.section.Department.UnitId == department.UnitId).Sum(a => a.Bonus).ToString(); salaryReportParameter.DTE = viewSalarySheetsCompany.Where(a => a.section.DepartmentId == department.Id).Sum(a => a.Bonus).ToString(); salaryReportParameter.STE = viewSalarySheets.Sum(a => a.Bonus).ToString(); salaryReportParameter.CTB = viewSalarySheetsCompany.Count.ToString(); salaryReportParameter.UTB = viewSalarySheetsCompany.Count(a => a.section.Department.UnitId == department.UnitId).ToString(); salaryReportParameter.DTB = viewSalarySheetsCompany.Count(a => a.section.DepartmentId == department.Id).ToString(); salaryReportParameter.STB = viewSalarySheets.Count.ToString(); } catch { } using (BonusCrystalReport salaryCrystalReport = new BonusCrystalReport(salaryReportParameter, viewSalarySheets)) { salaryCrystalReport.ShowDialog(); } }
private List <ViewBonus> GetList(List <Employee> employees) { int bonusId = Convert.ToInt32(comboBox1.SelectedValue); Bonus bonus = db.Bonus.Find(bonusId); DateTime To = bonus.Date; DateTime From = To.AddYears(-1); List <ViewBonus> viewBonus = new List <ViewBonus>(); foreach (Employee employee in employees) { ViewBonus view = new ViewBonus(); try { DateTime JoiningDate = Convert.ToDateTime(employee.HireDate); view.JoiningDate = JoiningDate; TimeSpan timeSpan = To.Subtract(JoiningDate); view.Year = timeSpan.TotalDays / 365; } catch { } DL.Section section = db.Sections.Find(employee.SectionId); view.section = section; view.CompanyPercentage = bonus.Amount; view.Emp_Id = employee.Emp_Id; view.Name = employee.EmpFullName; if (employee.IsWorker == true) { List <WorkerDesignationHistory> workerDesignationHistories = db.WorkerDesignationHistories.Where(a => a.EmployeeId == employee.Id && a.From <= To).ToList(); if (workerDesignationHistories.Count > 0) { DateTime maxDate = workerDesignationHistories.Max(a => a.From); WorkerDesignationHistory workerDesignationHistory = workerDesignationHistories.FirstOrDefault(a => a.From == maxDate); // Find Salary Grade At That Time DL.WorkerDesignation workerDesignation = db.WorkerDesignations.Find(workerDesignationHistory.WorkerDesignationId); List <ShadowSalaryGrade> shadowSalaryGrades = db.ShadowSalaryGrades.Where(a => a.UpdatedAt <= To && a.RoWId == workerDesignation.SalaryGrade.Id).ToList(); DateTime D2 = DateTime.Now; if (shadowSalaryGrades.Count > 0) { D2 = shadowSalaryGrades.Max(a => a.UpdatedAt); var shadowgrade = shadowSalaryGrades.FirstOrDefault(a => a.RoWId == workerDesignation.SalaryGrade.Id && a.UpdatedAt == D2); view.Grade = workerDesignation.Name; view.Gross = shadowgrade.Total; view.Basic = shadowgrade.Salary; } } } else { List <Salary> salaries = db.Salaries.Where(a => a.EmployeeId == employee.Id && a.Date <= To).ToList(); if (salaries.Count > 0) { DateTime maxDate = salaries.Max(a => a.Date); Salary salary = salaries.FirstOrDefault(a => a.Date == maxDate); //view.Grade = salary.; view.Gross = salary.Amount; List <SalarySetting> salarySettings = db.SalarySettings.Where(a => a.Date <= To).ToList(); if (salarySettings.Count > 0) { DateTime maxDate2 = salarySettings.Max(a => a.Date); SalarySetting settings = salarySettings.FirstOrDefault(a => a.Date == maxDate2); view.Basic = salary.Amount * (100 / settings.Basic); } } } //Count Employee attendance List <Emp_CheckInOut> emp_CheckInOuts = db.Emp_CheckInOuts.Where(a => a.UserId == employee.Emp_Id).ToList(); var DayCount = emp_CheckInOuts.Where(a => a.CHECKTIME >= From && a.CHECKTIME <= To).GroupBy(a => a.CHECKTIME.Date).ToList(); view.Days = DayCount.Count - 1; viewBonus.Add(view); } return(viewBonus.ToList()); }
private void button2_Click(object sender, EventArgs e) { var emp = viewSalarySheetDataGridView.DataSource; List <ViewSalarySheet> viewSalarySheets = (List <ViewSalarySheet>)emp; DateTime From = dateTimePicker1.Value; DateTime Loop = new DateTime(From.Year, From.Month, 1); int id = Convert.ToInt32(comboBox4.SelectedValue); DL.Section section = db.Sections.Find(id); SalaryReportParameter salaryReportParameter = new SalaryReportParameter(); salaryReportParameter.Unit = section.Department.Unit.Name; salaryReportParameter.Department = section.Department.Name; salaryReportParameter.Section = section.Name; salaryReportParameter.Date = From; do { salaryReportParameter.Days = salaryReportParameter.Days + 1; if (Loop.DayOfWeek.ToString() == "Friday") { salaryReportParameter.Weekend = salaryReportParameter.Weekend + 1; } var Holiday = db.Holidays.FirstOrDefault(a => a.DepartmentId == section.DepartmentId && a.From <= Loop && a.To >= Loop); if (Holiday != null) { salaryReportParameter.Holiday = salaryReportParameter.Holiday + 1; } Loop = Loop.AddDays(1); } while (Loop.Month == From.Month); using (SalaryCrystalReport salaryCrystalReport = new SalaryCrystalReport(salaryReportParameter, viewSalarySheets)) { salaryCrystalReport.ShowDialog(); } // public partial class SalaryCrystalReport : Form //{ // List<ViewSalarySheet> viewSalarySheets = new List<ViewSalarySheet>(); // SalaryReportParameter SalaryReportParameter = new SalaryReportParameter(); // public SalaryCrystalReport(SalaryReportParameter salaryReportParameter, List<ViewSalarySheet> vS) // { // InitializeComponent(); // viewSalarySheets = vS; // SalaryReportParameter = salaryReportParameter; // } // private void crystalReportViewer1_Load(object sender, EventArgs e) // { // } // private void SalaryCrystalReport_Load(object sender, EventArgs e) // { // salaryReport1.SetDataSource(viewSalarySheets); // salaryReport1.SetParameterValue("Date", SalaryReportParameter.Date.ToString("dd/MM/yyyy")); // salaryReport1.SetParameterValue("Days", SalaryReportParameter.Days); // salaryReport1.SetParameterValue("Weekend", SalaryReportParameter.Weekend); // salaryReport1.SetParameterValue("Holiday", SalaryReportParameter.Holiday); // salaryReport1.SetParameterValue("Dept", SalaryReportParameter.Department); // salaryReport1.SetParameterValue("Unit", SalaryReportParameter.Unit); // salaryReport1.SetParameterValue("Section", SalaryReportParameter.Section); // crystalReportViewer1.ReportSource = salaryReport1; // crystalReportViewer1.Refresh(); // } //} //DGVPrinter printer = new DGVPrinter(); //printer.Title = "Salary Report"; //printer.SubTitle = "Saad Musa Group of Industries"; //printer.SubTitle = string.Format("Date:{0}", dateTimePicker1.Value.Date); //printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | // StringFormatFlags.NoClip; //printer.PageNumbers = true; //printer.PageNumberInHeader = false; //printer.PrintMargins.Left = 10; //printer.PrintMargins.Right = 10; //printer.PorportionalColumns = true; //printer.HeaderCellAlignment = StringAlignment.Near; //printer.Footer = "Saad Musa-Home Textile"; //printer.FooterSpacing = 15; //printer.PageSettings.Landscape = true; //printer.PrintDataGridView(viewSalarySheetDataGridView); }