Ejemplo n.º 1
0
        public ActionResult AddFine(EmployeeFine fine)
        {
            var list = fine.Save(UserID, Employee.ID, Employee.BussinessID, DbAction.Employee.Modify);

            return(Json(new
            {
                html = RenderPartialViewToString("FineList", list)
            }, JsonRequestBehavior.DenyGet));
        }
Ejemplo n.º 2
0
        public ActionResult RemoveFine(int id, int subID)
        {
            var list = EmployeeFine.Remove(UserID, Employee.ID, Employee.BussinessID, DbAction.Employee.Modify, id, subID);

            return(Json(new
            {
                html = RenderPartialViewToString("FineList", list)
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public ActionResult GetFine(int id)
        {
            var list = EmployeeFine.Get(UserID, Employee.ID, Employee.BussinessID, DbAction.Employee.View, new EmployeeFineFilter(id));

            return(Json(new
            {
                html = RenderPartialViewToString("FineList", list)
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public static SalaryCalculator Get(int userID, int employeeID, SalaryInfo info, bool?find = null, EmployeeInfo employeeInfo = null)
        {
            var result = new SalaryCalculator(new EmployeeFilter(), info, employeeInfo);

            try
            {
                using (var con = Repo.DB.SKtimeManagement)
                {
                    if (find.HasValue && find.Value)
                    {
                        var dbInfo = con.Query <SalaryInfo>(String.Format("select top 1 * from Salary where EmployeeID = {0} order by Month desc", result.Info.EmployeeID)).FirstOrDefault();
                        if (dbInfo != null)
                        {
                            result = new SalaryCalculator(new EmployeeFilter(), dbInfo, employeeInfo);
                        }
                    }
                    if (employeeInfo == null)
                    {
                        result.EmployeeInfo = con.Query <EmployeeInfo>(
                            String.Format(@"select e.*, l.ID as [LoginID], l.Username, s.Name as [StoreName], isnull(sum(o.Total - o.Discount), 0) as [CurrentSale]
                                from Employee e left join Login l on l.EmployeeID = e.ID left join Store s on e.StoreID = s.ID left join [Order] o on o.EmployeeID  = e.ID and o.Removed = 0 and o.Status <> N'{1}'
                                where e.Status = 'active' and e.ID = {0}
                                group by e.AdditionalSalary, e.Address,  e.BaseSalary, e.BussinessID, e.ID, e.Image, e.MonthlySale, e.Name,  e.OffDays, e.Phone, e.Position, e.DOB,
	                                e.StartDate, e.Status, e.StoreID, e.Summary,  e.WorkDays, e.WorkTime, e.EndDate, e.BankNumber, e.BankName, e.BankBranch, e.WorkStatus, l.ID, l.Username, s.Name"    , info.EmployeeID, OrderStatus.Refunded)).FirstOrDefault();
                    }

                    //result.Offsets = SaleOffset.Get(userID, employeeID, info.ID);
                    result.OffDays = con.Query <EmployeeOffDay>(String.Format("select * from EmployeeOffDay where EmployeeID = {0} order by OffDate desc", info.EmployeeID)).ToList();
                    if (result.EmployeeInfo.StoreID.HasValue)
                    {
                        result.Orders = con.Query <ExportRecord>(GetStoreOrders(userID, employeeID, result.EmployeeInfo.StoreID.Value, result.From, result.To)).ToList();
                    }
                    else
                    {
                        result.Orders = new List <ExportRecord>();
                    }
                    result.Fines     = con.Query <EmployeeFine>(EmployeeFine.Query(result.EmployeeInfo.BussinessID, new EmployeeFineFilter(result.EmployeeInfo.ID, result.From, result.To))).ToList();
                    result.SaleTotal = result.Orders.Where(i => i.EmployeeID == info.EmployeeID).Sum(i => i.Paid);
                    result.StoreSale = result.Orders.Sum(i => i.Paid);
                    //result.SaleRate = result.Offsets.Count == 0 ? 0 : result.Offsets.FirstOrDefault(i => result.SaleTotal >= i.Offset).Value;
                    result.OffCount = result.OffDays.Where(i => i.OffDate >= result.From && i.OffDate <= result.To).Count() + info.AdditionalOffDays;
                    if (find.HasValue && !find.Value)
                    {
                        con.Execute(String.Format(
                                        @"delete Salary where EmployeeID = {0} and Month = '{1}'
                            insert into Salary(EmployeeID, Month, OffValue, ValidOffDays, AdditionalOffDays, EmployeeCount, SalePoint, SaleAdd, Paid, Other, Note, CalculatedTotal, BaseSalary) 
                            values ({0}, '{1}', {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, N'{10}', {11}, {12})",
                                        result.Info.EmployeeID, result.From.ToString(Constants.DatabaseDateString), result.Info.OffValue, result.Info.ValidOffDays, result.Info.AdditionalOffDays,
                                        result.Info.EmployeeCount, result.Info.SalePoint, result.Info.SaleAdd, result.Info.Paid, result.Info.Other, result.Info.Note, result.Total, result.BaseSalary));
                    }
                }
            }
            catch { }
            return(result);
        }
Ejemplo n.º 5
0
        public ActionResult GetFine()
        {
            var list = EmployeeFine.Get(Employee.BussinessID, Employee.ID);

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString("FineListPartial", list)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View("FineList", list));
        }