public ActionResult SaveCommodity(Commodity model, string BtnSubmit)
        {
            //如果是按键操作,返回重定向
            CommodityBusinessLayer commodityBusinessLayer = new CommodityBusinessLayer();

            if (BtnSubmit == "添加")
            {
                //如果没有填写条码号,将默认以当前时间创建一个条码号
                if (model.Co_bar_code == null || model.Co_bar_code == "")
                {
                    model.Co_bar_code = DateTime.Now.ToString("yyMMddHHmmss");
                }
                //保存图片地址
                string path = Server.MapPath("/image/");
                commodityBusinessLayer.InsertCommodity(model, path);
                return(RedirectToAction("Attributes"));
            }
            else if (BtnSubmit == "提交更改")
            {
                string path = Server.MapPath("/image/");
                commodityBusinessLayer.UpdataCommoditys(model.Co_Id.ToString(), model, path);
                return(RedirectToAction("Attributes"));
            }

            //如果不是按键操作,刷新本页面
            return(PartialView("CreateCommodity"));
        }
        public ActionResult InOutTable()
        {
            //if (Session["Table_Id"] == null)
            if (Table_Id == "" || Table_Id == null)
            {
                //没有创建表单号
                return(new EmptyResult());
            }
            //获取信息
            InOutTableViewModel inOutTableViewModel = new InOutTableViewModel();

            inOutTableViewModel.type = I_type;
            inOutTableViewModel.commodityViewModels = new List <CommodityViewModel>();
            inOutTableViewModel.IO_id = Table_Id;

            //通过表号查询storate表的数据(物品编号,数量,时间),
            //通过编号查询commodity表
            //将数据(commodity表、时间、数量)存入CommodityViewModel
            CommodityBusinessLayer commodityBusinessLayer = new CommodityBusinessLayer();
            Commodity            commodity;
            StorageBusinessLayer storageBusinessLayer = new StorageBusinessLayer();
            //List<Storage> storages = storageBusinessLayer.GetStorage("IO_Id", Session["Table_Id"].ToString());
            List <Storage> storages = storageBusinessLayer.GetStorage("IO_Id", Table_Id);

            foreach (Storage storage in storages)
            {
                commodity = commodityBusinessLayer.GetCommodity(storage.Co_id, "", "");
                inOutTableViewModel.commodityViewModels.Add(new CommodityViewModel()
                {
                    commodity = commodity, Count = storage.Count, Out_into_date = storage.IntoDate
                });
            }

            return(PartialView("InOutTable", inOutTableViewModel));
        }
        public ActionResult DeleteItem(string T_name, string D_name, string D_id, string BtnSubmit)
        {
            if (BtnSubmit == "确定")
            {
                switch (T_name)
                {
                case "物品":
                    //Commodity表的删除操作
                    CommodityBusinessLayer commodityBusinessLayer = new CommodityBusinessLayer();
                    string path = Server.MapPath("/image/");
                    commodityBusinessLayer.DeleteCommodity(D_id, path);
                    return(RedirectToAction("Attributes"));

                case "用户":
                    UserBusinessLayer userBusinessLayer = new UserBusinessLayer();
                    userBusinessLayer.DeleteUser(D_id);
                    return(RedirectToAction("Information"));

                default:
                    return(RedirectToAction("Warehouse"));
                }
            }
            else if (BtnSubmit == "取消")
            {
                return(RedirectToAction("Warehouse"));
            }

            //如果不是按键操作,刷新本页面
            CreateWarehouseViewModel createWarehouseViewModel = new CreateWarehouseViewModel();

            createWarehouseViewModel.warehouse = new Warehouse();
            return(PartialView("CreateWarehouse", createWarehouseViewModel));
        }
        public ActionResult searchAttrbutetes(string Select, string name, string BtnSubmit, int?page)
        {
            if (BtnSubmit != "Attributes")
            {
                RedirectToAction("view");
            }
            if (name == null || name == "")
            {
                return(RedirectToAction("Attributes"));
            }
            //如果BtnSubmit是触发的搜索按键
            AttributesViewModel attributesViewModel = new AttributesViewModel();

            attributesViewModel.IsSearch = true;
            attributesViewModel.UserName = Session["User"].ToString();//继承的,显示右边的用户名

            CommodityBusinessLayer commodityBusinessLayer = new CommodityBusinessLayer();

            //第几页
            int pageNumber = page ?? 1;
            //每页显示多少条
            int pageSize = int.Parse(ConfigurationManager.AppSettings["pageSize"]);

            //attributesViewModel.commodities = commodityBusinessLayer.GetCommodity(Select, name).ToPagedList(pageNumber, pageSize);
            List <Commodity>         commodities        = commodityBusinessLayer.GetCommodity(Select, name);
            List <CommPathViewModel> commPathViewModels = new List <CommPathViewModel>();
            string path;

            foreach (var com in commodities)
            {
                path = Server.MapPath("/image/");
                if (!System.IO.File.Exists(path))
                {
                    //如果不存在这个文件,则创建
                    BarCode barCode = new BarCode();
                    barCode.Code(com.Co_bar_code, path);
                }
                commPathViewModels.Add(new CommPathViewModel()
                {
                    commodity = com, path = "/image/" + com.Co_bar_code + ".jpg"
                });
            }
            attributesViewModel.commPathViewModels = commPathViewModels.ToPagedList(pageNumber, pageSize);

            attributesViewModel.commoditie = new Commodity();

            return(View("Attributes", attributesViewModel));
        }
Пример #5
0
        /// <summary>
        /// 返回在存的全部数据
        /// </summary>
        /// <param name="U_name"></param>
        /// <returns></returns>
        public StorageViewModel GetStorageViewModel(bool Display, string U_name, int pageNumber = 1)
        {
            StorageViewModel storageViewModel = new StorageViewModel();

            storageViewModel.UserName = U_name;
            storageViewModel.existTableListViewModel         = new ExistTableListViewModel();
            storageViewModel.existTableListViewModel.Display = Display ? "" : "none";
            //storageViewModel.existTableListViewModel.existTableViewModels = new List<ExistTableViewModel>();
            List <ExistTableViewModel> existTableViewModels = new List <ExistTableViewModel>();

            ExistBusinessLayer       existBusinessLayer       = new ExistBusinessLayer();
            CommodityBusinessLayer   commodityBusinessLayer   = new CommodityBusinessLayer();
            OutIntoWareBusinessLayer outIntoWareBusinessLayer = new OutIntoWareBusinessLayer();
            UserBusinessLayer        userBusinessLayer        = new UserBusinessLayer();
            WarehouseBusinessLayer   warehouseBusinessLayer   = new WarehouseBusinessLayer();

            //得到全部在存表中的数据
            List <Exist> exists = existBusinessLayer.GetExist();
            //Out_Into_ware out_Into_Ware;
            ExistTableViewModel existTableViewModel;

            foreach (Exist item in exists)
            {
                existTableViewModel       = new ExistTableViewModel();
                existTableViewModel.exist = item;
                //out_Into_Ware = outIntoWareBusinessLayer.GetOut_Into_ware(item.IO_Id);
                //得到姓名
                existTableViewModel.U_name = userBusinessLayer.GetUsers("员工编号", item.U_id.ToString()).FirstOrDefault().U_name;
                //得到仓库名
                existTableViewModel.W_name    = warehouseBusinessLayer.GetWarehouse("仓库编号", item.W_id.ToString()).FirstOrDefault().Wa_name;
                existTableViewModel.commodity = commodityBusinessLayer.GetCommodity("商品编号", item.Co_id.ToString()).FirstOrDefault();

                //storageViewModel.existTableListViewModel.existTableViewModels.Add(existTableViewModel);
                existTableViewModels.Add(existTableViewModel);
            }

            //每页显示多少条
            //int pageSize = int.Parse(ConfigurationManager.AppSettings["pageSize"]);
            storageViewModel.existTableListViewModel.existTableViewModels = existTableViewModels;

            return(storageViewModel);
        }
        //[HttpGet]
        public ActionResult Attributes(int?page)
        {
            AttributesViewModel attributesViewModel = new AttributesViewModel();

            attributesViewModel.IsSearch = false;
            attributesViewModel.UserName = Session["User"].ToString();

            CommodityBusinessLayer commodityBusinessLayer = new CommodityBusinessLayer();

            //第几页
            int pageNumber = page ?? 1;
            //每页显示多少条
            int pageSize = int.Parse(ConfigurationManager.AppSettings["pageSize"]);

            List <Commodity>         commodities        = commodityBusinessLayer.GetCommodity();
            List <CommPathViewModel> commPathViewModels = new List <CommPathViewModel>();
            string path;

            foreach (var com in commodities)
            {
                path = Server.MapPath("/image/");
                if (!System.IO.File.Exists(path))
                {
                    //如果不存在这个文件,则创建
                    BarCode barCode = new BarCode();
                    barCode.Code(com.Co_bar_code, path);
                }
                commPathViewModels.Add(new CommPathViewModel()
                {
                    commodity = com, path = "/image/" + com.Co_bar_code + ".jpg"
                });
            }
            attributesViewModel.commPathViewModels = commPathViewModels.ToPagedList(pageNumber, pageSize);
            //attributesViewModel.commodities = commodities.ToPagedList(pageNumber, pageSize);

            attributesViewModel.commoditie = new Commodity();

            return(View("Attributes", attributesViewModel));
        }
        //[HttpGet]
        public ActionResult RedirectStorage(int?page)
        {
            MyStorageBusinessLayer storageBusinessLayer = new MyStorageBusinessLayer();
            //判断是否为管理员,是管理员则为空,不是则为none,对应修改按钮是否显示
            bool Display = (level.Admin == (level)Session["level"]);
            //获取显示的数据
            StorageViewModel storageViewMode1;
            int pageSize   = int.Parse(ConfigurationManager.AppSettings["pageSize"]);
            int pageNumber = page ?? 1;

            while (IsSearchExist)
            {
                //获取user id
                string U_id = null;
                if (!S_userMember.Equals(new UserMember()))
                {
                    if (S_userMember.U_Id != "" || S_userMember.U_name != "")
                    {
                        UserBusinessLayer userBusinessLayer = new UserBusinessLayer();
                        List <User>       users             = userBusinessLayer.GetUsers(S_userMember);
                        if (users == null)
                        {
                            break;
                        }
                        U_id = users.FirstOrDefault().U_Id.ToString();
                    }
                }

                //获取全部exist的数据
                storageViewMode1 = storageBusinessLayer.GetStorageViewModel(Display, Session["User"].ToString(), pageNumber);

                //获取comm id集合
                List <Commodity> commodities = new List <Commodity>();
                if (!S_commodityMember.Equals(new CommodityMember()))
                {
                    CommodityBusinessLayer commodityBusinessLayer = new CommodityBusinessLayer();
                    commodities = commodityBusinessLayer.GetCommodities(S_commodityMember);
                }

                //获取ware id集合
                List <Warehouse> warehouses = new List <Warehouse>();
                if (!S_warehouseMember.Equals(new WarehouseMember()))
                {
                    WarehouseBusinessLayer warehouseBusinessLayer = new WarehouseBusinessLayer();
                    warehouses = warehouseBusinessLayer.GetWarehouse(S_warehouseMember);
                }

                bool[] k = new bool[4];
                ExistTableViewModel existTableViewModel;
                for (int i = storageViewMode1.existTableListViewModel.existTableViewModels.Count() - 1; i >= 0; i--)
                {
                    k[0] = k[1] = k[2] = k[3] = true;
                    existTableViewModel = storageViewMode1.existTableListViewModel.existTableViewModels[i];
                    //是否符合物品条件
                    if (U_id == null || existTableViewModel.exist.U_id.ToString() == U_id)
                    {
                        k[0] = false;
                    }
                    //是否符合物品条件
                    if (commodities != null && commodities.Count() > 0)
                    {
                        foreach (Commodity commodity in commodities)
                        {
                            if (commodity.Co_Id == existTableViewModel.exist.Co_id)
                            {
                                k[1] = false;
                                break;
                            }
                        }
                    }
                    else
                    {
                        k[1] = false;
                    }
                    //是否符合仓库条件
                    if (warehouses != null && warehouses.Count() > 0)
                    {
                        foreach (Warehouse warehouse in warehouses)
                        {
                            if (warehouse.Wa_Id == existTableViewModel.exist.W_id)
                            {
                                k[2] = false;
                                break;
                            }
                        }
                    }
                    else
                    {
                        k[2] = false;
                    }
                    //是否符合时间区间
                    DateTime dateTime = new DateTime();
                    if ((S_existMember.Star_date.Equals(dateTime.ToString()) || DateTime.Compare(Convert.ToDateTime(S_existMember.Star_date), existTableViewModel.exist.IntoDate) != 1) &&
                        (S_existMember.End_date.Equals(dateTime.ToString()) || DateTime.Compare(Convert.ToDateTime(S_existMember.End_date), existTableViewModel.exist.IntoDate) != -1))
                    {
                        k[3] = false;
                    }
                    //整合条件
                    if (k[0] || k[1] || k[2] || k[3])
                    {
                        storageViewMode1.existTableListViewModel.existTableViewModels.Remove(existTableViewModel);
                    }
                }

                // storageViewMode1 = storageBusinessLayer.GetStorageViewModel(Display, Session["User"].ToString());
                storageViewMode1.existTableListViewModel.iPagedLists = storageViewMode1.existTableListViewModel.existTableViewModels.ToPagedList(pageNumber, pageSize);
                return(View("Storage", storageViewMode1));
            }

            storageViewMode1 = storageBusinessLayer.GetStorageViewModel(Display, Session["User"].ToString());
            storageViewMode1.existTableListViewModel.iPagedLists = storageViewMode1.existTableListViewModel.existTableViewModels.ToPagedList(pageNumber, pageSize);
            return(View("Storage", storageViewMode1));
        }
        public ActionResult InOutWarehouse(string BtnSubmit, Commodity commodity, string sid, int Count)
        {
            InOutWarehouseViewModel inOutWarehouseViewModel = new InOutWarehouseViewModel();

            inOutWarehouseViewModel.UserName = Session["User"].ToString();
            if (BtnSubmit == "手动入库" || BtnSubmit == "手动出库")
            {
                if (!SelectIntoOut)
                {
                    //显示物品的数据
                    CommodityBusinessLayer commodityBusinessLayer = new CommodityBusinessLayer();
                    inOutWarehouseViewModel.commodity = commodityBusinessLayer.GetCommodity(sid, commodity);
                    if (!inOutWarehouseViewModel.commodity.Equals(commodity))
                    {
                        SelectIntoOut = true;
                    }
                }
                else
                {
                    //存储数据到Storage表(出入库单号、物品号、物品数量)
                    StorageBusinessLayer storageBusinessLayer = new StorageBusinessLayer();
                    Storage storage = new Storage();
                    storage.Co_id = commodity.Co_Id;
                    //storage.IO_Id = Session["Table_Id"].ToString();
                    storage.IO_Id    = Table_Id;
                    storage.Count    = Count;
                    storage.IntoDate = DateTime.Now;
                    storageBusinessLayer.InsertStorage(storage);

                    SelectIntoOut = false;
                    inOutWarehouseViewModel.commodity = new Commodity();
                }
            }
            else
            {
                StorageBusinessLayer storageBusinessLayer = new StorageBusinessLayer();
                if (BtnSubmit == "完成入库")
                {
                    //将入库的数据存储到Exist表中
                    ExistBusinessLayer          existBusinessLayer          = new ExistBusinessLayer();
                    InOutWarehouseBusinessLayer inOutWarehouseBusinessLayer = new InOutWarehouseBusinessLayer();
                    Exist          exist;
                    List <Storage> storages = storageBusinessLayer.GetStorage("IO_Id", Table_Id);
                    foreach (Storage storage in storages)
                    {
                        exist = inOutWarehouseBusinessLayer.GetExist(storage);
                        existBusinessLayer.InsertExist(exist);
                    }
                }
                else if (BtnSubmit == "完成出库")
                {
                    //将入库的数据在exit表中删除
                    //将入库的数据存储到Exist表中
                    ExistBusinessLayer          existBusinessLayer          = new ExistBusinessLayer();
                    InOutWarehouseBusinessLayer inOutWarehouseBusinessLayer = new InOutWarehouseBusinessLayer();
                    //Exist exist;
                    List <Storage> storages = storageBusinessLayer.GetStorage("IO_Id", Table_Id);
                    foreach (Storage storage in storages)
                    {
                        existBusinessLayer.Delete(storage);
                    }
                }
                else if (BtnSubmit == "取消入库" || BtnSubmit == "取消出库")
                {
                    //将入库的数据删除
                    storageBusinessLayer.Delete(Table_Id);
                    OutIntoWareBusinessLayer outIntoWareBusinessLayer = new OutIntoWareBusinessLayer();
                    outIntoWareBusinessLayer.Delete(Table_Id);
                }
                IsIntoOutWaretor = false; //设置为不是出入库状态IsIntoOutWaretor = false;
                SelectIntoOut    = false; //设置状态为取消SelectIntoOut = false;
                Table_Id         = "";    //表数据清除
            }

            I_commodity = inOutWarehouseViewModel.commodity;

            return(RedirectToAction("RedirectInOutWarehouse"));
            //return View("inOutWarehouse", inOutWarehouseViewModel);
        }
Пример #9
0
        /// <summary>
        /// 得到符合条件的在存数据
        /// </summary>
        /// <param name="U_name">登陆人</param>
        /// <param name="Select">属性</param>
        /// <param name="name">属性值</param>
        /// <returns></returns>
        public StorageViewModel GetStorageViewModel(bool Display, string U_name, string Select, string name, int pageNumber = 1)
        {
            StorageViewModel storageViewModel = new StorageViewModel();

            storageViewModel.UserName = U_name;
            storageViewModel.existTableListViewModel         = new ExistTableListViewModel();
            storageViewModel.existTableListViewModel.Display = Display ? "" : "none";
            //storageViewModel.existTableListViewModel.existTableViewModels = new List<ExistTableViewModel>();
            List <ExistTableViewModel> existTableViewModels = new List <ExistTableViewModel>();

            ExistBusinessLayer       existBusinessLayer       = new ExistBusinessLayer();
            CommodityBusinessLayer   commodityBusinessLayer   = new CommodityBusinessLayer();
            OutIntoWareBusinessLayer outIntoWareBusinessLayer = new OutIntoWareBusinessLayer();
            UserBusinessLayer        userBusinessLayer        = new UserBusinessLayer();
            WarehouseBusinessLayer   warehouseBusinessLayer   = new WarehouseBusinessLayer();

            //得到全部在存表中的数据
            List <Exist> exists;

            if (Select == "入库单号" || Select == "商品编号")
            {
                exists = existBusinessLayer.GetExist(Select, name);
            }
            else
            {
                exists = existBusinessLayer.GetExist();
            }
            //Out_Into_ware out_Into_Ware;
            ExistTableViewModel existTableViewModel;

            foreach (Exist item in exists)
            {
                existTableViewModel       = new ExistTableViewModel();
                existTableViewModel.exist = item;
                //out_Into_Ware = outIntoWareBusinessLayer.GetOut_Into_ware(item.IO_Id);
                //得到姓名
                existTableViewModel.U_name = userBusinessLayer.GetUsers("员工编号", item.U_id.ToString()).FirstOrDefault().U_name;
                if (Select == "入库员工" && existTableViewModel.U_name != name)
                {
                    continue;
                }
                //得到仓库名
                existTableViewModel.W_name = warehouseBusinessLayer.GetWarehouse("仓库编号", item.W_id.ToString()).FirstOrDefault().Wa_name;
                if (Select == "存储仓库" && existTableViewModel.W_name != name)
                {
                    continue;
                }
                //existTableViewModel.commodity = commodityBusinessLayer.GetCommodity("商品编号", item.Co_id.ToString()).FirstOrDefault();
                CommodityMember commodityMember = new CommodityMember();
                switch (Select)
                {
                case "商品编号":
                    commodityMember.Co_Id = name;
                    break;

                case "商品名称":
                    commodityMember.Co_name = name;
                    break;

                case "条码编号":
                    commodityMember.Co_bar_code = name;
                    break;

                case "商品分类":
                    commodityMember.Co_type = name;
                    break;
                }
                existTableViewModel.commodity = commodityBusinessLayer.GetCommodities(commodityMember).FirstOrDefault();


                //storageViewModel.existTableListViewModel.existTableViewModels.Add(existTableViewModel);
                existTableViewModels.Add(existTableViewModel);
            }

            //每页显示多少条
            //int pageSize = int.Parse(ConfigurationManager.AppSettings["pageSize"]);
            storageViewModel.existTableListViewModel.existTableViewModels = existTableViewModels;

            return(storageViewModel);
        }