Beispiel #1
0
        private void btnAddEmployee_Click(object sender, RoutedEventArgs e)
        {
            if (txtFirst.Text != "" && txtLast.Text != "" && txtIRDNum.Text != "" && txtBankNum.Text != "" && txtPayRate.Text != "")
            {
                using (var db = new LoginContext())
                {
                    Employee EmployeeObj = new Employee();
                    DateTime dt          = dpStartDate.SelectedDate.Value;

                    EmployeeObj.First_Name   = txtFirst.Text;
                    EmployeeObj.Last_Name    = txtLast.Text;
                    EmployeeObj.IRD_Number   = txtIRDNum.Text;
                    EmployeeObj.Taxcode      = cbTaxCode.SelectionBoxItem.ToString();
                    EmployeeObj.Kiwisaver    = Convert.ToDouble(cbKiwiSaver.SelectionBoxItem.ToString());
                    EmployeeObj.StudentLoan  = cbStudentLoan.SelectionBoxItem.ToString();
                    EmployeeObj.Start_Date   = dt;
                    EmployeeObj.Pay_Rate     = Convert.ToDouble(txtPayRate.Text);
                    EmployeeObj.Bank_ACC_Num = txtBankNum.Text;
                    EmployeeObj.Annual_Leave = 5;
                    EmployeeObj.Sick_Days    = 5;

                    var User = (from u in db.LoginInfo
                                where u.EMP_ID == ManagerID
                                select u).First();

                    User.Employees.Add(EmployeeObj);

                    db.SaveChanges();
                    DGSearchEmployee.ItemsSource = db.EmployeeInfo.ToList();
                    MessageBox.Show("Employee Added Successfully");
                }
            }
        }
Beispiel #2
0
        private void DGSearchEmployee_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                using (var db = new LoginContext())
                {
                    var row = DGSearchEmployee.SelectedItems[0];

                    Type type = row.GetType();

                    txtFirst.Text            = (string)type.GetProperty("First_Name").GetValue(row, null);
                    txtLast.Text             = (string)type.GetProperty("Last_Name").GetValue(row, null);
                    txtIRDNum.Text           = (string)type.GetProperty("IRD_Number").GetValue(row, null);
                    cbTaxCode.SelectedValue  = (string)type.GetProperty("Taxcode").GetValue(row, null);
                    cbKiwiSaver.Text         = (double)type.GetProperty("Kiwisaver").GetValue(row, null) + "";
                    cbStudentLoan.Text       = (string)type.GetProperty("StudentLoan").GetValue(row, null);
                    dpStartDate.SelectedDate = (DateTime)type.GetProperty("Start_Date").GetValue(row, null);
                    txtPayRate.Text          = (double)type.GetProperty("Pay_Rate").GetValue(row, null) + "";
                    txtBankNum.Text          = (string)type.GetProperty("Bank_ACC_Num").GetValue(row, null);
                }
            }
            catch (Exception)
            {
            }
        }
Beispiel #3
0
        public double payment()
        {
            using (var db = new LoginContext())
            {
                Employee EmployeeDB = new Employee();
                annualPay = grossPay * 52;

                if (annualPay <= 14000)
                {
                    taxDeductionYearly = annualPay * tax1;
                    taxDeductionWeekly = taxDeductionYearly / 52;
                    takeHomePayYearly  = annualPay - taxDeductionYearly;
                    takeHomePayWeekly  = takeHomePayYearly / 52;
                }
                else if (annualPay >= 14000 && annualPay <= 48000)
                {
                    leftoverPay        = annualPay - 14000;
                    taxDeductionYearly = leftoverPay * tax2;
                    taxDeductionYearly = taxDeductionYearly + 1470;
                    taxDeductionWeekly = taxDeductionYearly / 52;
                    takeHomePayYearly  = annualPay - taxDeductionYearly;
                    takeHomePayWeekly  = takeHomePayYearly / 52;
                }
                else if (annualPay >= 48000 && annualPay <= 70000)
                {
                    leftoverPay        = annualPay - 48000;
                    taxDeductionYearly = leftoverPay * tax3;
                    taxDeductionYearly = taxDeductionYearly + 1470 + 5950;
                    taxDeductionWeekly = taxDeductionYearly / 52;
                    takeHomePayYearly  = annualPay - taxDeductionYearly;
                    takeHomePayWeekly  = takeHomePayYearly / 52;
                }
                else if (annualPay >= 70000)
                {
                    leftoverPay        = annualPay - 70000;
                    taxDeductionYearly = leftoverPay * tax4;
                    taxDeductionYearly = taxDeductionYearly + 1470 + 5950 + 6600;
                    taxDeductionWeekly = taxDeductionYearly / 52;
                    takeHomePayYearly  = annualPay - taxDeductionYearly;
                    takeHomePayWeekly  = takeHomePayYearly / 52;
                }

                if (KiwisaverPercent != 0)
                {
                    KiwisaverPercent   = KiwisaverPercent / 100;
                    KiwiSaverDeduction = takeHomePayWeekly * KiwisaverPercent;
                    takeHomePayWeekly  = takeHomePayWeekly - KiwiSaverDeduction;
                }

                if (studentLoan == "Yes")
                {
                    studentLoanDeduction = takeHomePayWeekly * studentLoanPercent;
                    takeHomePayWeekly    = takeHomePayWeekly - studentLoanDeduction;
                }
            }
            return(takeHomePayWeekly);
        }
Beispiel #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            lblWelcome.Content += " " + EmployeeName + "\nCompany Name: " + CompanyName;

            using (var db = new LoginContext())
            {
                DGEmployees.ItemsSource = db.EmployeeInfo.ToList();
            }
        }
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new LoginContext())
            {
                string companyName  = txtCompanyName.Text;
                string employeeName = txtEmployeeName.Text;
                string irdNumber    = txtIRD.Text;
                string bankNumber   = txtAcountNum.Text;
                string userName     = txtUserName.Text;
                string password     = txtPassword.Password;
                string passwordAuth = txtPasswordAuth.Password;

                if (companyName != "" && employeeName != "" && irdNumber != "" && bankNumber != "" && userName != "" && password != "" && passwordAuth != "")
                {
                    if (password == passwordAuth && password != "" && passwordAuth != "")
                    {
                        var User = (from u in db.LoginInfo
                                    where u.UserName == userName
                                    select u);

                        if (User.Any())
                        {
                            MessageBox.Show("The Username that you've selected is already taken");
                        }
                        else
                        {
                            var newUser = new LoginID
                            {
                                CompanyName   = companyName,
                                EmployeeName  = employeeName,
                                IRDNumber     = irdNumber,
                                AccountNumber = bankNumber,
                                UserName      = userName,
                                Password      = password
                            };

                            db.LoginInfo.Add(newUser);
                            db.SaveChanges();
                            MessageBox.Show("User Succesfully Created");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please make sure passwords are the same");
                    }
                }
                else
                {
                    MessageBox.Show("Please fill in all the information");
                }
            }
        }
Beispiel #6
0
        private void addUpdateEmployee_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new LoginContext())
            {
                var User = (from u in db.LoginInfo
                            select new { u.EMP_ID, u.CompanyName, u.EmployeeName });

                var emp = User.First();

                AddUpdateEmployee AUEmployee = new AddUpdateEmployee(emp.EMP_ID, emp.EmployeeName, emp.CompanyName);
                AUEmployee.Show();
                Hide();
                Close();
            }
        }
Beispiel #7
0
        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new LoginContext())
            {
                var User = (from u in db.LoginInfo
                            select new { u.EMP_ID, u.CompanyName, u.EmployeeName });

                var emp = User.First();

                MainUI mainUI = new MainUI(emp.EMP_ID, emp.EmployeeName, emp.CompanyName);
                mainUI.Show();
                Hide();
                Close();
            }
        }
Beispiel #8
0
        private void txtSearch_TextChanged(object sender, TextChangedEventArgs e)
        {
            using (var db = new LoginContext())
            {
                var sQuery = from x in db.EmployeeInfo
                             select x;

                if (!string.IsNullOrEmpty(txtSearch.Text))
                {
                    sQuery = sQuery.Where(x => x.First_Name.Contains(txtSearch.Text) || x.Last_Name.Contains(txtSearch.Text));
                }

                DGSearchEmployee.ItemsSource = sQuery.ToList();
            }
        }
Beispiel #9
0
        private void DGEmployees_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                using (var db = new LoginContext())
                {
                    cbSickLeave.Items.Clear();
                    cbAnnualLeave.Items.Clear();

                    var row = DGEmployees.SelectedItems[0];

                    Type type = row.GetType();

                    double sickLeave   = (double)type.GetProperty("Sick_Days").GetValue(row, null);
                    double annualLeave = (double)type.GetProperty("Annual_Leave").GetValue(row, null);

                    for (int i = 1; i <= sickLeave; i++)
                    {
                        cbSickLeave.Items.Add(i);
                    }

                    for (int i = 1; i <= annualLeave; i++)
                    {
                        cbAnnualLeave.Items.Add(i);
                    }

                    tbEmpInfo.Text  = " EMPLOYEE INFORMATION \n";
                    tbEmpInfo.Text += "\n First Name: " + (string)type.GetProperty("First_Name").GetValue(row, null);
                    tbEmpInfo.Text += "\n Last Name: " + (string)type.GetProperty("Last_Name").GetValue(row, null);
                    tbEmpInfo.Text += "\n IRD Number: " + (string)type.GetProperty("IRD_Number").GetValue(row, null);
                    tbEmpInfo.Text += "\n Tax Code: " + (string)type.GetProperty("Taxcode").GetValue(row, null);
                    tbEmpInfo.Text += "\n Kiwisaver: " + (double)type.GetProperty("Kiwisaver").GetValue(row, null) + "%";
                    tbEmpInfo.Text += "\n Student Loan: " + (string)type.GetProperty("StudentLoan").GetValue(row, null);
                    tbEmpInfo.Text += "\n Start Date: " + (DateTime)type.GetProperty("Start_Date").GetValue(row, null);
                    tbEmpInfo.Text += "\n Bank Account Number: " + (string)type.GetProperty("Bank_ACC_Num").GetValue(row, null);
                    tbEmpInfo.Text += "\n Annual Leave Days: " + (double)type.GetProperty("Annual_Leave").GetValue(row, null);
                    tbEmpInfo.Text += "\n Sick Days Remaining: " + (double)type.GetProperty("Sick_Days").GetValue(row, null);
                    tbEmpInfo.Text += "\n Pay Rate: $" + (double)type.GetProperty("Pay_Rate").GetValue(row, null);
                }
            }
            catch (Exception)
            {
            }
        }
Beispiel #10
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            cbTaxCode.Items.Add("M");
            cbTaxCode.Items.Add("M SL");
            cbTaxCode.Items.Add("ME");
            cbTaxCode.Items.Add("ME SL");
            cbTaxCode.Items.Add("SB");
            cbTaxCode.Items.Add("SB SL");
            cbTaxCode.Items.Add("S");
            cbTaxCode.Items.Add("S SL");
            cbTaxCode.Items.Add("SH");
            cbTaxCode.Items.Add("SH SL");
            cbTaxCode.Items.Add("ST SL");

            using (var db = new LoginContext())
            {
                DGSearchEmployee.ItemsSource = db.EmployeeInfo.ToList();
            }
        }
Beispiel #11
0
        private void btnUpdateEmployee_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtFirst.Text != "" && txtLast.Text != "" && txtIRDNum.Text != "" && txtBankNum.Text != "" && txtPayRate.Text != "")
                {
                    using (var db = new LoginContext())
                    {
                        Employee EmployeeObj = new Employee();
                        DateTime dt          = dpStartDate.SelectedDate.Value;

                        var  row  = DGSearchEmployee.SelectedItems[0];
                        Type type = row.GetType();

                        var ID = (int)type.GetProperty("EMPLOYEE_ID").GetValue(row, null);


                        var User = (from u in db.EmployeeInfo
                                    where u.EMPLOYEE_ID == ID
                                    select u).First();

                        User.First_Name   = txtFirst.Text;
                        User.Last_Name    = txtLast.Text;
                        User.IRD_Number   = txtIRDNum.Text;
                        User.Taxcode      = cbTaxCode.SelectionBoxItem.ToString();
                        User.Kiwisaver    = Convert.ToDouble(cbKiwiSaver.SelectionBoxItem.ToString());
                        User.StudentLoan  = cbStudentLoan.SelectionBoxItem.ToString();
                        User.Pay_Rate     = Convert.ToDouble(txtPayRate.Text);
                        User.Bank_ACC_Num = txtBankNum.Text;

                        db.SaveChanges();
                        DGSearchEmployee.ItemsSource = db.EmployeeInfo.ToList();
                        MessageBox.Show("Employee Updated Successfully");
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please Select An Employee");
            }
        }
Beispiel #12
0
        private void deleteEmployee_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Are You Sure?", "Delete Employee", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
            {
                using (var db = new LoginContext())
                {
                    Employee emp = (Employee)DGEmployees.SelectedItems[0];
                    int      ID  = emp.EMPLOYEE_ID;

                    var User = (from c in db.EmployeeInfo
                                where c.EMPLOYEE_ID == ID
                                select c).First();

                    db.EmployeeInfo.Remove(User);

                    db.SaveChanges();
                    MessageBox.Show("Employee Successfully Deleted");
                    DGEmployees.ItemsSource = db.EmployeeInfo.ToList();
                }
            }
        }
Beispiel #13
0
        private void btnPay_Click(object sender, RoutedEventArgs e)
        {
            if (txtHoursWorked.Text != "" && DGEmployees.SelectedItem != null)
            {
                using (var db = new LoginContext())
                {
                    Payment  objPayment  = new Payment();
                    Employee objEmployee = new Employee();

                    var row = DGEmployees.SelectedItems[0];

                    Type type = row.GetType();

                    DateTime startDate      = (DateTime)type.GetProperty("Start_Date").GetValue(row, null);
                    DateTime sickLeaveRenew = startDate.AddDays(365);
                    if (DateTime.Now == sickLeaveRenew)
                    {
                        objEmployee.Start_Date   = DateTime.Today;
                        objEmployee.Sick_Days    = objEmployee.Sick_Days + 5;
                        objEmployee.Annual_Leave = objEmployee.Annual_Leave + 20;
                    }

                    objSalary.hoursWorked      = Convert.ToDouble(txtHoursWorked.Text);
                    objSalary.studentLoan      = (string)type.GetProperty("StudentLoan").GetValue(row, null);
                    objSalary.payRate          = (double)type.GetProperty("Pay_Rate").GetValue(row, null);
                    objSalary.KiwisaverPercent = (double)type.GetProperty("Kiwisaver").GetValue(row, null);

                    objSalary.sickLeave   = Convert.ToDouble(cbSickLeave.SelectedValue);
                    objSalary.annualLeave = Convert.ToDouble(cbAnnualLeave.SelectedValue);

                    objSalary.grossPayment();
                    objSalary.payment();

                    objPayment.Gross_Income           = Convert.ToDouble(objSalary.annualPay);
                    objPayment.Payment_Date           = DateTime.Today;
                    objPayment.Sick_Days_Used         = Convert.ToDouble(cbSickLeave.SelectedValue);
                    objPayment.Annual_Leave           = Convert.ToDouble(cbAnnualLeave.SelectedValue);
                    objPayment.Tax_Deduction          = Convert.ToDouble(objSalary.taxDeductionWeekly);
                    objPayment.Kiwi_Saver_Deduction   = Convert.ToDouble(objSalary.KiwiSaverDeduction);
                    objPayment.StudentLoan_Deduction  = Convert.ToDouble(objSalary.studentLoanDeduction);
                    objPayment.Yearly_Income          = Convert.ToDouble(objSalary.takeHomePayYearly);
                    objPayment.Sick_Days_Remaining    = (double)type.GetProperty("Sick_Days").GetValue(row, null);
                    objPayment.Annual_Leave_Remaining = (double)type.GetProperty("Annual_Leave").GetValue(row, null);
                    var id = (int)type.GetProperty("EMPLOYEE_ID").GetValue(row, null);

                    var User = (from u in db.EmployeeInfo
                                where u.EMPLOYEE_ID == id
                                select u).First();

                    User.Sick_Days    = User.Sick_Days - Convert.ToDouble(cbSickLeave.SelectedValue);
                    User.Annual_Leave = User.Annual_Leave - Convert.ToDouble(cbAnnualLeave.SelectedValue);
                    objPayment.Sick_Days_Remaining    = objPayment.Sick_Days_Remaining - Convert.ToDouble(cbSickLeave.SelectedValue);
                    objPayment.Annual_Leave_Remaining = objPayment.Annual_Leave_Remaining - Convert.ToDouble(cbAnnualLeave.SelectedValue);

                    User.Payments.Add(objPayment);
                    db.SaveChanges();

                    tbResult.Text  = "PAYSLIP FOR " + (string)type.GetProperty("First_Name").GetValue(row, null) + " " + (string)type.GetProperty("Last_Name").GetValue(row, null);
                    tbResult.Text += "\n\nHOURS WORKED: " + objSalary.hoursWorked.ToString();
                    tbResult.Text += " @ " + objSalary.payRate.ToString("$" + "#.##");
                    tbResult.Text += "\nSICK LEAVE USED: " + objSalary.sickLeave / 8;
                    tbResult.Text += "\nANNUAL LEAVE USED: " + objSalary.annualLeave / 8;
                    tbResult.Text += "\nGROSS PAY: $" + objSalary.grossPay.ToString("#.##");
                    tbResult.Text += "\nTAX DEDUCTIONS: $" + objSalary.taxDeductionWeekly.ToString("#.##");
                    tbResult.Text += "\nTAX CODE: " + (string)type.GetProperty("Taxcode").GetValue(row, null);
                    tbResult.Text += "\nSTUDENT LOANS DEDUCTION: " + objSalary.studentLoanDeduction.ToString("$" + "#.##");
                    tbResult.Text += "\nKIWISAVER DEDUCTION: " + objSalary.KiwiSaverDeduction.ToString("$" + "#.##");
                    tbResult.Text += "\n\nTAKE HOME PAY: $" + objSalary.takeHomePayWeekly.ToString("#.##");
                    tbResult.Text += "\n\nSICK DAYS REMAINING: " + objPayment.Sick_Days_Remaining;
                    tbResult.Text += "\nANNUAL LEAVE REMAINING: " + objPayment.Annual_Leave_Remaining;

                    DGEmployees.ItemsSource = db.EmployeeInfo.ToList();
                    MessageBox.Show("Payment Processed");
                }
            }
            else
            {
                MessageBox.Show("Select an employee or allocate hours worked");
            }
        }