Пример #1
0
        public ActionResult Remove(int id, int whid)
        {
            var list = SessionValue <List <ImexItem> >(SessionKey.ImportList);

            if (list == null)
            {
                list = new List <ImexItem>();
            }
            list.Remove(list.FirstOrDefault(i => i.ID == id && i.WarehouseID == whid));
            Session[SessionKey.ImportList] = list;
            return(Json(new
            {
                data = ImexItem.ToJson(list)
            }, JsonRequestBehavior.DenyGet));
        }
Пример #2
0
        public ActionResult Remove(int id, int whid)
        {
            var list = SessionValue <List <ImexItem> >(SessionKey.ExportList);

            if (list == null)
            {
                list = new List <ImexItem>();
            }
            list.Remove(list.FirstOrDefault(i => i.ID == id && i.WarehouseID == whid));
            Session[SessionKey.ExportList] = list;
            return(Json(new
            {
                data = ImexItem.ToJson(list),
                total = list.Sum(i => i.Quantity * i.Price).GetCurrencyString()
            }, JsonRequestBehavior.DenyGet));
        }
Пример #3
0
        public ActionResult UploadFile(int id)
        {
            var list    = new List <ImexItem>();
            var result  = false;
            var message = "";

            foreach (string f in Request.Files)
            {
                var fileContent = Request.Files[f];
                if (fileContent != null && fileContent.ContentLength > 0)
                {
                    // get a stream
                    var      stream   = fileContent.InputStream;
                    var      fileName = String.Format("{1}_{0}", Path.GetFileName(fileContent.FileName), DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"));
                    FileInfo fileInfo;
                    FileManagement.SaveFile("Import/Import", fileName, stream, out fileInfo);
                    list = ImexItem.Read(UserID, Employee.ID, fileInfo, Employee.BussinessID);
                    var unavailable = list.Count(i => i.ID <= 0 || i.WarehouseID <= 0);
                    if (unavailable > 0)
                    {
                        message = String.Format("{0} sản phẩm không tìm thấy", unavailable);
                    }
                    else
                    {
                        message = "Nhập sản phẩn từ file thành công";
                        result  = true;
                    }
                }
                break;
            }
            return(Json(new
            {
                result = result,
                list = ImexItem.ToJson(list.Where(i => i.ID > 0 && i.WarehouseID > 0)),
                message = message
            }, JsonRequestBehavior.DenyGet));
        }