public string Addpsize(int sizeid, int psize) { var ty = (from p in db.Product_Sizes where p.Size_Id.Equals(sizeid) && p.Product_Id.Equals(psize) select p).FirstOrDefault(); if (ty == null) { var newtype = new Product_Size { Size_Id = sizeid, Product_Id = psize }; db.Product_Sizes.InsertOnSubmit(newtype); try { db.SubmitChanges(); return("added"); } catch (Exception ex) { ex.GetBaseException(); return("not added"); } } else { return("error"); } }
protected Pants(string name, Product_Size size) //Protected encapsulation used to //access to members of same class //and the derived classes of Shirt { Name = name; Size = size; }
public Product_Size UpdateBase(Product_Size productSize, ProductSizeItem productSizeItem) { productSize.Name = productSizeItem.Name; productSize.Value = productSizeItem.Value; //productSize.AgencyID = productSizeItem.AgencyID; return(productSize); }
public ActionResult Actions() { var msg = new JsonMessage(); var product = new Product_Size(); List <Shop_Product> lstProduct; StringBuilder stbMessage; switch (DoAction) { case ActionType.Add: try { UpdateModel(product); //product.AgencyID = 2010; _da.Add(product); _da.Save(); msg = new JsonMessage { Erros = false, ID = product.ID.ToString(), Message = string.Format("Đã thêm mới sản phẩm: <b>{0}</b>", Server.HtmlEncode(product.Name)) }; } catch (Exception) { } break; case ActionType.Edit: try { product = _da.GetById(ArrId.FirstOrDefault()); UpdateModel(product); product.Name = Convert.ToString(product.Name); _da.Save(); msg = new JsonMessage { Erros = false, ID = product.ID.ToString(), Message = string.Format("Đã cập nhật sản phẩm: <b>{0}</b>", Server.HtmlEncode(product.Name)) }; } catch (Exception) { //Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } break; } if (string.IsNullOrEmpty(msg.Message)) { msg.Message = "Không có hành động nào được thực hiện."; msg.Erros = true; } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult AjaxForm() { var model = new Product_Size(); if (DoAction == ActionType.Edit) { model = _da.GetById(ArrId.FirstOrDefault()); } ViewBag.Action = DoAction; ViewBag.ActionText = ActionText; return(View(model)); }
public ActionResult Add(string key, string json) { if (key == Keyapi) { var dayOff = JsonConvert.DeserializeObject <ProductSizeItem>(json); var obj = new Product_Size(); UpdateBase(obj, dayOff); _da.Add(obj); _da.Save(); return(Json(1, JsonRequestBehavior.AllowGet)); } return(Json(0, JsonRequestBehavior.AllowGet)); }
public List <Product_Size> GetSheetValues2(string filepath, int ShopID = 0) { FileInfo file = new FileInfo(filepath); if (file != null) { List <Product_Size> list = new List <Product_Size>(); int DefaultCityID = Globals.Configuration["AppSettings:DefaultCityID"].ToInt().Value; int DefaultProvinceID = Globals.Configuration["AppSettings:DefaultProvinceID"].ToInt().Value; using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; //获取表格的列数和行数 int rowCount = worksheet.Dimension.Rows; int ColCount = worksheet.Dimension.Columns; for (int row = 2; row <= rowCount; row++) { Product_Size modle = new Product_Size(); modle.Id = worksheet.Cells[row, 1].Value.ToString(); modle.ProductCode = worksheet.Cells[row, 2].Value.ToString(); modle.ProSize = worksheet.Cells[row, 3].Value.ToString(); modle.Price = worksheet.Cells[row, 4].Value != DBNull.Value ? Convert.ToDecimal(worksheet.Cells[row, 4].Value) : 0; modle.BasePrice = worksheet.Cells[row, 5].Value != DBNull.Value ? Convert.ToDecimal(worksheet.Cells[row, 5].Value) : 0; modle.BatchPrice = worksheet.Cells[row, 6].Value != DBNull.Value ? Convert.ToDecimal(worksheet.Cells[row, 6].Value) : 0; //modle.ImageUrl = worksheet.Cells[row, 8].Value.ToString(); //modle.ImageList = worksheet.Cells[row, 9].Value.ToString(); modle.ShopID = ShopID; modle.CreateDate = DateTime.Now; modle.CreateID = this.CurrentSession.UserId; list.Add(modle); } return(list); } } return(null); }
public IHttpActionResult GetRequestID(int id) { List <dynamic> list = new List <dynamic>(); List <Quotation_Request_Line> quotation_Request_Lines = db.Quotation_Request_Line.Where(x => x.Request_ID == id).ToList(); foreach (var i in quotation_Request_Lines) { Design design = db.Designs.Where(x => x.Design_ID == i.Design_ID).FirstOrDefault(); Customer customer = db.Customers.Where(x => x.Customer_ID == design.Customer_ID).FirstOrDefault(); Product_Type product_Type = db.Product_Type.Where(x => x.Product_Type_ID == design.Product_Type_ID).FirstOrDefault(); Product_Size product_Size = db.Product_Size.Where(x => x.Product_Size_ID == i.Product_Size_ID).FirstOrDefault(); dynamic obj = new ExpandoObject(); obj.Date = DateTime.Now; obj.Name = customer.First_Name + " " + customer.Last_Name; obj.Contact_Number = customer.Contact_Number; obj.Email = customer.Email_Address; obj.Product_Type = product_Type.Name; obj.Description = i.Product_Code + " - " + product_Size.Description + " " + i.Colour; obj.Quantity = i.Quantity; list.Add(obj); } return(Ok(list)); }
public void Delete(Product_Size productSize) { FDIDB.Product_Size.Remove(productSize); }
public void Add(Product_Size productSize) { FDIDB.Product_Size.Add(productSize); }
public ActionResult CreateProduct(FormCollection f, HttpPostedFileBase file, IEnumerable <HttpPostedFileBase> files) { if (ModelState.IsValid) { ProductDao productDAO = new ProductDao(); Product product = new Product(); product.Name = f["Name"].ToUpper().ToString(); product.Price = decimal.Parse(f["Price"]); product.PromotionPrice = product.Price; product.Detail = f["Detail"].ToString(); product.Quantity = f["Quantity"] == "" ? 0 : int.Parse(f["Quantity"]); product.CategoryID = long.Parse(f["Category"]); product.ProductCategoryID = long.Parse(f["ProductCategory"]); product.Warranty = int.Parse(f["Warranty"]); product.CreatedDate = DateTime.Now; product.CreatedBy = Session["UserNameAdmin"].ToString(); product.New = f["New"] == "1" ? true : false; string filename = ""; if (file != null && file.ContentLength > 0) { filename = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/ProductImage"), filename); file.SaveAs(path); } product.Image = "ProductImage" + "/" + filename; db.Products.Add(product); //get max product_id long maxid = productDAO.getMaxIdProduct() + 1; //add data table product_color Product_Color productcolor = new Product_Color(); productcolor.ProductID = maxid; productcolor.ColorID = int.Parse(f["Color"]); db.Product_Color.Add(productcolor); //add data table product_size Product_Size productsize = new Product_Size(); productsize.ProductID = maxid; productsize.SizeID = int.Parse(f["Size"]); db.Product_Size.Add(productsize); //add data table product_image foreach (var file1 in files) { ProductImage productimage = new ProductImage(); if (file1 != null && file1.ContentLength > 0) { filename = Path.GetFileName(file1.FileName); var path = Path.Combine(Server.MapPath("~/ProductImage"), filename); file1.SaveAs(path); productimage.ProductID = maxid; productimage.ImageDetail = "ProductImage" + "/" + filename; } db.ProductImages.Add(productimage); } db.SaveChanges(); return(RedirectToAction("Index")); } return(null); }
public Golfer(string name, Product_Size size) : base(name, size) { }
public Formal_Pants(string name, Product_Size size) : base(name, size) { }
public T_Shirt(string name, Product_Size size) : base(name, size) { }
public Jeans(string name, Product_Size size) : base(name, size) { }