Exemple #1
0
        protected void lbtn_Edit_Option_Command(object sender, CommandEventArgs e)
        {
            if (!DataEval.IsEmptyQuery(e.CommandArgument.ToString()))
            {
                ProductAttributeMgr myProductAttributeMgr = new ProductAttributeMgr();

                Product_Attribute myProduct_Attribute = myProductAttributeMgr.Get_Product_Attribute(e.CommandArgument.ToString());

                tbx_AttributeName.Text                  = myProduct_Attribute.Attribute_Name;
                chkbox_IsPreSelected.Checked            = myProduct_Attribute.IsPreSelected;
                RadNumericTextBox_PriceAdjustment.Text  = myProduct_Attribute.Price_Adjustment.ToString();
                RadNumericTextBox_WeightAdjustment.Text = myProduct_Attribute.Weight_Adjustment.ToString();
                chkbox_IsActive.Checked                 = myProduct_Attribute.IsActive;
                chkbox_IsActive.Enabled                 = true;

                btn_Add_Option.Visible            = false;
                btn_Update_Option.Visible         = true;
                btn_Update_Option.CommandArgument = myProduct_Attribute.AttributeID;

                btn_Cancel.Visible      = true;
                btn_CloseWindow.Visible = false;

                MultiView_OptionForm.SetActiveView(View_Form);
            }
        }
        /// <summary>
        /// 编辑新增页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Edit()
        {
            int classId = RequestInt("classId");

            if (classId == 0)
            {
                return(LayerAlertErrorAndClose("分类有误!"));
            }

            int id = RequestInt("id");
            Product_Attribute model = null;

            if (id > 0)
            {
                model = Bll.BllProduct_Attribute.First(o => o.Id == id);
                if (model == null)
                {
                    return(LayerAlertErrorAndClose("属性不存在!"));
                }
            }

            ViewBag.hasSpecail      = Bll.BllProduct_Attribute.hasSpecial(classId);
            ViewBag.classId         = classId;
            ViewBag.inputTypeSelect = Tools.Enums.Tools.GetOptionHtml(typeof(Tools.Enums.ESite.AttrType), (byte)(model?.InputType ?? 0));
            ViewBag.fieldTypeSelect = Tools.Enums.Tools.GetOptionHtml(typeof(Tools.Enums.ESite.AttrValueType), (byte)(model?.FieldType ?? 0));
            return(View(model));
        }
Exemple #3
0
 private void LoadChildProductAttribute(Entities db, Product_Attribute item)
 {
     foreach (var childItem in item.Product_AttributeChild)
     {
         LoadChildProductAttribute(db, childItem);
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Product_Attribute product_Attribute = db.Product_Attribute.Find(id);

            db.Product_Attribute.Remove(product_Attribute);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #5
0
 public Product_Attribute GetProductAttribute(int id)
 {
     using (Entities db = new Entities())
     {
         Product_Attribute productAttribute = db.Product_Attribute
                                              //.Include(c=>c.Superior_Agent)
                                              .AsNoTracking()
                                              .FirstOrDefault(e => e.id == id);
         return(productAttribute);
     }
 }
Exemple #6
0
        public NormalResult CreateProductAttribute(Product_Attribute productAttribute)
        {
            //productAttribute.Id = Guid.NewGuid();

            using (Entities db = new Entities())
            {
                db.Product_Attribute.Add(productAttribute);
                db.SaveChanges();
            }

            return(new NormalResult());
        }
        public ActionResult GetProductAttribute(int id)
        {
            Product_Attribute productAttribute = _productManager.GetProductAttribute(id);

            if (productAttribute == null)
            {
                return(FailedResult("指定的数据不存在。"));
            }

            Product_AttributeDto productAttributeDto = Mapper.Map <Product_AttributeDto>(productAttribute);

            return(DataResult(productAttributeDto));
        }
        // GET: Product_Attribute/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Product_Attribute product_Attribute = db.Product_Attribute.Find(id);

            if (product_Attribute == null)
            {
                return(HttpNotFound());
            }
            return(View(product_Attribute));
        }
        public static ResponseViewModel<List<Product>> AddProduct()
        {
            ResponseViewModel<List<Product>> responseViewModel = new ResponseViewModel<List<Product>>();
            string imageName = null;
            HttpRequest httpRequest = HttpContext.Current.Request;
            var postedFile = httpRequest.Files["Image"];
            imageName = new String(Path.GetFileNameWithoutExtension(postedFile.FileName).Take(10).ToArray()).Replace(" ", "-");
            imageName = imageName + DateTime.Now.ToString("yymmssff") + Path.GetExtension(postedFile.FileName);
            var filePath = HttpContext.Current.Server.MapPath("~/Images/" + imageName);
            postedFile.SaveAs(filePath);
            Product productObj = new Product();
            /*productObj.Name = httpRequest["name"];
            productObj.Price = Convert.ToInt32(httpRequest["price"]);
            productObj.Description = httpRequest["description"];
            productObj.ProductCateogoryID = Convert.ToInt32(httpRequest["category"]);
            productObj.Quentity = Convert.ToInt32(httpRequest["quentity"]);
            productObj.Discount = Convert.ToInt32(httpRequest["discount"]);
            productObj.ProductSubCategoryID = Convert.ToInt32(httpRequest["subcategory"]);*/
            productObj = JsonConvert.DeserializeObject<Product>(httpRequest["product"]);
            productObj.Image = imageName;
            List<OptionViewModel> options = JsonConvert.DeserializeObject<List<OptionViewModel>>(httpRequest["option"]);
            using (EcommerceEntities entities = new EcommerceEntities())
            {

                if (CheckDuplicate(productObj))
                {
                    responseViewModel.errorViewModel = new ErrorViewModel();
                    responseViewModel.errorViewModel.statusCode = 400;
                    return responseViewModel;
                }
                else
                {
                    entities.Products.Add(productObj);
                    responseViewModel.Data.Add(productObj);
                    entities.SaveChanges();
                    foreach(var option in options)
                    {
                        Product_Attribute productAttribute = new Product_Attribute();
                        //option.productId = Convert.ToInt32(productObj.ID);
                        productAttribute.ProductID = productObj.ID;
                        productAttribute.OptionID = option.id;
                        entities.Product_Attribute.Add(productAttribute);
                    }
                    entities.SaveChanges();
                }

            }
            return responseViewModel;
        }
        public ActionResult UpdateProductAttribute()
        {
            Product_AttributeDto args = RequestArgs <Product_AttributeDto>();

            if (args == null)
            {
                return(FailedResult("参数无效。"));
            }

            Product_Attribute productAttribute = Mapper.Map <Product_Attribute>(args);

            NormalResult result = _productManager.UpdateProductAttribute(productAttribute);

            return(ApiResult(result.Successful, result.Message));
        }
 public ActionResult Edit([Bind(Include = "Product_attributeID,Product_Purchase_record,P_Code,Quality,Net_Weight,Westages,Total_weight,Wages,Product_ID,Diamond_Stone,Rate,Sold_OrNot,Date,Bikri_Date,Client_ID,Bill_ID,Purchase_Date,Shop_name")] Product_Attribute product_Attribute)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product_Attribute).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Bill_ID    = new SelectList(db.Bill_Number, "Bill_ID", "Bill_Number1", product_Attribute.Bill_ID);
     ViewBag.Client_ID  = new SelectList(db.Clients, "Client_ID", "Client_name", product_Attribute.Client_ID);
     ViewBag.Date       = new SelectList(db.Date_Time, "Date_Time_ID", "Date_Time_ID", product_Attribute.Date);
     ViewBag.Product_ID = new SelectList(db.Products, "Product_ID", "Product_Name", product_Attribute.Product_ID);
     ViewBag.Product_Purchase_record = new SelectList(db.Product_Purchase_Record, "PPR_ID", "Product_name", product_Attribute.Product_Purchase_record);
     ViewBag.Shop_name = new SelectList(db.Shop_Details, "Shop_ID", "Shop_name", product_Attribute.Shop_name);
     return(View(product_Attribute));
 }
        public static Product UpdateProduct()
        {
            string imageName = null;
            HttpRequest httpRequest = HttpContext.Current.Request;
            var postedFile = httpRequest.Files["Image"];
            imageName = new String(Path.GetFileNameWithoutExtension(postedFile.FileName).Take(10).ToArray()).Replace(" ", "-");
            imageName = imageName + DateTime.Now.ToString("yymmssff") + Path.GetExtension(postedFile.FileName);
            var filePath = HttpContext.Current.Server.MapPath("~/Images/" + imageName);
            postedFile.SaveAs(filePath);
            Product productObj = new Product();
            int id = Convert.ToInt16(httpRequest["id"]);
            productObj = JsonConvert.DeserializeObject<Product>(httpRequest["product"]);
            productObj.Image = imageName;
            List<OptionViewModel> options = JsonConvert.DeserializeObject<List<OptionViewModel>>(httpRequest["option"]);
            using (EcommerceEntities entities = new EcommerceEntities())
            {
                Product productDb = entities.Products.Where(entry => entry.ID == id).FirstOrDefault();
                if (productDb != null)
                {
                    productDb.Name = productObj.Name;
                    productDb.Price = productObj.Price;
                    productDb.Image = productObj.Image;
                    productDb.ProductCateogoryID = productObj.ProductCateogoryID;
                    productDb.Discount = productObj.Discount;
                    productDb.Quentity = productObj.Quentity;
                    entities.SaveChanges();
                    foreach (var option in options)
                    {
                        Product_Attribute productAttribute = new Product_Attribute();
                        //option.productId = Convert.ToInt32(productObj.ID);
                        productAttribute.ProductID = productObj.ID;
                        productAttribute.OptionID = option.id;
                        if (ProductManager.CheckDuplicateOption(option.id, productObj.ID))
                        {
                            continue;
                        }
                        else
                        {
                            entities.Product_Attribute.Add(productAttribute);
                        }
                        entities.SaveChanges();
                    }
                }
            }
            return productObj;

        }
Exemple #13
0
        public NormalResult UpdateProductAttribute(Product_Attribute productAttribute)
        {
            using (Entities db = new Entities())
            {
                IQueryable <Product_Attribute> queryable = db.Product_Attribute;

                Product_Attribute dbProduct_Attribute = queryable.FirstOrDefault(e => e.id == productAttribute.id);
                if (dbProduct_Attribute == null)
                {
                    return(new NormalResult("指定的数据不存在。"));
                }

                ShengMapper.SetValuesSkipVirtual(productAttribute, dbProduct_Attribute);

                db.SaveChanges();
            }

            return(new NormalResult());
        }
Exemple #14
0
        public void RemoveProductAttribute(int id)
        {
            using (Entities db = new Entities())
            {
                Product_Attribute productAttribute = db.Product_Attribute.FirstOrDefault(e => e.id == id);
                if (productAttribute != null)
                {
                    //先删除子属性
                    List <Product_Attribute> productAttributeList = db.Product_Attribute.Where(e => e.parent_id == id).ToList();
                    foreach (var item in productAttributeList)
                    {
                        db.Product_Attribute.Remove(item);
                    }

                    db.Product_Attribute.Remove(productAttribute);
                    db.SaveChanges();
                }
            }
        }
Exemple #15
0
        protected void RadGrid_Options_RowDrop(object sender, GridDragDropEventArgs e)
        {
            if (e.DestDataItem != null &&
                string.IsNullOrEmpty(e.HtmlElement) &&
                e.DestDataItem.OwnerGridID == RadGrid_Options.ClientID)
            {
                ProductAttributeMgr myProductAttributeMgr = new ProductAttributeMgr();

                List <Product_Attribute> myProduct_Attributes = myProductAttributeMgr.Get_Product_Attributes(_attribute_indexid);

                Product_Attribute draggedAttribute = Get_Attribute_in_List(myProduct_Attributes, e.DraggedItems[0].GetDataKeyValue("AttributeID").ToString());
                Product_Attribute destAttribute    = Get_Attribute_in_List(myProduct_Attributes, e.DestDataItem.GetDataKeyValue("AttributeID").ToString());

                int destIndex = myProduct_Attributes.IndexOf(destAttribute);

                if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex)
                {
                    destIndex -= 1;
                }
                if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex)
                {
                    destIndex += 1;
                }

                myProduct_Attributes.Remove(draggedAttribute);
                myProduct_Attributes.Insert(destIndex, draggedAttribute);

                foreach (Product_Attribute myAttribute in myProduct_Attributes)
                {
                    // Product Variant
                    e2Data[] UpdateData =
                    {
                        new e2Data("AttributeID", myAttribute.AttributeID),
                        new e2Data("SortOrder",   (myProduct_Attributes.IndexOf(Get_Attribute_in_List(myProduct_Attributes, myAttribute.AttributeID)) + 1).ToString())
                    };

                    myProductAttributeMgr.Edit_Product_Attribute(UpdateData);
                }

                RadGrid_Options.Rebind();
            }
        }
        // GET: Product_Attribute/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Product_Attribute product_Attribute = db.Product_Attribute.Find(id);

            if (product_Attribute == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Bill_ID    = new SelectList(db.Bill_Number, "Bill_ID", "Bill_Number1", product_Attribute.Bill_ID);
            ViewBag.Client_ID  = new SelectList(db.Clients, "Client_ID", "Client_name", product_Attribute.Client_ID);
            ViewBag.Date       = new SelectList(db.Date_Time, "Date_Time_ID", "Date_Time_ID", product_Attribute.Date);
            ViewBag.Product_ID = new SelectList(db.Products, "Product_ID", "Product_Name", product_Attribute.Product_ID);
            ViewBag.Product_Purchase_record = new SelectList(db.Product_Purchase_Record, "PPR_ID", "Product_name", product_Attribute.Product_Purchase_record);
            ViewBag.Shop_name = new SelectList(db.Shop_Details, "Shop_ID", "Shop_name", product_Attribute.Shop_name);
            return(View(product_Attribute));
        }
        /// <summary>
        /// 编辑新增页面
        /// </summary>
        /// <returns></returns>
        public ActionResult ValueEdit()
        {
            int attrId = RequestInt("attrId");

            if (attrId == 0)
            {
                return(LayerAlertErrorAndClose("属性有误!"));
            }
            Product_Attribute modAttr = Bll.BllProduct_Attribute.First(o => o.Id == attrId);

            if (modAttr == null)
            {
                LayerAlertErrorAndClose("属性有误!");
            }

            //判断是否是文本
            bool isString = false;

            if (modAttr.InputType == (int)Tools.Enums.ESite.AttrType.Text)
            {
                isString = true;
            }

            int id = RequestInt("id");
            Product_AttributeSelect model = null;

            if (id > 0)
            {
                model = Bll.BllProduct_AttributeSelect.First(o => o.Id == id);
                if (model == null)
                {
                    return(LayerAlertErrorAndClose("属性不存在!"));
                }
            }

            ViewBag.isString = isString;
            ViewBag.modAttr  = modAttr;
            ViewBag.attrId   = attrId;
            return(View(model));
        }
Exemple #18
0
        private void Display_Form()
        {
            ProductAttributeMgr myProductAttributeMgr = new ProductAttributeMgr();

            Product_Attribute myProduct_Attribute = myProductAttributeMgr.Get_Product_Attribute_ByIndexID(_attribute_indexid);

            tbx_AttributeName.Text                  = myProduct_Attribute.Attribute_Name;
            chkbox_IsPreSelected.Checked            = myProduct_Attribute.IsPreSelected;
            RadNumericTextBox_PriceAdjustment.Text  = myProduct_Attribute.Price_Adjustment.ToString();
            RadNumericTextBox_WeightAdjustment.Text = myProduct_Attribute.Weight_Adjustment.ToString();
            chkbox_IsActive.Checked                 = myProduct_Attribute.IsActive;
            chkbox_IsActive.Enabled                 = false;

            btn_Add_Option.Visible            = false;
            btn_Update_Option.Visible         = true;
            btn_Update_Option.CommandArgument = myProduct_Attribute.AttributeID;

            btn_Cancel.Visible      = false;
            btn_CloseWindow.Visible = true;

            MultiView_OptionForm.SetActiveView(View_Form);
            Panel_Input_Options.Visible = false;
        }
        public ActionResult Save(Product_Attribute model)
        {
            Product_Attribute mod = null;
            bool IsRequired       = RequestBool("isneeded");
            bool isSpecial        = RequestBool("isspecial");

            if (model.Id > 0)
            {
                mod = Bll.BllProduct_Attribute.First(o => o.Id == model.Id);
                if (mod == null)
                {
                    return(LayerAlertErrorAndClose("属性不存在!"));
                }
                mod.InputType     = model.InputType;
                mod.IsRequired    = IsRequired;
                mod.Remark        = model.Remark;
                mod.AttributeName = model.AttributeName;
                mod.FieldType     = model.FieldType;
                if (mod.IsSpecial.HasValue && mod.IsSpecial.Value)
                {
                    mod.IsSpecial = isSpecial;
                }
                else
                {
                    mod.IsSpecial = Bll.BllProduct_Attribute.hasSpecial(model.ClassId.Value) ? false : isSpecial;
                }
                if (Bll.BllProduct_Attribute.Update(mod, o => o.Id == model.Id) > 0)
                {
                    return(LayerAlertSuccessAndRefreshPage("修改成功!"));
                }
                else
                {
                    return(LayerAlertErrorAndClose("修改失败!"));
                }
            }
            else
            {
                mod               = new Product_Attribute();
                mod.InputType     = model.InputType;
                mod.IsRequired    = IsRequired;
                mod.Remark        = model.Remark;
                mod.AttributeName = model.AttributeName;
                mod.FieldType     = model.FieldType;
                mod.ClassId       = model.ClassId;
                mod.DefaultValue  = "";
                mod.IsShow        = false;
                mod.IsSort        = false;
                mod.Unit          = "";
                mod.IsSpecial     = Bll.BllProduct_Attribute.hasSpecial(model.ClassId.Value) ? false : isSpecial;
                mod.Sequence      = Bll.BllSys_Class <Product_Attribute> .Instance().GetMaxSequence("ClassID=" + model.ClassId);

                if (Bll.BllProduct_Attribute.Add(mod) > 0)
                {
                    return(LayerAlertSuccessAndRefreshPage("添加成功!"));
                }
                else
                {
                    return(LayerAlertErrorAndClose("添加失败!"));
                }
            }
        }
        public ActionResult ValueSave()
        {
            int    id       = RequestInt("id");
            int    attrId   = RequestInt("attrId");
            string itemName = RequestString("ItemName");

            if (attrId == 0)
            {
                return(LayerAlertErrorAndClose("属性有误!"));
            }

            Product_Attribute modAttr = Bll.BllProduct_Attribute.First(o => o.Id == attrId);

            if (modAttr == null)
            {
                LayerAlertErrorAndClose("属性有误!");
            }

            //判断是否是文本
            if (modAttr.InputType == (int)Tools.Enums.ESite.AttrType.Text)
            {
                modAttr.DefaultValue = itemName;
                if (Bll.BllProduct_Attribute.Update(modAttr, o => o.Id == modAttr.Id) > 0)
                {
                    return(LayerAlertSuccessAndRefreshPage("添加成功!"));
                }
                else
                {
                    return(LayerAlertErrorAndClose("添加失败!"));
                }
            }
            else
            {
                Product_AttributeSelect mod = null;
                if (id > 0)
                {
                    mod = Bll.BllProduct_AttributeSelect.First(o => o.Id == id);
                    if (mod == null)
                    {
                        return(LayerAlertErrorAndClose("属性不存在!"));
                    }
                    mod.ItemName = itemName;
                    if (Bll.BllProduct_AttributeSelect.Update(mod, o => o.Id == id) > 0)
                    {
                        return(LayerAlertSuccessAndRefreshPage("修改成功!"));
                    }
                    else
                    {
                        return(LayerAlertErrorAndClose("修改失败!"));
                    }
                }
                else
                {
                    mod             = new Product_AttributeSelect();
                    mod.ItemName    = itemName;
                    mod.AttributeId = attrId;
                    mod.Sequence    = Bll.BllSys_Class <Product_AttributeSelect> .Instance().GetMaxSequence("AttributeID=" + attrId);

                    if (Bll.BllProduct_AttributeSelect.Insert(mod) > 0)
                    {
                        return(LayerAlertSuccessAndRefreshPage("添加成功!"));
                    }
                    else
                    {
                        return(LayerAlertErrorAndClose("添加失败!"));
                    }
                }
            }
        }