protected void GetClassName(int classid, int id, Boolean bFind, ref string sl) { if (!bFind) { if (classid == -1 && id == -1) { sl = ">>所有产品"; } else { ProClassModel c = EispProClassBLL.GetParentName(id); //string temp = string.Empty; // temp = sl; sl = ">>" + c.F_ClassName + sl; if (c.F_ParentID != 0) { GetClassName(classid, c.F_ParentID, false, ref sl); } else { bFind = true; } } } }
/// <summary> /// 获取类别 /// </summary> /// <param name="parentid"></param> /// <returns></returns> public static List <ProClassModel> GetProClassListByLang(int lang, int parentid) { string sql = "select * from T_ProClass where F_ParentID = ? And F_Lang=? order by F_Sort desc"; OleDbParameter[] parameter = new OleDbParameter[2]; parameter[0] = new OleDbParameter("@F_ParentID", OleDbType.Integer); parameter[0].Value = parentid; parameter[1] = new OleDbParameter("@F_Lang", OleDbType.Integer); parameter[1].Value = lang; List <ProClassModel> list = new List <ProClassModel>(); OleDbDataReader dr = AccessorDB.ExecuteReader(sql, parameter); ProClassModel proclass = null; while (dr.Read()) { proclass = new ProClassModel(); proclass.ID = Convert.ToInt32(dr["ID"].ToString()); proclass.F_ClassName = dr["F_ClassName"].ToString(); proclass.F_ParentID = Convert.ToInt32(dr["F_ParentID"]); proclass.F_Sort = Convert.ToInt32(dr["F_Sort"]); list.Add(proclass); } dr.Close(); dr.Dispose(); return(list); }
public static ProClassModel GetParentName(int parentid) { string sql = "select * from T_ProClass where ID=?"; OleDbParameter[] parameter = new OleDbParameter[1]; parameter[0] = new OleDbParameter("@ID", OleDbType.Integer); parameter[0].Value = parentid; OleDbDataReader dr = AccessorDB.ExecuteReader(sql, parameter); ProClassModel proclass = null; if (dr.Read()) { proclass = new ProClassModel(); proclass.ID = Convert.ToInt32(dr["ID"].ToString()); proclass.F_ClassName = dr["F_ClassName"].ToString(); proclass.F_ParentID = Convert.ToInt32(dr["F_ParentID"]); proclass.F_Sort = Convert.ToInt32(dr["F_Sort"]); } dr.Close(); dr.Dispose(); return(proclass); }
protected void Button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtClassName.Text)) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('分类名称不能为空!');", true); return; } if (string.IsNullOrEmpty(this.txtSort.Text)) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('排序不能为空!');", true); return; } if (!VerifyTool.IsInt(this.txtSort.Text, true, true)) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('排序格式只能是数字!');", true); return; } int res; ProClassModel proclass = new ProClassModel(); proclass.F_ParentID = Convert.ToInt32(this.hidParentID.Value); proclass.F_ClassName = this.txtClassName.Text.Trim().ToString(); proclass.F_Sort = Convert.ToInt32(this.txtSort.Text); proclass.F_Lang = lang; if (this.txtHiddParentName.Value.Trim().ToString() == "编辑分类") { res = EispProClassBLL.UpdateProClass(proclass.F_ClassName, proclass.F_ParentID); } else { res = EispProClassBLL.AddProClass(proclass); } if (res > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加成功');location.href='ProClassAdmin.aspx?lang=" + lang + "&';", true); } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加失败,数据库繁忙');", true); } }
/// <summary> /// 添加 /// </summary> /// <param name="t"></param> /// <returns>0失败,1成功</returns> public static int AddProClass(ProClassModel t) { string sql = "insert into T_ProClass(F_ClassName,F_ParentID,F_Sort,F_Lang) values(@F_ClassName,@F_ParentID,@F_Sort,@F_Lang)"; OleDbParameter[] parameter = new OleDbParameter[4]; parameter[0] = new OleDbParameter("@F_ClassName", OleDbType.VarChar, 50); parameter[1] = new OleDbParameter("@F_ParentID", OleDbType.Integer); parameter[2] = new OleDbParameter("@F_Sort", OleDbType.Integer); parameter[3] = new OleDbParameter("@F_Sort", OleDbType.Integer); parameter[0].Value = t.F_ClassName; parameter[1].Value = t.F_ParentID; parameter[2].Value = t.F_Sort; parameter[3].Value = t.F_Lang; return(AccessorDB.ExecuteNonQuery(sql, parameter)); }
/// <summary> /// 添加 /// </summary> /// <param name="t"></param> /// <returns>0失败,1成功</returns> public static int AddProClass(ProClassModel t) { return(EispProClassDAL.AddProClass(t)); }