public ActionResult Export()
        {
            int    count  = 0;
            object footer = null;
            var    dt     = TakeStockService.FindPageList(Request.Params, out count, ref footer, false);

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(RedirectAlert("Index", "暂无数据!"));
            }
            dt.Columns.Add("盘点员工号");
            dt.Columns.Add("序号");
            //string[] fields = { "StoreTitle", "CheckBatch", "Barcode", "Title", "BrandTitle", "SubUnit", "ActualNumber"};
            //string[] names = { "盘点门店", "盘点批次", "条码", "品名", "品牌", "单位", "实盘数量" };
            string[] fields = { "序号", "CategoryTitle", "Barcode", "Title", "BrandTitle", "SubUnit", "ActualNumber", "盘点员工号" };
            string[] names  = { "序号", "品类", "条码", "品名", "品牌", "单位", "实盘数量", "盘点员工号" };
            var      title  = "";
            var      i      = 1;

            foreach (DataRow dr in dt.Rows)
            {
                dr["ActualNumber"] = DBNull.Value;
                dr["序号"]           = i++;
            }
            int[] merger = { };
            new ExportExcel()
            {
                IsBufferOutput = true, HeaderText = title
            }.ToExcel(dt.Rows[0]["StoreTitle"] + "_盘点_" + dt.Rows[0]["CheckBatch"], dt, fields, names, merger, formatFileName: false);
            return(new EmptyResult());
        }
        public ActionResult StockLock(TreasuryLocks obj)
        {
            obj.LockCategorySN = Request["selectCategorySN"];
            var op = TakeStockService.AddStockLock(obj);

            return(Content(op.ToJson()));
        }
        public ActionResult SubExport(string storeId, string checkBatch)
        {
            int count = 0;
            var nl    = new System.Collections.Specialized.NameValueCollection()
            {
                Request.Params
            };
            //nl.Add("state", "1");
            object footer = null;
            var    dt     = TakeStockService.ReportList(nl, out count, ref footer, false);

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(RedirectAlert("Report", "暂无数据,请先确认是否已审核!"));
            }
            dt.Columns.Add("序号");
            dt.Columns.Add("复盘数量");
            dt.Columns.Add("盘点员工号");
            for (var i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i]["序号"] = i + 1;
            }
            string[] fields    = { "序号", "SureTitle", "SupplierTitle", "CategoryTitle", "Barcode", "Title", "Size", "SubUnit", "SysPrice", "LockNumber", "ActualNumber", "复盘数量", "盘点员工号" };
            string[] names     = { "序号", "差异确认", "供应商", "品类", "条码", "品名", "规格", "单位", "系统售价", "锁库库存", "盘点数量", "复盘数量", "盘点员工号" };
            var      totalCols = new int[] { };
            var      title     = "";

            new ExportExcel()
            {
                IsBufferOutput = true, HeaderText = title
            }.ToExcel("盘点", dt, fields, names, null, totalCols);
            return(new EmptyResult());
        }
        public ActionResult FindStockList(string lockStoreID, string checkBatch)
        {
            int count = 0;
            var list  = TakeStockService.FindStockList(lockStoreID, checkBatch);

            return(ToDataGrid(list, count));
        }
        public ActionResult CheckerSelect(string batchNo)
        {
            var list = TakeStockService.GetCheckerByBatchnoList(batchNo).ToList();

            list.Insert(0, new DropdownItem("", "全部", true));
            return(new JsonNetResult(list));
        }
        public void SaveStock(string data, int cid)
        {
            //SaveStock([FromBody]SaveTakeStockRequest requestParams)

            /*string storeId = requestParams.Property("storeId", true);
             * string checkBatch = requestParams.Property("checkBatch", true);
             * string userCode = requestParams.Property("userCode", true);
             * string barcodes = requestParams.Property("barcodes", true);
             * var barnums = new Dictionary<string, decimal>();
             * if (!string.IsNullOrWhiteSpace(barcodes))
             * {
             *  var bars = JArray.Parse(barcodes);
             *  for (var i = 0; i < bars.Count; i++)
             *  {
             *      var barjson = JObject.Parse(bars[i].ToString());
             *      var barc = barjson.Property("barcode", true);
             *      var num = barjson.Property("num", true);
             *      if (string.IsNullOrWhiteSpace(barc) || string.IsNullOrWhiteSpace(num))
             *          continue;
             *      barnums[barc] = Convert.ToDecimal(num);
             *  }
             * }*/
            if (string.IsNullOrWhiteSpace(data))
            {
                throw new MessageException("参数不能为空!");
            }
            var requestParams = data.ToObject <SaveTakeStockRequest>();

            if (requestParams == null)
            {
                throw new MessageException("JSON参数不正确!");
            }
            TakeStockService.SaveStock(requestParams.StoreId, requestParams.CheckBatch, requestParams.UserCode, requestParams.TakeStockList.ToDictionary(o => o.Barcode, o => o.Number));
        }
        public object GetTakestockByinputBarcode([FromBody] JObject requestParams)
        {
            string storeId    = requestParams.Property("storeId", true);
            string checkBatch = requestParams.Property("checkBatch", true);
            string barcode    = requestParams.Property("barcode", true);

            return(TakeStockService.GetTakestockByinputBarcode(storeId, checkBatch, barcode));
        }
 public object GetTakestockList([FromBody] TakeStockRequest requestParams)
 {
     if (requestParams.BaseList == null)
     {
         throw new MessageException("BaseList为空!");
     }
     return(TakeStockService.GetTakestockList(requestParams.StoreId, requestParams.CheckBatch, requestParams.Barcode, requestParams.UserCode, "3", requestParams.BaseList.PageIndex, requestParams.BaseList.PageSize, requestParams.Sure));
 }
 public PageResult <object> GetTakestockUnList([FromBody] TakeStockRequest requestParams)
 {
     if (requestParams.BaseList == null)
     {
         throw new MessageException("BaseList为空!");
     }
     return(TakeStockService.GetTakestockList(requestParams.StoreId, requestParams.CheckBatch, requestParams.Barcode, "", "2", requestParams.BaseList.PageIndex, requestParams.BaseList.PageSize, ""));
 }
        public ActionResult FindPageList()
        {
            int count  = 0;
            var footer = new object();
            var list   = TakeStockService.FindPageList(Request.Params, out count, ref footer);

            //var l = list.FirstOrDefault(o => o.CheckBatch == "2_0722_1");
            return(ToDataGrid(list, count, footer));
        }
        public ActionResult SetSure(string ids, short sure)
        {
            var idls = ids.Split(',').Select(o => int.Parse(o)).ToList();
            var list = TakeStockService.FindList(o => idls.Contains(o.Id));

            list.Each(o => o.Sure = sure);
            var op = TakeStockService.Update(list);

            return(new JsonNetResult(op));
        }
        public ActionResult Save(TreasuryLocks obj, short state, short hasrepeat)
        {
            var op = TakeStockService.SaveOrUpdate(obj, Request["Updated"], Request["Inserted"], Request["Deleted"], Request["ActualDate"], state, hasrepeat);

            if (op.Successed)
            {
                TakeStockService.RemoveCache(obj.CheckBatch);
            }
            return(Content(op.ToJson()));
        }
        public ActionResult FindApprovalList(string storeId, string checkBatch)
        {
            int    count = 0;
            object list = null, footer = null;

            if (!storeId.IsNullOrEmpty() && !checkBatch.IsNullOrEmpty())
            {
                list = TakeStockService.FindPageList(Request.Params, out count, ref footer);
            }
            return(ToDataGrid(list, count, footer));
        }
        public ActionResult FindStockLogList(string checkBatch, string checkUID, string state)
        {
            int count  = 0;
            var list   = TakeStockService.FindStockLogList(checkBatch, checkUID, state);
            var footer = new List <object>()
            {
                new { Number = 0, SubUnit = "小计:" }
            };

            return(ToDataGrid(list, count, footer));
        }
        public ActionResult ReSave(int id)
        {
            var    obj     = TakeStockService.GetObjByid(id);
            string storeId = Convert.ToString(obj.GetPropertyValue("LockStoreID"));
            var    users   = ListToSelect(_userBLL.GetStoreUser(storeId, null, 0).Select(o => new SelectListItem()
            {
                Value = o.UID, Text = o.FullName
            }), emptyTitle: "请选择");

            ViewBag.users = users;
            return(View(obj));
        }
        public ActionResult ReportList(string storeId, string checkBatch)
        {
            int       count  = 0;
            DataTable dt     = null;
            object    footer = null;

            if (!storeId.IsNullOrEmpty() && !checkBatch.IsNullOrEmpty())
            {
                dt = TakeStockService.ReportList(Request.Params, out count, ref footer);
            }
            return(ToDataGrid(dt, count, footer));
        }
        public void ReSaveStock(string data, int cid)
        {
            //[FromBody]SaveTakeStockRequest requestParams
            if (string.IsNullOrWhiteSpace(data))
            {
                throw new MessageException("参数不能为空!");
            }
            var requestParams = data.ToObject <SaveTakeStockRequest>();

            if (requestParams == null)
            {
                throw new MessageException("JSON参数不正确!");
            }

            string  barcode = "";
            decimal?number  = null;

            if (requestParams.TakeStockList.Any())
            {
                barcode = requestParams.TakeStockList[0].Barcode;
                number  = requestParams.TakeStockList[0].Number;
            }
            TakeStockService.ReSaveStock(requestParams.StoreId, requestParams.CheckBatch, requestParams.UserCode, barcode, number, requestParams.Sure);
        }
        public ActionResult ReBatchSelect(string storeId, string batchNo)
        {
            var list = TakeStockService.FindBarcodesByBatch(batchNo, 1);

            return(Json(list));
        }
 public object GetStoreBatchnoList([FromBody] BaseApiParams requestParams)
 {
     //string storeId = requestParams.Property("storeId", true);
     return(TakeStockService.GetStoreBatchnoList(requestParams.StoreId));
 }
 public object GetCheckerListByBatchno([FromBody] TakeStockBatchRequest requestParams)
 {
     //string storeId = requestParams.Property("storeId", true);
     return(TakeStockService.GetCheckerByBatchnoList(requestParams.CheckBatch));
 }
        public ActionResult ReSave(StockTaking stock)
        {
            var op = TakeStockService.ReSave(stock);

            return(Content(op.ToJson()));
        }
        public ActionResult TakeStockLogs(string checkBatch, string barcode)
        {
            var list = TakeStockService.TakeStockLogs(checkBatch, barcode);

            return(ToDataGrid(list, list.Count()));
        }
 public void AutoBalance()
 {
     TakeStockService.AutoInventoryBalance();
 }
 public void PostCache(string rows, string checkBatch)
 {
     TakeStockService.PostCache(rows, checkBatch);
 }
        public ActionResult GetProductInput(string searchName, string checkBatch, string storeId, short?state)
        {
            var list = TakeStockService.GetProductInput(searchName, checkBatch, storeId, state);

            return(ToDataGrid(list, 0));
        }
        public ActionResult CrrectSave(int id)
        {
            var obj = TakeStockService.GetObjByid(id);

            return(View(obj));
        }
        public ActionResult CrrectSave(int id, decimal correctNumber)
        {
            var op = TakeStockService.CrrectSave(id, correctNumber);

            return(Content(op.ToJson()));
        }
        public ActionResult Import(TreasuryLocks obj, char codeCol, char countCol, int?minRow, int?maxRow, string checkUID)
        {
            var re = TakeStockService.Import(obj, Request.Files, codeCol, countCol, minRow.GetValueOrDefault(), maxRow.GetValueOrDefault(), checkUID);

            return(Content(re.ToJson()));
        }
        public ActionResult ApprovalPass(string checkBatch)
        {
            var op = TakeStockService.ApprovalPass(checkBatch);

            return(new JsonNetResult(op));
        }
        public ActionResult GetBatchAndCategory(string storeId)
        {
            var no = TakeStockService.GetBatchAndCategory(storeId);

            return(Content(no));
        }