Example #1
0
        public ActionResult PayrollAction(CustomPayroll payroll)
        {
            if (ModelState.IsValid)
            {
                string msg = "";

                if (payroll.PayrollID > 0)
                {
                    var dataset = entities.Payrolls.Where(f => f.PayrollID == payroll.PayrollID).FirstOrDefault();
                    if (dataset != null)
                    {
                        PayList payList = new PayList();
                        payList.Deduction   = payroll.Deduction;
                        payList.NetPay      = payroll.NetPay;
                        payList.PaymentDate = DateTime.Now;
                        payList.PayrollID   = payroll.PayrollID;
                        entities.PayLists.Add(payList);
                        dataset.PaymentStatus = 1;
                        msg = "payroll Updated Successfully";
                    }
                }
                else
                {
                    msg = "New payroll Added successfully";
                }
                entities.SaveChanges();
                return(new JsonResult
                {
                    Data = new
                    {
                        success = true,
                        action = "Payroll",
                        message = msg
                    },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            return(PartialView(payroll));
        }
Example #2
0
        public ActionResult PayrollAction(int?id)
        {
            if (id != 0)
            {
                CustomPayroll custompayroll = new CustomPayroll();
                Payroll       dataset       = entities.Payrolls.Find(id);

                custompayroll.UserID    = dataset.UserID;
                custompayroll.UserName  = dataset.User.FirstName + " " + dataset.User.LastName;
                custompayroll.PayDate   = dataset.PayDate;
                custompayroll.GrossPay  = dataset.GrossPay;
                custompayroll.Deduction = 0;
                custompayroll.NetPay    = dataset.GrossPay;
                custompayroll.PayrollID = dataset.PayrollID;

                return(PartialView(custompayroll));
            }

            else
            {
                return(PartialView());
            }
        }
        public Returner PayrollReport(int SalaryType, DateTime From, DateTime To)
        {
            var                  Rep = db.Payrolls.Where(p => p.Date >= From && p.Date <= To && p.Type == 3).ToList();
            DateTime             Larger;
            List <CustomPayroll> LOCPR = new List <CustomPayroll>();

            foreach (Payroll PPP in Rep)
            {
                if (SalaryType == 2)
                {
                    Larger = PPP.Date.Value.AddDays(-15);
                }
                else if (SalaryType == 3)
                {
                    Larger = PPP.Date.Value.AddMonths(-1);
                }
                else
                {
                    Larger = PPP.Date.Value.AddDays(-7);
                }
                CustomPayroll CPR = new CustomPayroll();
                CPR.Id    = Convert.ToInt32(PPP.EmpID);
                CPR.Date  = PPP.Date;
                CPR.Pens  = db.Payrolls.Where(p => p.Type == 2 && p.Date <= PPP.Date && p.Date >= Larger).ToList().Sum(p => p.Amount);
                CPR.Benis = db.Payrolls.Where(p => p.Type == 1 && p.Date <= PPP.Date && p.Date >= Larger).ToList().Sum(p => p.Amount);
                LOCPR.Add(CPR);
            }
            if (SalaryType == 2)
            {
                var RepInJSON = (from P in Rep
                                 select new
                {
                    P.Amount,
                    P.Date,
                    P.Id,
                    Pens = LOCPR.Where(p => p.Id == P.EmpID && p.Date == P.Date).SingleOrDefault().Pens,
                    Benis = LOCPR.Where(p => p.Id == P.EmpID && p.Date == P.Date).SingleOrDefault().Benis,
                    P.Type,
                    Employee = new
                    {
                        P.Employee.Name,
                        P.Employee.BasicSalary
                    }
                }).ToList();
                return(new Returner
                {
                    Data = Rep,
                    DataInJSON = RepInJSON.ToJSON()
                });
            }
            else if (SalaryType == 3)
            {
                var RepInJSON = (from P in Rep
                                 select new
                {
                    P.Amount,
                    P.Date,
                    P.Id,
                    Pens = LOCPR.Where(p => p.Id == P.EmpID && p.Date == P.Date).SingleOrDefault().Pens,
                    Benis = LOCPR.Where(p => p.Id == P.EmpID && p.Date == P.Date).SingleOrDefault().Benis,
                    P.Type,
                    Employee = new
                    {
                        P.Employee.Name,
                        P.Employee.BasicSalary
                    }
                }).ToList();
                return(new Returner
                {
                    Data = Rep,
                    DataInJSON = RepInJSON.ToJSON()
                });
            }
            else
            {
                var RepInJSON = (from P in Rep
                                 select new
                {
                    P.Amount,
                    P.Date,
                    P.Id,
                    Pens = LOCPR.Where(p => p.Id == P.EmpID && p.Date == P.Date).SingleOrDefault().Pens,
                    Benis = LOCPR.Where(p => p.Id == P.EmpID && p.Date == P.Date).SingleOrDefault().Benis,
                    P.Type,
                    Employee = new
                    {
                        P.Employee.Name,
                        P.Employee.BasicSalary
                    }
                }).ToList();
                return(new Returner
                {
                    Data = Rep,
                    DataInJSON = RepInJSON.ToJSON()
                });
            }
        }