资源简介

用.net和sqlserver结合,写的大学生竞赛系统,包括主办方,教委,学生,老师,学校等多个用户登录,网站形式,可用作数据库课设和软件工程课设

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

/// 
///UMSQL 的摘要说明
/// 

namespace UserManage.SQLManage
{
    public class UMSQL
    {

        //打开数据库链接
        public static SqlConnection open()
        {
            string ConnStr = ConfigurationManager.ConnectionStrings[“connstr“].ToString();
            SqlConnection conn = new SqlConnection(ConnStr);
            conn.Open();
            return conn;
        }

        //关闭数据库链接:conn-数据库链接对象
        public static void close(SqlConnection conn)
        {
            if (conn.State != ConnectionState.Closed)
                conn.Close();
        }

        //用SqlCommand执行SQL语句,返回影响条数
        public static int execSQL_cmd(SqlCommand cmd)
        {
            SqlConnection conn = open();
            cmd.Connection = conn;
            int state = cmd.ExecuteNonQuery();
            close(conn);
            return state;
        }
        
        //用SQL字符串执行SQL语句,返回影响条数
        public static int execSQL_str(string sql)
        {
            SqlConnection conn = open();
            SqlCommand command = conn.CreateCommand();
            command.CommandText = sql;
            int state = command.ExecuteNonQuery();
            close(conn);
            return state;
        }
        
        //用SqlCommand执行SQL SELECT 语句,返回DataTable
        public static DataTable getDataTable_cmd(SqlCommand cmd)
        {
            DataTable dt = new DataTable();
            SqlConnection conn = open();
            cmd.Connection = conn;
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            if (da.UpdateBatchSize==0)
            {
                close(conn);
                return dt;
            }
            else
            {
                da.Fill(dt);
                close(conn);
                return dt;
            }
        }

        //用SQl字符串执行SQL SELECT 语句,返回DataTable
        public static DataTable getDataTable_str(string sql)
        {
            DataTable dt = new DataTable();
            SqlConnection conn = open();
            SqlCommand command = conn.CreateCommand();
            command.CommandText = sql;
            SqlDataAdapter da = new SqlDataAdapter(command);

            if (da.UpdateBatchSize == 0)
            {
                close(conn);
                return dt;
            }
            else
            {
                da.Fill(dt);
                close(conn);
                return dt;
            }
        }

        //数据备份
        public static int DoBackup(string filename)
        {
            SqlConnection conn = open();
            SqlCommand cmd = new SqlCommand();
            string sql = “backup database CourseStudyManagement to disk = @path“;
            cmd.CommandText = sql;
            cmd.Conne

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-06-04 08:26  UC\
     目录           0  2013-06-04 12:42  UC\UniversityCompetition\
     目录           0  2013-06-04 08:26  UC\UniversityCompetition\App_Code\
     文件        3973  2013-06-02 15:58  UC\UniversityCompetition\App_Code\UMSQL.cs
     目录           0  2013-06-04 08:26  UC\UniversityCompetition\Common\
     文件        7157  2013-05-09 07:03  UC\UniversityCompetition\Common\CommonOprations.cs
     文件        7719  2013-05-26 19:01  UC\UniversityCompetition\Common\CommonStr.resx
     文件        6733  2013-05-26 19:01  UC\UniversityCompetition\Common\CommonStr1.Designer.cs
     文件       10781  2013-06-02 15:54  UC\UniversityCompetition\Common\Db.dbml
     文件        5424  2013-06-02 15:54  UC\UniversityCompetition\Common\Db.dbml.layout
     文件       70650  2013-06-02 15:54  UC\UniversityCompetition\Common\Db.designer.cs
     文件        1881  2013-05-08 15:04  UC\UniversityCompetition\Common\EMail.cs
     目录           0  2013-06-04 08:26  UC\UniversityCompetition\Common\User\
     文件        3929  2013-06-02 16:50  UC\UniversityCompetition\Common\User\UMSQL.cs
     目录           0  2013-06-04 08:26  UC\UniversityCompetition\Controller\
     文件         445  2013-05-08 15:03  UC\UniversityCompetition\Controller\LoginController.aspx
     文件        1730  2013-05-09 17:18  UC\UniversityCompetition\Controller\LoginController.aspx.cs
     文件         828  2013-05-08 15:03  UC\UniversityCompetition\Controller\LoginController.aspx.designer.cs
     文件         447  2013-05-09 17:20  UC\UniversityCompetition\Controller\LogoutController.aspx
     文件         754  2013-05-09 19:29  UC\UniversityCompetition\Controller\LogoutController.aspx.cs
     文件         829  2013-05-09 17:20  UC\UniversityCompetition\Controller\LogoutController.aspx.designer.cs
     文件         451  2013-05-08 15:03  UC\UniversityCompetition\Controller\RegisterController.aspx
     文件        1839  2013-05-09 17:36  UC\UniversityCompetition\Controller\RegisterController.aspx.cs
     文件         831  2013-05-08 15:03  UC\UniversityCompetition\Controller\RegisterController.aspx.designer.cs
     文件         447  2013-05-09 08:10  UC\UniversityCompetition\Controller\VerifyController.aspx
     文件        1439  2013-05-09 17:06  UC\UniversityCompetition\Controller\VerifyController.aspx.cs
     文件         829  2013-05-09 08:10  UC\UniversityCompetition\Controller\VerifyController.aspx.designer.cs
     目录           0  2013-06-04 08:26  UC\UniversityCompetition\Css\
     目录           0  2013-06-04 08:26  UC\UniversityCompetition\Css\CompetitionRegister\
     文件         214  2013-06-04 00:11  UC\UniversityCompetition\Css\CompetitionRegister\cr.css
     文件         609  2013-06-03 10:39  UC\UniversityCompetition\Css\Grade_Commission.css
............此处省略265个文件信息

评论

共有 条评论