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

📄 constr.cs

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

namespace NetCMS.DALSQLServer
{
    public class Constr : DbBase, IConstr
    {
        #region 前台
        public DataTable sel_ConstrInfo(string UserNum, int flag)
        {
            #region
            SqlParameter param = new SqlParameter("@ID", UserNum);
            string Sql = null;
            if (flag == 0)
            {
                Sql = "select Ccid,cName from " + Pre + "User_ConstrClass where UserNum=@ID";
            }
            else if (flag == 1)
            {
                Sql = "select Content,ClassID,Title,Source,Tags,Contrflg,Author,isCheck,PicURL,SiteID,creatTime,passcontent,isadmidel,isuserdel,UserNum,ispass from " + Pre + "user_Constr where ConID=@ID";
            }
            else if (flag == 2)
            {
                Sql = "select address,postcode,RealName,bankName,bankaccount,bankcard,bankRealName from " + Pre + "sys_userother where ConID=@ID ";
            }
            else if (flag == 3)
            {
                Sql = "select Id from " + Pre + "user_Constr where ClassID=@ID";
            }
            else if (flag == 4)
            {
                Sql = "select cName,Content from " + Pre + "user_ConstrClass where Ccid=@ID";
            }
            else if (flag == 5)
            {
                Sql = "select gPoint,iPoint,money,ConstrPayName,Gunit from " + Pre + "sys_ParmConstr where PCId=@ID";
            }
            else if (flag == 6)
            {
                Sql = "select iPoint,gPoint,ParmConstrNum,cPoint,aPoint,UserName from " + Pre + "sys_User where UserNum=@ID";
            }
            else if (flag == 7)
            {
                Sql = "select address,postcode,RealName,bankName,bankcard,bankRealName from " + Pre + "sys_userother where UserNum=@ID";
            }
            else if (flag == 8)
            {
                Sql = "select creatTime from " + Pre + "User_Constr where UserNum=@ID and isCheck=1  and substring(Contrflg,3,1) = '1' and isadmidel=0 and ispass=0";
            }
            else if (flag == 9)
            {
                Sql = "select ReadNewsTemplet,NewsSavePath,NewsFileRule,FileName,checkint from " + Pre + "news_class Where ClassID=@ID";
            }
            return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
            #endregion
        }

        public DataTable sel_userConstr(int flag)
        {
            #region
            string Sql = null;
            if (flag == 0)
            {
                Sql = "select Ccid from " + Pre + "user_ConstrClass";
            }
            else if (flag == 1)
            {
                Sql = "Select ConstrPayName,PCId From " + Pre + "sys_ParmConstr where SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 2)
            {
                Sql = "select cPointParam,aPointparam from " + Pre + "sys_PramUser";
            }
            else if (flag == 3)
            {
                Sql = "select constrPayID from " + Pre + "user_constrPay";
            }
            else if (flag == 4)
            {
                Sql = "select PCId from " + Pre + "sys_ParmConstr";
            }
            return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
            #endregion
        }

        public int sel_conStrCount(string UserNum, int flag)
        {
            #region
            SqlParameter param = new SqlParameter("@UserNum", UserNum);
            string Sql = null;
            if (flag == 0)
            {
                Sql = "select count(*) from " + Pre + "sys_userother where UserNum=@UserNum";
            }
            else if (flag == 1)
            {
                Sql = "select count(Id) from " + Pre + "User_Constr where UserNum=@UserNum and substring(Contrflg,3,1) = '1' and isadmidel=0 and ispass=0";
            }
            else if (flag == 2)
            {
                Sql = "select count(Id) from " + Pre + "User_Constr where UserNum=@UserNum and isCheck=1  and substring(Contrflg,3,1) = '1' and isadmidel=0 and ispass=0";
            }
            else if (flag == 3)
            {
                Sql = "select count(*) from " + Pre + "sys_userother";
            }
            return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
            #endregion
        }

        public int sel_ConstrNum(string UserNum, int flag)
        {
            #region
            SqlParameter param = new SqlParameter("@UserNum", UserNum);
            int result = 0;
            string Sql = null;
            if (flag == 0)
            {
                Sql = "select UserGroupNumber from " + Pre + "sys_user where UserNum=@UserNum";
                IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, Sql, param);
                dr.Read();
                string GroupNumber = dr["UserGroupNumber"].ToString();
                string Sql1 = "select ContrNum from " + Pre + "User_Group where GroupNumber='" + GroupNumber + "'";
                IDataReader dr1 = DbHelper.ExecuteReader(CommandType.Text, Sql1, null);
                dr1.Read();
                int ContrNum = int.Parse(dr1["ContrNum"].ToString());
                string Sql2 = "select count(*) from " + Pre + "user_Constr where UserNum=@UserNum";
                int cut = (int)DbHelper.ExecuteScalar(CommandType.Text, Sql2, param);
                if (cut >= ContrNum)
                {
                    result = 1;
                }
            }
            else if (flag == 1)
            {
                Sql = "select ParmConstrNum from " + Pre + "sys_user where UserNum=@UserNum and SiteID='" + NetCMS.Global.Current.SiteID + "'";
                DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        if (NetCMS.Common.Input.IsInteger(dt.Rows[0]["ParmConstrNum"].ToString()))
                        {
                            result = int.Parse(dt.Rows[0]["ParmConstrNum"].ToString());
                        }
                    }
                    dt.Clear(); dt.Dispose();
                }
            }
            return result;
            #endregion
        }

        public int del_conStrInfo(string ID, int flag)
        {
            #region
            SqlParameter param = new SqlParameter("@ID", ID);
            string Sql = null;
            if (flag == 0)
            {
                Sql = "delete " + Pre + "sys_userother where ConID=@ID";
            }
            else if (flag == 1)
            {
                string Sql1 = "Delete " + Pre + "user_Constr Where ClassID=@ID";
                DbHelper.ExecuteNonQuery(CommandType.Text, Sql1, param);
                Sql = "delete " + Pre + "user_ConstrClass where Ccid=@ID";
            }
            else if (flag == 2)
            {
                Sql = "delete " + Pre + "user_Constr where ConID=@ID";
            }
            else if (flag == 3)
            {
                Sql = " delete " + Pre + "sys_ParmConstr where PCId=@ID";
            }
            else if (flag == 4)
            {
                Sql = "delete " + Pre + "user_constrPay where constrPayID=@ID";
            }
            return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
            #endregion
        }

        public string sel_conStr(string u_ClassID)
        {
            SqlParameter param = new SqlParameter("@ID", u_ClassID);
            string Sql = "select isSuper from " + Pre + "sys_admin where UserNum=@ID";
            return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
        }

        public int Add(STConstr Con)
        {
            string Sql = "Insert Into " + Pre + "user_Constr(ConID,Content,ClassID,Title,creatTime,Source,Tags,Contrflg,Author,UserNum,isCheck,PicURL,SiteID,ispass,isadmidel,isuserdel) Values(@ConID,@Content,@ClassID,@Title,@creatTime,@Source,@Tags,@Contrflg,@Author,@UserNum,0,@PicURL,@SiteID,0,0,0)";
            SqlParameter[] parm = GetParameters(Con);
            return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
        }

        public int Update(STConstr Con, string ConIDs)
        {
            #region
            string SQL = "update " + Pre + "user_Constr set Content=@Content,ClassID=@ClassID,Title=@Title,Contrflg=@Contrflg,creatTime=@creatTime,Source=@Source,Tags=@Tags,Author=@Author,PicURL=@PicURL,SiteID=@SiteID where ConID=@Con_ID";
            SqlParameter[] parm = GetParameters(Con);
            int i_length = parm.Length;
            Array.Resize<SqlParameter>(ref parm, i_length + 1);
            parm[i_length] = new SqlParameter("@Con_ID", ConIDs);
            return DbHelper.ExecuteNonQuery(CommandType.Text, SQL, parm);
            #endregion
        }
        private SqlParameter[] GetParameters(STConstr Con)
        {
            #region
            SqlParameter[] parm = new SqlParameter[12];
            parm[0] = new SqlParameter("@ConID", SqlDbType.NVarChar, 50);
            parm[0].Value = Rand.Number(12);
            parm[1] = new SqlParameter("@Content", SqlDbType.NText);
            parm[1].Value = Con.Content;
            parm[2] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 16);
            parm[2].Value = Con.ClassID;
            parm[3] = new SqlParameter("@Title", SqlDbType.NVarChar, 16);
            parm[3].Value = Con.Title;
            parm[4] = new SqlParameter("@creatTime", SqlDbType.DateTime);
            parm[4].Value = DateTime.Now;
            parm[5] = new SqlParameter("@Source", SqlDbType.NVarChar, 12);
            parm[5].Value = Con.Source;
            parm[6] = new SqlParameter("@Tags", SqlDbType.NVarChar, 50);
            if (Con.Tags == "" || Con.Tags == null)
            {
                parm[6].Value = DBNull.Value;
            }
            else
            {
                parm[6].Value = Con.Tags;
            }
            parm[7] = new SqlParameter("@Contrflg", SqlDbType.NVarChar, 50);
            parm[7].Value = Con.Contrflg;
            parm[8] = new SqlParameter("@Author", SqlDbType.NVarChar, 50);
            parm[8].Value = Con.Author;
            parm[9] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 50);
            parm[9].Value = Con.UserNum;
            parm[10] = new SqlParameter("@PicURL", SqlDbType.NVarChar, 50);
            if (Con.PicURL == "" || Con.PicURL == null)
            {
                parm[10].Value = DBNull.Value;
            }
            else
            {
                parm[10].Value = Con.PicURL;
            }
            parm[11] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 50);
            parm[11].Value = Con.SiteID;
            return parm;
            #endregion
        }

        public int add_sysUserOther(STuserother Con, string UserNum)
        {
            #region
            string Sql = "insert into " + Pre + "sys_userother(ConID,address,postcode,RealName,bankName,bankaccount,bankcard,bankRealName,UserNum) values(@ConID,@address,@postcode,@RealName,@bankName,@bankaccount,@bankcard,@bankRealName,@UserNum) ";
            SqlParameter[] parm = GetUserother(Con);
            int i_length = parm.Length;
            Array.Resize<SqlParameter>(ref parm, i_length + 1);
            parm[i_length] = new SqlParameter("@UserNum", UserNum);
            return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
            #endregion
        }
        public int update_sysUserOther(STuserother Con, string ConIDs)
        {
            #region
            string Sql = "update " + Pre + "sys_userother set address=@address,postcode=@postcode,RealName=@RealName,bankName=@bankName,bankaccount=@bankaccount,bankcard=@bankcard,bankRealName=@bankRealName where ConID=@ConIDs ";
            SqlParameter[] parm = GetUserother(Con);
            int i_length = parm.Length;
            Array.Resize<SqlParameter>(ref parm, i_length + 1);
            parm[i_length] = new SqlParameter("@ConIDs", ConIDs);
            return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
            #endregion
        }

        private SqlParameter[] GetUserother(STuserother Con)
        {
            #region
            SqlParameter[] parm = new SqlParameter[8];
            parm[0] = new SqlParameter("@ConID", SqlDbType.NVarChar, 15);
            parm[0].Value = Rand.Number(12);
            parm[1] = new SqlParameter("@address", SqlDbType.NVarChar, 100);
            parm[1].Value = Con.address;
            parm[2] = new SqlParameter("@postcode", SqlDbType.NVarChar, 20);
            parm[2].Value = Con.postcode;
            parm[3] = new SqlParameter("@RealName", SqlDbType.NVarChar, 20);
            parm[3].Value = Con.RealName;
            parm[4] = new SqlParameter("@bankName", SqlDbType.NVarChar, 100);
            parm[4].Value = Con.bankName;
            parm[5] = new SqlParameter("@bankaccount", SqlDbType.NVarChar, 30);
            parm[5].Value = Con.bankaccount;
            parm[6] = new SqlParameter("@bankcard", SqlDbType.NVarChar, 50);
            parm[6].Value = Con.bankcard;
            parm[7] = new SqlParameter("@bankRealName", SqlDbType.NVarChar, 50);
            parm[7].Value = Con.bankRealName;
            return parm;
            #endregion
        }

⌨️ 快捷键说明

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