private bool saveImg(productImage pic) //사진 업로드 (ftp) { try { if (!((pic.parameter == "no image") || (pic.registeredImgName == ""))) { imgUploadHelper ftpClient = new imgUploadHelper(commonVar.userFTPServerIP, commonVar.userFTPID, commonVar.userFTPPassword); string ftpFilePath = "JEPUM/" + txt_id.Text + "/" + pic.registeredImgName; if (ftpClient.Upload(pic.imgLocalPath, ftpFilePath)) { pic.parameter = imgDBpath + ftpFilePath; return(true); } else { return(false); } } else { return(true); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\r 이미지 업로드에 실패했습니다.", "이미지 업로드 에러"); return(false); } }
public ProductDetailsWithImages PutProductDetails(productDetail pd, productImage pi) { ProductDetailsWithImages finalModel = new ProductDetailsWithImages(); finalModel.productdetails = pd; finalModel.productimages = pi; return(finalModel); }
public ActionResult DeleteConfirmed(int id) { productImage productImage = db.productImages.Find(id); db.productImages.Remove(productImage); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(productImage productimage) { if (ModelState.IsValid) { db.Entry(productimage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productimage)); }
public void Delete(int id) { productImage img = _context.productImage.Find(id); if (img != null) { _context.productImage.Remove(img); _context.SaveChanges(); } }
// // GET: /Image/Delete/5 public ActionResult Delete(int id = 0) { productImage productimage = db.productImages.Find(id); if (productimage == null) { return(HttpNotFound()); } return(View(productimage)); }
//public ActionResult ViewDetails() //{ DataModel datamodel = new DataModel(); // datamodel.productDetail = db.productDetails.ToList(); // ViewData[ "productImage" ] = datamodel.productDetail; // return View(db.productDetails.ToList()); //} public ActionResult EditImage(int id = 0) { productImage ProductImage = new productImage(); ProductImage = db.GetMainImage().ToList <productImage>().Find(x => x.pID == id); productID = id; ViewBag.id = id; return(View(ProductImage)); }
public ActionResult Create(productImage productimage) { if (ModelState.IsValid) { db.productImages.Add(productimage); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productimage)); }
public void Delete(int id) { // delete içerisine bir id geldiğinde resim silecek productImage img = _context.productImage.Find(id); if (img != null) { _context.productImage.Remove(img); _context.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "Id,ProductId,Image,Title")] productImage productImage) { if (ModelState.IsValid) { db.Entry(productImage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductId = new SelectList(db.products, "Id", "Name", productImage.ProductId); return(View(productImage)); }
private void btn_picAdd_Click(object sender, EventArgs e) //로컬에서 사진 불러오기 { string ctlName = ((SimpleButton)sender).Name; string filename = ""; string local = ""; PictureEdit pic = null; productImage singleImage = null; switch (ctlName) { case "btn_picAdd1": singleImage = img1; pic = img1.ctl; break; case "btn_picAdd2": singleImage = img2; pic = img2.ctl; break; case "btn_picAdd3": singleImage = img3; pic = img3.ctl; break; case "btn_picAdd4": singleImage = img4; pic = img4.ctl; break; case "btn_picAddStd": singleImage = imgStd; pic = imgStd.ctl; break; } if (pic.Image != null) { MessageBox.Show("등록된 이미지가 있습니다. \n\r기존 이미지를 먼저 삭제 하세요.", "이미지 로드 에러"); } else { pic.LoadImage(); local = pic.GetLoadedImageLocation(); filename = local.Substring(local.LastIndexOf("\\") + 1); singleImage.registeredImgName = filename; singleImage.imgLocalPath = local; chkValueChanged(this, e); } }
// GET: ProductImage/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } productImage productImage = db.productImages.Find(id); if (productImage == null) { return(HttpNotFound()); } return(View(productImage)); }
public ActionResult AddNewImage() { productImage ProductImage = new productImage(); var ID = db.GetNewProductID().ToList(); if (db.GetMainImage().ToList <productImage>().Find(x => x.pID == ID[0]) != null) { ProductImage = db.GetMainImage().ToList <productImage>().Find(x => x.pID == ID[0]); } ViewBag.id = ID[0]; return(View(ProductImage)); }
// GET: ProductImage/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } productImage productImage = db.productImages.Find(id); if (productImage == null) { return(HttpNotFound()); } ViewBag.ProductId = new SelectList(db.products, "Id", "Name", productImage.ProductId); return(View(productImage)); }
public ActionResult Create([Bind(Include = "Id,ProductId,Image,Title")] productImage productImage, HttpPostedFileBase Image) { productImage.Image = System.IO.Path.GetFileName(Image.FileName); if (ModelState.IsValid) { db.productImages.Add(productImage); db.SaveChanges(); Image.SaveAs(Server.MapPath("../uploads/productImages/" + productImage.Id.ToString() + "_" + productImage.Image)); return(RedirectToAction("Index")); } ViewBag.ProductId = new SelectList(db.products, "Id", "Name", productImage.ProductId); return(View(productImage)); }
public ActionResult Create(product support) { if (ModelState.IsValid) { List <productImage> fileDetails = new List <productImage>(); for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); productImage fileDetail = new productImage() { FileName = fileName, Extension = Path.GetExtension(fileName), Id = Guid.NewGuid() }; fileDetails.Add(fileDetail); var path = Path.Combine(Server.MapPath("~/saveImages/"), fileDetail.Id + fileDetail.Extension); file.SaveAs(path); // save to folder ResizeSettings resizeSetting = new ResizeSettings { Width = 253, Height = 337, Format = "jpg" }; ImageBuilder.Current.Build(path, path, resizeSetting); } } ViewBag.typeenumm = db.Types; support.date = DateTime.Now; support.productImage = fileDetails; // save to db db.products.Add(support); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(support)); }
public ActionResult EditImage(string productId) { if (Session["user"] == null) { return(RedirectToAction("home", "home")); } PRFancyRepository dal = new PRFancyRepository(); PRFancyAutoMapper <productImage, Models.ProductImage> map = new PRFancyAutoMapper <productImage, Models.ProductImage>(); try { productImage obj = dal.GetProductImage(productId); Models.ProductImage modObj = map.Translate(obj); return(View(map.Translate(obj))); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
public ActionResult Edit(product product, IEnumerable <HttpPostedFileBase> image1) { if (product != null) { repository.Update(product); } if (image1.First() != null) { productImage newImg = new productImage(); newImg.productId = product.productId; foreach (var item in image1) { using (var br = new BinaryReader(item.InputStream)) { var data = br.ReadBytes(item.ContentLength); newImg.image = data; } repository.Save(newImg); } } return(RedirectToAction("Index")); }
public ActionResult AddNewImage(HttpPostedFileBase postedFile) { string columnName = Request.Form[Request.Form.AllKeys[0]].ToString(); int ProductID = Convert.ToInt32(Request.Form[Request.Form.AllKeys[1]]); byte[] bytes = new byte[1000]; if (ModelState.IsValid) { using (BinaryReader br = new BinaryReader(postedFile.InputStream)) { bytes = br.ReadBytes(postedFile.ContentLength); } } if (columnName == "mainImg") { db.AddNewImage(bytes, ProductID, columnName); } else { db.AddImage1(bytes, ProductID, columnName); } productImage ProductImage = new productImage(); var ID = db.GetNewProductID().ToList(); if (db.GetMainImage().ToList <productImage>().Find(x => x.pID == ID[0]) != null) { ProductImage = db.GetMainImage().ToList <productImage>().Find(x => x.pID == ID[0]); } ViewBag.id = ID[0]; return(View(ProductImage)); }
public void Save(productImage model) { _context.productImage.Add(model); _context.SaveChanges(); }
private bool save() //저장버튼 누를 때 호출되는 함수 { if (txt_id.Text.Length == 0) { MessageBox.Show("제품코드를 입력하세요.", "주의"); return(false); } else if (txt_name.Text.Length == 0) { MessageBox.Show("제품이름을 입력하세요.", "주의"); return(false); } else if (txt_num.Text.Length == 0) { MessageBox.Show("제품번호를 입력하세요.", "주의"); return(false); } else { if ((is_add == true) && (chkDuplicate() == false)) { MessageBox.Show("제품코드가 중복되었습니다.", "주의"); return(false); } cmd = new SqlCommand(); //제품코드 차종 모델 품명 품번 캐비티 포장수량 사이클타임 자재번호 사양 색상 색상명 등록일자 승인일자 양산일자 단종일자 단종사유 적정재고 사용여부 메모 이미지1,2,3,4 cmd.Parameters.Clear(); cmd.Parameters.Add("@jp_id", SqlDbType.VarChar, 20).Value = Convert.ToString(txt_id.Text.Trim()); cmd.Parameters.Add("@car", SqlDbType.NVarChar, 40).Value = Convert.ToString(txt_car.Text); cmd.Parameters.Add("@model", SqlDbType.NVarChar, 40).Value = Convert.ToString(txt_model.Text); cmd.Parameters.Add("@jp_name", SqlDbType.NVarChar, 40).Value = Convert.ToString(txt_name.Text); cmd.Parameters.Add("@jp_num", SqlDbType.VarChar, 20).Value = Convert.ToString(txt_num.Text); cmd.Parameters.Add("@cavity", SqlDbType.VarChar, 10).Value = Convert.ToString(txt_cavity.Text); cmd.Parameters.Add("@cavity_num", SqlDbType.Int).Value = Convert.ToInt32(txt_cavity.Text.Substring(0, 2)); //작업지시에서 불러올 캐비티 cmd.Parameters.Add("@qt_pkg", SqlDbType.Int).Value = Convert.ToDecimal(txt_pkg.Value); cmd.Parameters.Add("@cycle_t", SqlDbType.Money).Value = Convert.ToDecimal(txt_cycle.Value); cmd.Parameters.Add("@mtrl_num", SqlDbType.VarChar, 20).Value = Convert.ToString(txt_mtrl.Text); cmd.Parameters.Add("@spec", SqlDbType.NVarChar, 40).Value = Convert.ToString(txt_spec.Text); cmd.Parameters.Add("@gh_id", SqlDbType.VarChar, 20).Value = Convert.ToString(txt_mold.Text); cmd.Parameters.Add("@jp_color", SqlDbType.Int).Value = Convert.ToInt32(cbx_color.Color.ToArgb()); cmd.Parameters.Add("@color_name", SqlDbType.NVarChar, 20).Value = Convert.ToString(txt_colorName.Text); cmd.Parameters.Add("@sj_id", SqlDbType.VarChar, 20).Value = Convert.ToString(txt_resin.Tag); cmd.Parameters.Add("@wr_date", SqlDbType.VarChar, 10).Value = Convert.ToString(txt_write.Text); cmd.Parameters.Add("@aprv_date", SqlDbType.VarChar, 10).Value = Convert.ToString(txt_aprv.Text); cmd.Parameters.Add("@mass_date", SqlDbType.VarChar, 10).Value = Convert.ToString(txt_mass.Text); cmd.Parameters.Add("@discont_date", SqlDbType.VarChar, 10).Value = Convert.ToString(txt_discont.Text); cmd.Parameters.Add("@discont_why", SqlDbType.NVarChar, 100).Value = Convert.ToString(txt_why.Text); cmd.Parameters.Add("@opt_stock", SqlDbType.Money).Value = Convert.ToDecimal(txt_optStock.Value); cmd.Parameters.Add("@now_stock", SqlDbType.Money).Value = Convert.ToDecimal(txt_nowStock.Value); cmd.Parameters.Add("@memo", SqlDbType.NVarChar, 100).Value = Convert.ToString(txt_memo.Text); cmd.Parameters.Add("@use_chk", SqlDbType.Char, 1).Value = Convert.ToString(cbx_use.Text.Trim()); //---------------------------------------------------------------------------------이미지 저장 string imgEmpty = "no image"; productImage[] pictureBoxes = new productImage[] { img1, img2, img3, img4, imgStd }; foreach (productImage singlePictureBox in pictureBoxes) { if (singlePictureBox.ctl.Image == null) //컨트롤에 이미지 없을때 { singlePictureBox.parameter = imgEmpty; } else { //컨트롤에 이미지가 있을때 path읽어오기 //기존경로가 존재하고 수정되지 않았을경우에는 원래 경로 저장 if ((singlePictureBox.downloadedImgPath != "") && (singlePictureBox.registeredImgName == "")) { singlePictureBox.parameter = singlePictureBox.downloadedImgPath; } } if (!saveImg(singlePictureBox)) { MessageBox.Show("이미지 저장 실패", "단일 이미지 저장"); return(false); } } //--------------------------------------------------------------------------------스칼라변수 설정 cmd.Parameters.Add("jp_img1", SqlDbType.VarChar, 250).Value = img1.parameter; cmd.Parameters.Add("jp_img2", SqlDbType.VarChar, 250).Value = img2.parameter; cmd.Parameters.Add("jp_img3", SqlDbType.VarChar, 250).Value = img3.parameter; cmd.Parameters.Add("jp_img4", SqlDbType.VarChar, 250).Value = img4.parameter; cmd.Parameters.Add("jp_stdpaper", SqlDbType.VarChar, 250).Value = imgStd.parameter; commonReturn Return = new commonReturn(); Return = fx_productCode.write(commonVar.DBconn, is_add, cmd); if (Return.Message == "") { return(true); } else { MessageBox.Show(Return.Message); return(false); } } }
private void btn_picDel_Click(object sender, EventArgs e) { string ctlName = ((SimpleButton)sender).Name; string imgName = ""; PictureEdit pic = null; productImage singleImage = null; switch (ctlName) { case "btn_picDel1": pic = img1.ctl; imgName = img1.downloadedImgName; singleImage = img1; break; case "btn_picDel2": pic = img2.ctl; imgName = img2.downloadedImgName; singleImage = img2; break; case "btn_picDel3": pic = img3.ctl; imgName = img3.downloadedImgName; singleImage = img3; break; case "btn_picDel4": pic = img4.ctl; imgName = img4.downloadedImgName; singleImage = img4; break; case "btn_picDelStd": pic = imgStd.ctl; imgName = imgStd.downloadedImgName; singleImage = imgStd; break; } if (pic.Image == null) { MessageBox.Show("등록된 이미지가 없습니다. \n\r이미지를 먼저 등록 하세요.", "이미지 삭제 에러"); } else { if ((is_add == true) || (singleImage.downloadedImgPath == "")) { pic.Image = null; } else { if (deleteImage(imgName)) { pic.Image = null; singleImage.imgLocalPath = ""; singleImage.registeredImgName = ""; singleImage.downloadedImgPath = ""; singleImage.downloadedImgName = ""; chkValueChanged(this, e); } else { MessageBox.Show("이미지 삭제에 실패 했습니다."); } } } }
private void ctl_productEdit_Load(object sender, EventArgs e) { is_loading = true; //이미지컨트롤 초기화 img1.ctl = pic_img1; img1.downloadedImgName = ""; img1.downloadedImgPath = ""; img1.registeredImgName = ""; img1.imgLocalPath = ""; img1.parameter = ""; img2.ctl = pic_img2; img2.downloadedImgName = ""; img2.downloadedImgPath = ""; img2.registeredImgName = ""; img2.imgLocalPath = ""; img2.parameter = ""; img3.ctl = pic_img3; img3.downloadedImgName = ""; img3.downloadedImgPath = ""; img3.registeredImgName = ""; img3.imgLocalPath = ""; img3.parameter = ""; img4.ctl = pic_img4; img4.downloadedImgName = ""; img4.downloadedImgPath = ""; img4.registeredImgName = ""; img4.imgLocalPath = ""; img4.parameter = ""; imgStd.ctl = pic_std; imgStd.downloadedImgName = ""; imgStd.downloadedImgPath = ""; imgStd.registeredImgName = ""; imgStd.imgLocalPath = ""; imgStd.parameter = ""; if ((is_add == false) || (is_read == true)) //수정 또는 단순조회 { txt_id.ReadOnly = true; if (is_read == true) { readOnlyMode(true); } commonReturn Return = new commonReturn(); Return = fx_productCode.findByID(commonVar.DBconn, productID); if (Return.Message == "") { DataRow tempRow = Return.Dataset.Tables[0].Rows[0]; txt_id.Text = Convert.ToString(tempRow["jp_id"]); txt_car.Text = Convert.ToString(tempRow["car"]); txt_model.Text = Convert.ToString(tempRow["model"]); txt_name.Text = Convert.ToString(tempRow["jp_name"]); txt_num.Text = Convert.ToString(tempRow["jp_num"]); txt_cavity.Text = Convert.ToString(tempRow["cavity"]); txt_pkg.Value = Convert.ToDecimal(tempRow["qt_pkg"]); txt_cycle.Value = Convert.ToDecimal(tempRow["cycle_t"]); txt_mtrl.Text = Convert.ToString(tempRow["mtrl_num"]); txt_spec.Text = Convert.ToString(tempRow["spec"]); txt_mold.Text = Convert.ToString(tempRow["gh_id"]); cbx_color.Color = Color.FromArgb(Convert.ToInt32(tempRow["jp_color"])); txt_colorName.Text = Convert.ToString(tempRow["color_name"]); txt_resin.Text = Convert.ToString(tempRow["sj_name"]); txt_resin.Tag = Convert.ToString(tempRow["sj_id"]); txt_write.Text = Convert.ToString(tempRow["wr_date"]); txt_aprv.Text = Convert.ToString(tempRow["aprv_date"]); txt_mass.Text = Convert.ToString(tempRow["mass_date"]); txt_discont.Text = Convert.ToString(tempRow["discont_date"]); txt_why.Text = Convert.ToString(tempRow["discont_why"]); txt_optStock.Value = Convert.ToDecimal(tempRow["opt_stock"]); txt_nowStock.Value = Convert.ToDecimal(tempRow["now_stock"]); txt_memo.Text = Convert.ToString(tempRow["memo"]); if (Convert.ToString(tempRow["use_chk"]) == "Y") { cbx_use.SelectedIndex = 0; } else { cbx_use.SelectedIndex = 1; } //이미지로딩 productImage[] images = new productImage[] { img1, img2, img3, img4, imgStd }; string[] paths = new string[] { Convert.ToString(tempRow["jp_img1"]), Convert.ToString(tempRow["jp_img2"]), Convert.ToString(tempRow["jp_img3"]), Convert.ToString(tempRow["jp_img4"]), Convert.ToString(tempRow["jp_stdpaper"]) }; int i = 0; foreach (productImage myImage in images) { myImage.downloadedImgPath = paths[i]; if (paths[i] == "no image" || paths[i].Length == 0) { myImage.ctl.Image = null; myImage.downloadedImgPath = ""; } else { myImage.ctl.LoadAsync(paths[i]); string filename = myImage.downloadedImgPath.Substring(myImage.downloadedImgPath.LastIndexOf("/") + 1); myImage.downloadedImgName = filename; } i++; } } else { MessageBox.Show(Return.Message); } }//if if (is_add == true) //추가 { clear(); txt_id.ReadOnly = false; txt_id.Focus(); } btn_save.Enabled = false; is_ValueChanged = false; is_loading = false; }