bool IPriceService.AddPrice(AddPriceModel WebPageData) { IPriceDAO PriceData = new PriceDAO(); Price PriceToAdd = new Price(); // verify that this is not a duplicate Price Price Duplicate = PriceData.GetPrice(WebPageData.PricingName); if (Duplicate != null) { throw new Exception("Price Name already in system"); } PriceToAdd.PricingName = WebPageData.PricingName; PriceToAdd.CardPrice = Convert.ToDecimal(WebPageData.CardPrice); PriceToAdd.TransactionPrice = Convert.ToDecimal(WebPageData.TransactionPrice); PriceToAdd.SupportTransactionPrice = Convert.ToDecimal(WebPageData.SupportTransactionPrice); PriceToAdd.GiftMonthlyFee = Convert.ToDecimal(WebPageData.GiftMonthlyFee); PriceToAdd.CardholderMonthlyFee = Convert.ToDecimal(WebPageData.CardholderMonthlyFee); PriceToAdd.CardHolderPercentageCharge = Convert.ToInt32(WebPageData.CardHolderPercentageCharge); PriceToAdd.AfterXMonths = Convert.ToInt32(WebPageData.AfterXMonths); PriceData.CreatePrice(PriceToAdd); return(true); }
public ShoesManageController(SneakerStoreContext context, IHostingEnvironment env) { this.context = context; this._env = env; shoesDao = new ShoesDAO(context); shoesColorDao = new ShoesColorDAO(context); shoesSizeDao = new ShoesSizeDAO(context); priceDao = new PriceDAO(context); imageDao = new ImageDAO(context); }
bool IPriceService.DeletePrice(int PriceID) { using (var GiftEntity = new GiftEntities()) { IPriceDAO PriceData = new PriceDAO(GiftEntity); PriceData.DeletePrice(PriceID); } return(true); }
List <SelectListItem> IPriceService.GetPricesForSelection() { List <SelectListItem> PriceSelection = new List <SelectListItem>(); IPriceDAO PriceData = new PriceDAO(); List <Price> DBPrices = PriceData.ListPrices(); foreach (Price DBPrice in DBPrices) { SelectListItem WebPrice = new SelectListItem(); WebPrice.Value = Convert.ToString(DBPrice.ID); WebPrice.Text = DBPrice.PricingName; PriceSelection.Add(WebPrice); } return(PriceSelection); }
private void btnLuu_Click(object sender, EventArgs e) { SANPHAM1 sp1 = new SANPHAM1(); sp1.KHOILUONG = (int)spKL.Value; sp1.ANH = "/Resources/Image/" + System.IO.Path.GetFileName(picAnh.ImageLocation); sp1.MOTA = webMota.Document.InvokeScript("getValue").ToString(); sp1.LOAISP_ID = (int)cbBLSP.SelectedValue; int row = flag == 1 ? grViewSP.RowCount : grViewSP.FocusedRowHandle; if (flag == 1) { sp1.SOLUONG = 0; spDAO.insertSANPHAM(sp1); SANPHAM sp2 = spDAO.GetLastSanpham(); PRICE pr = new PRICE(); pr.GIABAN = Convert.ToInt32(txtGia.Text); pr.BATDAU = DateTime.Now; pr.KETTHUC = (DateTime?)null; pr.SANPHAM_ID = sp2.ID; new PriceDAO().insertPrice(pr); MessageBox.Show("Thêm thành công!"); } if (flag == 2) { sp1.ID = sp.ID; sp1.SOLUONG = sp.SOLUONG; spDAO.updateSANPHAM(sp1); PRICE pr = new PriceDAO().getPriceBySanphamId(sp.ID); pr.GIABAN = Convert.ToInt32(txtGia.Text); new PriceDAO().updatePrice(pr); MessageBox.Show("Update thành công!"); } string despath = @"E:\Projects\DEPLOY IIS\QuanCafeAPI IIS" + sp1.ANH; if (!File.Exists(despath)) { File.Copy(picAnh.ImageLocation, despath); } //grCtrlSP.DataSource = spDAO.getListSANPHAM(); flag = 0; LoadData(); grViewSP.FocusedRowHandle = row; Hienthi(); }
// G e t P r i c e EditPriceModel IPriceService.GetPrice(int ID) { IPriceDAO PriceData = new PriceDAO(); Price DBPrice = PriceData.GetPriceByID(ID); EditPriceModel WebPrice = new EditPriceModel(); WebPrice.DatabaseID = Convert.ToString(DBPrice.ID); WebPrice.PricingName = DBPrice.PricingName; WebPrice.CardPrice = DBPrice.CardPrice.ToString(); WebPrice.TransactionPrice = DBPrice.TransactionPrice.ToString(); WebPrice.SupportTransactionPrice = DBPrice.SupportTransactionPrice.ToString(); WebPrice.GiftMonthlyFee = DBPrice.GiftMonthlyFee.ToString(); WebPrice.CardholderMonthlyFee = DBPrice.CardholderMonthlyFee.ToString(); WebPrice.CardHolderPercentageCharge = DBPrice.CardHolderPercentageCharge.ToString(); WebPrice.AfterXMonths = DBPrice.AfterXMonths.ToString(); return(WebPrice); }
// G e t P r i c e s List <EditPriceModel> IPriceService.GetPrices() { IPriceDAO PriceData = new PriceDAO(); List <Price> DBPrices = PriceData.ListPrices(); List <EditPriceModel> WebPrices = new List <EditPriceModel>(); foreach (Price DBPrice in DBPrices) { EditPriceModel WebPrice = new EditPriceModel(); WebPrice.DatabaseID = Convert.ToString(DBPrice.ID); WebPrice.PricingName = DBPrice.PricingName; WebPrice.CardPrice = DBPrice.CardPrice.ToString(); WebPrice.TransactionPrice = DBPrice.TransactionPrice.ToString(); WebPrice.SupportTransactionPrice = DBPrice.SupportTransactionPrice.ToString(); WebPrice.GiftMonthlyFee = DBPrice.GiftMonthlyFee.ToString(); WebPrice.CardholderMonthlyFee = DBPrice.CardholderMonthlyFee.ToString(); WebPrice.CardHolderPercentageCharge = DBPrice.CardHolderPercentageCharge.ToString(); WebPrice.AfterXMonths = DBPrice.AfterXMonths.ToString(); WebPrices.Add(WebPrice); } return(WebPrices); }
public ActionResult Edit(Product product, IEnumerable <HttpPostedFileBase> MoreImage, long?price, long?sale, DateTime?beginDate, DateTime?endDate) { if (ModelState.IsValid) { //láy hình ảnh thêm vao trong thư mục data //mục thêm nhiều hình ảnh int i = 0; string path = "/Data/images/Product/"; XElement xElement = new XElement("Images");//khổi tạo xml có node là Images if (MoreImage.First() != null) { foreach (var file in MoreImage) { if (file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); //lấy tên hình ảnh string[] name = fileName.Split('.'); //tách để đổi tên hình ảnh name[0] = product.MetaTitle + "-item_" + i++; //đổi tên sản phẩm var rename = name[0] + "." + name[1]; //gáng lại vào chuỗi var filePath = Path.Combine(Server.MapPath(path), rename); file.SaveAs(filePath); xElement.Add(new XElement("Image", path + rename)); } } //gáng hình vào object product product.MoreImage = xElement.ToString(); } var dao = new ProductDAO(); var model = dao.Update(product); if (model) { TempData["Success"] = "Cập nhập sản phẩm thành công"; //nếu giá mà thay đổi sé thêm mới //cập nhập giá var prices = new PriceDAO().ViewDetailNew(product.ID); var sales = new SaleDAO().ViewDetailNew(product.ID); if (prices.Price1 != price && price != null) { var priceNew = new Price(); priceNew.Price1 = price; priceNew.ProductID = product.ID; new PriceDAO().Create(priceNew, Session["username"].ToString()); } if (sales != null) { if (sales.Price != sale && sale != null) { var saleNew = new Sale(); saleNew.Price = sale; saleNew.ProductID = product.ID; saleNew.BeginDate = (DateTime)beginDate; saleNew.EndDate = (DateTime)endDate; new SaleDAO().Create(saleNew); } } else { var saleNew = new Sale(); saleNew.Price = sale; saleNew.ProductID = product.ID; saleNew.BeginDate = (DateTime)beginDate; saleNew.EndDate = (DateTime)endDate; new SaleDAO().Create(saleNew); } return(RedirectToAction("Index", "Product")); } else { TempData["Error"] = "Cập nhập sản phẩm thất bại"; return(View("Edit")); } } setViewBag(); setProducer(); TempData["Error"] = "Cập nhập sản phẩm thất bại"; return(View("Edit")); }