⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseclass.cs

📁 课程设计时使用的
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Collections;
/// <summary>
/// BaseClass 的摘要说明
/// </summary>
public class BaseClass :System.Web.UI.Page
{
	public BaseClass()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}
#region   显示消息函数
    public string MessageBox(string strMessage)
    {
        string str;
        str = "<script language=javascript>alert('" + strMessage + "')</script>";
        return str;
    }
#endregion

    #region 执行单个SQL语句
    public Boolean SqlExecute(string strSQL)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
        con.Open();
        SqlCommand com = new SqlCommand(strSQL, con);
        if (com.ExecuteNonQuery() > 0)
        {
            con.Close();
            return true;

        }

        else
        {

            con.Close();
            return false;
        }



    }

    #endregion

#region 执行查询SQL语句 
    public DataSet GetDataSet(string strSql,string strTableName) 
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
        conn.Open();
        
        SqlCommand com = new SqlCommand(strSql ,conn);
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = com;
        DataSet ds = new DataSet();
        da.Fill(ds,strTableName);
        conn.Close();
        return ds;
    
    }
                
#endregion
#region  执行存储过程--专门用于FreeTextBox
    public Boolean  ExecProcNotice(string strTitle ,string strContent,string strName)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
        conn.Open();
        SqlCommand com = new SqlCommand("insert_tb_notice", conn);
        com.CommandType = CommandType.StoredProcedure;
        //标题
        SqlParameter pTitle = new SqlParameter("@noticeTitle", SqlDbType.VarChar, 40);
        pTitle.Value = strTitle;
        com.Parameters.Add(pTitle);
        //内容
        SqlParameter pContent = new SqlParameter("@noticeContent", SqlDbType.VarChar, 0);
        pContent.Value = strContent;
        com.Parameters.Add(pContent);
        //发布者
        SqlParameter pName = new SqlParameter("@noticePerson", SqlDbType.VarChar, 20);
        pName.Value = strName;
        com.Parameters.Add(pName);
        if (com.ExecuteNonQuery()>0)
        {
            conn.Close();
            return true;
        } 
        else
        {
            conn.Close();
            return false;
        }
        
        
    }
#endregion
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -