/// <summary> /// 由一级类目名称获取一级类目ID /// </summary> /// <param name="firstclassdm">一级类目对象</param> /// <returns>一级类目ID</returns> public string FcNameGetID(FirstClassDm firstclassdm) { string Sqlstring = "select FirstClassDmID from FirstClassDm where FirstClassDmName=N'" + firstclassdm.FirstClassDmName + "'"; Object obj = SqlHelper.ReadSclar(Sqlstring); return((string)obj); }
/// <summary> /// 通过一级类目名称搜索二级类目名称 /// </summary> /// <param name="firstclassdm">一级类目对象</param> /// <param name="secondclassdm">二级类目对象</param> /// <returns>二级类目名称表</returns> public static List <SecondClassDm> FcShowContent(FirstClassDm firstclassdm, SecondClassDm secondclassdm) { string Sqlstring = "select FirstClassDmID from FirstClassDm where FirstClassDmName=N'" + firstclassdm.FirstClassDmName + "'"; Object obj = SqlHelper.ReadSclar(Sqlstring); string str = (string)obj; List <SecondClassDm> secondCluList = new List <SecondClassDm>(); secondCluList = SecondClassDm.Getlist(str); return(secondCluList); }
/// <summary> /// 删除一级类目 /// </summary> /// <returns>是否删除成功</returns> public bool DeleteFirstclassdm(FirstClassDm first) { string str = first.FirstClassDmName; string Sql = "delete from FirstClassDm where FirstClassDmName=N'" + str + "'"; if (SqlHelper.ExecuteNonQuery(Sql) > 0) { return(true); } else { return(false); } }
/// <summary> /// 判断添加的一级类目是否重复 /// </summary> /// <returns>是否重复</returns> public bool FcIsRepeat(FirstClassDm firstclassdm) { string Sqlstring = "select FirstClassDmID from FirstClassDm where FirstClassDmName=N'" + firstclassdm.FirstClassDmName + "'"; Object obj = SqlHelper.ReadSclar(Sqlstring); string str = (string)obj; if (str == null) { return(true); } else { return(false); } }
/// <summary> /// 一级类目名字获取二级类目名字 /// </summary> /// <param name="firstclassdm">一级类目对象</param> /// <returns>二级类目名字表</returns> public static List <SecondClassDm> FcNameGetScName(FirstClassDm firstclassdm) { List <SecondClassDm> Sclist = new List <SecondClassDm>(); string sqlstring = "select SecondClassDmName from SecondClassDm where FirstClassDmID=(select FirstClassDmID from FirstClassDm where FirstClassDmName=N'" + firstclassdm.FirstClassDmName + "')"; SqlHelper.ReadDateReadBegin(sqlstring); while (SqlHelper.SqlReader.Read()) { SecondClassDm secondclassdm = new SecondClassDm(); secondclassdm.SecondClassDmName = SqlHelper.SqlReader["SecondClassDmName"].ToString(); Sclist.Add(secondclassdm); } SqlHelper.ReadDateReadEnd(); return(Sclist); }
/// <summary> /// 获取一级类目名称 /// </summary> /// <returns>一个对象表</returns> public static List <FirstClassDm> Getlist() { List <FirstClassDm> lUserlist = new List <FirstClassDm>(); string Sqlstring = "select * from FirstClassDm"; SqlHelper.ReadDateReadBegin(Sqlstring); while (SqlHelper.SqlReader.Read()) { FirstClassDm firstclum = new FirstClassDm(); firstclum.FirstClassDmName = SqlHelper.SqlReader["FirstClassDmName"].ToString(); firstclum.FirstClassDmID = SqlHelper.SqlReader["FirstClassDmID"].ToString(); lUserlist.Add(firstclum); } SqlHelper.ReadDateReadEnd(); return(lUserlist); }
/// <summary> /// 在一级类目中进行模糊搜索 /// </summary> /// <param name="textBox">搜索框中的字符串</param> /// <returns>二级类目表</returns> public List <FirstClassDm> FirstClassSelect(string textBox) { List <FirstClassDm> lFirstList = new List <FirstClassDm>(); string lTextBox = this.CutTbxText1(textBox); string sqlFirstClassSelect = "select * from FirstClassDm where FirstClassDmName like N'%" + lTextBox + "%'"; SqlHelper.ReadDateReadBegin(sqlFirstClassSelect); while (SqlHelper.SqlReader.Read()) { FirstClassDm lFirstClassDm = new FirstClassDm(); lFirstClassDm.FirstClassDmID = SqlHelper.SqlReader["FirstClassDmID"].ToString(); lFirstClassDm.FirstClassDmName = SqlHelper.SqlReader["FirstClassDmName"].ToString(); lFirstList.Add(lFirstClassDm); } SqlHelper.ReadDateReadEnd(); return(lFirstList); }
/// <summary> /// 添加二级类目 /// </summary> /// <param name="secondclassdm">二级类目对象</param> /// <param name="firstclassdm">对应的一级类目对象</param> /// <returns></returns> public int AddClum(SecondClassDm secondclassdm, FirstClassDm firstclassdm) { string c = null; string sql1 = "select top 1 * from SecondClassDm order by SecondClassDmID desc"; Object obj = SqlHelper.ReadSclar(sql1); if (obj == null) { c = "001"; } else { string a = obj.ToString(); int b1 = Convert.ToInt32(a.Substring(2, 1)); int b2 = Convert.ToInt32(a.Substring(1, 1)); int b3 = Convert.ToInt32(a.Substring(0, 1)); if (b1 < 9) { b1 = b1 + 1; c = a.Substring(0, 1) + a.Substring(1, 1) + b1.ToString(); } if (b1 == 9 && b2 < 9) { b1 = 0; b2 = b2 + 1; c = a.Substring(0, 1) + b2.ToString() + b1.ToString(); } if (b1 == 9 && b2 == 9) { b3 = b3 + 1; b2 = 0; b1 = 0; c = b3.ToString() + b2.ToString() + b1.ToString(); } } string Sqlstring = "insert SecondClassDm(SecondClassDmID,FirstClassDmID,SecondClassDmName)values('" + c + "','" + firstclassdm.FirstClassDmID + "',N'" + secondclassdm.SecondClassDmName + "')"; return(SqlHelper.ExecuteNonQuery(Sqlstring)); }