Esempio n. 1
0
        public static int AddCategory(ProductCategory pc)
        {
            WarehouseEntities entity = new WarehouseEntities();

            entity.ProductCategory.Add(pc);
            return(entity.SaveChanges());
        }
Esempio n. 2
0
        public static int Add(ReturnOrderStock b)
        {
            WarehouseEntities entity = new WarehouseEntities();

            entity.ReturnOrderStock.Add(b);
            return(entity.SaveChanges());
        }
        public void DeleteFromRepository(WarehouseLocation item)
        {
            if (_repositoryContext.GetEntityDescriptor(item) != null)
            {
                //if it exists in the db delete it from the db
                WarehouseEntities context = new WarehouseEntities(_rootUri);
                context.MergeOption = MergeOption.AppendOnly;
                context.IgnoreResourceNotFoundException = true;
                WarehouseLocation deletedWarehouseLocation = (from q in context.WarehouseLocations
                                                              where q.WarehouseLocationID == item.WarehouseLocationID
                                                              select q).FirstOrDefault();
                if (deletedWarehouseLocation != null)
                {
                    context.DeleteObject(deletedWarehouseLocation);
                    context.SaveChanges();
                }
                context = null;

                _repositoryContext.MergeOption = MergeOption.AppendOnly;
                //if it is being tracked remove it...
                if (GetWarehouseLocationEntityState(item) != EntityStates.Detached)
                {
                    _repositoryContext.Detach(item);
                }
            }
        }
        public DBResult EditAll(List <InventoryList> entities)
        {
            if (entities == null)
            {
                return(DBResult.WrongParameter);
            }

            using (var db = new WarehouseEntities())
            {
                foreach (var entity in entities)
                {
                    if (EntityHelper.HasNullProperty(entity))
                    {
                        return(DBResult.WrongParameter);
                    }

                    var inventoryList = db.InventoryList.FirstOrDefault(l => l.POID == entity.POID);
                    if (inventoryList == null)
                    {
                        return(DBResult.NotFound);
                    }

                    EntityHelper.CopyEntity(entity, inventoryList);
                }

                db.SaveChanges();
                return(DBResult.Succeed);
            }
        }
        private static List <Merchandise> merchandises()
        {
            var context           = new WarehouseEntities();
            var listOfMerchandise = context.Merchandise.ToList();

            return(listOfMerchandise);
        }
Esempio n. 6
0
        public List <logModel.logString> getLogsByItem(int itemID)
        {
            using (var db = new WarehouseEntities())
            {
                List <logModel.logDate> logs =
                    (from l in db.logs
                     where l.itemID == itemID
                     join i in db.items on l.itemID equals i.itemID
                     select new logModel.logDate
                {
                    historyID = l.historyID,
                    itemID = l.itemID,
                    itemName = i.itemName,
                    total = l.total,
                    description = l.description,
                    date = l.date,
                    invoicenumber = l.invoicenumber
                }).ToList();

                List <logModel.logString> lms = (from l in logs
                                                 select new logModel.logString
                {
                    historyID = l.historyID,
                    itemID = l.itemID,
                    itemName = l.itemName,
                    total = l.total,
                    description = l.description,
                    date = l.date.ToString("yyyyMMdd"),
                    invoicenumber = l.invoicenumber
                }).ToList();
                return(lms);
            }
        }
        public static List <Temp> GetMetaData(this WarehouseCode entityObject)
        {
            XERP.Server.DAL.WarehouseDAL.DALUtility dalUtility = new DALUtility();
            List <Temp> tempList = new List <Temp>();
            int         id       = 0;

            using (WarehouseEntities ctx = new WarehouseEntities(dalUtility.EntityConectionString))
            {
                var c            = ctx.WarehouseCodes.FirstOrDefault();
                var queryResults = from meta in ctx.MetadataWorkspace.GetItems(DataSpace.CSpace)
                                   .Where(m => m.BuiltInTypeKind == BuiltInTypeKind.EntityType)
                                   from query in (meta as EntityType).Properties
                                   .Where(p => p.DeclaringType.Name == entityObject.GetType().Name)
                                   select query;

                if (queryResults.Count() > 0)
                {
                    foreach (var queryResult in queryResults.ToList())
                    {
                        Temp temp = new Temp();
                        temp.ID          = id;
                        temp.Name        = queryResult.Name.ToString();
                        temp.ShortChar_1 = queryResult.TypeUsage.EdmType.Name;
                        if (queryResult.TypeUsage.EdmType.Name == "String")
                        {
                            temp.Int_1 = Convert.ToInt32(queryResult.TypeUsage.Facets["MaxLength"].Value);
                        }
                        temp.Bool_1 = false; //we use this as a error trigger false = not an error...
                        tempList.Add(temp);
                        id++;
                    }
                }
            }
            return(tempList);
        }
Esempio n. 8
0
        public static int Add(MoveReport b)
        {
            WarehouseEntities entity = new WarehouseEntities();

            entity.MoveReport.Add(b);
            return(entity.SaveChanges());
        }
Esempio n. 9
0
        private static List <User_Inf> getUsers()
        {
            var contex = new WarehouseEntities();
            var users  = contex.User_Inf.ToList();

            return(users);
        }
Esempio n. 10
0
        public static List <Depart> bumenselect()
        {
            WarehouseEntities entities = new WarehouseEntities();
            var obj = from p in entities.Depart where p.IsDelete == 0 select p;

            return(obj.ToList());
        }
Esempio n. 11
0
        //获取总条数
        public static int GetMoveReportCount()
        {
            WarehouseEntities entity = new WarehouseEntities();
            var obj = (from p in entity.MoveReport where p.IsDelete == 0 select p).Count();

            return(obj);
        }
Esempio n. 12
0
        public static List <Role> juesselect()
        {
            WarehouseEntities entities = new WarehouseEntities();
            var obj = from p in entities.Role where p.IsDelete == 0 select p;

            return(obj.ToList());
        }
Esempio n. 13
0
        /// <summary>
        /// The main function that runs the update of log, item, and warehouse.
        /// </summary>
        /// <param name="itemID"></param>
        /// <param name="totalnumber"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public warehouse UpdateWarehouse(int itemID, int totalnumber, string description)
        {
            using (var db = new WarehouseEntities())
            {
                item existingitem = (from i in db.items where i.itemID == itemID select i).FirstOrDefault();

                if (existingitem != null)
                {   // if the item is already registered
                    warehouse oldwarehouse = Find(w => w.itemID == itemID);
                    if (oldwarehouse != null)
                    {
                        int totalstock = oldwarehouse.totalstock;
                        totalstock = _reasonRepository.calculate(description) > 0 ? totalstock + totalnumber : totalstock - totalnumber;
                        oldwarehouse.totalstock = totalstock;
                        Update(oldwarehouse);
                        return(oldwarehouse);
                    }
                    else
                    {
                        warehouse newWarehouse = new warehouse();
                        newWarehouse.itemID     = existingitem.itemID;
                        newWarehouse.totalstock = _reasonRepository.calculate(description) > 0 ? totalnumber : (-1) * totalnumber;

                        return(Create(newWarehouse));
                    }
                }

                return(null);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="BadNum"></param>
        /// <returns></returns>
        public static IQueryable GetBadReportId(string BadNum)
        {
            WarehouseEntities entity = new WarehouseEntities();
            //先修改主表数据
            var ll = from p in entity.BadReport
                     where p.BadNum == BadNum
                     select new
            {
                Id        = p.Id,
                BadNum    = p.BadNum,
                BadTypeId = p.BadTypeId,
                ProductId = p.ProductId,
                //BadTypeName= BadReportType.BadTypeName,
                Num       = p.Num,
                SumMoney  = p.SumMoney,
                Status    = p.Status,
                Operation = p.Operation,
                AuditUser = p.AuditUser,
                AuditTime = p.AuditTime,
                IsDelete  = p.IsDelete,
                Remark    = p.Remark
            };

            return(ll);
        }
Esempio n. 15
0
        //根据ID查询
        public static List <Function> menuSelectById(int id)
        {
            WarehouseEntities con = new WarehouseEntities();
            var obj = from p in con.Function where p.NodeId == id select p;

            return(obj.ToList());
        }
Esempio n. 16
0
        public static PageList getMeasureByName(int pageIndex, int pageSize, string name)
        {
            WarehouseEntities con  = new WarehouseEntities();
            PageList          list = new PageList();
            var obj = from p in con.Measure
                      where p.IsDelete == 0
                      orderby p.Id
                      select new
            {
                Id          = p.Id,
                MeasureNum  = p.MeasureNum,
                MeasureName = p.MeasureName
            };

            if (!string.IsNullOrEmpty(name))
            {
                for (int i = 0; i < name.Length; i++)
                {
                    if (!Char.IsNumber(name, i))
                    {
                        obj = obj.Where(item => item.MeasureName.IndexOf(name) != -1);
                    }
                    else
                    {
                        string Name = name;
                        obj = obj.Where(item => item.MeasureName.IndexOf(name) != -1 || item.MeasureNum == Name);
                    }
                }
            }
            list.DataList = obj.Skip((pageIndex - 1) * pageSize).Take(pageSize);
            int rows = obj.Count();

            list.PageCount = rows;
            return(list);
        }
Esempio n. 17
0
        public logModel.logString getLastLog()
        {
            using (var db = new WarehouseEntities())
            {
                List <logModel.logDate> lastlog = (from l in db.logs
                                                   orderby l.historyID descending
                                                   join i in db.items on l.itemID equals i.itemID
                                                   select new logModel.logDate
                {
                    historyID = l.historyID,
                    itemID = l.itemID,
                    itemName = i.itemName,
                    total = l.total,
                    description = l.description,
                    date = l.date,
                    invoicenumber = l.invoicenumber
                }).ToList();

                logModel.logString ll = (from l in lastlog
                                         select new logModel.logString
                {
                    historyID = l.historyID,
                    itemID = l.itemID,
                    itemName = l.itemName,
                    total = l.total,
                    description = l.description,
                    date = l.date.ToString("yyyyMMdd"),
                    invoicenumber = l.invoicenumber
                }).First();
                return(ll);
            }
        }
Esempio n. 18
0
        //新增
        public static int AddMeasure(Measure mes)
        {
            WarehouseEntities con = new WarehouseEntities();

            con.Measure.Add(mes);
            return(con.SaveChanges());
        }
Esempio n. 19
0
        public List <logModel.logString> getLogsByName(string itemName)
        {
            using (var db = new WarehouseEntities())
            {
                List <logModel.logDate> logs = (from i in db.items
                                                where i.itemName == itemName
                                                join l in db.logs on i.itemID equals l.itemID
                                                select new logModel.logDate
                {
                    historyID = l.historyID,
                    itemID = l.itemID,
                    itemName = itemName,
                    total = l.total,
                    description = l.description,
                    date = l.date,
                    invoicenumber = l.invoicenumber
                }).ToList();

                List <logModel.logString> lms = (from l in logs.AsEnumerable()
                                                 select new logModel.logString
                {
                    historyID = l.historyID,
                    itemID = l.itemID,
                    itemName = l.itemName,
                    total = l.total,
                    description = l.description,
                    date = l.date.ToString("yyyyMMdd"),
                    invoicenumber = l.invoicenumber
                }).ToList();
                return(lms);
            }
        }
Esempio n. 20
0
        //根据ID查询
        public static List <Measure> mesSelectById(int id)
        {
            WarehouseEntities con = new WarehouseEntities();
            var obj = from p in con.Measure where p.Id == id select p;

            return(obj.ToList());
        }
        public DBResult DeleteAll(List <InventoryList> entities)
        {
            if (entities == null)
            {
                return(DBResult.WrongParameter);
            }

            using (var db = new WarehouseEntities())
            {
                foreach (var entity in entities)
                {
                    if (string.IsNullOrEmpty(entity.POID))
                    {
                        return(DBResult.WrongParameter);
                    }

                    var inventoryList = db.InventoryList.FirstOrDefault(l => l.POID == entity.POID);
                    if (inventoryList == null)
                    {
                        return(DBResult.NotFound);
                    }

                    db.InventoryList.Remove(inventoryList);
                }

                db.SaveChanges();
                return(DBResult.Succeed);
            }
        }
Esempio n. 22
0
        //新增
        public static int AddCustomer(Customer cus)
        {
            WarehouseEntities con = new WarehouseEntities();

            con.Customer.Add(cus);
            return(con.SaveChanges());
        }
Esempio n. 23
0
        private static List <Types> getTypes()
        {
            var context     = new WarehouseEntities();
            var listOfTypes = context.Types.ToList();

            return(listOfTypes);
        }
Esempio n. 24
0
        //根据ID查询
        public static List <Customer> CustomerSelectById(int id)
        {
            WarehouseEntities con = new WarehouseEntities();
            var obj = from p in con.Customer where p.Id == id select p;

            return(obj.ToList());
        }
Esempio n. 25
0
        //获取总条数
        public static int GetReturnOrderStockCount()
        {
            WarehouseEntities entity = new WarehouseEntities();
            var obj = (from p in entity.ReturnOrderStock where p.IsDelete == 0 select p).Count();

            return(obj);
        }
Esempio n. 26
0
        //页面加载
        //public static PageList getDepart(int pageIndex, int pageSize)
        //{
        //    WarehouseEntities con = new WarehouseEntities();
        //    PageList list = new PageList();
        //    var obj = from p in con.Depart
        //              where p.IsDelete == 0
        //              orderby p.Id
        //              select new
        //              {
        //                  Id = p.Id,
        //                  DepartNum = p.DepartNum,
        //                  DepartName = p.DepartName,
        //                  CreateTime = p.CreateTime
        //              };
        //    list.DataList = obj.Skip((pageIndex - 1) * pageSize).Take(pageSize);
        //    //设置总页数
        //    int rows = obj.Count();
        //    list.PageCount = rows; //rows % pageSize == 0 ? rows / pageSize : rows / pageSize + 1;

        //    return list;
        //}

        //新增
        public static int Add(Depart det)
        {
            WarehouseEntities con = new WarehouseEntities();

            con.Depart.Add(det);
            return(con.SaveChanges());
        }
        private WarehouseLocationSingletonRepository()
        {
            ServiceUtility serviceUtility = new ServiceUtility();

            _rootUri           = serviceUtility.BaseUri;
            _repositoryContext = new WarehouseEntities(_rootUri);
        }
Esempio n. 28
0
        //新增
        public static int Add(Function fun)
        {
            WarehouseEntities con = new WarehouseEntities();

            con.Function.Add(fun);
            return(con.SaveChanges());
        }
        public IEnumerable <WarehouseLocation> GetWarehouseLocations(WarehouseLocation itemQuerryObject, string companyID)
        {
            _repositoryContext             = new WarehouseEntities(_rootUri);
            _repositoryContext.MergeOption = MergeOption.AppendOnly;
            _repositoryContext.IgnoreResourceNotFoundException = true;
            var queryResult = from q in _repositoryContext.WarehouseLocations.Expand("Warehouse/Plant")
                              where q.CompanyID == companyID
                              select q;

            if (!string.IsNullOrEmpty(itemQuerryObject.Name))
            {
                queryResult = queryResult.Where(q => q.Name.StartsWith(itemQuerryObject.Name.ToString()));
            }

            if (!string.IsNullOrEmpty(itemQuerryObject.Description))
            {
                queryResult = queryResult.Where(q => q.Description.StartsWith(itemQuerryObject.Description.ToString()));
            }

            if (!string.IsNullOrEmpty(itemQuerryObject.WarehouseLocationTypeID))
            {
                queryResult = queryResult.Where(q => q.WarehouseLocationTypeID.StartsWith(itemQuerryObject.WarehouseLocationTypeID.ToString()));
            }

            if (!string.IsNullOrEmpty(itemQuerryObject.WarehouseLocationCodeID))
            {
                queryResult = queryResult.Where(q => q.WarehouseLocationCodeID.StartsWith(itemQuerryObject.WarehouseLocationCodeID.ToString()));
            }

            return(queryResult);
        }
Esempio n. 30
0
        public static PageList GetQuery(int pageIndex, int pageSize, ProductCategory pc)
        {
            //实例化分页类
            PageList list = new PageList();

            WarehouseEntities entity = new WarehouseEntities();
            var query = from p in entity.ProductCategory select p;

            if (!string.IsNullOrEmpty(pc.PCateName))
            {
                query = query.Where(p => p.PCateName.Contains(pc.PCateName));
            }
            var obj = from p in query
                      orderby p.Id
                      where p.IsDelete == 0
                      select new
            {
                Id         = p.Id,
                IsDelete   = p.IsDelete,
                PCateName  = p.PCateName,
                PCateNum   = p.PCateNum,
                Remark     = p.Remark,
                CreateUser = p.CreateUser,
                CreateTime = p.CreateTime
            };

            //设置分页数据
            list.DataList = obj.Skip((pageIndex - 1) * pageSize).Take(pageSize);
            //设置总页数
            int rows = query.Count();

            list.PageCount = rows;/*% pageSize == 0 ? rows / pageSize : rows / pageSize + 1;*/
            return(list);
        }