public ActionResult Create(GoodsType goodstype) { GoodsType @class = new GoodsType { Type_Name = goodstype.Type_Name }; var temp = GoodsTypeBll.Add(@class); if (temp == true) { return(RedirectToAction("Index")); } return(View(goodstype)); }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { GoodsTypeModel mod; if (this.id != "" && this.id != null) { mod = bll.GetModel(this.id); } else { mod = new GoodsTypeModel(); } string pPath = ""; string[] codeList = this.cSelect.hfCode.Split('|'); StarTech.DBUtility.AdoHelper adoHelper = StarTech.DBUtility.AdoHelper.CreateHelper("DB_Instance"); if (codeList.Length < 1 || cSelect.hfCode == "") { mod.PCategoryId = ""; mod.CategoryLevel = 1; mod.CategoryPath = mod.CategoryId; } else { //if(this.cSelect.categoryID) mod.PCategoryId = codeList[codeList.Length - 1]; DataSet ds = adoHelper.ExecuteSqlDataset("select * from T_Info_Category where categoryid='" + KillSqlIn.Form_ReplaceByString(mod.PCategoryId, 20) + "';"); mod.CategoryLevel = Convert.ToInt32(ds.Tables[0].Rows[0]["CategoryLevel"].ToString()) + 1; pPath = ds.Tables[0].Rows[0]["CategoryPath"].ToString(); } if (pPath != "") { pPath += ","; } mod.CategoryName = this.txtMenuName.Text.Trim(); //mod.CategoryPath= //mod.Remarks = this.txtRemarks.Text.Trim(); int orderdy = 0; int.TryParse(this.txtSort.Text.Trim(), out orderdy); mod.Orderby = orderdy; mod.CategoryFlag = (this.cbIsVisible.Checked == true) ? "Course" : "Category"; if (fuImg.FileName != null && fuImg.FileName != "") { //mod.Url = fuImg.FileName; string nowUrl = Guid.NewGuid().ToString(); string tzm = fuImg.FileName.Substring(fuImg.FileName.LastIndexOf(".")); string url = "/upload/Category/" + nowUrl + "" + tzm; fuImg.SaveAs(Server.MapPath("~" + url)); mod.Url = url; } if (this.id != "" && this.id != null) { if (this.id == mod.PCategoryId) { ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('上级分类不能选择当前分类');layer_close_refresh();</script>"); return; } mod.CategoryPath = pPath + mod.CategoryId; if (bll.Update(mod)) { LogAdd.CreateLog(HttpContext.Current.Session["UserId"].ToString(), "修改任务分类《" + mod.CategoryName + "》", "修改", "", "", HttpContext.Current.Request.Url.ToString()); ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>"); } } else { mod.CategoryId = IdCreator.CreateId("T_Info_Category", "CategoryId"); mod.CategoryPath = pPath + mod.CategoryId; bll.Add(mod); LogAdd.CreateLog(HttpContext.Current.Session["UserId"].ToString(), "添加任务分类《" + mod.CategoryName + "》;", "添加", "", "", HttpContext.Current.Request.Url.ToString()); ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('添加成功');layer_close_refresh();</script>"); //JSUtility.ReplaceOpenerParentWindow("menuTree.aspx"); } //ModMenu detail = new ModMenu(); //detail.menuName = this.txtMenuName.Text.Trim(); //detail.menuTarget = this.txtMenuLink.Text.Trim(); //detail.isShow = (this.cbIsVisible.Checked == true ? 1 : 0); //detail.orderIndex = Convert.ToInt32(this.txtSort.Text.Trim()); //detail.parentMenuId = Convert.ToInt32(this.cSelect.categoryID); //if (this._menuId != null) //{ // int menuId = Convert.ToInt32(this._menuId); // detail.uniqueId = menuId; // this._menu.Update(detail); // ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>"); //} //else //{ // this._menu.Add(detail); // ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('添加成功');layer_close_refresh();</script>"); // //JSUtility.ReplaceOpenerParentWindow("menuTree.aspx"); //} }