private void BindData(String foodID) { txtRestaurant.Value = svRestaurant.getRestaurant(hdRestaurantID.Value).RestaurantName; MODEL.MenuDetail _Menu = new MODEL.MenuDetail(); BLL.Menu _BLL = new BLL.Menu(); _Menu = _BLL.getMenuDetail(foodID); ddlCategoryLV1.SelectedValue = _Menu.MenuCategoryLV1ID; ddlCategoryLV2.SelectedValue = _Menu.MenuCategoryLV2ID; ddlStatus.SelectedValue = _Menu.MenuActivate; txtMenuName.Value = _Menu.MenuName; txtMenuDescription.Value = _Menu.MenuDescription; txtPriceS.Value = _Menu.MenuPriceS; txtPriceM.Value = _Menu.MenuPriceM; txtPriceL.Value = _Menu.MenuPriceL; txtMenuRemark.Value = _Menu.MenuRemark; if (_Menu.MenuRecommend == "True") { ddlRecommend.SelectedValue = "1"; } else { ddlRecommend.SelectedValue = "0"; } imgFood.ImageUrl = "~/ImagesFood/" + _Menu.MenuPicture; }
protected void btnSave_Click(object sender, EventArgs e) { if (txtMenuName.Value.Trim() == "") { MSG("กรุณาป้อนชื่อเมนูอาหาร !!!"); return; } if (txtMenuDescription.Value.Trim() == "") { MSG("กรุณาป้อนรายละเอียดเมนูอาหาร !!!"); return; } if (txtPriceS.Value.Trim() == "") { MSG("กรุณาป้อนราคา [S] !!!"); return; } //Insert //string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName); //string FileNameDesinatoin = DateTime.Now.ToString("yyMMddhhmmss") + "_" + fileName; MODEL.Criteria.reqeMenu modelMenu = new MODEL.Criteria.reqeMenu(); modelMenu.MemberID = Session["memberID"].ToString(); modelMenu.MenuID = Session["foodID"].ToString(); modelMenu.MenuCategoryLV1ID = ddlCategoryLV1.SelectedValue.ToString().Trim(); modelMenu.MenuCategoryLV2ID = ddlCategoryLV2.SelectedValue.ToString().Trim(); modelMenu.MenuName = txtMenuName.Value.ToString().Trim(); if (imgFood.ImageUrl != "") { string imageName = imgFood.ImageUrl.Substring(imgFood.ImageUrl.LastIndexOf(@"/") + 1); modelMenu.MenuPicture = imageName; string Origin = Server.MapPath("~/ImageTemp/") + imageName; if (File.Exists(@Origin)) { string FileName = DateTime.Now.ToString("yyMMddhhmmss") + "_" + imageName; string Desination = Server.MapPath("~/ImagesFood/") + FileName; File.Copy(Origin, Desination); modelMenu.MenuPicture = FileName; File.Delete(@Origin); } } modelMenu.MenuDescription = txtMenuDescription.Value.ToString().Trim(); modelMenu.MenuActivate = ddlStatus.SelectedValue.ToString().Trim(); modelMenu.MenuRemark = txtMenuRemark.Value.Trim(); modelMenu.MenuPrice = txtPriceS.Value.ToString().Trim(); modelMenu.MenuPriceS = txtPriceS.Value.ToString().Trim(); modelMenu.MenuPriceM = txtPriceM.Value.ToString().Trim(); modelMenu.MenuPriceL = txtPriceL.Value.ToString().Trim(); modelMenu.MenuRecommend = ddlRecommend.SelectedValue.ToString().Trim(); modelMenu.restaurantID = hdRestaurantID.Value; MODEL.Result result; BLL.Menu _mBLL = new BLL.Menu(); if (_mBLL.updateMenu(modelMenu).ResultOk == "true") { MSG("บันทึกข้อมูลเรียบร้อย"); string URL = @"memberID=" + hdMemberID.Value + "&restaurantID=" + hdRestaurantID.Value; URL = svURL.Encrypt(URL, "r0b1nr0y"); Response.Redirect("MenuList.aspx?" + URL, true); } else { MSG("บันทึกข้อมูลไม่สำเร็จ"); } }