using SQLData; using System.Data; using System.Text; namespace BizCom { public class CategoryService { public static void SaveCategory(string table, string name, int id) { StringBuilder sql = new StringBuilder(); if (id > 0) sql.AppendFormat("update {0} set name='{1}' where id={2} ;", table, name, id); else { sql.AppendFormat("insert into {0}(name) values('{1}') ;", table, name); } DbHelper.DbConn.ExecuteNonQuery(sql.ToString()); } public static void DelCategory(string table, int id) { string sql = string.Format("delete from {0} where id={1} ;", table, id); DbHelper.DbConn.ExecuteNonQuery(sql); } public static DataTable GetCategory(string table, string where) { string sql = ""; if (where == "") sql = string.Format("select * from {0} ;", table); else sql = string.Format("select * from {0} where {1} ;", table, where); return DbHelper.DbConn.ExecuteDataset(sql).Tables[0]; } } }