Пример #1
0
        public static SalaryReport Get(int userID, int employeeID, int bussinessID, EmployeeFilter filter)
        {
            var result    = new SalaryReport(filter);
            var employees = SalaryReport.FindEmployees(bussinessID, filter);

            foreach (var employee in employees)
            {
                var     infos      = SalaryCalculator.Find(employee.ID, filter.From, filter.To);
                dynamic record     = new ExpandoObject();
                var     dictionary = (IDictionary <string, object>)record;
                dictionary.Add("Name", employee.Name);
                foreach (var info in infos)
                {
                    result.Employees.Add(info);
                    var month = info.Month.Value;
                    if (!result.Months.Contains(month))
                    {
                        result.Months.Add(month);
                    }
                    dictionary.Add(info.Month.Value.ToString("_MMyyyy"), filter.ViewBaseSalary ? info.BaseSalary > 0 ? info.BaseSalary : employee.BaseSalary : info.CalculatedTotal.Round());
                }
                result.Records.Add(record);
            }
            result.Months = result.Months.OrderByDescending(i => i).ToList();
            return(result);
        }
Пример #2
0
 public ActionResult ForEmployee(SalaryInfo info)
 {
     using (var dataClass = new DataClassesDataContext())
     {
         if (!info.Month.HasValue)
         {
             info.Month = DateTime.Now.AddMonths(-1);
         }
         var data    = SalaryCalculator.Get(UserID, Employee.ID, info, false);
         var isAdmin = dataClass.CheckCurrentLoginInAdmin(UserID).SingleOrDefault().IsAdmin;
         var model   = new SalaryDetail()
         {
             SalaryCalculator = data,
             IsAdmin          = (bool)isAdmin
         };
         if (Request.IsAjaxRequest())
         {
             return(Json(new
             {
                 html = RenderPartialViewToString(Views.ForEmployeePartial, model)
             }, JsonRequestBehavior.AllowGet));
         }
         return(View(Views.ForEmployee, model));
     }
 }
Пример #3
0
        public ActionResult FindSalary(EmployeeFilter filter)
        {
            var data = SalaryCalculator.Find(Employee.BussinessID, filter);

            return(Json(new
            {
                html = RenderPartialViewToString("SalaryList", data)
            }, JsonRequestBehavior.DenyGet));
        }
Пример #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);
        }
Пример #5
0
 public ActionResult Detail(int id)
 {
     using (var dataClass = new DataClassesDataContext())
     {
         var data    = SalaryCalculator.Get(UserID, Employee.ID, SalaryCalculator.Get(id));
         var isAdmin = dataClass.CheckCurrentLoginInAdmin(UserID).SingleOrDefault().IsAdmin;
         var model   = new SalaryDetail()
         {
             SalaryCalculator = data,
             IsAdmin          = (bool)isAdmin
         };
         return(Json(new
         {
             html = RenderPartialViewToString(Views.Detail, model)
         }, JsonRequestBehavior.AllowGet));
     }
 }