Exemple #1
0
        public JsonResult UpdateManagerToSeniorAjax(int id)
        {
            var manager = _offlineDB.Off_StoreManager.SingleOrDefault(m => m.Id == id);

            if (manager != null)
            {
                var currentuser = UserManager.FindById(User.Identity.GetUserId());
                if (manager.Off_System_Id == currentuser.DefaultSystemId)
                {
                    var user = UserManager.FindByName(manager.UserName);
                    UserManager.AddToRole(user.Id, "Senior");
                    manager.Status = 2;
                    _offlineDB.Entry(manager).State = System.Data.Entity.EntityState.Modified;
                    _offlineDB.SaveChanges();
                    return(Json(new { result = "SUCCESS" }));
                }
                else
                {
                    return(Json(new { result = "UNZUTHORIZED" }));
                }
            }
            else
            {
                return(Json(new { result = "FAIL" }));
            }
        }
 public ActionResult UpdateAccountInfo(Wx_SellerCreditViewModel model)
 {
     if (ModelState.IsValid)
     {
         var item = new Wx_SellerCreditViewModel();
         if (TryUpdateModel(item))
         {
             var seller = _offlineDB.Off_Seller.SingleOrDefault(m => m.Id == item.Id);
             if (seller != null)
             {
                 seller.IdNumber                = item.IdNumber;
                 seller.CardName                = item.CardName;
                 seller.CardNo                  = item.CardNo;
                 seller.UploadUser              = User.Identity.Name;
                 seller.UploadTime              = DateTime.Now;
                 seller.AccountName             = item.AccountName;
                 seller.AccountSource           = item.AccountSource;
                 _offlineDB.Entry(seller).State = System.Data.Entity.EntityState.Modified;
                 _offlineDB.SaveChanges();
                 return(Content("SUCCESS"));
             }
         }
         return(View("Error"));
     }
     else
     {
         ModelState.AddModelError("", "错误");
         var user          = UserManager.FindById(User.Identity.GetUserId());
         var banklistArray = _offlineDB.Off_System_Setting.SingleOrDefault(m => m.Off_System_Id == user.DefaultSystemId && m.SettingName == "BankList");
         if (banklistArray != null)
         {
             string[]      regionarray = banklistArray.SettingValue.Split(',');
             List <Object> banklist    = new List <object>();
             foreach (var i in regionarray)
             {
                 banklist.Add(new { Key = i, Value = i });
             }
             ViewBag.BankList = new SelectList(banklist, "Key", "Value");
             return(View(model));
         }
         else
         {
             return(View("Error"));
         }
     }
 }
Exemple #3
0
 public ActionResult EditProduct(Off_Product model)
 {
     if (ModelState.IsValid)
     {
         Off_Product item = new Off_Product();
         if (TryUpdateModel(item))
         {
             _offlineDB.Entry(item).State = System.Data.Entity.EntityState.Modified;
             _offlineDB.SaveChanges();
             return(Content("SUCCESS"));
         }
         return(PartialView("Error"));
     }
     else
     {
         ModelState.AddModelError("", "发生错误");
         return(PartialView(model));
     }
 }
Exemple #4
0
 public ActionResult EditSellerPartial(int id, FormCollection form)
 {
     if (ModelState.IsValid)
     {
         var item = new Off_Seller();
         if (TryUpdateModel(item))
         {
             item.UploadTime = DateTime.Now;
             item.UploadUser = User.Identity.Name;
             _offlineDB.Entry(item).State = System.Data.Entity.EntityState.Modified;
             _offlineDB.SaveChanges();
             return(Content("SUCCESS"));
         }
         else
         {
             ModelState.AddModelError("", "错误");
             return(PartialView(item));
         }
     }
     else
     {
         return(PartialView("ErrorPartial"));
     }
 }
Exemple #5
0
 public ActionResult EditExpenses(Off_Expenses model, FormCollection form)
 {
     if (ModelState.IsValid)
     {
         Off_Expenses item = new Off_Expenses();
         if (TryUpdateModel(item))
         {
             var detailitemcnt = form.GetValues("detailid") == null ? 0 : form.GetValues("detailid").Length;
             for (int i = 0; i < detailitemcnt; i++)
             {
                 if (form.GetValues("detailid")[i] == "0")
                 {
                     Off_Expenses_Details detailtemp = new Off_Expenses_Details()
                     {
                         Off_Expenses = item,
                         DetailsFee   = Convert.ToDecimal(form.GetValues("detailfee")[i].ToString()),
                         DetailsName  = form.GetValues("detaillist")[i].ToString(),
                         Remarks      = form.GetValues("detailremarks")[i].ToString(),
                         UploadTime   = DateTime.Now,
                         UploadUser   = User.Identity.Name,
                         ExpensesType = 0
                     };
                     _offlineDB.Off_Expenses_Details.Add(detailtemp);
                 }
                 else
                 {
                     int d_id = Convert.ToInt32(form.GetValues("detailid")[i]);
                     Off_Expenses_Details detailstemp = _offlineDB.Off_Expenses_Details.SingleOrDefault(m => m.Id == d_id);
                     detailstemp.DetailsFee              = Convert.ToDecimal(form.GetValues("detailfee")[i].ToString());
                     detailstemp.DetailsName             = form.GetValues("detaillist")[i].ToString();
                     detailstemp.Remarks                 = form.GetValues("detailremarks")[i].ToString();
                     detailstemp.UploadTime              = DateTime.Now;
                     detailstemp.UploadUser              = User.Identity.Name;
                     _offlineDB.Entry(detailstemp).State = System.Data.Entity.EntityState.Modified;
                 }
             }
             item.UploadTime = DateTime.Now;
             item.UploadUser = User.Identity.Name;
             _offlineDB.Entry(item).State = System.Data.Entity.EntityState.Modified;
             _offlineDB.SaveChanges();
         }
         return(RedirectToAction("ExpensesIndex"));
     }
     else
     {
         ModelState.AddModelError("", "发生错误");
         List <Object> attendance = new List <Object>();
         attendance.Add(new { Key = 0, Value = "进场费" });
         attendance.Add(new { Key = 1, Value = "活动费" });
         ViewBag.PayType = new SelectList(attendance, "Key", "Value", model.Status);
         return(View(model));
     }
 }
Exemple #6
0
 public ActionResult AccountSettingAjax(FormCollection form)
 {
     if (ModelState.IsValid)
     {
         //form.AllKeys;
         AccountSetting_ViewModel model = new AccountSetting_ViewModel();
         if (TryUpdateModel(model))
         {
             Type t = model.GetType();
             var  s = t.GetProperties();
             //var result = "";
             var user = UserManager.FindById(User.Identity.GetUserId());
             for (int i = 0; i < s.Length; i++)
             {
                 string settingName = s[i].Name;
                 var    settingitem = _offlineDB.Off_System_Setting.SingleOrDefault(m => m.SettingName == settingName && m.Off_System_Id == user.DefaultSystemId);
                 if (settingitem != null)
                 {
                     settingitem.SettingValue            = (string)s[i].GetValue(model);
                     _offlineDB.Entry(settingitem).State = System.Data.Entity.EntityState.Modified;
                 }
                 else
                 {
                     var setting = new Off_System_Setting()
                     {
                         Off_System_Id = user.DefaultSystemId,
                         SettingName   = settingName,
                         SettingResult = true,
                         SettingValue  = (string)s[i].GetValue(model)
                     };
                     _offlineDB.Off_System_Setting.Add(setting);
                 }
             }
             _offlineDB.SaveChanges();
             return(Content("SUCCESS"));
         }
         return(Content("FAIL"));
     }
     else
     {
         return(Content("FAIL"));
     }
 }
        public async Task <JsonResult> RefreshBonusStatus(int id)
        {
            var request = _offlineDB.Off_BonusRequest.SingleOrDefault(m => m.Id == id && m.Status == 1);

            if (request != null)
            {
                AppPayUtilities pay    = new AppPayUtilities();
                string          result = await pay.WxRedPackQuery(request.Mch_BillNo);

                switch (result)
                {
                case "SENT":
                    request.Status = 1;
                    break;

                case "RECEIVED":
                    request.Status = 2;
                    break;

                case "FAIL":
                    request.Status = 3;
                    break;

                case "REFUND":
                    request.Status = 4;
                    break;

                default:
                    request.Status = 1;
                    break;
                }
                _offlineDB.Entry(request).State = System.Data.Entity.EntityState.Modified;
                await _offlineDB.SaveChangesAsync();

                return(Json(new { result = "SUCCESS" }));
            }
            else
            {
                return(Json(new { result = "FAIL" }));
            }
        }
 public ActionResult EditStorePartial(int id, FormCollection form)
 {
     if (ModelState.IsValid)
     {
         var item = new Off_Store();
         if (TryUpdateModel(item))
         {
             item.UploadTime = DateTime.Now;
             item.UploadUser = User.Identity.Name;
             _offlineDB.Entry(item).State = System.Data.Entity.EntityState.Modified;
             _offlineDB.SaveChanges();
             return(Content("SUCCESS"));
         }
         else
         {
             ModelState.AddModelError("", "错误");
             var user       = UserManager.FindById(User.Identity.GetUserId());
             var regionlist = _offlineDB.Off_System_Setting.SingleOrDefault(m => m.Off_System_Id == user.DefaultSystemId && m.SettingName == "AreaList");
             if (regionlist != null)
             {
                 string[]      regionarray = regionlist.SettingValue.Split(',');
                 List <Object> attendance  = new List <Object>();
                 foreach (var i in regionarray)
                 {
                     attendance.Add(new { Key = i, Value = i });
                 }
                 ViewBag.Regionlist = new SelectList(attendance, "Key", "Value", item.Region);
                 return(PartialView(item));
             }
             else
             {
                 return(PartialView("ErrorPartial"));
             }
         }
     }
     else
     {
         return(PartialView("ErrorPartial"));
     }
 }
Exemple #9
0
        public async Task <ActionResult> EditDailySalesPartial(int id, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                var item = new Off_SalesInfo_Daily();
                if (TryUpdateModel(item))
                {
                    List <int> plist       = new List <int>();
                    var        user        = UserManager.FindById(User.Identity.GetUserId());
                    var        productlist = from m in _offlineDB.Off_Product
                                             where m.Off_System_Id == user.DefaultSystemId &&
                                             m.status >= 0
                                             select m;
                    // 添加或修改销售列表
                    foreach (var product in productlist)
                    {
                        // 获取单品数据
                        int?sales = null;
                        if (form["sales_" + product.Id] != "")
                        {
                            sales = Convert.ToInt32(form["sales_" + product.Id]);
                        }
                        int?storage = null;
                        if (form["storage_" + product.Id] != "")
                        {
                            storage = Convert.ToInt32(form["storage_" + product.Id]);
                        }
                        decimal?amount = null;
                        if (form["amount_" + product.Id] != "")
                        {
                            amount = Convert.ToDecimal(form["amount_" + product.Id]);
                        }
                        // 判断是否已有数据
                        var checkinproductlist = _offlineDB.Off_Daily_Product.Where(m => m.DailyId == id);
                        var existdata          = checkinproductlist.SingleOrDefault(m => m.ProductId == product.Id);
                        if (existdata != null)
                        {
                            if (sales == null && storage == null && amount == null)
                            {
                                // 无数据则删除
                                _offlineDB.Off_Daily_Product.Remove(existdata);
                            }
                            else if (sales == 0 && storage == 0 && amount == 0)
                            {
                                _offlineDB.Off_Daily_Product.Remove(existdata);
                            }
                            else
                            {
                                // 修改数据
                                existdata.SalesAmount  = amount;
                                existdata.SalesCount   = sales;
                                existdata.StorageCount = storage;
                            }
                        }
                        else
                        {
                            // 添加数据
                            // 如果三项数据不为空,则添加
                            if (sales == null && storage == null && amount == null)
                            {
                            }
                            else if (sales == 0 && storage == 0 && amount == 0)
                            {
                            }
                            else
                            {
                                existdata = new Off_Daily_Product()
                                {
                                    DailyId      = id,
                                    ItemCode     = product.ItemCode,
                                    ProductId    = product.Id,
                                    SalesAmount  = amount,
                                    SalesCount   = sales,
                                    StorageCount = storage
                                };
                                _offlineDB.Off_Daily_Product.Add(existdata);
                                //offlineDB.SaveChanges();
                            }
                        }
                    }
                    item.UploadTime = DateTime.Now;
                    item.UploadUser = User.Identity.Name;
                    _offlineDB.Entry(item).State = System.Data.Entity.EntityState.Modified;
                    var result = await _offlineDB.SaveChangesAsync();

                    // 该代码需要重写

                    OfflineSalesUtilities util = new OfflineSalesUtilities();
                    var result2 = await util.UpdateDailySalesAvg(item.StoreId, (int)item.Date.DayOfWeek + 1);

                    //update_Sales_AVGINfo(item.StoreId, (int)item.Date.DayOfWeek + 1);
                    return(Content("SUCCESS"));
                }
                else
                {
                    return(PartialView("AuthorizeErrorPartial"));
                }
            }
            else
            {
                return(PartialView("ErrorPartial"));
            }
        }