public static RecipeEntity getById(int recipeId) { DataRow dr = DbHelper.ExecuteDataRow("p_recipe_getById", recipeId); RecipeEntity recipe = new RecipeEntity(); if (dr != null) { recipe.RecipeId = int.Parse(dr["recipeId"].ToString()); recipe.Name = dr["name"].ToString(); recipe.Rcid = int.Parse(dr["rcid"].ToString()); recipe.Description = dr["description"].ToString(); recipe.IsShow = bool.Parse(dr["isShow"].ToString()); recipe.Source = dr["source"].ToString(); recipe.Sort = int.Parse(dr["sort"].ToString()); recipe.IsRecommend = bool.Parse(dr["isRecommend"].ToString()); recipe.Favorite = bool.Parse(dr["favorite"].ToString()); recipe.CompanyId = int.Parse(dr["companyId"].ToString()); recipe.InputDt = DateTime.Parse(dr["inputDt"].ToString()); recipe.CompanyName = dr["companyName"].ToString(); } return recipe; }
public static int insert(RecipeEntity recipe) { int id = 0; object recipeId = DbHelper.ExecuteScalar("p_Recipe_insert", recipe.Name, recipe.Rcid, recipe.Description, recipe.IsShow, recipe.Source, recipe.CompanyId, recipe.Sort, recipe.IsRecommend, recipe.Favorite ); if (recipeId != null) { int.TryParse(recipeId.ToString(), out id); } return id; }
protected void btnSaveRecipe_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(hdAction.Value)) { int companyId = logic.customer.getCompanyId(); if (txtDishName.Value!=hdCurrentDishName.Value) { // 编辑系统菜谱转换成我的菜谱(菜谱名称唯一性判断) bool isExists = logic.recipe.isExistsRecipeName(companyId, txtDishName.Value, "2"); if (isExists) { Library.Script.ClientMsg("您的菜谱列表中已经存在当前菜谱!您可以重新命名菜谱名称,然后点击保存."); return; } } if (string.IsNullOrEmpty(hdProductIds.Value)) { Library.Script.ClientMsg("您未选择任何原料,不能保存当前菜谱!"); return; } int recipeId = 0; if (hdAction.Value == "Add") { RecipeEntity recipe = new RecipeEntity(); recipe.Name = txtDishName.Value; int rcid = 0; int.TryParse(ddlRecipeCategory.SelectedValue, out rcid); recipe.Rcid = rcid; recipe.Description = ""; int sort = 0; recipe.Sort = sort; recipe.Source = "2"; recipe.IsShow = true; recipe.IsRecommend = false; recipe.Favorite = false; recipe.CompanyId = companyId; recipeId = logic.recipe.insert(recipe); } else if (hdAction.Value == "Edit") { int.TryParse(hdCurrentRecipeId.Value, out recipeId); if (recipeId != 0) { // 编辑 RecipeEntity recipe = logic.recipe.getById(recipeId); int rcid = 0; int.TryParse(ddlRecipeCategory.SelectedValue, out rcid); recipe.Name = txtDishName.Value; recipe.Rcid = rcid; logic.recipe.update(recipe); logic.recipeItem.delByRecipeId(recipeId); } } SaveRecipeItems(recipeId); // 跳转 String redirectURL = String.Format("buyer_myRecipeList.html?name={0}&category={1}", HttpUtility.UrlEncodeUnicode(ddlRecipeCategory.SelectedItem.Text), ddlRecipeCategory.SelectedValue); Library.Script.ClientMsgUrl("保存成功!", redirectURL); } }
public static void update(RecipeEntity recipe) { Recipe.update(recipe); }
// 将用户菜谱转换成系统菜谱 public static int insertFromDiyToSystem(RecipeEntity cat) { return Recipe.insertFromDiyToSystem(cat); }
public static int insert(RecipeEntity recipe) { return Recipe.insert(recipe); }
protected void btn_Save_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(hdProductSotre.Value)) { Library.Script.ClientMsg("请选择菜谱原料!"); return; } if (txt_Name.Text != hdCurrentDishName.Value || (!string.IsNullOrEmpty(Request.QueryString["action"]) && Request.QueryString["action"] == "view")) { if (logic.recipe.isExistsRecipeName(0, txt_Name.Text, "1")) { Library.Script.ClientMsg("菜谱列表中已经存在该名称!"); return; } } #region 保存菜谱信息 RecipeEntity cat = new RecipeEntity(); cat.Name = txt_Name.Text; int rcid = 0; int.TryParse(drp_ParentCategory.SelectedValue, out rcid); cat.Rcid = rcid; cat.Description = txtDescrption.Text; int sort = 0; int.TryParse(txt_Sort.Text, out sort); cat.Sort = sort; cat.Source = "1"; cat.IsShow = chx_isShow.Checked; cat.IsRecommend = chkRecommend.Checked; cat.Favorite = false; cat.CompanyId = 0;// 系统录入由CompanyId和Source两个条件决定 if (id != 0) { cat.RecipeId = id; // 将当前菜谱转换成系统菜谱 if (!string.IsNullOrEmpty(Request.QueryString["action"]) && Request.QueryString["action"] == "view") { cat.RecipeId = logic.recipe.insertFromDiyToSystem(cat); } else { logic.recipe.update(cat); } SaveRecipeItems(cat.RecipeId); } else { int recipeId = logic.recipe.insert(cat); if (recipeId != 0) { SaveRecipeItems(recipeId); } } Library.Script.ClientMsgUrl("保存成功!", "recipeList.aspx"); #endregion }
// 将当前菜谱转换成系统菜谱 public static int insertFromDiyToSystem(RecipeEntity cat) { int id = 0; object tmp = DbHelper.ExecuteScalar("p_Recipe_From_Diy_To_System", cat.RecipeId,cat.Name,cat.Rcid,cat.Description,cat.IsShow,cat.Sort,cat.IsRecommend); if (tmp!=null) { int.TryParse(tmp.ToString(),out id); } return id; }
public static void update(RecipeEntity recipe) { DbHelper.ExecuteNonQuery("p_Recipe_update", recipe.RecipeId, recipe.Name, recipe.Rcid, recipe.Description, recipe.IsShow, recipe.Source, recipe.CompanyId, recipe.Sort, recipe.IsRecommend, recipe.Favorite ); }