/// <summary>
        ///
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public long InsertInfo(LocationInfo info)
        {
            ///工位代码③不允许重复,单字段进行全表校验
            int locationCnt = dal.GetCounts("[LOCATION] = N'" + info.Location + "'");

            if (locationCnt > 0)
            {
                throw new Exception("Err_:MC:0x00000163");
            }
            ///工位名称④、顺序号⑥在同一工段中不允许重复
            int locationNameCnt = dal.GetCounts("[LOCATION_NAME] = N'" + info.LocationName + "' and [WORKSHOP_SECTION] = N'" + info.WorkshopSection + "'");

            if (locationNameCnt > 0)
            {
                throw new Exception("Err_:MC:0x00000194");
            }
            ///当顺序号非空时再进行判断
            if (info.SequenceNo.GetValueOrDefault() > 0)
            {
                int sequenceNoCnt = dal.GetCounts("[SEQUENCE_NO] = " + info.SequenceNo + " and [WORKSHOP_SECTION] = N'" + info.WorkshopSection + "'");
                if (sequenceNoCnt > 0)
                {
                    throw new Exception("Err_:MC:0x00000195");
                }
            }
            return(dal.Add(info));
        }
예제 #2
0
        public void TestSetup(WheyMenContext context)
        {
            OrderDAL    Repo;
            LocationDAL LocDal;
            CustomerDAL CustDal;

            Repo    = new OrderDAL(context);
            LocDal  = new LocationDAL(context);
            CustDal = new CustomerDAL(context);
            var cust = new Customer
            {
                Id       = 1,
                Name     = "jon",
                LastName = "asd",
                Email    = "*****@*****.**",
                Username = "******",
                Pwd      = "asd"
            };
            var loc = new Loc
            {
                Id   = 1,
                Name = "gnc",
            };
            var prod = new Products
            {
                Id    = 1,
                Price = 12,
                Name  = "wpi",
            };
            var inventory = new Inventory
            {
                Id      = 5,
                Qty     = 10000,
                Pid     = 1,
                StoreId = 1
            };

            CustDal.Add(cust);
            LocDal.Add(loc);
            context.Products.Add(prod);
            context.Inventory.Add(inventory);
            context.SaveChanges();
        }