public async Task <ActionResult> Edit(Guid id) { ISession se = NHibernateHelper.CurrentSession; Employee o = await Task.Run(() => { return(se.Get <Employee>(id)); }); Employeecontact oc = o.Employeecontact; Employeejob oej = o.Employeejob; Employeesalary osa = o.Employeesalary; Employeequalification oq = o.Employeequalification; EmployeeView e = new EmployeeView { Employee = o, Employeecontact = oc == null ? new Employeecontact() : oc, Employeejob = oej == null ? new Employeejob() : oej, Employeesalary = osa == null ? new Employeesalary() : osa, Employeequalification = oq == null ? new Employeequalification() : oq }; ViewBag.form_id = "edit-form"; ViewBag.users = se.QueryOver <Domain.Model.User>() .OrderBy(x => x.Username).Asc.List(); ViewBag.designations = se.QueryOver <Designation>() .OrderBy(x => x.Title).Asc.List(); ViewBag.employment_statuses = se.QueryOver <Employmentstatus>() .OrderBy(x => x.Name).Asc.List(); ViewBag.job_categories = se.QueryOver <Jobcategory>() .OrderBy(x => x.Name).Asc.List(); ViewBag.departments = se.QueryOver <Department>() .OrderBy(x => x.Name).Asc.List(); return(View("_form", e)); }
public static double GetTotalDeductions(Employeesalary employee_salary) { if (employee_salary == null) { return(0); } return(employee_salary.Epf + employee_salary.Socso + employee_salary.Incometax); }
public static async Task <double[]> GetTotalEarningsHourly(Employeesalary employee_salary, Dictionary <string, object> filters) { double total_hours = await AttendanceHelper.GetTotalHours(filters); double rate = await PayrateHelper.GetPayRate(filters); double earnings = (total_hours * rate) + employee_salary.Allowance; double[] a = new double[] { earnings, total_hours, rate }; return(a); }
public static double GetTotalEarnings(Employeesalary employee_salary, double adjustment, double total_overtime_earnings) { if (employee_salary == null) { return(0); } double amt = employee_salary.Salary + adjustment; return(amt + employee_salary.Allowance + total_overtime_earnings); }
public static Employeesalary Find(object id) { Employeesalary o = null; ISession se = NHibernateHelper.CurrentSession; o = se.Get <Employeesalary>(id); if (o == null) { o = new Employeesalary(); } return(o); }
public static Employeesalary GetObject(Employee e, FormCollection fc) { string paramSalary = GetParam("salary", fc); double salary = CommonHelper.GetValue <double>(paramSalary); string paramAllowance = GetParam("allowance", fc); double allowance = CommonHelper.GetValue <double>(paramAllowance); string paramEpf = GetParam("epf", fc); double epf = CommonHelper.GetValue <double>(paramEpf); string paramSocso = GetParam("socso", fc); double socso = CommonHelper.GetValue <double>(paramSocso); string paramIncometax = GetParam("income_tax", fc); double incometax = CommonHelper.GetValue <double>(paramIncometax); string paramPaytype = GetParam("pay_type", fc); int? paytype = string.IsNullOrEmpty(paramPaytype) ? null : new Nullable <int>(CommonHelper.GetValue <int>(paramPaytype)); Employeesalary o = e.Employeesalary; if (o == null) { o = new Employeesalary(); o.Id = e.Id; } o.Salary = salary; o.Allowance = allowance; o.Epf = epf; o.Socso = socso; o.Incometax = incometax; o.Bankname = GetParam("bank_name", fc); o.Bankaccno = GetParam("bank_acc_no", fc); o.Bankacctype = GetParam("bank_acc_type", fc); o.Bankaddress = GetParam("bank_address", fc); o.Epfno = GetParam("epf_no", fc); o.Socsono = GetParam("socso_no", fc); o.Incometaxno = GetParam("ncome_tax_no", fc); o.Paytype = paytype; return(o); }
public async Task <ActionResult> Payslip(int month, int year) { ISession se = NHibernateHelper.CurrentSession; object id = Session["employee_id"]; Employee employee = se.Get <Employee>(id); Employeesalary employee_salary = employee.Employeesalary; PayslipModel o = new PayslipModel(); o.Period = string.Format("{0}-{1}", CommonHelper.GetMonthName(month), year); o.Employee = employee; o.EmployeeSalary = employee_salary; if (employee_salary == null) { o.EmployeeSalary = new Employeesalary(); return(View("payslip_monthly", o)); } else { if (employee_salary.Paytype == 1) { Dictionary <string, object> filters = new Dictionary <string, object> { { "year", year }, { "month", month }, { "staff_id", employee.Staffid } }; o.TotalOvertime = await PayslipHelper.GetTotalOvertime(filters); o.TotalOvertimeEarnings = await PayslipHelper.GetTotalOvertimeEarnings(filters, o.TotalOvertime); o.Adjustment = await SalaryadjustmentHelper.GetSalaryAdjustment(filters); o.TotalEarnings = PayslipHelper.GetTotalEarnings(employee_salary, o.Adjustment, o.TotalOvertimeEarnings); o.TotalDeduct = PayslipHelper.GetTotalDeductions(employee_salary); o.NettSalary = PayslipHelper.GetNettSalary(o.TotalEarnings, o.TotalDeduct); o.BasicPay = employee_salary.Salary + o.Adjustment; return(View("payslip_monthly", o)); } else { Dictionary <string, object> filters = new Dictionary <string, object> { { "year", year }, { "month", month }, { "staff_id", employee.Staffid } }; double[] x = await PayslipHelper.GetTotalEarningsHourly(employee_salary, filters); o.TotalEarnings = x[0]; o.TotalHours = x[1]; o.HourlyPayRate = x[2]; o.TotalDeduct = PayslipHelper.GetTotalDeductions(employee_salary); o.NettSalary = PayslipHelper.GetNettSalaryHourly(o.TotalEarnings, o.TotalDeduct); return(View("payslip_hourly", o)); } } }
private static async Task CreateSeed(ISessionFactory s) { using (ISession se = s.OpenSession()) { using (ITransaction tx = se.BeginTransaction()) { User a = new User { Username = "******", Password = "******", Role = 1, Status = true }; a.EncryptPassword(); se.SaveOrUpdate(a); a = new User { Username = "******", Password = "******", Role = 2, Status = true }; a.EncryptPassword(); se.SaveOrUpdate(a); Employee o = new Employee { Staffid = "S0001", Firstname = "Ben", Lastname = "Ng", Newic = "77665544", Gender = "M", Maritalstatus = "S", Nationality = "Malaysian", Dob = new DateTime(1988, 6, 5), Placeofbirth = "PJ", Race = "Chinese", Isbumi = false, User = a }; se.SaveOrUpdate(o); Employeecontact ect = new Employeecontact { Id = o.Id, Address1 = "No. 6, Jalan Awan Kecil 1", Address2 = "Taman OUG", Address3 = "Off Jalan Klang Lama", City = "KL", State = "WP", Postcode = "58200", Country = "Malaysia", Homephone = "88098776", Mobilephone = "77609887", Workemail = "*****@*****.**", Otheremail = "*****@*****.**", }; se.SaveOrUpdate(ect); await CreateListAttendance(se, o.Staffid, o); Employeesalary es = new Employeesalary { Id = o.Id, Salary = 0, Allowance = 45, Epf = 278, Socso = 46, Incometax = 57, Bankname = "RHB", Bankaccno = "5509800076", Bankacctype = "Savings", Bankaddress = "Jalan Awan Besar", Epfno = "443987542", Socsono = "8876908539", Incometaxno = "439877055", Paytype = 2 }; se.SaveOrUpdate(es); Designation des = new Designation { Title = "Software Developer" }; se.SaveOrUpdate(des); Department dept = new Department { Name = "R&D" }; se.SaveOrUpdate(dept); Jobcategory jobcat = new Jobcategory { Name = "Software Development" }; se.SaveOrUpdate(jobcat); Employmentstatus empstat = new Employmentstatus { Name = "Probation" }; se.SaveOrUpdate(empstat); empstat = new Employmentstatus { Name = "Confirmed" }; se.SaveOrUpdate(empstat); Employeejob empjob = new Employeejob { Id = o.Id, Designation = des, Department = dept, Employmentstatus = empstat, Jobcategory = jobcat, Joindate = new DateTime(2000, 1, 1), Confirmdate = new DateTime(2000, 3, 1) }; se.SaveOrUpdate(empjob); // a = new User { Username = "******", Password = "******", Role = 2, Status = true }; a.EncryptPassword(); se.SaveOrUpdate(a); o = new Employee { Staffid = "S0002", Firstname = "Ken", Lastname = "Lee", Newic = "785400", Gender = "M", Maritalstatus = "S", Nationality = "Malaysian", Dob = new DateTime(1986, 6, 5), Placeofbirth = "PJ", Race = "Chinese", Isbumi = false, User = a }; se.SaveOrUpdate(o); ect = new Employeecontact { Id = o.Id, Address1 = "No. 7, Jalan Putra 1", Address2 = "Taman Pinang", Address3 = "Off Jalan Putra Perdana", City = "KL", State = "WP", Postcode = "59200", Country = "Malaysia", Homephone = "88028776", Mobilephone = "77659887", Workemail = "*****@*****.**", Otheremail = "*****@*****.**" }; se.SaveOrUpdate(ect); await CreateListAttendance(se, o.Staffid, o); es = new Employeesalary { Id = o.Id, Salary = 0, Allowance = 55, Epf = 298, Socso = 65, Incometax = 95, Bankname = "RHB", Bankaccno = "5509800077", Bankacctype = "Savings", Bankaddress = "Jalan Awan Besar", Epfno = "443987548", Socsono = "8878908539", Incometaxno = "439899055", Paytype = 2 }; se.SaveOrUpdate(es); des = new Designation { Title = "Account Executive" }; se.SaveOrUpdate(des); dept = new Department { Name = "Admin" }; se.SaveOrUpdate(dept); jobcat = new Jobcategory { Name = "Administration" }; se.SaveOrUpdate(jobcat); empjob = new Employeejob { Id = o.Id, Designation = des, Department = dept, Employmentstatus = empstat, Jobcategory = jobcat, Joindate = new DateTime(2000, 2, 1), Confirmdate = new DateTime(2000, 4, 1) }; se.SaveOrUpdate(empjob); // a = new User { Username = "******", Password = "******", Role = 2, Status = true }; a.EncryptPassword(); se.SaveOrUpdate(a); o = new Employee { Staffid = "S0003", Firstname = "Steve", Lastname = "Yap", Newic = "65098765", Gender = "M", Maritalstatus = "S", Nationality = "Malaysian", Dob = new DateTime(1974, 6, 5), Placeofbirth = "PJ", Race = "Chinese", Isbumi = false, User = a }; se.SaveOrUpdate(o); ect = new Employeecontact { Id = o.Id, Address1 = "No. 5, Jalan Bukit Bintang", Address2 = "Taman Bintang", Address3 = "Off Jalan Bukit", City = "KL", State = "WP", Postcode = "57200", Country = "Malaysia", Homephone = "88798776", Mobilephone = "79609887", Workemail = "*****@*****.**", Otheremail = "*****@*****.**" }; se.SaveOrUpdate(ect); await CreateListAttendance(se, o.Staffid, o); es = new Employeesalary { Id = o.Id, Salary = 0, Allowance = 55, Epf = 300, Socso = 62, Incometax = 48, Bankname = "RHB", Bankaccno = "5509100076", Bankacctype = "Savings", Bankaddress = "Jalan Awan Besar", Epfno = "473987542", Socsono = "8879908539", Incometaxno = "439817055", Paytype = 2 }; se.SaveOrUpdate(es); des = new Designation { Title = "Sales Executive" }; se.SaveOrUpdate(des); dept = new Department { Name = "Sales" }; se.SaveOrUpdate(dept); jobcat = new Jobcategory { Name = "Sales" }; se.SaveOrUpdate(jobcat); empjob = new Employeejob { Id = o.Id, Designation = des, Department = dept, Employmentstatus = empstat, Jobcategory = jobcat, Joindate = new DateTime(2000, 3, 1), Confirmdate = new DateTime(2000, 5, 1) }; se.SaveOrUpdate(empjob); await CreatePayRate(se, "S0001"); await CreatePayRate(se, "S0002"); await CreatePayRate(se, "S0003"); // a = new User { Username = "******", Password = "******", Role = 2, Status = true }; a.EncryptPassword(); se.SaveOrUpdate(a); o = new Employee { Staffid = "S0004", Firstname = "Kelly", Lastname = "Yap", Newic = "55441122", Gender = "F", Maritalstatus = "S", Nationality = "Malaysian", Dob = new DateTime(1979, 6, 5), Placeofbirth = "KL", Race = "Chinese", Isbumi = false, User = a }; se.SaveOrUpdate(o); ect = new Employeecontact { Id = o.Id, Address1 = "No. 2, Jalan Kerinchi 5", Address2 = "Taman Bukit Kerinchi", Address3 = "Off Jalan Kerinchi Besar", City = "KL", State = "WP", Postcode = "56200", Country = "Malaysia", Homephone = "88098476", Mobilephone = "77609187", Workemail = "*****@*****.**", Otheremail = "*****@*****.**" }; se.SaveOrUpdate(ect); await CreateListAttendance(se, o.Staffid, o); Random r = new Random(); es = new Employeesalary { Id = o.Id, Salary = r.Next(2500, 3000), Allowance = r.Next(60, 100), Epf = r.Next(100, 200), Socso = r.Next(90, 100), Incometax = r.Next(100, 200), Bankname = "RHB", Bankaccno = "667743290", Bankacctype = "Savings", Bankaddress = "Jalan Pinang", Epfno = "59876000", Socsono = "76545", Incometaxno = "ASD965777", Paytype = 1 }; se.SaveOrUpdate(es); des = new Designation { Title = "Marketing Executive" }; se.SaveOrUpdate(des); dept = new Department { Name = "Marketing" }; se.SaveOrUpdate(dept); jobcat = new Jobcategory { Name = "Marketing" }; se.SaveOrUpdate(jobcat); empjob = new Employeejob { Id = o.Id, Designation = des, Department = dept, Employmentstatus = empstat, Jobcategory = jobcat, Joindate = new DateTime(2000, 1, 1), Confirmdate = new DateTime(2000, 3, 1) }; se.SaveOrUpdate(empjob); await CreateOvertimeRate(se); await CreateSalaryAdj(se, o.Staffid); tx.Commit(); } } }
public async Task <JsonResult> Update(Guid id, FormCollection fc) { ISession se = NHibernateHelper.CurrentSession; Employee o = await Task.Run(() => { return(se.Get <Employee>(id)); }); o = await EmployeeHelper.GetObject(se, o, fc); Employeecontact oc = EmployeecontactHelper.GetObject(o, fc); Employeejob oej = await EmployeejobHelper.GetObject(se, o, fc);; Employeesalary osa = EmployeesalaryHelper.GetObject(o, fc); Employeequalification oq = EmployeequalificationHelper.GetObject(o, fc); bool b1 = EmployeecontactHelper.IsEmptyParams(fc); bool b2 = EmployeejobHelper.IsEmptyParams(fc); bool b3 = EmployeesalaryHelper.IsEmptyParams(fc); bool b4 = EmployeequalificationHelper.IsEmptyParams(fc); Dictionary <string, object> employeeErrors = o.IsValid(se); Dictionary <string, object> employeeContactErrors = null; Dictionary <string, object> employeeJobErrors = null; Dictionary <string, object> employeeSalaryErrors = null; Dictionary <string, object> employeeQualificationErrors = null; bool v1 = employeeErrors == null; bool v2 = b1 ? true : (employeeContactErrors = oc.IsValid()) == null; bool v3 = b2 ? true : (employeeJobErrors = oej.IsValid()) == null; bool v4 = b3 ? true : (employeeSalaryErrors = osa.IsValid()) == null; bool v5 = b4 ? true : (employeeQualificationErrors = oq.IsValid()) == null; if (!v1 || !v2 || !v3 || !v4 || !v5) { Dictionary <string, object> err = new Dictionary <string, object> { { "error", 1 }, { "employee", CommonHelper.GetErrors(employeeErrors) }, { "employee_contact", CommonHelper.GetErrors(employeeContactErrors) }, { "employee_job", CommonHelper.GetErrors(employeeJobErrors) }, { "employee_salary", CommonHelper.GetErrors(employeeSalaryErrors) }, { "employee_qualification", CommonHelper.GetErrors(employeeQualificationErrors) } }; return(Json(err, JsonRequestBehavior.AllowGet)); } await Task.Run(() => { using (ITransaction tx = se.BeginTransaction()) { se.SaveOrUpdate(o); if (!b1) { se.SaveOrUpdate(oc); } if (!b2) { se.SaveOrUpdate(oej); } if (!b3) { se.SaveOrUpdate(osa); } if (!b4) { se.SaveOrUpdate(oq); } tx.Commit(); } }); return(Json(new Dictionary <string, object> { { "success", 1 }, { "message", "Employee was successfully updated." } }, JsonRequestBehavior.AllowGet)); }