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

📄 label.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
📖 第 1 页 / 共 2 页
字号:
//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using NetCMS.Model;
using NetCMS.DALFactory;
using NetCMS.DALProfile;
using NetCMS.Config;

namespace NetCMS.DALSQLServer
{
    public class Label : DbBase, ILabel
    {
        public int LabelAdd(LabelInfo lbc)
        {
            int result = 0;
            SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
            Conn.Open();
            try
            {
                string checkSql = string.Empty;
                int recordCount = 0;
                string LabelID = NetCMS.Common.Rand.Number(12);
                while (true)
                {
                    checkSql = "select count(*) from " + Pre + "sys_Label where LabelID='" + LabelID + "'";
                    recordCount = (int)DbHelper.ExecuteScalar(Conn, CommandType.Text, checkSql, null);
                    if (recordCount < 1)
                        break;
                    else
                        LabelID = NetCMS.Common.Rand.Number(12, true);
                }
                checkSql = "select count(*) from " + Pre + "sys_Label where Label_Name='" + lbc.Label_Name + "'";
                recordCount = (int)DbHelper.ExecuteScalar(Conn, CommandType.Text, checkSql, null);
                if (recordCount > 0)
                {
                    throw new Exception("标签名称重复,请重新添加!");
                }
                string Sql = "insert into " + Pre + "sys_Label (";
                Sql += "LabelID,ClassID,Label_Name,Label_Content,Description,CreatTime,isBack,isRecyle,isSys,SiteID";
                Sql += ") values ('" + LabelID + "',";
                Sql += "@ClassID,@Label_Name,@Label_Content,@Description,@CreatTime,@isBack,@isRecyle,@isSys,@SiteID)";
                SqlParameter[] param = GetLabelParameters(lbc);
                result = DbHelper.ExecuteNonQuery(Conn, CommandType.Text, Sql, param);
            }
            finally
            {
                if (Conn != null && Conn.State == ConnectionState.Open)
                    Conn.Close();
            }

            return result;
        }

        public int LabelEdit(LabelInfo lbc)
        {
            int result = 0;
            SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
            Conn.Open();
            try
            {
                string checkSql = "";
                int recordCount = 0;
                checkSql = "select count(*) from " + Pre + "sys_Label Where LabelID!='" + lbc.LabelID + "' And Label_Name='" + lbc.Label_Name + "'";
                recordCount = (int)DbHelper.ExecuteScalar(Conn, CommandType.Text, checkSql, null);
                if (recordCount > 0)
                {
                    throw new Exception("标签名称重复,请重新修改!");
                }
                string Sql = "Update " + Pre + "sys_Label Set ClassID=@ClassID,Label_Name=@Label_Name,Label_Content=@Label_Content";
                Sql += ",Description=@Description,isBack=@isBack ";
                Sql += "Where LabelID='" + lbc.LabelID + "' " + NetCMS.Common.Public.getSessionStr() + "";
                SqlParameter[] param = GetLabelParameters(lbc);
                result = DbHelper.ExecuteNonQuery(Conn, CommandType.Text, Sql, param);
            }
            finally
            {
                if (Conn != null && Conn.State == ConnectionState.Open)
                    Conn.Close();
            }
            return result;
        }
        public void LabelDel(string id)
        {
            string str_sql = "Update " + Pre + "sys_Label Set isRecyle=1 Where LabelID='" + id + "' " + NetCMS.Common.Public.getSessionStr() + "";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
        }
        public void LabelDels(string id)
        {
            string str_sql = "Delete From " + Pre + "sys_Label Where LabelID='" + id + "'" + NetCMS.Common.Public.getSessionStr() + "";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
        }
        public void LabelBackUp(string id)
        {
            string str_sql = "Update " + Pre + "sys_Label Set isBack=1 Where LabelID='" + id + "' " + NetCMS.Common.Public.getSessionStr() + "";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
        }
        public DataTable GetLabelInfo(string id)
        {
            string str_Sql = "Select ClassID,Label_Name,Label_Content,Description,isBack From " + Pre + "sys_Label Where LabelID='" + id + "'" + NetCMS.Common.Public.getSessionStr() + "";
            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            return dt;
        }
        public int LabelClassAdd(LabelClassInfo lbcc)
        {
            int result = 0;
            SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
            Conn.Open();
            try
            {
                string checkSql = "";
                int recordCount = 0;
                string ClassID = NetCMS.Common.Rand.Number(12);
                while (true)
                {
                    checkSql = "select count(*) from " + Pre + "sys_LabelClass where ClassID='" + ClassID + "'";
                    recordCount = (int)DbHelper.ExecuteScalar(Conn, CommandType.Text, checkSql, null);
                    if (recordCount < 1)
                        break;
                    else
                        ClassID = NetCMS.Common.Rand.Number(12, true);
                }
                checkSql = "select count(*) from " + Pre + "sys_LabelClass where ClassName='" + lbcc.ClassName + "'";
                recordCount = (int)DbHelper.ExecuteScalar(Conn, CommandType.Text, checkSql, null);
                if (recordCount > 0)
                {
                    throw new Exception("标签分类名称重复,请重新添加!");
                }
                string Sql = "insert into " + Pre + "sys_LabelClass (";
                Sql += "ClassID,ClassName,Content,CreatTime,SiteID,isRecyle";
                Sql += ") values ('" + ClassID + "',";
                Sql += "@ClassName,@Content,@CreatTime,@SiteID,@isRecyle)";
                SqlParameter[] param = GetLabelClassParameters(lbcc);
                result = DbHelper.ExecuteNonQuery(Conn, CommandType.Text, Sql, param);
            }
            finally
            {
                if (Conn != null && Conn.State == ConnectionState.Open)
                    Conn.Close();
            }
            return result;
        }
        public int LabelClassEdit(LabelClassInfo lbcc)
        {
            int result = 0;
            SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
            Conn.Open();
            try
            {
                string checkSql = "";
                int recordCount = 0;
                checkSql = "select count(*) from " + Pre + "sys_LabelClass Where ClassID!='" + lbcc.ClassID + "' And ClassName='" + lbcc.ClassName + "'";
                recordCount = (int)DbHelper.ExecuteScalar(Conn, CommandType.Text, checkSql, null);
                if (recordCount > 0)
                {
                    throw new Exception("标签分类名称重复,请重新修改!");
                }
                string Sql = "Update " + Pre + "sys_LabelClass Set ClassName=@ClassName,Content=@Content ";
                Sql += "Where ClassID='" + lbcc.ClassID + "' " + NetCMS.Common.Public.getSessionStr() + "";
                SqlParameter[] param = GetLabelClassParameters(lbcc);
                result = DbHelper.ExecuteNonQuery(Conn, CommandType.Text, Sql, param);
            }
            finally
            {
                if (Conn != null && Conn.State == ConnectionState.Open)
                    Conn.Close();
            }
            return result;
        }
        public void LabelClassDel(string id)
        {
            SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
            Conn.Open();
            SqlTransaction tran = Conn.BeginTransaction();
            try
            {
                string str_Label = "Update " + Pre + "sys_Label Set isRecyle=1 Where ClassID='" + id + "' " + NetCMS.Common.Public.getSessionStr() + "";
                DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Label, null);
                string str_LabelClass = "Update " + Pre + "sys_LabelClass Set isRecyle=1 Where ClassID='" + id + "' " + NetCMS.Common.Public.getSessionStr() + "";
                DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_LabelClass, null);
                tran.Commit();
                Conn.Close();
            }
            catch (SqlException e)
            {
                tran.Rollback();
                Conn.Close();
                throw e;
            }
        }
        public void LabelClassDels(string id)
        {
            SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
            Conn.Open();
            SqlTransaction tran = Conn.BeginTransaction();
            try
            {
                string str_Label = "Delete From " + Pre + "sys_Label Where ClassID='" + id + "' " + NetCMS.Common.Public.getSessionStr() + "";
                DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Label, null);
                string str_LabelClass = "Delete From " + Pre + "sys_LabelClass Where ClassID='" + id + "'" + NetCMS.Common.Public.getSessionStr() + "";
                DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_LabelClass, null);
                tran.Commit();
                Conn.Close();
            }
            catch (SqlException e)
            {
                tran.Rollback();
                Conn.Close();
                throw e;
            }
        }
        public DataTable GetLabelClassInfo(string id)
        {
            string str_Sql = "Select ClassName,Content From " + Pre + "sys_LabelClass Where ClassID='" + id + "' " + NetCMS.Common.Public.getSessionStr() + "";
            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            return dt;
        }

        public DataTable GetLabelClassList()
        {
            string str_Sql = "Select ClassID,ClassName From " + Pre + "sys_LabelClass Where isRecyle=0 And ClassID!='99999999' and ClassID!='88888888' and SiteID ='" + NetCMS.Global.Current.SiteID + "'";
            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            return dt;
        }

        public DataTable GetLabelinClassList()
        {
            string str_Sql = "Select ClassID,ClassName From " + Pre + "sys_LabelClass Where isRecyle=0 " + NetCMS.Common.Public.getSessionStr() + " order by id desc";
            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            return dt;
        }

        public void LabelToResume(string id)
        {
            string str_sql = "Update " + Pre + "sys_Label Set isBack=0 Where LabelID='" + id + "' " + NetCMS.Common.Public.getSessionStr() + "";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);

⌨️ 快捷键说明

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