/// <summary> /// 执行查询一行一列操作数据库命令 /// 支持事务操作 /// </summary> /// <param name="cmdText"></param> /// <param name="commandType"></param> /// <param name="transaction"></param> /// <param name="array"></param> /// <returns></returns> public static object ExecuteScalar(string cmdText, CommandType commandType, SqlTransaction transaction, params SqlParameter[] array) { object rowCount = -1; try { Common.Config cfg = new Common.Config(); cfg.connDb(); using (SqlCommand cmd = new SqlCommand(cmdText, cfg.Conn)) { cmd.CommandType = commandType; if (array != null) { cmd.Parameters.AddRange(array); } cmd.Transaction = transaction; rowCount = cmd.ExecuteScalar(); } } catch (Exception) { throw new Exception("数据库操作异常!"); } return(rowCount); }
public static DataTable Select_Detail(string Main_parameter, string Extended_parameter, long Aid, int Alive) { Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_Article_Select", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Page", SqlDbType.Int).Value = 0; sc.Parameters.Add("@Ps", SqlDbType.SmallInt).Value = 0; sc.Parameters.Add("@Main_parameter", SqlDbType.VarChar, 8000).Value = Main_parameter; sc.Parameters.Add("@Extended_parameter", SqlDbType.VarChar, 8000).Value = Extended_parameter; sc.Parameters.Add("@Order", SqlDbType.VarChar, 200).Value = ""; sc.Parameters.Add("@Aid", SqlDbType.VarChar, 8000).Value = Aid.ToString(); sc.Parameters.Add("@Asid", SqlDbType.VarChar, 8000).Value = ""; sc.Parameters.Add("@Keywords", SqlDbType.VarChar, 8000).Value = ""; sc.Parameters.Add("@Alive", SqlDbType.SmallInt).Value = Alive; sc.Parameters.Add("@Hot", SqlDbType.SmallInt).Value = 0; sc.Parameters.Add("@Recommend", SqlDbType.SmallInt).Value = 0; sc.Parameters.Add("@Kind", SqlDbType.VarChar, 8000).Value = ""; sc.Parameters.Add("@d1", SqlDbType.VarChar, 20).Value = ""; sc.Parameters.Add("@d2", SqlDbType.VarChar, 20).Value = ""; sc.Parameters.Add("@rc", SqlDbType.BigInt).Direction = ParameterDirection.Output; SqlDataAdapter da = new SqlDataAdapter(sc); DataTable dt = new DataTable(); da.Fill(dt); sc.Dispose(); da.Dispose(); cfg.closeDb(); return(dt); dt.Dispose(); }
public static void Modify(int Aulid_old, int Aulid, string Ltitle, string Area) { if (Ltitle == null) { Ltitle = ""; } if (Area == null) { Area = "-1"; } Area = getArea(Area); Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_adminUsersLevel_Modify", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Aulid_old", SqlDbType.SmallInt).Value = Aulid_old; sc.Parameters.Add("@Aulid", SqlDbType.SmallInt).Value = Aulid; sc.Parameters.Add("@Ltitle", SqlDbType.VarChar, 20).Value = Ltitle; sc.Parameters.Add("@Area", SqlDbType.VarChar, 50).Value = Area; sc.ExecuteNonQuery(); sc.Dispose(); cfg.closeDb(); }
public static int Add(int Aulid, string Ltitle, string Area) { if (Ltitle == null) { Ltitle = ""; } if (Area == null) { Area = ""; } Area = getArea(Area); Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_adminUsersLevel_Add", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Area", SqlDbType.VarChar, 50).Value = Area; sc.Parameters.Add("@Ltitle", SqlDbType.VarChar, 20).Value = Ltitle; sc.Parameters.Add("@Aulid", SqlDbType.SmallInt).Value = Aulid; sc.ExecuteNonQuery(); Aulid = Common.Functions.ConvertInt16(sc.Parameters["@Aulid"].Value, 0); sc.Dispose(); cfg.closeDb(); return(Aulid); }
///<summary> /// 删除 /// </summary> /// <param name="Lid">要删除的编号,多个编号用逗号分隔</param> public static void Del(string Lid) { Common.Config cfg = new Common.Config(); cfg.connDb(); Common.Functions.recordDel("[zzlh2017_LegalAdvice]", "Lid", Lid, 0, "", "Ltitle", "", cfg.Conn, true); cfg.closeDb(); }
public static long Add(string Auser, string Passwd, int Aulid) { if (Auser == null) { Auser = ""; } if (Passwd == null) { Passwd = ""; } Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_adminUsers_Add", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Auser", SqlDbType.VarChar, 20).Value = Auser; sc.Parameters.Add("@Passwd", SqlDbType.Char, 32).Value = Passwd; sc.Parameters.Add("@Aulid", SqlDbType.SmallInt).Value = Aulid; sc.Parameters.Add("@Auid", SqlDbType.BigInt).Direction = ParameterDirection.Output; sc.ExecuteNonQuery(); long Auid = Common.Functions.ConvertInt64(sc.Parameters["@Auid"].Value, 0); sc.Dispose(); cfg.closeDb(); return(Auid); }
public static void Modify(long Lid, string Pic1, string Lname, string Summary, string Linfo) { if (Pic1 == null) { Pic1 = ""; } if (Lname == null) { Lname = ""; } if (Summary == null) { Summary = ""; } if (Linfo == null) { Linfo = ""; } Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_LawyerFirst_Modify", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Lid", SqlDbType.BigInt).Value = Lid; sc.Parameters.Add("@Pic1", SqlDbType.VarChar, 1000).Value = Pic1; sc.Parameters.Add("@Lname", SqlDbType.VarChar, 50).Value = Lname; sc.Parameters.Add("@Summary", SqlDbType.VarChar, 8000).Value = Summary; sc.Parameters.Add("@Linfo", SqlDbType.VarChar, 8000).Value = Linfo; sc.ExecuteNonQuery(); sc.Dispose(); cfg.closeDb(); }
///<summary> /// 删除 /// </summary> /// <param name="Aid">要删除的编号,多个编号用逗号分隔</param> public static void Del(string Aid) { Common.Config cfg = new Common.Config(); sortTitle.Article st = new sortTitle.Article(); cfg.connDb(); Common.Functions.recordDel("[zzlh2017_Article]", "Aid", Aid, 2, "Ainfo", "Atitle", st.st, cfg.Conn, true); cfg.closeDb(); }
///<summary> /// 删除 /// </summary> /// <param name="Asid">要删除的编号,多个编号用,分隔</param> public static void Del(string Asid) { Common.Config cfg = new Common.Config(); sortTitle.ArticleSort st = new sortTitle.ArticleSort(); cfg.connDb(); Common.Functions.recordDel("[zzlh2017_ArticleSort]", "Asid", Asid, 0, "", "Stitle", st.st, cfg.Conn, true); cfg.closeDb(); }
///<summary> /// 删除 /// </summary> /// <param name="Auid">要删除的编号,多个编号用,分隔</param> public static void Del(string Auid) { Common.Config cfg = new Common.Config(); sortTitle.adminUsers st = new sortTitle.adminUsers(); cfg.connDb(); Common.Functions.recordDel("[zzlh2017_adminUsers]", "Auid", Auid, 0, "", "Auser", st.st, cfg.Conn, true); cfg.closeDb(); }
///<summary> /// 删除 /// </summary> /// <param name="Aulid">要删除的编号,多个编号用,分隔</param> public static void Del(string Uid) { Common.Config cfg = new Common.Config(); sortTitle.Uploadfile st = new sortTitle.Uploadfile(); cfg.connDb(); Common.Functions.recordDel("[zzlh2017_Uploadfile]", "Uid", Uid, 0, "", "Url", st.st, cfg.Conn, true); cfg.closeDb(); }
public static void Alive(long Asid) { Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_ArticleSort_Alive", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Asid", SqlDbType.BigInt).Value = Asid; sc.ExecuteNonQuery(); sc.Dispose(); cfg.closeDb(); }
public static void Alive(int Aulid) { Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_adminUsersLevel_Alive", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Aulid", SqlDbType.SmallInt).Value = Aulid; sc.ExecuteNonQuery(); sc.Dispose(); cfg.closeDb(); }
public static SqlDataAdapter getDa(string sql) { Common.Config cfg = new Common.Config(); cfg.connDb(); SqlDataAdapter da = new SqlDataAdapter(sql, cfg.Conn); cfg.closeDb(); return(da); }
public static long Add(string Ltitle, string Linfo, string Lname, string Tel, string QQ, string Email) { if (Ltitle == null) { Ltitle = ""; } if (Linfo == null) { Linfo = ""; } if (Lname == null) { Lname = ""; } if (Tel == null) { Tel = ""; } if (QQ == null) { QQ = ""; } if (Email == null) { Email = ""; } Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_LegalAdvice_Add", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Ltitle", SqlDbType.VarChar, 100).Value = Ltitle; sc.Parameters.Add("@Linfo", SqlDbType.VarChar, 8000).Value = Linfo; sc.Parameters.Add("@Lname", SqlDbType.VarChar, 50).Value = Lname; sc.Parameters.Add("@Tel", SqlDbType.VarChar, 50).Value = Tel; sc.Parameters.Add("@QQ", SqlDbType.VarChar, 50).Value = QQ; sc.Parameters.Add("@Email", SqlDbType.VarChar, 100).Value = Email; sc.Parameters.Add("@Lid", SqlDbType.BigInt).Direction = ParameterDirection.Output; sc.ExecuteNonQuery(); long Lid = Common.Functions.ConvertInt64(sc.Parameters["@Lid"].Value, 0); sc.Dispose(); cfg.closeDb(); return(Lid); }
public static DataSet getDs(string sql) { Common.Config cfg = new Common.Config(); cfg.connDb(); SqlDataAdapter da = new SqlDataAdapter(sql, cfg.Conn); DataSet ds = new DataSet(); da.Fill(ds); da.Dispose(); cfg.closeDb(); return(ds); }
public static void Passwd(long Auid, string Passwd) { if (Passwd == null) { Passwd = ""; } Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_adminUsers_Passwd", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Auid", SqlDbType.SmallInt).Value = Auid; sc.Parameters.Add("@Passwd", SqlDbType.Char, 32).Value = Passwd; sc.ExecuteNonQuery(); sc.Dispose(); cfg.closeDb(); }
public static DataTable Select_Detail(int Aid) { Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_Advertise_Select", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Aid", SqlDbType.VarChar, 8000).Value = Aid.ToString(); SqlDataAdapter da = new SqlDataAdapter(sc); DataTable dt = new DataTable(); da.Fill(dt); sc.Dispose(); da.Dispose(); cfg.closeDb(); return(dt); }
public static DataTable getDt(string sql) { Common.Config cfg = new Common.Config(); cfg.connDb(); SqlDataAdapter da = new SqlDataAdapter(sql, cfg.Conn); DataTable dt = new DataTable(); da.Fill(dt); da.Dispose(); cfg.closeDb(); return(dt); }
public static void Modify(long Lid, string Reply) { if (Reply == null) { Reply = ""; } Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_LegalAdvice_Modify", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Lid", SqlDbType.BigInt).Value = Lid; sc.Parameters.Add("@Reply", SqlDbType.VarChar, 8000).Value = Reply; sc.ExecuteNonQuery(); sc.Dispose(); cfg.closeDb(); }
public static void Modify(long Uid, string Url) { if (Url == null) { Url = ""; } Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_Uploadfile_Modify", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Uid", SqlDbType.BigInt).Value = Uid; sc.Parameters.Add("@Url", SqlDbType.VarChar, 200).Value = Url; sc.ExecuteNonQuery(); sc.Dispose(); cfg.closeDb(); }
public static void Modify(long Asid, string Stitle) { if (Stitle == null) { Stitle = ""; } Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_ArticleSort_Modify", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Asid", SqlDbType.BigInt).Value = Asid; sc.Parameters.Add("@Stitle", SqlDbType.VarChar, 20).Value = Stitle; sc.ExecuteNonQuery(); sc.Dispose(); cfg.closeDb(); }
/// <summary> /// 返回符合条件查询结果的泛型集合 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="cmdText"></param> /// <param name="commandType"></param> /// <param name="array"></param> /// <returns></returns> public static List <T> ExecuteList <T>(string cmdText, CommandType commandType, params SqlParameter[] array) { List <T> lists = new List <T>(); try { Common.Config cfg = new Common.Config(); cfg.connDb(); using (cfg.Conn) { using (SqlCommand cmd = new SqlCommand(cmdText, cfg.Conn)) { cmd.CommandType = commandType; if (array != null) { cmd.Parameters.AddRange(array); } using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { if (dr != null) { while (dr.Read()) { T obj = ExecuteDataReader <T>(dr); if (obj != null) { lists.Add(obj); } } } } } } } catch (Exception) { throw new Exception("数据库操作异常!"); } return(lists); }
public static void ExecuteNonQuery(string sql) { Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand(sql, cfg.Conn); try { sc.ExecuteNonQuery(); } catch (Exception e) { HttpContext.Current.Response.Write(e.ToString() + "<br />" + sql); } finally { sc.Dispose(); cfg.closeDb(); } }
public static long GetCount(int Alive, string Kind) { if (Kind == null) { Kind = ""; } Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_Article_Count", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Kind", SqlDbType.VarChar, 8000).Value = Kind; sc.Parameters.Add("@Alive", SqlDbType.SmallInt).Value = Alive; sc.Parameters.Add("@rc", SqlDbType.BigInt).Direction = ParameterDirection.Output; sc.ExecuteNonQuery(); long Rc = Common.Functions.ConvertInt64(sc.Parameters["@rc"].Value, 0); sc.Dispose(); cfg.closeDb(); return(Rc); }
public static DataTable Select_Detail(string Main_parameter, string Extended_parameter, long Asid, int Alive) { #region ==null判断== if (Main_parameter == null) { Main_parameter = ""; } if (Extended_parameter == null) { Extended_parameter = ""; } #endregion Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_ArticleSort_Select", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Page", SqlDbType.Int).Value = 0; sc.Parameters.Add("@Ps", SqlDbType.SmallInt).Value = 0; sc.Parameters.Add("@Main_parameter", SqlDbType.VarChar, 8000).Value = Main_parameter; sc.Parameters.Add("@Extended_parameter", SqlDbType.VarChar, 8000).Value = Extended_parameter; sc.Parameters.Add("@Keywords", SqlDbType.VarChar, 8000).Value = ""; sc.Parameters.Add("@Asid", SqlDbType.VarChar, 8000).Value = Asid.ToString(); sc.Parameters.Add("@Kind", SqlDbType.VarChar, 8000).Value = ""; sc.Parameters.Add("@Alive", SqlDbType.SmallInt).Value = Alive; sc.Parameters.Add("@Order", SqlDbType.VarChar, 200).Value = ""; IDataParameter parameters_Rc = new SqlParameter("@Rc", SqlDbType.BigInt, 8); parameters_Rc.Direction = ParameterDirection.Output; sc.Parameters.Add(parameters_Rc); SqlDataAdapter da = new SqlDataAdapter(sc); DataTable dt = new DataTable(); da.Fill(dt); da.Dispose(); sc.Dispose(); cfg.closeDb(); return(dt); dt.Dispose(); }
public static long Add(string Url) { if (Url == null) { Url = ""; } Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_Uploadfile_Add", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Url", SqlDbType.VarChar, 200).Value = Url; sc.Parameters.Add("@Uid", SqlDbType.BigInt).Direction = ParameterDirection.Output; sc.ExecuteNonQuery(); long Uid = Common.Functions.ConvertInt64(sc.Parameters["@Uid"].Value, 0); sc.Dispose(); cfg.closeDb(); return(Uid); }
public static DataTable Select_Detail(string Main_parameter, string Extended_parameter, long Uid, string Uid_not) { #region ==null判断== if (Extended_parameter == null) { Extended_parameter = ""; } if (Main_parameter == null) { Main_parameter = ""; } if (Uid_not == null) { Uid_not = ""; } #endregion Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_Uploadfile_Select", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Page", SqlDbType.Int).Value = 0; sc.Parameters.Add("@Ps", SqlDbType.SmallInt).Value = 0; sc.Parameters.Add("@Main_parameter", SqlDbType.VarChar, 8000).Value = Main_parameter; sc.Parameters.Add("@Extended_parameter", SqlDbType.VarChar, 8000).Value = Extended_parameter; sc.Parameters.Add("@Uid", SqlDbType.VarChar, 8000).Value = Uid.ToString(); sc.Parameters.Add("@Uid_not", SqlDbType.VarChar, 8000).Value = Uid_not; sc.Parameters.Add("@Order", SqlDbType.VarChar, 200).Value = ""; sc.Parameters.Add("@rc", SqlDbType.BigInt).Direction = ParameterDirection.Output; SqlDataAdapter da = new SqlDataAdapter(sc); DataTable dt = new DataTable(); da.Fill(dt); da.Dispose(); sc.Dispose(); cfg.closeDb(); return(dt); }
public static void Modify(int Aid, string Url, string Pic1) { if (Url == null) { Url = ""; } if (Pic1 == null) { Pic1 = ""; } Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_Advertise_Modify", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Aid", SqlDbType.SmallInt).Value = Aid; sc.Parameters.Add("@Url", SqlDbType.VarChar, 100).Value = Url; sc.Parameters.Add("@Pic1", SqlDbType.VarChar, 100).Value = Pic1; sc.ExecuteNonQuery(); sc.Dispose(); cfg.closeDb(); }
public static long Add(string Stitle, int Kind) { if (Stitle == null) { Stitle = ""; } Common.Config cfg = new Common.Config(); cfg.connDb(); SqlCommand sc = new SqlCommand("zzlh2017_ArticleSort_Add", cfg.Conn); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@Kind", SqlDbType.SmallInt).Value = Kind; sc.Parameters.Add("@Stitle", SqlDbType.VarChar, 20).Value = Stitle; sc.Parameters.Add("@Asid", SqlDbType.BigInt).Direction = ParameterDirection.Output; sc.ExecuteNonQuery(); long Asid = Common.Functions.ConvertInt64(sc.Parameters["@Asid"].Value, 0); sc.Dispose(); cfg.closeDb(); return(Asid); }