public async Task <IActionResult> Edit(string id, [Bind("ProductLineId,Percentage,ProductId,createdAt,ComponentId")] ProductLine productLine)
        {
            if (id != productLine.ProductLineId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductLineExists(productLine.ProductLineId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"]   = new SelectList(_context.Product, "productId", "productName", productLine.ProductId);
            ViewData["componentId"] = new SelectList(_context.Product.Where(x => x.IsMaterial == true), "productId", "productName", productLine.ComponentId);
            return(View(productLine));
        }
        public void TestDecreaseAmountOnProductLine()
        {
            // Arrange
            var context = new Mock <ControllerContext>();
            var session = new MockHttpSession();

            List <ProductLine> productLineList = new List <ProductLine>();

            ShoppingCartController cartController = new ShoppingCartController();

            cartController.ControllerContext = context.Object;

            Product product = new Product();

            product.ProductId = 1;
            product.Price     = 100;

            ProductLine productLine = new ProductLine();

            productLine.Amount  = 1;
            productLine.Product = product;

            productLineList.Add(productLine);
            session.insertIntoDictionary("shoppingCart", productLineList);

            context.Setup(m => m.HttpContext.Session).Returns(session);

            // Act
            cartController.Add(product);
            cartController.DecreaseAmount(productLine.Product.ProductId);

            // Assert
            Assert.AreEqual(1, productLine.Amount);
        }
Exemple #3
0
 public Procedure(ProductLine productionLine, DateTime createdDate, int order)
 {
     _productionLine = productionLine;
     _formulas       = new List <Formula>();
     _createdDate    = createdDate;
     _order          = order;
 }
Exemple #4
0
        private void BindData()
        {
            ProductLineBLL bll       = null;
            DataPage       dp        = new DataPage();
            ProductLine    condition = new ProductLine();

            try
            {
                bll = BLLFactory.CreateBLL <ProductLineBLL>();
                condition.PLCODE = this.PLCODE.Text;
                condition.PLNAME = this.PLNAME.Text;

                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <ProductLine> list = dp.Result as List <ProductLine>;
                this.GvList.DataSource = list;
                this.GvList.DataBind();

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["PID"].ToString());

                    (this.GvList.Rows[i].Cells[6].Controls[0] as WebControl).Attributes.Add("onclick", click);
                }
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void InitializeTest()
        {
            //Code Ran before window is brought to screen, this is where available JSON configs should be loaded

            string fextension = ".json";
            var    myFiles    = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.*", SearchOption.AllDirectories)
                                .Where(s => fextension.Contains(Path.GetExtension(s)));

            foreach (var file in myFiles)
            {
                using (var stream = new StreamReader(file))                //put a test file in your bin/Debug/ folder to see this in action
                {
                    string  json_data       = stream.ReadToEnd();
                    dynamic productListJson = JsonConvert.DeserializeObject <Object>(json_data);  //A dynamic object has dynamic runtime properties that can be referenced even though the compiler doesn't know what they are

                    foreach (var productLine in productListJson.ProductLines)                     // Look at each product line in the config
                    {
                        // Create a new product line
                        ProductLine product = new ProductLine(productLine);

                        // Add the product to the product list
                        productList.Add(product);
                    }
                }
            }
        }
Exemple #6
0
        public void Handle(SourceProductLineUpdateCommand command)
        {
            var entity = _entities.Get <ProductLine>()
                         .SingleOrDefault(p => p.ID == command.Id);

            if (entity == null)
            {
                entity = new ProductLine()
                {
                    ID              = command.Id,
                    supplierID      = command.SupplierId,
                    ProductLineName = command.ProductLineName
                };
                _entities.Create(entity);
            }
            else
            {
                entity.ProductLineName = command.ProductLineName;
                entity.supplierID      = command.SupplierId;
            }
            int rowsAffected = _entities.SaveChanges();

            if (rowsAffected > 0)
            {
            }
        }
Exemple #7
0
        /// <summary>
        /// 更新信息
        /// </summary>
        /// <param name="">信息</param>
        /// <returns>更新行数</returns>
        public DataResult <int> Update(ProductLine model)
        {
            DataResult <int> result = new DataResult <int>();

            try
            {
                if (ExistsCode(model))
                {
                    result.Msg    = "编号已存在";
                    result.Result = -1;
                    return(result);
                }
                if (ExistsName(model))
                {
                    result.Msg    = "名称已存在";
                    result.Result = -1;
                    return(result);
                }
                model.UPDATEUSER = this.LoginUser.UserID;
                result.Result    = new ProductLineDAL().Update(model);
                result.IsSuccess = true;
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <OrderVm> CreateAsync(OrderVm orderVm)
        {
            orderVm.Reference = Guid.NewGuid();
            var dbOrder = Mapper.Map <Order>(orderVm);

            var orderProducts = orderVm.ProductLines.Select(p => p.ProductId);
            var products      = _database.Products.Where(p => orderProducts.Contains(p.Guid));

            var productLines = new List <ProductLine>();

            foreach (var p in products)
            {
                var newProductLine = new ProductLine
                {
                    Product  = p,
                    Price    = p.Price,
                    Quantity = orderVm.ProductLines.Single(prd => prd.ProductId == p.Guid).Quantity
                };

                productLines.Add(newProductLine);
            }
            dbOrder.ProductLines = productLines;

            _database.Orders.Add(dbOrder);
            await _database.SaveChangesAsync();

            return(Mapper.Map <OrderVm>(dbOrder));
        }
Exemple #9
0
        public async Task ShoudFailWhenIdInvalid_whenCallingGetById()
        {
            ProductLine productLine = null;

            _productLineRepository.GetById(Guid.Empty).Returns(productLine);
            await Assert.ThrowsAsync <Exception>(async() => await _productLineService.GetById(Guid.Empty));
        }
Exemple #10
0
        /// <summary>
        /// The update shopping cart.
        /// </summary>
        protected void UpdateShoppingCart()
        {
            foreach (var product in this.UcProductsListView.GetProducts())
            {
                string productCode = product.Key;
                uint   quant       = product.Value;

                ProductLine existingProductLine = this.Cart.ShoppingCartLines.FirstOrDefault(p => p.Product.Code.Equals(productCode));

                if (existingProductLine == null)
                {
                    return;
                }

                IShoppingCartManager shoppingCartManager = Sitecore.Ecommerce.Context.Entity.Resolve <IShoppingCartManager>();
                shoppingCartManager.UpdateProductQuantity(productCode, quant);

                AnalyticsUtil.ShoppingCartItemUpdated(productCode, existingProductLine.Product.Title, quant);
            }

            Sitecore.Ecommerce.Context.Entity.SetInstance(this.Cart);

            this.UpdateTotals(this.Cart);
            this.UpdateProductLines(this.Cart);
        }
Exemple #11
0
        /// <summary>
        /// Handles the ItemCommand event of the UcProductsListView control.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterCommandEventArgs"/> instance containing the event data.</param>
        protected void UcProductsListView_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName != "Delete" || string.IsNullOrEmpty((string)e.CommandArgument))
            {
                return;
            }

            ListString listString  = new ListString((string)e.CommandArgument);
            string     productCode = listString[0];

            ProductLine existingProductLine = this.Cart.ShoppingCartLines.FirstOrDefault(p => p.Product.Code.Equals(productCode));

            if (existingProductLine != null)
            {
                AnalyticsUtil.ShoppingCartItemRemoved(productCode, existingProductLine.Product.Title, existingProductLine.Quantity);
            }

            IShoppingCartManager shoppingCartManager = Sitecore.Ecommerce.Context.Entity.Resolve <IShoppingCartManager>();

            shoppingCartManager.RemoveProductLine(productCode);

            if (this.Cart.ShoppingCartLines.Count == 0)
            {
                this.Response.Redirect(LinkManager.GetItemUrl(Sitecore.Context.Item));
            }

            Sitecore.Ecommerce.Context.Entity.SetInstance(this.Cart);

            this.UpdateTotals(this.Cart);
            this.UpdateProductLines(this.Cart);
        }
Exemple #12
0
        public void Remove(ProductLine entity)
        {
            Delete delete = new Delete("ProductLine");

            delete.AddCriterions("ID", entity.Id, CriteriaOperator.Equal);
            dataFactory.Remove(delete);
        }
Exemple #13
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + (Class == null ? 0 : Class.GetHashCode());
         hash = hash * 23 + (Color == null ? 0 : Color.GetHashCode());
         hash = hash * 23 + (DaysToManufacture == default(int) ? 0 : DaysToManufacture.GetHashCode());
         hash = hash * 23 + (DiscontinuedDate == null ? 0 : DiscontinuedDate.GetHashCode());
         hash = hash * 23 + (FinishedGoodsFlag == default(bool) ? 0 : FinishedGoodsFlag.GetHashCode());
         hash = hash * 23 + (ListPrice == default(decimal) ? 0 : ListPrice.GetHashCode());
         hash = hash * 23 + (MakeFlag == default(bool) ? 0 : MakeFlag.GetHashCode());
         hash = hash * 23 + (ModifiedDate == default(DateTime) ? 0 : ModifiedDate.GetHashCode());
         hash = hash * 23 + (Name == null ? 0 : Name.GetHashCode());
         hash = hash * 23 + (ProductLine == null ? 0 : ProductLine.GetHashCode());
         hash = hash * 23 + (ProductModelId == null ? 0 : ProductModelId.GetHashCode());
         hash = hash * 23 + (ProductNumber == null ? 0 : ProductNumber.GetHashCode());
         hash = hash * 23 + (ProductSubcategoryId == null ? 0 : ProductSubcategoryId.GetHashCode());
         hash = hash * 23 + (ReorderPoint == default(short) ? 0 : ReorderPoint.GetHashCode());
         hash = hash * 23 + (Rowguid == default(Guid) ? 0 : Rowguid.GetHashCode());
         hash = hash * 23 + (SafetyStockLevel == default(short) ? 0 : SafetyStockLevel.GetHashCode());
         hash = hash * 23 + (SellEndDate == null ? 0 : SellEndDate.GetHashCode());
         hash = hash * 23 + (SellStartDate == default(DateTime) ? 0 : SellStartDate.GetHashCode());
         hash = hash * 23 + (Size == null ? 0 : Size.GetHashCode());
         hash = hash * 23 + (SizeUnitMeasureCode == null ? 0 : SizeUnitMeasureCode.GetHashCode());
         hash = hash * 23 + (StandardCost == default(decimal) ? 0 : StandardCost.GetHashCode());
         hash = hash * 23 + (Style == null ? 0 : Style.GetHashCode());
         hash = hash * 23 + (Weight == null ? 0 : Weight.GetHashCode());
         hash = hash * 23 + (WeightUnitMeasureCode == null ? 0 : WeightUnitMeasureCode.GetHashCode());
         return(hash);
     }
 }
        public ActionResult DecreaseAmount(int id)
        {
            productLineList = (List <ProductLine>)Session["shoppingCart"];

            bool        found            = false;
            int         i                = 0;
            ProductLine foundProductLine = null;

            while (!found)
            {
                if (productLineList[i].Product.ProductId == id)
                {
                    found = true;
                    productLineList[i].Amount  -= 1;
                    productLineList[i].SubTotal = productLineList[i].SubTotal - productLineList[i].Product.Price;
                    foundProductLine            = productLineList[i];
                }
                if (!found)
                {
                    i++;
                }
            }

            if (foundProductLine.Amount == 0)
            {
                productLineList.Remove(foundProductLine);
            }

            Session["shoppingCart"] = productLineList;
            return(RedirectToAction("Order"));
        }
Exemple #15
0
        protected void btSave_Click(object sender, EventArgs e)
        {
            ProductLine    info = new ProductLine();
            ProductLineBLL bll  = null;

            try
            {
                UIBindHelper.BindModelByControls(this.Page, info);

                bll = BLLFactory.CreateBLL <ProductLineBLL>();

                if (this.hiID.Value == "")
                {
                    bll.Insert(info);
                }
                else
                {
                    info.CREATEUSER = this.HiCREATEUSER.Value;
                    info.CREATETIME = DateTime.Parse(this.HiCREATETIME.Value);
                    info.PID        = this.hiID.Value;
                    bll.Update(info);
                }

                ClientScript.RegisterStartupScript(this.GetType(), "myjs", "parent.refreshData();parent.closeAppWindow1();", true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #16
0
        private void bbiSauvegarderFermer_ItemClick(object sender, ItemClickEventArgs e)
        {
            IsProductLineModified = false;

            if (_newProductLine)
            {
                _editProductLinePresenter.Write(comboBoxStock.SelectedItem as Stock, comboBoxProduit.SelectedItem as Product,
                                                Convert.ToInt32(textEditQuantité.EditValue.ToString()));
                MessageBox.Show(Resources.succesAdd);
            }
            else
            {
                var productLineModif = new ProductLine
                {
                    id       = ProductLineOut.Id,
                    Product  = comboBoxProduit.SelectedItem as Product,
                    Quantity = Convert.ToInt32(textEditQuantité.EditValue.ToString())
                };

                var repositoryStock = new RepositoryStock();
                repositoryStock.Save(comboBoxStock.SelectedItem as Stock, productLineModif);
                MessageBox.Show(Resources.succesUpdate);
            }

            Close();
        }
 public async Task <ActionResult> ProductLineCreate([Bind(Include = "Name, Description")] ProductLine productLine)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (productLine != null)
             {
                 db.ProductLines.Add(productLine);
                 await db.SaveChangesAsync();
             }
             else
             {
                 return(Json(new { warning = "ProductLines is null" }));
             }
         }
         else
         {
             return(Json(new { warning = "model is not valid" }));
         }
     }
     catch (Exception e)
     {
         ModelState.AddModelError("", e.Message);
         return(View(productLine));
     }
     return(RedirectToAction("Index", "Parts"));
 }
Exemple #18
0
        private void BindData()
        {
            string         id   = Request.QueryString["id"];
            ProductLineBLL bll  = null;
            ProductLine    info = new ProductLine();

            try
            {
                bll = BLLFactory.CreateBLL <ProductLineBLL>();
                if (string.IsNullOrEmpty(id) == false)
                {
                    info.PID = id;
                    info     = bll.Get(info);

                    UIBindHelper.BindForm(this.Page, info);
                    this.hiID.Value         = info.PID;
                    this.HiCREATEUSER.Value = info.CREATEUSER;
                    this.HiCREATETIME.Value = info.CREATETIME.ToString();
                }
                else
                {
                    info = new ProductLine();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #19
0
        /// <summary>
        /// 插入信息(单表)
        /// </summary>
        /// <param name="">信息</param>
        /// <returns>插入行数</returns>
        public DataResult <int> Insert(ProductLine model)
        {
            DataResult <int> result = new DataResult <int>();

            try
            {
                //基本信息
                model.PID        = Guid.NewGuid().ToString();
                model.CREATEUSER = this.LoginUser.UserID;
                model.CREATETIME = DateTime.Now;
                model.UPDATEUSER = model.CREATEUSER;
                model.UPDATETIME = model.CREATETIME;
                ProductLineDAL cmdDAL = new ProductLineDAL();
                if (ExistsCode(model))
                {
                    result.Msg    = "编号已存在";
                    result.Result = -1;
                    return(result);
                }
                if (ExistsName(model))
                {
                    result.Msg    = "名称已存在";
                    result.Result = -1;
                    return(result);
                }
                result.Result    = new ProductLineDAL().Insert(model);
                result.IsSuccess = true;
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #20
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="condition">条件</param>
        /// <param name="page">数据页</param>
        /// <returns>数据页</returns>
        public DataPage GetList(ProductLine condition, DataPage page)
        {
            string sql = null;
            List <DataParameter> parameters = new List <DataParameter>();

            try
            {
                sql = this.GetQuerySql(condition, ref parameters);
                //分页关键字段及排序
                page.KeyName = "PID";
                if (string.IsNullOrEmpty(page.SortExpression))
                {
                    page.SortExpression = "UPDATETIME DESC";
                }
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    page = session.GetDataPage <ProductLine>(sql, parameters.ToArray(), page);
                }
                return(page);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #21
0
        /// <summary>
        /// 获取查询语句
        /// </summary>
        /// <param name="user">查询条件</param>
        /// <param name="parameters">参数</param>
        /// <returns>查询语句</returns>
        private string GetQuerySql(ProductLine condition, ref List <DataParameter> parameters)
        {
            StringBuilder sqlBuilder   = new StringBuilder();
            StringBuilder whereBuilder = new StringBuilder();

            try
            {
                //构成查询语句
                sqlBuilder.Append(@"SELECT t1.*,t2.PNAME as FNAME FROM T_FP_PRODUCTLINE t1 LEFT OUTER JOIN T_FP_FACTORYINFO t2 on t1.FACTORYPID = t2.PID");

                if (!string.IsNullOrEmpty(condition.PLCODE))
                {
                    whereBuilder.Append(" AND t1.PLCODE like @PLCODE");
                    parameters.Add(new DataParameter("PLCODE", "%" + condition.PLCODE + "%"));
                }

                if (!string.IsNullOrEmpty(condition.PLNAME))
                {
                    whereBuilder.Append(" AND t1.PNAME like @PNAME");
                    parameters.Add(new DataParameter("PLNAME", "%" + condition.PLNAME + "%"));
                }

                //查询条件
                if (whereBuilder.Length > 0)
                {
                    sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
                }
                return(sqlBuilder.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ProductLine productLine = db.ProductLines.Find(id);

            db.ProductLines.Remove(productLine);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #23
0
        public void Update(ProductLine productLine)
        {
            if (productLine == null)
            {
                throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null.");
            }

            base.Update(productLine);
        }
Exemple #24
0
        /////////////////////////////////////////////////////////////////////////////////



        public void Save(ProductLine entity)
        {
            Update <ProductLine> update = new Update <ProductLine>("ProductLine", entity);

            update.AddCriterion("ID", entity.Id, CriteriaOperator.Equal);
            update.AddExcludeField("ID");

            dataFactory.Save <ProductLine>(update);
        }
Exemple #25
0
        public override ManualProduce Add(ManualProduce entity)
        {
            ProductLine line = base.m_UnitOfWork.GetRepositoryBase <ProductLine>().Get(entity.ProductLineID);

            if (line != null)
            {
                entity.ProductLineName = line.ProductLineName;
            }
            return(base.Add(entity));
        }
 public ActionResult Edit([Bind(Include = "ProductLineId,ProductLineName")] ProductLine productLine)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productLine).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(productLine));
 }
Exemple #27
0
        public void Delete(ProductLine productLine)
        {
            if (productLine == null)
            {
                throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null.");
            }

            //base.Delete(productLine);
            ExecuteDelete(productLine.ProductLineKey);
        }
Exemple #28
0
        public override void Update(ManualProduce entity, NameValueCollection form)
        {
            ProductLine line = base.m_UnitOfWork.GetRepositoryBase <ProductLine>().Get(entity.ProductLineID);

            if (line != null)
            {
                entity.ProductLineName = line.ProductLineName;
            }
            base.Update(entity, form);
        }
        public ActionResult Create([Bind(Include = "ProductLineId,ProductLineName")] ProductLine productLine)
        {
            if (ModelState.IsValid)
            {
                db.ProductLines.Add(productLine);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(productLine));
        }
Exemple #30
0
        private void stopProductLine(ProductLine pl)
        {
            pl.IsRunning = false;
            _productLineRepository.Update(pl);

            if (ThreadList.ContainsKey(pl.Id))
            {
                ThreadList[pl.Id].Abort();
                ThreadList.Remove(pl.Id);
            }
        }
 private bool foundIn(IEnumerable<ProductLine> list, ProductLine pl)
 {
     foreach (var item in list)
     {
         if (item.LineId == pl.LineId && item.ProductId == pl.ProductId)
         {
             return true;
         }
     }
     return false;
 }
        public ProductLine FindBy(int id)
        {
            Query query = new Query("ProductLine");
            query.AddCriterion("ID", id, CriteriaOperator.Equal);
            DataTable table = dataFactory.Query(query);

            ProductLine result = new ProductLine
            {
                Id = int.Parse(table.Rows[0]["ID"].ToString().Trim()),
                Address = table.Rows[0]["Address"].ToString().Trim(),
                Name = table.Rows[0]["Name"].ToString().Trim(),
                Remarks = table.Rows[0]["Remarks"].ToString().Trim(),
            };
            return result;
        }
        /////////////////////////////////////////////////////////////////////////////////
        public void Save(ProductLine entity)
        {
            Update<ProductLine> update = new Update<ProductLine>("ProductLine", entity);
            update.AddCriterion("ID", entity.Id, CriteriaOperator.Equal);
            update.AddExcludeField("ID");

            dataFactory.Save<ProductLine>(update);
        }
Exemple #34
0
 public Group(ProductLine productionLine, DateTime createdDate, int order)
     : base(productionLine, createdDate, order)
 {
 }
 public void Remove(ProductLine entity)
 {
     Delete delete = new Delete("ProductLine");
     delete.AddCriterions("ID", entity.Id, CriteriaOperator.Equal);
     dataFactory.Remove(delete);
 }
 public void Add(ProductLine entity)
 {
     Insert<ProductLine> insert = new Insert<ProductLine>("ProductLine", entity);
     dataFactory.Save<ProductLine>(insert);
 }