示例#1
0
        public ActionResult Create([Bind(Include = "ID,DeptName")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(department));
        }
示例#2
0
        public ActionResult Create([Bind(Include = "ID,EmpID,Regular_Hours,Overtime_Hours,Holiday,PTO,Vacation,DateTime")] Hour hour)
        {
            if (ModelState.IsValid)
            {
                db.Hours.Add(hour);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmpID = new SelectList(db.Employees, "ID", "FirstName", hour.EmpID);
            return(View(hour));
        }
        public ActionResult Create([Bind(Include = "ID,DeptID,FirstName,LastName,Birthday,SSN,HireDate,Address,Phone")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DeptID = new SelectList(db.Departments, "ID", "DeptName", employee.DeptID);
            return(View(employee));
        }
示例#4
0
 public void InsertPayrollPeriod(PayrollPeriod payrollPeriod)
 {
     using (var db = new PayrollEntities())
     {
         db.PayrollPeriods.Add(payrollPeriod);
         db.SaveChanges();
     }
 }
示例#5
0
 public void InsertDepartment(Department department)
 {
     using (var db = new PayrollEntities())
     {
         db.Departments.Add(department);
         db.SaveChanges();
     }
 }
示例#6
0
 public void InsertIncome(Income income)
 {
     using (var db = new PayrollEntities())
     {
         db.Incomes.Add(income);
         db.SaveChanges();
     }
 }
示例#7
0
 public void InsertEmployee(UserPersonalInformation toDB)
 {
     using (var db = new PayrollEntities())
     {
         db.UserPersonalInformations.Add(toDB);
         db.SaveChanges();
     }
 }
 public void AddEmployeeDeductions(AssignedEmployeeDeduction toDB)
 {
     using (var db = new PayrollEntities())
     {
         db.AssignedEmployeeDeductions.Add(toDB);
         db.SaveChanges();
     }
 }
示例#9
0
 public void InsertDeduction(Deduction deduction)
 {
     using (var db = new PayrollEntities())
     {
         db.Deductions.Add(deduction);
         db.SaveChanges();
     }
 }
示例#10
0
 public void AddEmployeeIncome(AssignedEmployeeIncome toDB)
 {
     using (var db = new PayrollEntities())
     {
         db.AssignedEmployeeIncomes.Add(toDB);
         db.SaveChanges();
     }
 }
示例#11
0
 public void UpdateEmployeeDepartment(int?userPersonalInformationID, int departmentID)
 {
     using (var db = new PayrollEntities())
     {
         var result = db.UserPersonalInformations.SingleOrDefault(b => b.UserPersonalInformationId == userPersonalInformationID);
         if (result != null)
         {
             result.DepartmentId = departmentID;
             db.SaveChanges();
         }
     }
 }
示例#12
0
 public void UpdateEmployeeIncome(AssignedEmployeeIncome toDB)
 {
     using (var db = new PayrollEntities())
     {
         var result = db.AssignedEmployeeIncomes.SingleOrDefault(b => b.UserPersonalInformationID == toDB.UserPersonalInformationID &&
                                                                 b.IncomeId == toDB.IncomeId);
         if (result != null)
         {
             //result.CustomAmount = toDB.CustomAmount;
             db.SaveChanges();
         }
     }
 }
示例#13
0
        //public decimal GetAssignedEmployeeIncomesByIncomeId(int userPersonalInformationId, int incomeId)
        //{
        //    decimal returnValue = 0.0M;
        //    using (var db = new PayrollEntities())
        //    {
        //        var query = from a in db.AssignedEmployeeIncomes
        //                    join b in db.Incomes on a.IncomeId equals b.IncomeId
        //                    where (a.UserPersonalInformationID == userPersonalInformationId)
        //                    && (a.IncomeId == incomeId)
        //                    select a.CustomAmount;

        //        if (query != null)
        //        {
        //            returnValue = Convert.ToDecimal(query.FirstOrDefault().Value);
        //        };

        //        return returnValue;
        //    }
        //}

        public void DeleteIncome(int userPersonalInformationId, int incomeId)
        {
            using (var db = new PayrollEntities())
            {
                var itemToRemove = db.AssignedEmployeeIncomes.SingleOrDefault(x => x.UserPersonalInformationID == userPersonalInformationId && x.IncomeId == incomeId); //returns a single item.

                if (itemToRemove != null)
                {
                    db.AssignedEmployeeIncomes.Remove(itemToRemove);
                    db.SaveChanges();
                }
            }
        }
示例#14
0
 public void UpdateDepartment(Department department)
 {
     using (var db = new PayrollEntities())
     {
         var result = db.Departments.SingleOrDefault(b => b.DepartmentId == department.DepartmentId);
         if (result != null)
         {
             result.Active = department.Active;
             result.DepartmentDescription = department.DepartmentDescription;
             result.DepartmentName        = department.DepartmentName;
             db.SaveChanges();
         }
     }
 }
示例#15
0
 public void UpdateIncome(Income income)
 {
     using (var db = new PayrollEntities())
     {
         var result = db.Incomes.SingleOrDefault(b => b.IncomeId == income.IncomeId);
         if (result != null)
         {
             result.Active            = income.Active;
             result.IncomeDescription = income.IncomeDescription;
             result.IncomeName        = income.IncomeName;
             //result.IncomeValue = income.IncomeValue;
             result.Order = income.Order;
             db.SaveChanges();
         }
     }
 }
示例#16
0
 public void UpdateDeduction(Deduction deduction)
 {
     using (var db = new PayrollEntities())
     {
         var result = db.Deductions.SingleOrDefault(b => b.DeductionId == deduction.DeductionId);
         if (result != null)
         {
             result.Active = deduction.Active;
             result.DeductionDescription = deduction.DeductionDescription;
             result.DeductionName        = deduction.DeductionName;
             //result.DeductionValue = deduction.DeductionValue;
             result.Order = deduction.Order;
             db.SaveChanges();
         }
     }
 }
示例#17
0
 public void UpdatePayrollPeriod(PayrollPeriod payrollPeriod)
 {
     using (var db = new PayrollEntities())
     {
         var result = db.PayrollPeriods.SingleOrDefault(b => b.PayrollPeriodId == payrollPeriod.PayrollPeriodId);
         if (result != null)
         {
             result.PayrollPeriodDescription = payrollPeriod.PayrollPeriodDescription;
             result.Year          = payrollPeriod.Year;
             result.Month         = payrollPeriod.Month;
             result.PayPeriodFrom = payrollPeriod.PayPeriodFrom;
             result.PayPeriodTo   = payrollPeriod.PayPeriodTo;
             result.WorkDays      = payrollPeriod.WorkDays;
             result.WorkHours     = payrollPeriod.WorkHours;
             db.SaveChanges();
         }
     }
 }
示例#18
0
        public PayrollTransactionDeduction InsertPayrollTransactionDeductions(PayrollTransactionDeductionViewModels viewModels)
        {
            using (var db = new PayrollEntities())
            {
                PayrollTransactionDeduction payroll = new PayrollTransactionDeduction();
                payroll.CustomDeductionAmount     = viewModels.CustomDeductionAmount;
                payroll.DeductionId               = viewModels.DeductionId;
                payroll.PayrollPeriodId           = viewModels.PayrollPeriodId;
                payroll.UserPersonalInformationid = viewModels.UserPersonalInformationid;

                db.PayrollTransactionDeductions.Add(payroll);
                db.SaveChanges();

                int id = payroll.PayrollTransactionDeductionId;

                return(GetPayrollTransactionDeduction(id));
            }
        }
示例#19
0
 public void UpdateEmployee(UserPersonalInformation userPersonalInformation)
 {
     using (var db = new PayrollEntities())
     {
         var result = db.UserPersonalInformations.SingleOrDefault(b => b.UserPersonalInformationId == userPersonalInformation.UserPersonalInformationId);
         if (result != null)
         {
             result.Active     = userPersonalInformation.Active;
             result.EmployeeId = userPersonalInformation.EmployeeId;
             result.Address    = userPersonalInformation.Address;
             result.FirstName  = userPersonalInformation.FirstName;
             result.LastName   = userPersonalInformation.LastName;
             result.Position   = userPersonalInformation.Position;
             result.BasicPay   = userPersonalInformation.BasicPay;
             db.SaveChanges();
         }
     }
 }
        public PayrollTransactionIncome InsertPayrollTransactionIncomes(PayrollTransactionIncomeViewModels viewModels)
        {
            using (var db = new PayrollEntities())
            {
                PayrollTransactionIncome payroll = new PayrollTransactionIncome();
                payroll.CustomIncomeAmount        = viewModels.CustomIncomeAmount;
                payroll.IncomeId                  = viewModels.IncomeId;
                payroll.PayrollPeriodId           = viewModels.PayrollPeriodId;
                payroll.UserPersonalInformationid = viewModels.UserPersonalInformationid;

                db.PayrollTransactionIncomes.Add(payroll);
                db.SaveChanges();

                int id = payroll.PayrollTransactionIncomeId;

                return(GetPayrollTransactionIncome(id));
            }
        }
示例#21
0
        public ActionResult Register(RegisterViewModel model)
        {
            TempData["Message"] = null;
            if (ModelState.IsValid)
            {
                try
                {
                    using (var db = new PayrollEntities())
                    {
                        var query = from b in db.Users
                                    where b.UserName == model.UserName
                                    select b;

                        if (query.Count() > 0)
                        {
                            TempData["Message"] = "Username already exists";
                            return(RedirectToAction("Register", "Account"));
                        }
                        else
                        {
                            string password = Helper.Encrypt(model.Password);
                            var    user     = new User {
                                UserName = model.UserName, Password = password, UserRoleId = 3
                            };
                            db.Users.Add(user);
                            db.SaveChanges();
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
示例#22
0
        private Model.TblVariableTermManual UpdateOrInsertTblVariableTermManual(Model.TblVariableTermManual newRow, bool save, int index, out int outindex)
        {
            var oldRow = new Model.TblVariableTermManual();

            outindex = index;
            using (var context = new TimeAttEntities())
            {
                if (save)
                {
                    context.TblVariableTermManuals.AddObject(newRow);
                }
                else
                {
                    oldRow = (from e in context.TblVariableTermManuals
                              where e.Iserial == newRow.Iserial
                              select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        GenericUpdate(oldRow, newRow, context);
                    }
                }
                context.SaveChanges();

                var srv = new EmployeePayrollServiceClient();
                //newRow
                var row = new ServiceReference1.TblVariableTermManual();
                row.InjectFrom(newRow);
                srv.InsertVariableTerm(row, row);
                var selectedTerm = context.TblSalaryTerms.FirstOrDefault(w => w.Iserial == newRow.TermId).Ename;



                using (PayrollEntities payrolldb = new PayrollEntities())
                {
                    if (oldRow != null)
                    {
                        deletePayrollVr(payrolldb, oldRow, selectedTerm);
                    }

                    var emp        = payrolldb.TblEmployeePayrolls.FirstOrDefault(w => w.EmpId == newRow.Emplid);
                    var period     = getPeriodByOrganizationUnit(emp.TblOrganizationUnit ?? 0, payrolldb).Iserial;
                    var periodline = payrolldb.TblPeriodLines.FirstOrDefault(x => x.FromDate <= newRow.TransDate && x.ToDate >= newRow.TransDate && x.TblPeriod == period);

                    var exType = payrolldb.PayrollTblSalaryTerms.FirstOrDefault(w => w.Ename == selectedTerm).Iserial;
                    if (emp != null && exType != null)
                    {
                        var ExToInsert = new PayrollTblVariableTermManual()
                        {
                            TblEmployee      = emp.Iserial,
                            TblSalaryTerm    = exType,
                            Hours            = newRow.Hours,
                            AmountCUR        = 0,
                            AttHours         = 0,
                            AttType          = "0",
                            ExcuseTransRECId = null,
                            OldAmount        = 0,
                            TblAttendaceFile = null,
                            TblCalculated    = 0,
                            TblCurrency      = null,
                            TblPenalty       = null,
                            TransDate        = newRow.TransDate,
                            FromAtt          = false,
                            TblPeriodLine    = periodline.Iserial,
                        };
                        payrolldb.PayrollTblVariableTermManuals.AddObject(ExToInsert);
                    }
                    payrolldb.SaveChanges();
                }



                return(newRow);
            }
        }