Esempio n. 1
0
        private void GetOtherIncomes()
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    lOtherIncome = new List <DMSIClass._OtherIncome>();
                    var otherincomes = db.OtherIncomes.Where(m => m.EmployeeID == empid).ToList();

                    foreach (var x in otherincomes)
                    {
                        DMSIClass._OtherIncome otherIncome = new DMSIClass._OtherIncome();
                        var period     = db.Periods.Where(m => m.PeriodID == x.PeriodID).FirstOrDefault();
                        var incometype = db.IncomeTypes.Where(m => m.IncomeTypeID == x.IncomeTypeID).FirstOrDefault();

                        otherIncome.OtherIncomeID = x.OtherIncomeID;
                        otherIncome.IncomeType    = incometype.Description;
                        otherIncome.StDate        = x.StDate;
                        otherIncome.ToDate        = x.ToDate;
                        otherIncome.Period        = period.PeriodDescription;
                        otherIncome.Amount        = x.Amount;

                        lOtherIncome.Add(otherIncome);
                    }

                    datagridview.ItemsSource = lOtherIncome.OrderBy(m => m.OtherIncomeID);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 2
0
        private void GetHoliday()
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    var holidays = db.Holidays.Where(m => m.EmployeeID == empid).ToList();
                    lHoliday = new List <DMSIClass._Holiday>();
                    foreach (var x in holidays)
                    {
                        DMSIClass._Holiday holiday = new DMSIClass._Holiday();
                        var holidaytype            = db.HolidayTypes.Where(m => m.HolidayTypeID == x.HolidayTypeID).FirstOrDefault();
                        var emp      = db.Employees.Where(m => m.EmployeeID == x.EmployeeID).FirstOrDefault();
                        var position = db.EmployeePositions.Where(m => m.EmployeePositionID == emp.EmployeePositionID).FirstOrDefault();
                        holiday.HolidayType   = holidaytype.Description;
                        holiday.HolidayID     = x.HolidayID;
                        holiday.HolidayPeriod = x.StDate.ToShortDateString() + " - " + x.ToDate.ToShortDateString();
                        holiday.NoOfDays      = x.NoOfDays;
                        holiday.PayrollDate   = x.PayrollDate;
                        holiday.Amount        = x.Amount;
                        holiday.DailyRate     = position.DailyRate;

                        lHoliday.Add(holiday);
                    }

                    datagridview.ItemsSource = lHoliday.OrderByDescending(m => m.HolidayID);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 3
0
        private void GetPYTable()
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    lPYTable = new List <DMSIClass.PYTable>();
                    var pytables = db.PYTables.Where(m => m.PYType == pytype).OrderBy(m => m.PYTableID).ToList();

                    foreach (var x in pytables)
                    {
                        DMSIClass.PYTable pytable = new DMSIClass.PYTable();
                        pytable.Comments  = x.Comments;
                        pytable.Duration  = x.StDate.ToShortDateString() + " - " + x.ToDate.ToShortDateString();
                        pytable.PYCode    = x.PYCode;
                        pytable.PYDate    = x.PYDate;
                        pytable.PYTableID = x.PYTableID;
                        lPYTable.Add(pytable);
                    }

                    datagridview.ItemsSource = lPYTable.OrderBy(m => m.PYTableID).ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 4
0
 public void LoadReport(int ReportID)
 {
     try
     {
         using (var db = new DMSIPayrollEntities())
         {
             if (ReportID == 1)
             {
                 if (Report1.Count > 0)
                 {
                     report = new Report.EmployeeDTR();
                     report.SetDataSource(Report1);
                     report.SetDatabaseLogon("sa", "Pa$$w0rd", "DMSIPAYROLL", "DMISPAYROLL");
                     report.SetParameterValue("startDate", startDate);
                     report.SetParameterValue("endDate", endDate);
                     crViewer1.ViewerCore.ReportSource = report;
                 }
                 else
                 {
                     MessageBox.Show("Report cannot be loaded.", "System Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         //MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Esempio n. 5
0
        private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    var emp = db.Employees.Where(m => m.EmployeeID == empid).FirstOrDefault();
                    var pos = db.EmployeePositions.Where(m => m.EmployeePositionID == emp.EmployeePositionID).FirstOrDefault();

                    tbEmployeeName.Text = (emp.LastName + ", " + emp.FirstName + " " + emp.MiddleName).ToUpper();
                    tbDailyRate.Text    = pos.DailyRate.ToString("G29");

                    cbHolidayType.ItemsSource       = db.HolidayTypes.OrderBy(m => m.Description).ToList();
                    cbHolidayType.DisplayMemberPath = "Description";
                    cbHolidayType.SelectedValuePath = "HolidayTypeID";
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (mode == 2)
            {
                this.Title = "UPDATE HOLIDAY";
                GetHoliday();
            }
        }
Esempio n. 6
0
        private void GetAdjustment()
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    var adjustments = db.Adjustments.Where(m => m.EmployeeID == empid).ToList();
                    lAdjustment = new List <DMSIClass._Adjustment>();
                    foreach (var x in adjustments)
                    {
                        DMSIClass._Adjustment adjustment = new DMSIClass._Adjustment();
                        var emp      = db.Employees.Where(m => m.EmployeeID == x.EmployeeID).FirstOrDefault();
                        var position = db.EmployeePositions.Where(m => m.EmployeePositionID == emp.EmployeeID).FirstOrDefault();

                        adjustment.AdjustmentID = x.AdjustmentID;
                        adjustment.PayrollDate  = x.PayrollDate;
                        adjustment.Amount       = x.Amount;
                        lAdjustment.Add(adjustment);
                    }

                    datagridview.ItemsSource = lAdjustment.OrderByDescending(m => m.AdjustmentID);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 7
0
        private void GetEmployee()
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    var employee = db.Employees.Where(m => m.EmployeeID == employeeid).FirstOrDefault();
                    tbEmployeeNumber.Text       = employee.EmployeeNumber;
                    tbLastName.Text             = employee.LastName;
                    tbFirstName.Text            = employee.FirstName;
                    tbMiddleName.Text           = employee.MiddleName;
                    cbCompany.SelectedValue     = employee.CompanyID;
                    cbPosition.SelectedValue    = employee.EmployeePositionID;
                    tbBiometricsID.Text         = employee.BiometricsID.ToString();
                    tbAddress.Text              = employee.Address;
                    dpDateHired.SelectedDate    = employee.DateHired;
                    dpBirthdate.SelectedDate    = employee.Birthdate;
                    dpDateResigned.SelectedDate = employee.DateResigned;
                    cbCivilStatus.SelectedValue = employee.CivilStatus;
                    tbSSS.Text               = employee.SSS;
                    tbPhilhealth.Text        = employee.Philhealth;
                    tbHDMF.Text              = employee.HMDF;
                    tbTIN.Text               = employee.Tin;
                    tbGuardian.Text          = employee.Guardian;
                    tbGuardianContactNo.Text = employee.GuardianContactNo;
                    tbContactNo.Text         = employee.ContactNo;
                    tbHDMF.Text              = employee.HMDF;
                    tbRelationship.Text      = employee.Relationship;
                    if (employee.Gender == "M")
                    {
                        rbMale.IsChecked = true;
                    }
                    else if (employee.Gender == "F")
                    {
                        rbFemale.IsChecked = true;
                    }
                    if (employee.PayrollType == 1)
                    {
                        rbLogistics.IsChecked = true;
                    }
                    else if (employee.PayrollType == 2)
                    {
                        rbOtherDivision.IsChecked = true;
                    }

                    if (employee.IsActive == true)
                    {
                        cboxIsActive.IsChecked = true;
                    }
                    else
                    {
                        cboxIsActive.IsChecked = false;
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 8
0
        private void GetAdjustment()
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    var leaves = db.Leaves.Where(m => m.EmployeeID == empid).ToList();
                    lLeave = new List <Leave>();
                    foreach (var x in leaves)
                    {
                        Leave leave = new Leave();

                        leave.LeaveID     = x.LeaveID;
                        leave.PayrollDate = x.PayrollDate;
                        leave.Amount      = x.Amount;
                        leave.Value       = x.Value;

                        lLeave.Add(leave);
                    }

                    datagridview.ItemsSource = lLeave.OrderByDescending(m => m.LeaveID);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 9
0
        private void GetDeductions()
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    lDeduction = new List <DMSIClass._Deduction>();
                    var deductions = db.Deductions.Where(m => m.EmployeeID == empid).ToList();

                    foreach (var x in deductions)
                    {
                        DMSIClass._Deduction deduction = new DMSIClass._Deduction();
                        var period        = db.Periods.Where(m => m.PeriodID == x.PeriodID).FirstOrDefault();
                        var deductiontype = db.DeductionTypes.Where(m => m.DeductionTypeID == x.DeductionTypeID).FirstOrDefault();

                        deduction.DeductionID   = x.DeductionID;
                        deduction.DeductionType = deductiontype.Description;
                        deduction.StDate        = x.StDate;
                        deduction.ToDate        = x.ToDate;
                        deduction.Period        = period.PeriodDescription;
                        deduction.Amortization  = x.Amortization;

                        lDeduction.Add(deduction);
                    }

                    datagridview.ItemsSource = lDeduction.OrderBy(m => m.DeductionID);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 10
0
        private async void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    MessageDialogResult mdr = await this.ShowMessageAsync("READ", "ARE YOU SURE YOU WANT TO SAVE THIS ATTENDANCE?", MessageDialogStyle.AffirmativeAndNegative);

                    if (mdr == MessageDialogResult.Affirmative)
                    {
                        foreach (var x in lAttendance.Where(m => m.ID == "8166"))
                        {
                            DateTime      datetime = DateTime.ParseExact(x.Date + " " + x.Time, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                            BiometricsLog bio      = new BiometricsLog();
                            bio.BiometricsID = Convert.ToInt32(x.ID);
                            bio.DTime        = datetime;
                            bio.Mode         = Convert.ToInt32(x.Mode);
                            db.BiometricsLogs.Add(bio);
                            db.SaveChanges();
                        }

                        MessageBox.Show("Saving Succesful", "System Succes!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void GetIncomes()
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    lIncome = new List <DMSIClass._Income>();
                    var incomes = db.Incomes.Where(m => m.EmployeeID == empid).ToList();
                    emp = db.Employees.Where(m => m.EmployeeID == empid).FirstOrDefault();

                    foreach (var x in incomes)
                    {
                        DMSIClass._Income income = new DMSIClass._Income();

                        var position = db.EmployeePositions.Where(m => m.EmployeePositionID == emp.EmployeePositionID).FirstOrDefault();

                        income.PayrollDate  = x.PayrollDate;
                        income.DailyRate    = position.DailyRate;
                        income.NoOfDays     = Convert.ToInt32(x.NoOfDays);
                        income.Amount       = x.Amount;
                        income.IncomeID     = x.IncomeID;
                        income.Trip         = x.Trip;
                        income.IncomePeriod = x.StDate.ToShortDateString() + " - " + x.ToDate.ToShortDateString();
                        income.PayrollID    = Convert.ToInt32(x.PayrollID);
                        lIncome.Add(income);
                    }

                    datagridview.ItemsSource = lIncome.OrderByDescending(m => m.IncomeID);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 12
0
        private void GetInfo()
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    var info = db.Incomes.Where(m => m.IncomeID == incomeid).FirstOrDefault();
                    var emp  = db.Employees.Where(m => m.EmployeeID == employeeid).FirstOrDefault();
                    tbAmount.Text            = info.Amount.ToString("G29");
                    tbEmployee.Text          = emp.LastName.ToUpper() + ", " + emp.FirstName.ToUpper();
                    dpToDate.SelectedDate    = info.ToDate;
                    dpStDate.SelectedDate    = info.StDate;
                    dpStartDate.SelectedDate = info.PayrollDate;
                    tbNoOfDays.Text          = info.NoOfDays.ToString("G29");
                    tbAmount.Text            = info.Amount.ToString("G29");

                    if (info.Trip == 1)
                    {
                        rb1st.IsChecked = true;
                    }
                    else
                    {
                        rb2nd.IsChecked = true;
                    }
                }
            }

            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 13
0
        private void GetHoliday()
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    var nightdiffs = db.NightDifferentials.Where(m => m.EmployeeID == empid).ToList();
                    lNightDiff = new List <DMSIClass._NightDiff>();
                    foreach (var x in nightdiffs)
                    {
                        DMSIClass._NightDiff nightdiff = new DMSIClass._NightDiff();
                        var nightshifttype             = db.NightShiftTypes.Where(m => m.NightShiftTypeID == x.NightShiftTypeID).FirstOrDefault();
                        var emp      = db.Employees.Where(m => m.EmployeeID == x.EmployeeID).FirstOrDefault();
                        var position = db.EmployeePositions.Where(m => m.EmployeePositionID == emp.EmployeePositionID).FirstOrDefault();
                        nightdiff.NightDiffIDType   = nightshifttype.Description;
                        nightdiff.NightDiffID       = x.NightDifferentialID;
                        nightdiff.NightDiffIDPeriod = x.StDate.ToShortDateString() + " - " + x.ToDate.ToShortDateString();
                        nightdiff.Value             = x.Value;
                        nightdiff.PayrollDate       = x.PayrollDate;
                        nightdiff.Amount            = x.Amount;
                        nightdiff.HourlyRate        = position.DailyRate / 8;

                        lNightDiff.Add(nightdiff);
                    }

                    datagridview.ItemsSource = lNightDiff.OrderByDescending(m => m.NightDiffID);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 14
0
        private void GetOvertime()
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    var overtimes = db.Overtimes.Where(m => m.EmployeID == empid).ToList();
                    lOvertime = new List <DMSIClass._Overtime>();
                    foreach (var x in overtimes)
                    {
                        DMSIClass._Overtime overtime = new DMSIClass._Overtime();
                        var overtimetype             = db.OvertimeTypes.Where(m => m.OvertimeTypeID == x.OvertimeTypeID).FirstOrDefault();
                        var emp      = db.Employees.Where(m => m.EmployeeID == x.EmployeID).FirstOrDefault();
                        var position = db.EmployeePositions.Where(m => m.EmployeePositionID == emp.EmployeePositionID).FirstOrDefault();
                        overtime.OvertimeType   = overtimetype.Description;
                        overtime.OvertimeID     = x.OvertimeID;
                        overtime.OvertimePeriod = x.StDate.ToShortDateString() + " - " + x.ToDate.ToShortDateString();
                        overtime.Value          = x.Value;
                        overtime.PayrollDate    = x.PayrollDate;
                        overtime.Amount         = x.Amount;
                        overtime.HourlyRate     = position.DailyRate / 8;

                        lOvertime.Add(overtime);
                    }

                    datagridview.ItemsSource = lOvertime.OrderByDescending(m => m.OvertimeID);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 15
0
        private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    cbLoanType.ItemsSource       = db.LoanTypes.OrderBy(m => m.Description).ToList();
                    cbLoanType.DisplayMemberPath = "Description";
                    cbLoanType.SelectedValuePath = "LoanTypeID";

                    cbPeriod.ItemsSource       = db.Periods.OrderBy(m => m.PeriodDescription).ToList();
                    cbPeriod.DisplayMemberPath = "PeriodDescription";
                    cbPeriod.SelectedValuePath = "PeriodID";

                    var emp = db.Employees.Where(m => m.EmployeeID == empid).FirstOrDefault();
                    tbEmployee.Text = (emp.LastName + ", " + emp.FirstName + " " + emp.MiddleName).ToUpper();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }


            if (mode == 2)
            {
                this.Title = "UPDATE LOAN";
                GetLoan();
            }
        }
Esempio n. 16
0
        private void GetEmployees()
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    lEmployee = new List <DMSIClass._Employee>();
                    var employees = db.Employees.ToList();

                    foreach (var x in employees)
                    {
                        DMSIClass._Employee employee = new DMSIClass._Employee();
                        var company  = db.Companies.Where(m => m.CompanyID == x.CompanyID).FirstOrDefault();
                        var position = db.EmployeePositions.Where(m => m.EmployeePositionID == x.EmployeePositionID).FirstOrDefault();

                        employee.Name       = (x.LastName + ", " + x.FirstName + " " + x.MiddleName).ToUpper();
                        employee.Company    = company.CompanyName;
                        employee.Position   = position.PositionName;
                        employee.EmployeeID = x.EmployeeID;
                        employee.EmployeeNo = x.EmployeeNumber;
                        employee.PositionID = x.EmployeePositionID;

                        lEmployee.Add(employee);
                    }

                    datagridview.ItemsSource = lEmployee.OrderBy(m => m.Name);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 17
0
        private void GetTardy()
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    var tardy = db.Tardies.Where(m => m.TardyID == tardyid).FirstOrDefault();
                    tbAmount.Text = tardy.Amount.ToString("G29");
                    tbValue.Text  = tardy.Value.ToString("G29");
                    dpPayrollDate.SelectedDate = tardy.PayrollDate;

                    if (tardy.Type == 1)
                    {
                        rbLate.IsChecked = true;
                    }
                    else
                    {
                        rbUndertime.IsChecked = true;
                    }
                }
            }

            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 18
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    if (tbAmount.Text == "" || tbValue.Text == "" || dpPayrollDate.SelectedDate == null || rbLate.IsChecked == false && rbUndertime.IsChecked == false)
                    {
                        MessageBox.Show("Required fields cannot be empty.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    if (mode == 1)
                    {
                        Tardy tardy = new Tardy();
                        tardy.Amount      = Decimal.Parse(tbAmount.Text);
                        tardy.EmployeeID  = empid;
                        tardy.PayrollDate = dpPayrollDate.SelectedDate.Value;
                        tardy.Value       = Convert.ToInt32(tbValue.Text);
                        if (rbLate.IsChecked == true)
                        {
                            tardy.Type = 1;
                        }
                        else
                        {
                            tardy.Type = 2;
                        }

                        db.Tardies.Add(tardy);
                        db.SaveChanges();
                        MessageBox.Show("Add Succesful", "System Succes!", MessageBoxButton.OK, MessageBoxImage.Information);
                        clear();
                    }
                    else if (mode == 2)
                    {
                        var tardy = db.Tardies.Where(m => m.TardyID == tardyid).FirstOrDefault();
                        tardy.Amount      = Decimal.Parse(tbAmount.Text);
                        tardy.EmployeeID  = empid;
                        tardy.PayrollDate = dpPayrollDate.SelectedDate.Value;
                        tardy.Value       = Convert.ToInt32(tbValue.Text);
                        if (rbLate.IsChecked == true)
                        {
                            tardy.Type = 1;
                        }
                        else
                        {
                            tardy.Type = 2;
                        }
                        db.SaveChanges();
                        MessageBox.Show("Update Succesful", "System Succes!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 19
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    if (tbAmortization.Text == "" || tbPrincipalAmount.Text == "" || tbTotalLoanAmount.Text == "" || tbTotalPayment.Text == "" || cbLoanType.SelectedItem == null || cbPeriod.SelectedItem == null || dpStartDate.SelectedDate == null || dpToDate.SelectedDate == null)
                    {
                        MessageBox.Show("Required fields cannot be empty.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }

                    if (mode == 1)
                    {
                        Loan loan = new Loan();
                        loan.EmployeeID      = empid;
                        loan.Amortization    = Decimal.Parse(tbAmortization.Text);
                        loan.PrincipalAmount = Decimal.Parse(tbPrincipalAmount.Text);
                        loan.TotalLoanAmount = Decimal.Parse(tbTotalLoanAmount.Text);
                        loan.TotalPayment    = Decimal.Parse(tbTotalPayment.Text);
                        loan.StDate          = dpStartDate.SelectedDate.Value;
                        loan.ToDate          = dpToDate.SelectedDate.Value;
                        loan.LoanTypeID      = Convert.ToInt32(cbLoanType.SelectedValue);
                        loan.PeriodID        = Convert.ToInt32(cbPeriod.SelectedValue);
                        db.Loans.Add(loan);
                        db.SaveChanges();
                        MessageBox.Show("Add Succesful", "System Succes!", MessageBoxButton.OK, MessageBoxImage.Information);
                        clear();
                    }
                    else if (mode == 2)
                    {
                        var loan = db.Loans.Where(m => m.LoanID == loanid).FirstOrDefault();
                        loan.EmployeeID      = empid;
                        loan.Amortization    = Decimal.Parse(tbAmortization.Text);
                        loan.PrincipalAmount = Decimal.Parse(tbPrincipalAmount.Text);
                        loan.TotalLoanAmount = Decimal.Parse(tbTotalLoanAmount.Text);
                        loan.TotalPayment    = Decimal.Parse(tbTotalPayment.Text);
                        loan.StDate          = dpStartDate.SelectedDate.Value;
                        loan.ToDate          = dpToDate.SelectedDate.Value;
                        loan.LoanTypeID      = Convert.ToInt32(cbLoanType.SelectedValue);
                        loan.PeriodID        = Convert.ToInt32(cbPeriod.SelectedValue);
                        db.SaveChanges();
                        MessageBox.Show("Update Succesful", "System Succes!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 20
0
 private void GetAdjustmentTypes()
 {
     try
     {
         using (var db = new DMSIPayrollEntities())
         {
             lOvertimeType            = db.OvertimeTypes.ToList();
             datagridview.ItemsSource = lOvertimeType.OrderBy(m => m.Description);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Esempio n. 21
0
 private void GetPeriods()
 {
     try
     {
         using (var db = new DMSIPayrollEntities())
         {
             lPeriod = db.Periods.ToList();
             datagridview.ItemsSource = lPeriod.OrderBy(m => m.PeriodDescription);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Esempio n. 22
0
 private void GetCompanies()
 {
     try
     {
         using (var db = new DMSIPayrollEntities())
         {
             lCompany = db.Companies.ToList();
             datagridview.ItemsSource = lCompany.OrderBy(m => m.CompanyName);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    if (cbNightShiftType.SelectedItem == null || tbValue.Text == "" || tbAmount.Text == "" || dpToDate.SelectedDate == null || dpStDate.SelectedDate == null || dpDate.SelectedDate == null)
                    {
                        MessageBox.Show("Required fields cannot be empty.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }


                    if (mode == 1)
                    {
                        NightDifferential NightDifferential = new NightDifferential();
                        NightDifferential.EmployeeID       = empid;
                        NightDifferential.PayrollDate      = dpDate.SelectedDate.Value;
                        NightDifferential.StDate           = dpStDate.SelectedDate.Value;
                        NightDifferential.ToDate           = dpToDate.SelectedDate.Value;
                        NightDifferential.Amount           = Decimal.Parse(tbAmount.Text);
                        NightDifferential.NightShiftTypeID = Convert.ToInt32(cbNightShiftType.SelectedValue);
                        NightDifferential.Value            = Convert.ToInt32(tbValue.Text);
                        db.NightDifferentials.Add(NightDifferential);
                        db.SaveChanges();
                        MessageBox.Show("Add Succesful", "System Succes!", MessageBoxButton.OK, MessageBoxImage.Information);
                        clear();
                    }
                    else if (mode == 2)
                    {
                        var nightdiff = db.NightDifferentials.Where(m => m.NightDifferentialID == nightdiffid).FirstOrDefault();
                        nightdiff.EmployeeID       = empid;
                        nightdiff.PayrollDate      = dpDate.SelectedDate.Value;
                        nightdiff.StDate           = dpStDate.SelectedDate.Value;
                        nightdiff.ToDate           = dpToDate.SelectedDate.Value;
                        nightdiff.Amount           = Decimal.Parse(tbAmount.Text);
                        nightdiff.NightShiftTypeID = Convert.ToInt32(cbNightShiftType.SelectedValue);
                        nightdiff.Value            = Decimal.Parse(tbValue.Text);
                        db.SaveChanges();
                        MessageBox.Show("Update Succesful", "System Succes!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 24
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new DMSIPayrollEntities())
                {
                    if (cbHolidayType.SelectedItem == null || tbNoOfDays.Text == "" || tbAmount.Text == "" || dpDate.SelectedDate == null || dpStDate.SelectedDate == null || dpToDate.SelectedDate == null)
                    {
                        MessageBox.Show("Required fields cannot be empty.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }


                    if (mode == 1)
                    {
                        Holiday holiday = new Holiday();
                        holiday.EmployeeID    = empid;
                        holiday.PayrollDate   = dpDate.SelectedDate.Value;
                        holiday.StDate        = dpStDate.SelectedDate.Value;
                        holiday.ToDate        = dpToDate.SelectedDate.Value;
                        holiday.Amount        = Decimal.Parse(tbAmount.Text);
                        holiday.HolidayTypeID = Convert.ToInt32(cbHolidayType.SelectedValue);
                        holiday.NoOfDays      = Decimal.Parse(tbNoOfDays.Text);
                        db.Holidays.Add(holiday);
                        db.SaveChanges();
                        MessageBox.Show("Add Succesful", "System Succes!", MessageBoxButton.OK, MessageBoxImage.Information);
                        clear();
                    }
                    else if (mode == 2)
                    {
                        var holiday = db.Holidays.Where(m => m.HolidayID == holidayid).FirstOrDefault();
                        holiday.EmployeeID    = empid;
                        holiday.PayrollDate   = dpDate.SelectedDate.Value;
                        holiday.StDate        = dpStDate.SelectedDate.Value;
                        holiday.ToDate        = dpToDate.SelectedDate.Value;
                        holiday.Amount        = Decimal.Parse(tbAmount.Text);
                        holiday.HolidayTypeID = Convert.ToInt32(cbHolidayType.SelectedValue);
                        holiday.NoOfDays      = Decimal.Parse(tbNoOfDays.Text);
                        db.SaveChanges();
                        MessageBox.Show("Update Succesful", "System Succes!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 25
0
 private void GetPeriod()
 {
     try
     {
         using (var db = new DMSIPayrollEntities())
         {
             var period = db.Periods.Where(m => m.PeriodID == periodid).FirstOrDefault();
             tbDescription.Text = period.PeriodDescription;
             tbPeriodCode.Text  = period.PeriodCode;
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Esempio n. 26
0
 private void Getcompany()
 {
     try
     {
         using (var db = new DMSIPayrollEntities())
         {
             var company = db.Companies.Where(m => m.CompanyID == companyid).FirstOrDefault();
             tbCompany.Text = company.CompanyName;
             tbAddress.Text = company.Address;
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Esempio n. 27
0
 private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         using (var db = new DMSIPayrollEntities())
         {
             cbPeriod.ItemsSource       = db.Periods.Where(m => m.PeriodID != 3).OrderBy(m => m.PeriodDescription).ToList();
             cbPeriod.DisplayMemberPath = "PeriodDescription";
             cbPeriod.SelectedValuePath = "PeriodID";
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Esempio n. 28
0
 private void GetIncomeType()
 {
     try
     {
         using (var db = new DMSIPayrollEntities())
         {
             var incomeType = db.IncomeTypes.Where(m => m.IncomeTypeID == incometypeid).FirstOrDefault();
             tbDescription.Text    = incomeType.Description;
             tbIncomeTypeCode.Text = incomeType.IncomeTypeCode;
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Esempio n. 29
0
 private void GetPosition()
 {
     try
     {
         using (var db = new DMSIPayrollEntities())
         {
             var position = db.EmployeePositions.Where(m => m.EmployeePositionID == positionid).FirstOrDefault();
             tbPosition.Text  = position.PositionName;
             tbDailyRate.Text = position.DailyRate.ToString();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Esempio n. 30
0
 private void GetAdjustment()
 {
     try
     {
         using (var db = new DMSIPayrollEntities())
         {
             var adjustment = db.Adjustments.Where(m => m.AdjustmentID == adjustmentid).FirstOrDefault();
             tbAmount.Text       = adjustment.Amount.ToString("G29");
             dpDate.SelectedDate = adjustment.PayrollDate;
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }