public ActionResult GetList()
        {
            int    status    = WebUtil.GetFormValue <int>("Status", 0);
            string orderNum  = WebUtil.GetFormValue <string>("OrderNum", string.Empty);
            string supName   = WebUtil.GetFormValue <string>("SupName", string.Empty);
            string beginTime = WebUtil.GetFormValue <string>("beginTime", string.Empty);
            string endTime   = WebUtil.GetFormValue <string>("endTime", string.Empty);
            int    pageSize  = WebUtil.GetFormValue <int>("PageSize", 10);
            int    pageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            int    InType    = WebUtil.GetFormValue <int>("InType", 0);
            string planNum   = WebUtil.GetFormValue <string>("planNum", string.Empty);

            PageInfo pageInfo = new PageInfo()
            {
                PageIndex = pageIndex, PageSize = pageSize
            };
            InStorageEntity entity = new InStorageEntity();

            if (status > 0)
            {
                entity.Where(a => a.Status == status);
            }
            if (!orderNum.IsEmpty())
            {
                entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%");
            }
            if (!supName.IsEmpty())
            {
                entity.AndBegin <InStorageEntity>()
                .And <InStorageEntity>("SupNum", ECondition.Like, "%" + supName + "%")
                .Or <InStorageEntity>("SupName", ECondition.Like, "%" + supName + "%")
                .End <InStorageEntity>()
                ;
            }
            if (!beginTime.IsEmpty() && !endTime.IsEmpty())
            {
                entity.Where("OrderTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime));
            }
            entity.And(a => a.StorageNum == this.DefaultStore);
            if (InType > 0)
            {
                entity.And(a => a.InType == InType);
            }
            if (!planNum.IsEmpty())
            {
                entity.And("ContractOrder", ECondition.Like, "%" + planNum + "%");
            }

            Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder();
            List <InStorageEntity> listResult = bill.GetList(entity, ref pageInfo);

            listResult = listResult == null ? new List <InStorageEntity>() : listResult;
            string json = ConvertJson.ListToJson <InStorageEntity>(listResult, "List");

            this.ReturnJson.AddProperty("Data", json);
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return(Content(this.ReturnJson.ToString()));
        }
Beispiel #2
0
        /// <summary>
        /// 根据入库单编号查询入库单
        /// </summary>
        /// <returns></returns>
        public InStorageEntity GetOrderByNum(string OrderNum)
        {
            InStorageEntity entity = new InStorageEntity();

            entity.IncludeAll();

            AdminEntity admin = new AdminEntity();

            admin.Include(a => new { CreateUserName = a.UserName });
            entity.Left <AdminEntity>(admin, new Params <string, string>()
            {
                Item1 = "CreateUser", Item2 = "UserNum"
            });

            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete)
            .And(a => a.CompanyID == this.CompanyID)
            .And(a => a.OrderNum == OrderNum);

            entity = this.InStorage.GetSingle(entity);
            return(entity);
        }
Beispiel #3
0
        /// <summary>
        /// 编辑入库单详细数量
        /// </summary>
        /// <param name="snNum"></param>
        /// <param name="num"></param>
        /// <returns></returns>
        public int EditInOrderNum(string snNum, double num)
        {
            InStorDetailEntity detail = new InStorDetailEntity();

            detail = new InStorDetailEntity();
            detail.Include(a => new { a.OrderNum, a.Num, a.InPrice });
            detail.Where(a => a.SnNum == snNum);
            detail = this.InStorDetail.GetSingle(detail);

            int line = 0;

            if (detail != null)
            {
                InStorDetailEntity editEntity = new InStorDetailEntity();
                editEntity.IncludeNum(true).IncludeAmount(true);
                editEntity.Num    = num;
                editEntity.Amount = num * detail.InPrice;
                editEntity.Where(a => a.SnNum == snNum);
                line = this.InStorDetail.Update(editEntity);

                string orderNum = detail.OrderNum;
                detail = new InStorDetailEntity();
                detail.IncludeNum(true).IncludeAmount(true);
                detail.Where(a => a.OrderNum == orderNum);
                List <InStorDetailEntity> list = this.InStorDetail.GetList(detail);

                double          total  = list.Sum(a => a.Num);
                double          amount = list.Sum(a => a.Amount);
                InStorageEntity entity = new InStorageEntity();
                entity.Num    = total;
                entity.Amount = amount;
                entity.IncludeNum(true).IncludeAmount(true);
                entity.Where(a => a.OrderNum == orderNum);

                line += this.InStorage.Update(entity);
            }
            return(line);
        }
Beispiel #4
0
        /// <summary>
        /// 获得某个供应商的所有订购产品数量
        /// </summary>
        /// <param name="supNum"></param>
        /// <param name="queryTime"></param>
        /// <param name="storageNum"></param>
        /// <returns></returns>
        public double GetNumBySupNum(string supNum, int queryTime, string storageNum)
        {
            InStorageEntity entity = new InStorageEntity();

            entity.IncludeNum(true);
            entity.Where("CreateTime", ECondition.Between, DateTime.Now.AddDays(-queryTime), DateTime.Now);
            entity.And("StorageNum", ECondition.Eth, storageNum);
            entity.And("SupNum", ECondition.Eth, supNum);
            entity.And("Status", ECondition.Eth, (int)EAudite.Pass);
            entity.And("IsDelete", ECondition.Eth, (int)EIsDelete.NotDelete);
            double allNum = 0;

            try
            {
                allNum = this.InStorage.Sum <double>(entity);
            }
            catch (Exception e)
            {
                allNum = 0;
                log.Info(e.Message);
            }
            return(allNum);
        }
        /// <summary>
        /// 导出Excel
        /// </summary>
        /// <returns></returns>
        public ActionResult ToExcel()
        {
            int      status    = WebUtil.GetFormValue <int>("Status", 0);
            string   orderNum  = WebUtil.GetFormValue <string>("OrderNum", string.Empty);
            string   supName   = WebUtil.GetFormValue <string>("SupName", string.Empty);
            string   beginTime = WebUtil.GetFormValue <string>("beginTime", string.Empty);
            string   endTime   = WebUtil.GetFormValue <string>("endTime", string.Empty);
            int      pageSize  = Int32.MaxValue;
            int      pageIndex = 1;
            PageInfo pageInfo  = new PageInfo()
            {
                PageIndex = pageIndex, PageSize = pageSize
            };
            InStorageEntity entity = new InStorageEntity();

            if (status > 0)
            {
                entity.Where(a => a.Status == status);
            }
            if (!orderNum.IsEmpty())
            {
                entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%");
            }
            if (!supName.IsEmpty())
            {
                entity.AndBegin <InStorageEntity>()
                .And <InStorageEntity>("SupNum", ECondition.Like, "%" + supName + "%")
                .Or <InStorageEntity>("SupName", ECondition.Like, "%" + supName + "%")
                .End <InStorageEntity>()
                ;
            }
            if (!beginTime.IsEmpty() && !endTime.IsEmpty())
            {
                entity.Where("OrderTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime));
            }
            Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder();
            List <InStorageEntity> listResult = bill.GetList(entity, ref pageInfo);

            listResult = listResult == null ? new List <InStorageEntity>() : listResult;
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("入库单单号"));
            dt.Columns.Add(new DataColumn("入库类型"));
            dt.Columns.Add(new DataColumn("供应商"));
            dt.Columns.Add(new DataColumn("关联单号"));
            dt.Columns.Add(new DataColumn("货品总数"));
            dt.Columns.Add(new DataColumn("总金额"));
            dt.Columns.Add(new DataColumn("状态"));
            dt.Columns.Add(new DataColumn("制单人"));
            dt.Columns.Add(new DataColumn("操作方式"));
            dt.Columns.Add(new DataColumn("创建时间"));
            foreach (InStorageEntity t in listResult)
            {
                DataRow row = dt.NewRow();
                row[0] = t.OrderNum;
                row[1] = EnumHelper.GetEnumDesc <EInType>(t.InType);
                row[2] = t.SupName;
                row[3] = t.ContractOrder;
                row[4] = t.Num;
                row[5] = t.Amount.ToString("0.00") + " 元";
                row[6] = EnumHelper.GetEnumDesc <EAudite>(t.Status);
                row[7] = t.CreateUserName;
                row[8] = EnumHelper.GetEnumDesc <EOpType>(t.OperateType);
                row[9] = t.OrderTime.ToString("yyyy-MM-dd");
                dt.Rows.Add(row);
            }
            string filePath = Server.MapPath("~/UploadFiles/");

            if (!System.IO.Directory.Exists(filePath))
            {
                System.IO.Directory.CreateDirectory(filePath);
            }
            string    filename = string.Format("入库单{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
            NPOIExcel excel    = new NPOIExcel("入库管理", "入库单", System.IO.Path.Combine(filePath, filename));

            excel.ToExcel(dt);
            this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());

            return(Content(this.ReturnJson.ToString()));
        }