private void rptlistBind() { Model.PageData <Model.Product> data = new DAL.Product().GetList(9, 1, "ClassID=" + classid + " and IsDelete=0 and IsPass=1", "Sort asc"); rptlist.DataSource = data.DataSoure; rptlist.DataBind(); hiddCount.Value = data.Count.ToString(); }
public static string FunctionsToaddNewProduct(DTO.ProductDTO productdDto , List <DTO.ParameterOfProductDTO> ParameterOfProductAreExistDto, List <DTO.ParameterDTO> NewParametersDto, List <DTO.ParameterOfProductDTO> NewParameterOfProductDto) { DAL.Product productdDAL = BLL.Convertions.ProductDtoToDAL(productdDto); List <DAL.ParameteOfProduct> ParameterOfProductAreExistDAL = new List <ParameteOfProduct>(); List <DAL.Parameter> NewParametersDAL = new List <Parameter>(); List <DAL.ParameteOfProduct> NewParameterOfProductDAL = new List <ParameteOfProduct>(); //המרת האוביקטים לסוג DAL foreach (var item in ParameterOfProductAreExistDto) { ParameterOfProductAreExistDAL.Add(BLL.Convertions.ParameterOfProductDtoToDAL(item)); } foreach (var item in NewParametersDto) { NewParametersDAL.Add(BLL.Convertions.ParameterDtoToDAL(item)); } foreach (var item in NewParameterOfProductDto) { NewParameterOfProductDAL.Add(BLL.Convertions.ParameterOfProductDtoToDAL(item)); } //ID של המוצר החדש שמוסיפים addNewProduct(productdDAL); int productId = productdDAL.ProductId; AddParameterOfProductAreExist(ParameterOfProductAreExistDAL, productId); AddNewParametersAndNewParametersOfProduct(NewParametersDAL, NewParameterOfProductDAL, productId); return("exellent!"); }
private void btnAdd_Click(object sender, EventArgs e) { if (validator1.Validate()) { if (product != null)//update { product.Description = txtDescription.Text; product.ProductName = txtName.Text; product.ProductCode = txtCode.Text; ProductType refProductType = productTypes.Single(pt => pt.Id == (int)cmbType.SelectedValue); product.ProductType1 = refProductType; ProductService productService = new ProductService(); bool result = productService.UpdateProduct(product); result = UpdateAttribute(product.Id); if (result) { MessageBox.Show("Sản phẩm đã được cập nhật thành công"); this.Close(); } else { MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else//add new { product = new Product { Description = txtDescription.Text, ProductName = txtName.Text, ProductCode = txtCode.Text, ProductType = (int)cmbType.SelectedValue }; ProductService productService = new ProductService(); bool result = productService.AddProduct(product); long newProductId = BaoHienRepository.GetMaxId<Product>(); result = UpdateAttribute(newProductId); if (result) { MessageBox.Show("Sản phẩm đã được tạo thành công"); if (this.CallFromUserControll != null && this.CallFromUserControll is ProductList) { ((ProductList)this.CallFromUserControll).loadProductList(); } this.Close(); } else { MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public void AddProduct() { //List<ProductType> list = (List<ProductType>)BaoHienRepository.SelectAll<ProductType>().Where<ProductType>(item => item.st == false).ToList<ProductType>(); //int count = list.Count; Product product = new Product { ProductCode = "Product code 1", ProductName = "Product Name 1", ProductType = 4 }; ProductService productTypeService = new ProductService(); bool result = productTypeService.AddProduct(product); Assert.AreEqual<bool>(true, result); ; }
private void rptlistBind(Model.Product model) { Model.PageData <Model.Product> data = new DAL.Product().GetList(int.MaxValue, 1, "ClassID=" + model.ClassID.Value + " and IsDelete=0 and IsPass=1 and ID <>" + model.ID.Value, "Sort asc"); rptlist.DataSource = data.DataSoure; rptlist.DataBind(); if (data.Count > 0) { Model.Product nextmodel = data.DataSoure.Find(delegate(Model.Product item) { return(item.Sort.Value >= model.Sort.Value && item.ID.Value > model.ID.Value); }); if (nextmodel != null) { lit_NextProduct.Text = "<a href='detail.aspx?id=" + nextmodel.ID.Value + "'>下一个产品</a>"; } Model.Product premodel = data.DataSoure.Find(delegate(Model.Product item) { return(item.Sort.Value <= model.Sort.Value && item.ID.Value < model.ID.Value); }); if (premodel != null) { lit_PreProduct.Text = "<a href='detail.aspx?id=" + nextmodel.ID.Value + "'>上一个产品</a> "; } } }
partial void InsertProduct(Product instance);
private void detach_Products(Product entity) { this.SendPropertyChanging(); entity.ProductType1 = null; }
private void attach_Products(Product entity) { this.SendPropertyChanging(); entity.ProductType1 = this; }
/// <summary> /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProducts(Product product) { base.AddObject("Products", product); }
public IHttpActionResult PutProduct(DAL.Product product) { var list = new List <Product>(); var model = db.Products.Where(x => x.IsActive == true && x.Id == product.Id).FirstOrDefault(); model.Id = product.Id; model.Image1 = product.Image1; model.Image2 = product.Image2; model.Image3 = product.Image3; model.Image4 = product.Image4; model.IsActive = true; model.ActualSellingPrice = product.ActualSellingPrice; model.IsAllowZero = product.IsAllowZero; model.IsConsignment = product.IsConsignment; model.IsDiscontinue = product.IsDiscontinue; model.IsFreeGift = product.IsFreeGift; model.IsMarkDown = product.IsMarkDown; model.IsVPI = product.IsVPI; model.LogId = product.LogId; model.CostPrice = product.CostPrice; // model.Log = db.Logs.Where(x => x.IsActive == true).FirstOrDefault(); model.LongDescription = product.LongDescription; model.MarkDownTemplateID = product.MarkDownTemplateID; model.PrimaryImage = product.PrimaryImage; model.ProdCat1ID = product.ProdCat1ID; model.ProdCat2ID = product.ProdCat2ID; model.ProdCat3ID = product.ProdCat3ID; model.ProdCat4ID = product.ProdCat4ID; model.ColorID = product.ColorID; model.CostPriceUSD = product.CostPriceUSD; model.Color = db.Colors.Where(x => x.IsActive == true && x.Id == model.ColorID).FirstOrDefault(); //model.ProductGroupID = product.ProductGroupID; //model.ProductGrp = db.ProductGrps.Where(x => x.IsActive == true && x.ID== product.ProductGroupID).FirstOrDefault(); //model.ProductSizes = product.ProductSizes; model.ProductSKU = product.ProductSKU; model.ProductSourceID = product.ProductSourceID; model.ProductSource = db.ProductSources.Where(x => x.IsActive == true && x.Id == product.ProductSourceID).FirstOrDefault(); model.StyleSKU = product.StyleSKU; // model.ProductStyle = db.ProductStyles.Where(x => x.IsActive == true && x.Id == product.ProductStyleId).FirstOrDefault(); model.RecommendedSellingPrice = product.RecommendedSellingPrice; model.SeasonID = product.SeasonID; model.Season = db.Seasons.Where(x => x.IsActive == true && x.Id == product.SeasonID).FirstOrDefault(); model.ShortDescription = product.ShortDescription; model.SizeGridID = product.SizeGridID; model.SizeGrid = db.SizeGrids.Where(x => x.IsActive == true && x.Id == product.SizeGridID).FirstOrDefault(); model.SupplierID = product.SupplierID; model.Supplier = db.Suppliers.Where(x => x.IsActive == true && x.Id == product.SupplierID).FirstOrDefault(); model.SupplierStyle = product.SupplierStyle; // model.UpdatedOn = product.UpdatedOn; model.MarkDownTemplateID = product.MarkDownTemplateID; model.DefaultTemplateID = product.DefaultTemplateID; model.Barcode = model.StyleSKU + model.ProductSKU + model.Color.Code; model.YearID = product.YearID; model.CreatedOn = product.CreatedOn; model.UpdatedOn = System.DateTime.UtcNow; model.CostPriceUSD = product.CostPriceUSD; model.AvailableSize = product.AvailableSize; model.SupplierStyle = product.SupplierStyle; model.Year = db.Years.Where(x => x.IsActive == true && x.Id == product.YearID).FirstOrDefault(); db.SaveChanges(); return(Ok(true)); }
//הוספת המוצר public static void addNewProduct(DAL.Product product) { db.Products.Add(product); db.SaveChanges(); }
private void btnSave_Click(object sender, EventArgs e) { int er = 0; if (txtName.Text == "") { er++; ep.SetError(txtName, "Required"); } if (txtDescription.Text == "") { er++; ep.SetError(txtDescription, "Required"); } if (txtCode.Text == "") { er++; ep.SetError(txtCode, "Required"); } if (txtType.Text == "") { er++; ep.SetError(txtOffer, "Required"); } if (txtTag.Text == "") { er++; ep.SetError(txtTag, "Required"); } if (txtDiscount.Text == "") { er++; ep.SetError(txtDiscount, "Required"); } if (cmbCategory.SelectedValue == null || cmbCategory.SelectedValue.ToString() == "") { er++; ep.SetError(cmbCategory, "Select One"); } if (cmbBrand.SelectedValue == null || cmbBrand.SelectedValue.ToString() == "") { er++; ep.SetError(cmbBrand, "Select One"); } if (er > 0) { return; } DAL.Product p = new DAL.Product(); p.Id = Id; p.BrandId = Convert.ToInt32(cmbBrand.SelectedValue); p.CategoryId = Convert.ToInt32(cmbCategory.SelectedValue); p.Code = txtCode.Text; p.Description = txtDescription.Text; p.Discount = Convert.ToDouble(txtDiscount.Text); p.Name = txtName.Text; p.Offers = txtOffer.Text; p.Tag = txtTag.Text; p.Type = txtType.Text; if (p.Update()) { MessageBox.Show("Data Saved"); } else { MessageBox.Show(p.Error); } }
private void LoadProducts(int productTypeId) { if (productTypeId == 0) { cbmProducts.Enabled = false; cbmProducts.SelectedValue = 0; cbmAttrs.Enabled = false; cbmAttrs.SelectedValue = 0; cbmUnits.Enabled = false; cbmUnits.SelectedValue = 0; } else { cbmProducts.Enabled = true; ProductService productService = new ProductService(); Product product = new Product { ProductName = "Tất cả", Id = 0 }; products = productService.GetProducts().Where(p => p.ProductType == productTypeId).ToList(); products.Add(product); products = products.OrderBy(p => p.Id).ToList(); if (products != null) { cbmProducts.DataSource = products; cbmProducts.DisplayMember = "ProductName"; cbmProducts.ValueMember = "Id"; } LoadAttributes(0); } }
partial void UpdateProduct(Product instance);
public void loadDataForEditProduct(int productId) { this.Text = "Chỉnh sửa sản phẩm này"; this.btnAdd.Text = "Cập nhật"; ProductService productTypeService = new ProductService(); product = productTypeService.GetProduct(productId); loadSomeData(); if (product != null) { mode = 1; // Edit mode if (productTypes != null) { cmbType.SelectedIndex = productTypes.FindIndex(p => p.Id == product.ProductType); } //dgvBaseAttributes.Enabled = false; txtDescription.Text = product.Description; txtCode.Text = product.ProductCode; txtName.Text = product.ProductName; } }
partial void DeleteProduct(Product instance);
/// <summary> /// Create a new Product object. /// </summary> /// <param name="productId">Initial value of the ProductId property.</param> /// <param name="productCode">Initial value of the ProductCode property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="productType">Initial value of the ProductType property.</param> public static Product CreateProduct(global::System.Int32 productId, global::System.String productCode, global::System.String name, global::System.Int32 productType) { Product product = new Product(); product.ProductId = productId; product.ProductCode = productCode; product.Name = name; product.ProductType = productType; return product; }