code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231
values | license stringclasses 13
values | size int64 1 2.01M |
|---|---|---|---|---|---|
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Collections.Generic;
using System.Text;
namespace NetCMS.Model
{
public class PSF
{
public int Id;
public string psfID;
public string psfName;
public string LocalDir;
public string RemoteDir;
public int isAll;
public int isSub;
public DateTime CreatTime;
public int isRecyle;
public string SiteID;
}
public class Task
{
public int Id;
public string taskID;
public string TaskName;
public int isIndex;
public string ClassID;
public string News;
public string Special;
public string TimeSet;
public DateTime CreatTime;
public string SiteID;
}
}
| 0575kaoshicj | trunk/NetCMS.Model/PSFInfo.cs | C# | asf20 | 1,083 |
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Collections.Generic;
using System.Text;
namespace NetCMS.Model
{
/// <summary>
/// 用户登录的状态
/// </summary>
public enum EnumLoginState
{
/// <summary>
/// 用户session超时
/// </summary>
Err_UserTimeOut,
/// <summary>
/// 管理员session超时
/// </summary>
Err_AdminTimeOut,
/// <summary>
/// 用户被锁定
/// </summary>
Err_Locked,
/// <summary>
/// 管理员锁定
/// </summary>
Err_AdminLocked,
/// <summary>
/// 用户编号不存在
/// </summary>
Err_UserNumInexistent,
/// <summary>
/// 管理员表编号不存在
/// </summary>
Err_AdminNumInexistent,
/// <summary>
/// 用户IP被限制
/// </summary>
Err_IPLimited,
/// <summary>
/// 用户权限不足
/// </summary>
Err_NoAuthority,
/// <summary>
/// 发生数据库异常
/// </summary>
Err_DbException,
/// <summary>
/// 登录状态正常
/// </summary>
Succeed,
/// <summary>
/// 未通过电子邮件激活
/// </summary>
Err_UnEmail,
/// <summary>
/// 未通过手机激活
/// </summary>
Err_UnMobile,
/// <summary>
/// 未通过实名认证
/// </summary>
Err_UnCert,
/// <summary>
/// 用户用户名或密码错误
/// </summary>
Err_UserNameOrPwdError,
/// <summary>
/// 管理员用户名或密码错误
/// </summary>
Err_AdminNameOrPwdError,
/// <summary>
/// 非管理员
/// </summary>
Err_NotAdmin,
/// <summary>
/// 连续登录错误锁定
/// </summary>
Err_DurativeLogError,
/// <summary>
/// 会员组超期
/// </summary>
Err_GroupExpire
}
}
| 0575kaoshicj | trunk/NetCMS.Model/LoginStateInfo.cs | C# | asf20 | 2,479 |
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using NetCMS.DALProfile;
using NetCMS.DALFactory;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Psframe : DbBase, IPsframe
{
/// <summary>
/// 删除PSF到回收站
/// </summary>
/// <param name="TableName"></param>
public void Del_PSF(string Psfid)
{
string Sql = "Update " + Pre + "sys_PSF Set isRecyle=1 where psfID='" + Psfid.ToString() + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 删除所有PSF到回收站
/// </summary>
/// <param name="TableName"></param>
public void DelAll_PSF()
{
string Sql = "Update " + Pre + "sys_PSF Set isRecyle=1 where 1=1 and SiteID='" + NetCMS.Global.Current.SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 插入psf
/// </summary>
/// <param name="uc2"></param>
public void InsertPSF(NetCMS.Model.PSF uc)
{
string Sql = "insert into " + Pre + "sys_PSF (";
Sql += "psfID,psfName,LocalDir,RemoteDir,isSub,isRecyle,CreatTime,SiteID,isAll";
Sql += ") values (";
Sql += "@psfID,@psfName,@LocalDir,@RemoteDir,@isSub,@isRecyle,@CreatTime,@SiteID,@isAll)";
SqlParameter[] parm = InsertPSFParameters(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
/// <summary>
/// 更新psf
/// </summary>
/// <param name="uc2"></param>
public int UpdatePSF(NetCMS.Model.PSF uc)
{
string Sql = "Update " + Pre + "sys_PSF set psfName=@psfName,LocalDir=@LocalDir,RemoteDir=@RemoteDir,isSub=@isSub,isRecyle=@isRecyle,isAll=@isAll where psfID='" + uc.psfID.ToString() + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
SqlParameter[] parm = InsertPSFParameters1(uc);
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
/// <summary>
/// 获取PSF构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] InsertPSFParameters(NetCMS.Model.PSF uc)
{
SqlParameter[] param = new SqlParameter[10];
param[0] = new SqlParameter("@psfID", SqlDbType.NVarChar, 12);
param[0].Value = uc.psfID;
param[1] = new SqlParameter("@psfName", SqlDbType.NVarChar, 30);
param[1].Value = uc.psfName;
param[2] = new SqlParameter("@LocalDir", SqlDbType.NVarChar, 200);
param[2].Value = uc.LocalDir;
param[3] = new SqlParameter("@RemoteDir", SqlDbType.NVarChar, 200);
param[3].Value = uc.RemoteDir;
param[4] = new SqlParameter("@isAll", SqlDbType.TinyInt, 1);
param[4].Value = uc.isAll;
param[5] = new SqlParameter("@isSub", SqlDbType.TinyInt, 1);
param[5].Value = uc.isSub;
param[6] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[6].Value = uc.CreatTime;
param[7] = new SqlParameter("@isRecyle", SqlDbType.TinyInt, 1);
param[7].Value = uc.isRecyle;
param[8] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[8].Value = uc.SiteID;
param[9] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[9].Value = uc.Id;
return param;
}
/// <summary>
/// 获取PSF构造1
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] InsertPSFParameters1(NetCMS.Model.PSF uc)
{
SqlParameter[] param = new SqlParameter[7];
param[0] = new SqlParameter("@psfName", SqlDbType.NVarChar, 30);
param[0].Value = uc.psfName;
param[1] = new SqlParameter("@LocalDir", SqlDbType.NVarChar, 200);
param[1].Value = uc.LocalDir;
param[2] = new SqlParameter("@RemoteDir", SqlDbType.NVarChar, 200);
param[2].Value = uc.RemoteDir;
param[3] = new SqlParameter("@isAll", SqlDbType.TinyInt, 1);
param[3].Value = uc.isAll;
param[4] = new SqlParameter("@isSub", SqlDbType.TinyInt, 1);
param[4].Value = uc.isSub;
param[5] = new SqlParameter("@isRecyle", SqlDbType.TinyInt, 1);
param[5].Value = uc.isRecyle;
param[6] = new SqlParameter("@psfID", SqlDbType.NVarChar, 12);
param[6].Value = uc.psfID;
return param;
}
public DataTable getTitleRecord(string psfName)
{
string Sql = "Select psfName From " + Pre + "sys_PSF Where psfName='" + psfName.ToString() + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return rdr;
}
public int IsExitPSFID(string PSFID)
{
string Str = "Select psfID From " + Pre + "sys_PSF where psfID = '" + PSFID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
return (int)DbHelper.ExecuteScalar(CommandType.Text, Str, null);
}
public DataTable getPSFParam(string psfID)
{
string Sql = "Select Id,psfID,psfName,LocalDir,RemoteDir,isSub,isAll,CreatTime,isRecyle,SiteID From " + Pre + "sys_PSF where psfID = '" + psfID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
#region 计划任务
/// <summary>
/// 检查计划任务ID是否重复
/// </summary>
/// <param name="TaskID"></param>
/// <returns></returns>
public DataTable getTaskParam(string TaskID)
{
string Sql = "Select Id,taskID From " + Pre + "sys_SiteTask where taskID = '" + TaskID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
/// <summary>
/// 检查计划任务名称是否重复
/// </summary>
/// <param name="TaskID"></param>
/// <returns></returns>
public DataTable getTaskName(string TaskName)
{
SqlParameter param = new SqlParameter("@TaskName", TaskName);
string Sql = "Select TaskName From " + Pre + "sys_SiteTask Where TaskName=@TaskNam and SiteID='" + NetCMS.Global.Current.SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
public int DelOneTask(string taskid)
{
string Str_DelOne_Sql = "Delete From " + Pre + "sys_SiteTask where taskID = '" + taskid + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
return DbHelper.ExecuteNonQuery(CommandType.Text, Str_DelOne_Sql, null);
}
public void DelPTask(string boxs)
{
string str_sql = "Delete From " + Pre + "sys_SiteTask where taskID in('" + boxs + "') and SiteID='" + NetCMS.Global.Current.SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
}
public int DelAllTask()
{
string Str_DelAll_Sql = "Delete From " + Pre + "sys_SiteTask where SiteID='" + NetCMS.Global.Current.SiteID + "'";
return DbHelper.ExecuteNonQuery(CommandType.Text, Str_DelAll_Sql, null);
}
/// <summary>
/// 获得某一ID的Task 信息
/// </summary>
/// <param name="TaskID"></param>
/// <returns></returns>
public DataTable getTaskIDInfo(string TaskID)
{
string Sql = "Select Id,taskID,TaskName,isIndex,ClassID,News,Special,TimeSet,CreatTime,SiteID From " + Pre + "sys_SiteTask where taskID='" + TaskID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
/// <summary>
/// 插入Task
/// </summary>
/// <param name="uc2"></param>
public void insertTask(NetCMS.Model.Task uc)
{
string Sql = "insert into " + Pre + "sys_SiteTask (";
Sql += "taskID,TaskName,isIndex,ClassID,News,Special,TimeSet,CreatTime,SiteID";
Sql += ") values (";
Sql += "@taskID,@TaskName,@isIndex,@ClassID,@News,@Special,@TimeSet,@CreatTime,@SiteID)";
SqlParameter[] parm = insertTaskParameters(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
/// <summary>
/// 插入Task
/// </summary>
/// <param name="uc2"></param>
public void UpdateTask(NetCMS.Model.Task uc)
{
string Sql = "Update " + Pre + "sys_SiteTask set taskID=@taskID,TaskName=@TaskName,isIndex=@isIndex,ClassID=@ClassID,News=@News,Special=@Special,TimeSet=@TimeSet,CreatTime=@CreatTime,SiteID=@SiteID where taskID='" + uc.taskID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
SqlParameter[] parm = insertTaskParameters(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
/// <summary>
/// 获取PSF构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] insertTaskParameters(NetCMS.Model.Task uc)
{
SqlParameter[] param = new SqlParameter[10];
param[0] = new SqlParameter("@taskID", SqlDbType.NVarChar, 12);
param[0].Value = uc.taskID;
param[1] = new SqlParameter("@TaskName", SqlDbType.NVarChar, 30);
param[1].Value = uc.TaskName;
param[2] = new SqlParameter("@isIndex", SqlDbType.TinyInt, 1);
param[2].Value = uc.isIndex;
param[3] = new SqlParameter("@ClassID", SqlDbType.NText);
param[3].Value = uc.ClassID;
param[4] = new SqlParameter("@News", SqlDbType.NText);
param[4].Value = uc.News;
param[5] = new SqlParameter("@Special", SqlDbType.NText);
param[5].Value = uc.Special;
param[6] = new SqlParameter("@TimeSet", SqlDbType.NVarChar, 100);
param[6].Value = uc.TimeSet;
param[7] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[7].Value = uc.CreatTime;
param[8] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[8].Value = uc.SiteID;
param[9] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[9].Value = uc.Id;
return param;
}
#endregion
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Psframe.cs | C# | asf20 | 11,459 |
//======================================================
//== (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 NetCMS.Common;
using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Ghistory : DbBase, IGhistory
{
public DataTable sel_sysUser(string UserNum,int flag)
{
#region
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = null;
if (flag == 0)
{
Sql = "Select UserGroupNumber,iPoint,gPoint,SiteID,UserName From " + Pre + "sys_user where UserNum=@UserNum";
}
else if (flag == 1)
{
Sql = "select UserName,PassQuestion,PassKey,Email,UserNum from " + Pre + "sys_User where UserName=@UserNum";
}
else if (flag == 2)
{
Sql = "Select CardNumber,CardPassWord,Money,TimeOutDate,isUse,isLock,isBuy,Point From " + Pre + "user_Card where CardNumber=@UserNum";
}
else if (flag == 3)
{
Sql = "select TopTitle,GoodTitle,CheckTtile,OCTF,DelSelfTitle,DelOTitle,EditSelfTitle,EditOtitle,ReadTitle,GIChange,GTChageRate from " + Pre + "user_Group where GroupNumber=@UserNum";
}
else if (flag == 4)//mycom_Look.aspx
{
Sql = "select Title,Content from " + Pre + "api_commentary where Commid=@UserNum";
}
else if (flag == 5)
{
Sql = "Select ClassCName From " + Pre + "friend_class where ClassID=@UserNum";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
#endregion
}
public int del_userInfo(string ID,int flag)
{
#region
SqlParameter param = new SqlParameter("@GhID", ID);
string Sql = null;
if (flag == 0)
{
Sql = "delete " + Pre + "user_Ghistory where GhID=@GhID";
}
else if (flag == 1)//collection.aspx
{
Sql = "delete " + Pre + "API_Faviate where FID=@GhID And UserNum='" + NetCMS.Global.Current.UserNum + "'";
}
else if (flag == 2)
{
Sql = "delete " + Pre + "api_commentary where Commid=@GhID";
}
else if (flag == 3)
{
Sql = "delete " + Pre + "user_Ghistory where GhID=@GhID " + NetCMS.Common.Public.getSessionStr() + "";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public int sel_sysUserInfo(string UserNum, string UserPassword)
{
#region
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@UserNum", UserNum), new SqlParameter("@UserPassword", UserPassword) };
int flg = 0;
string Sql = "select ID from " + Pre + "sys_User where UserNum=@UserNum and UserPassword=@UserPassword";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
flg = 1;
}
dt.Clear(); dt.Dispose();
}
return flg;
#endregion
}
public int update_sysUser(int Money1, string UserNum,int flag)
{
#region
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = null;
if (flag == 0)
{
Sql = "update " + Pre + "sys_User set gPoint=gPoint+" + Money1 + " where UserNum=@UserNum";
}
else if (flag == 1)
{
Sql = "update " + Pre + "sys_User set iPoint=iPoint+" + Money1 + " where UserNum=@UserNum";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public int update_userInfos(string UserNum, string cnm,int flag)
{
#region
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
param[0].Value = UserNum;
param[1] = new SqlParameter("@CardNumber", SqlDbType.NVarChar, 32);
param[1].Value = cnm;
string Sql = null;
if (flag == 0)
{
Sql = "update " + Pre + "user_Card set isUse='1',UserNum=@UserNum where CardNumber=@CardNumber";
}
else if (flag == 1)//getPassword.aspx
{
//md5码是16位的,用参数传的话就是15位了
Sql = "update " + Pre + "sys_User set UserPassword='" + UserNum + "' where UserNum=@CardNumber";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public bool addTo(string NewsID,int ChID)
{
#region
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@NewsID", SqlDbType.NVarChar, 15);
param[0].Value = NewsID;
param[1] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[1].Value = ChID;
string gsql = "select count(id) from " + Pre + "API_Faviate where FID=@NewsID and ChID=@ChID And UserNum='" + NetCMS.Global.Current.UserNum + "'";
int i_Count = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, gsql, param));
if (i_Count == 0)
{
string Sql = "insert " + Pre + "API_Faviate(FID,UserNum,CreatTime,APIID,DataLib,ChID) values(@NewsID,'" + NetCMS.Global.Current.UserNum + "','" + DateTime.Now + "','0','',@ChID)";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
return true;
}
return false;
#endregion
}
#region Exchange.aspx
public int Add(GhistoryInfo Gh, int ghtype, string UserNum, string content)
{
#region
string Sql = "insert into " + Pre + "User_Ghistory(GhID,ghtype,Gpoint,iPoint,Money,CreatTime,UserNUM,gtype,content) values(@GhID,'" + ghtype + "',@Gpoint,@iPoint,0,@CreatTime,@UserNum,3,@content)";
SqlParameter[] parm = GetGhistory(Gh);
int i_length = parm.Length;
Array.Resize<SqlParameter>(ref parm, i_length + 2);
parm[i_length] = new SqlParameter("@UserNum", UserNum);
parm[i_length + 1] = new SqlParameter("@content", content);
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
#endregion
}
private SqlParameter[] GetGhistory(GhistoryInfo Gh)
{
#region
SqlParameter[] parm = new SqlParameter[4];
parm[0] = new SqlParameter("@GhID", SqlDbType.NVarChar, 50);
parm[0].Value = Rand.Number(12);
parm[1] = new SqlParameter("@Gpoint", SqlDbType.NVarChar, 50);
parm[1].Value = Gh.Gpoint;
parm[2] = new SqlParameter("@iPoint", SqlDbType.NVarChar, 50);
parm[2].Value = Gh.iPoint;
parm[3] = new SqlParameter("@CreatTime", SqlDbType.DateTime);
parm[3].Value = DateTime.Now;
return parm;
#endregion
}
#endregion
public int sel_userCardInfo(string cnm)
{
#region
SqlParameter param = new SqlParameter("@CardNumber", cnm);
int flg = 0;
string Sql = "Select isUse From " + Pre + "user_Card where CardNumber=@CardNumber";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (dt != null && dt.Rows.Count > 0)
{
flg = int.Parse(dt.Rows[0]["isUse"].ToString());
dt.Clear(); dt.Dispose();
}
return flg;
#endregion
}
public int sel_sysPramUser()
{
#region
int flg = 0;
string Sql = "select GhClass from " + Pre + "sys_PramUser";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (dt != null && dt.Rows.Count > 0)
{
flg = int.Parse(dt.Rows[0]["GhClass"].ToString());
dt.Clear(); dt.Dispose();
}
return flg;
#endregion
}
public int add_userGhistory(string GhID, string UserNum, int Gpoint, int Money, DateTime CreatTime, string content)
{
#region
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@GhID", SqlDbType.NVarChar, 12);
param[0].Value = GhID;
param[1] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
param[1].Value = UserNum;
param[2] = new SqlParameter("@content", SqlDbType.NText);
param[2].Value = content;
string Sql = "insert into " + Pre + "User_Ghistory(GhID,UserNUM,Gpoint,ghtype,Money,CreatTime,gtype,content) values(@GhID,@UserNum," + Gpoint + ",1," + Money + ",'" + CreatTime + "',2,@content)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#region mycom.aspx
public DataTable GetPage(string title, string Um, string dtm1, string dtm2, string isCheck, string islock, string SiteID, string UserNum, int DelOTitle, int EditOtitle, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
#region
string QSQL = "";
if (title != "" && title != null)
{
QSQL = " and Title like '%" + title + "%'";
}
if (dtm1 != "" && dtm1 != null && dtm2 != "" && dtm2 != null)
{
DateTime dtms1 = DateTime.Parse(dtm1);
DateTime dtms2 = DateTime.Parse(dtm2);
QSQL += " and creatTime >= '" + dtms1 + "' and creatTime <= '" + dtms2 + "'";
}
if (isCheck != "" && isCheck != null && isCheck != "0")
{
QSQL += " and isCheck=@isCheck";
}
if (islock != "" && islock != null && islock != "0")
{
int islocks = 0;
if (islock == "1")
{
islocks = 0;
}
else
{
islocks = 1;
}
QSQL += " and islock = '" + islocks + "'";
}
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@UserNum", UserNum), new SqlParameter("@SiteID", SiteID) };
string sl = null;
if (UserNum != "")
{
sl = "" + Pre + "api_commentary where UserNum=@UserNum and SiteID=@SiteID " + QSQL + "";
}
else
{
sl = "" + Pre + "api_commentary where SiteID=@SiteID " + QSQL + "";
}
string AllFields = "Commid,Title,InfoID,APIID,creatTime,isCheck,UserNum,islock,OrderID,GoodTitle,Content,Datalib";
string Condition = sl;
string IndexField = "Id";
string OrderFields = "order by OrderID Desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, param);
#endregion
}
#endregion
#region mycom_up.aspx
public int update_apiCommentary(string Title, string Contents, DateTime CreatTime, string Commid, int islock)
{
#region
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@Title", SqlDbType.NVarChar, 200);
param[0].Value = "";
param[1] = new SqlParameter("@Contents", SqlDbType.NVarChar, 200);
param[1].Value = Contents;
param[2] = new SqlParameter("@Commid", SqlDbType.NVarChar, 12);
param[2].Value = Commid;
param[3] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[3].Value = CreatTime;
string Tmp = "";
if (islock != 2)
{
Tmp = ",islock=" + islock + "";
}
string Sql = "update " + Pre + "api_commentary set Title=@Title,Content=@Contents,creatTime=@creatTime " + Tmp + " where Commid=@Commid";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region pointhistory.aspx
public DataTable GetPagepoi(string typep, string UM, string sle_NUM, string SiteID, string UserNum, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
#region
string gtype = string.Empty;
string gtypes = string.Empty;
if (typep != "0" && typep != null)
{
gtype = "and gtype=@gtype";
}
if (typep == "8")
{
gtypes = "and ghtype=1";
}
if (typep == "9")
{
gtypes = "and ghtype=0";
}
string UserNumstr = "";
if (UserNum != "" && UserNum != null)
{
UserNumstr = " and UserNum=@UserNum";
}
string sel_UM = string.Empty;
if (UM != string.Empty)
{
if (sle_NUM != string.Empty)
{
sel_UM = " and UserNUM=@sle_NUM";
}
if (typep == "8" || typep == "9")
{
gtype = null;
}
else
{
gtypes = null;
}
}
string siteID1 = "";
if (SiteID != "" && SiteID != "0" && SiteID != null)
{
if (NetCMS.Global.Current.SiteID == "0")
{
siteID1 = " and SiteID='" + SiteID + "'";
}
else
{
siteID1 = " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
}
else
{
siteID1 = " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@gtype", int.Parse(typep)), new SqlParameter("@UserNum", UserNum), new SqlParameter("@sle_NUM", sle_NUM) };
string AllFields = "GhID,ghtype,Gpoint,iPoint,Money,CreatTime,UserNUM,gtype,content";
string Condition = "" + Pre + "user_Ghistory where 1=1 " + gtype + sel_UM + siteID1 + gtypes + UserNumstr + "";
string IndexField = "id";
string OrderFields = "order by id";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, param);
#endregion
}
#endregion
public int update_userInfo(int ipoint2, int gpoint2, string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "update " + Pre + "sys_user set iPoint='" + ipoint2 + "',gPoint='" + gpoint2 + "' where UserNum=@UserNum";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#region 前台友情连接
public DataTable sel_friendInfo(int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "Select IsOpen,Content From " + Pre + "friend_pram";
}
else if (flag == 1)
{
Sql = "Select ClassID,ClassCName,ParentID From " + Pre + "friend_class";
}
else if (flag == 2)
{
Sql = "Select UserNum,Email From " + Pre + "sys_User where UserNum='" + NetCMS.Global.Current.UserNum + "'";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
#endregion
}
public int ISExitNamee(string Str_Name)
{
SqlParameter param = new SqlParameter("@Name", Str_Name);
string Str_CheckSql = "Select count(Name) From " + Pre + "friend_link Where Name=@Name";
return (int)DbHelper.ExecuteScalar(CommandType.Text, Str_CheckSql, param);
}
public int SaveLink(string Str_Class, string Str_Name, string Str_Type, string Str_Url, string Str_Content, string Str_PicUrl, string Str_Author, string Str_Mail, string Str_ContentFor)
{
#region
SqlParameter[] param = new SqlParameter[9];
param[0] = new SqlParameter("@Str_Class", SqlDbType.NVarChar, 12);
param[0].Value = Str_Class;
param[1] = new SqlParameter("@Str_Name", SqlDbType.NVarChar,50);
param[1].Value = Str_Name;
param[2] = new SqlParameter("@Str_Type", SqlDbType.Int, 1);
param[2].Value = Convert.ToInt32(Str_Type);
param[3] = new SqlParameter("@Str_Url", SqlDbType.NVarChar, 250);
param[3].Value = Str_Url;
param[4] = new SqlParameter("@Str_Content", SqlDbType.NText);
param[4].Value = Str_Content;
param[5] = new SqlParameter("@Str_PicUrl", SqlDbType.NVarChar, 250);
param[5].Value = Str_PicUrl;
param[6] = new SqlParameter("@Str_Author", SqlDbType.NVarChar, 50);
param[6].Value = Str_Author;
param[7] = new SqlParameter("@Str_Mail", SqlDbType.NVarChar, 150);
param[7].Value = Str_Mail;
param[8] = new SqlParameter("@Str_ContentFor", SqlDbType.NText);
param[8].Value = Str_ContentFor;
string Str_InSql = "Insert into " + Pre + "friend_link (ClassID,Name,Type,Url,Content,PicUrl,Author,Mail,ContentFor,isAdmin,Lock,IsUser,SiteID) Values(@Str_Class,@Str_Name,@Str_Type,@Str_Url,@Str_Content,@Str_PicUrl,@Str_Author,@Str_Mail,@Str_ContentFor,0,1,1,'" + NetCMS.Global.Current.SiteID + "')";
return DbHelper.ExecuteNonQuery(CommandType.Text, Str_InSql, param);
#endregion
}
public void del_friendLink(string id)
{
SqlParameter param = new SqlParameter("@ID", id);
string Str_InSql = "delete from " + Pre + "friend_link where Author='" + NetCMS.Global.Current.UserNum + "' and ID=@ID";
DbHelper.ExecuteNonQuery(CommandType.Text, Str_InSql, param);
}
public DataTable sel_friendLink(int num, string uid)
{
SqlParameter param = new SqlParameter("@Author", uid);
string Str_InSql = "select Name,Url,Content,PicUrl,Author,LinkContent from " + Pre + "friend_link where Author=@Author and Type=" + num + "";
return DbHelper.ExecuteTable(CommandType.Text, Str_InSql, param);
}
#endregion
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Ghistory.cs | C# | asf20 | 20,089 |
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Text;
using System.Data;
using System.Text.RegularExpressions;
using System.Data.SqlClient;
using System.Collections;
using NetCMS.DALFactory;
using NetCMS.Model;
using NetCMS.Global;
using NetCMS.DALProfile;
using NetCMS.Config;
using NetCMS.Control;
using System.Collections.Generic;
using Discuz.Entity;
using Discuz.Common;
namespace NetCMS.DALSQLServer
{
public class Collect : DbBase, ICollect
{
public DataTable GetFolderSitePage(int FolderID, int PageIndex, int PageSize, out int RecordCount, out int PageCount)
{
if (FolderID < 1)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
int nf = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, "select count(*) from " + Pre + "Collect_SiteFolder where ChannelID='" + Current.SiteID + "'", null));
int ns = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, "select count(*) from " + Pre + "Collect_Site where ChannelID='" + Current.SiteID + "' and (Folder is null or Folder=0)", null));
RecordCount = nf + ns;
if (RecordCount % PageSize == 0)
PageCount = RecordCount / PageSize;
else
PageCount = RecordCount / PageSize + 1;
if (PageIndex > PageCount)
PageIndex = PageCount;
if (PageIndex < 1)
PageIndex = 1;
int nStart = PageSize * (PageIndex - 1);
string Sql = "(select 0 as TP,ID,SiteFolder as SName,'' as objURL,'' as LockState,0 as cjcount,0 as allcount,0 as needcount,'' as topchapter,'' as cjstate from " + Pre + "Collect_SiteFolder where ChannelID='" + Current.SiteID + "') union (select 1 as TP,ID,SiteName as SName,objURL,case when LinkSetting is null or PagebodySetting is null or PageTitleSetting is null then '不可用' else '有效' end as LockState, cjcount, allcount, needcount,topchapter,cjstate from " + Pre + "Collect_Site where ChannelID='" + Current.SiteID + "' and (Folder is null or Folder=0))";
SqlDataAdapter ap = new SqlDataAdapter(Sql, cn);
DataSet st = new DataSet();
ap.Fill(st, nStart, PageSize, "REST");
DataTable tb = st.Tables[0];
st.Dispose();
if (cn.State == ConnectionState.Open)
cn.Close();
return tb;
}
else
{
return DbHelper.ExecutePage(DBConfig.CollectConString, "1 as TP,ID,SiteName as SName,objURL,case when LinkSetting is null or PagebodySetting is null or PageTitleSetting is null then '不可用' else '有效' end as LockState, cjcount, allcount, needcount,topchapter,cjstate ", Pre + "Collect_Site where ChannelID='" + Current.SiteID + "' and Folder=" + FolderID, "ID", "Order by sitename,ID", PageIndex, PageSize, out RecordCount, out PageCount, null);
}
}
public int GetAutoCollectRules()
{
string sql = "insert into cjqueue(ruleid,collecttime)";
sql += "select ID,getdate() from NT_Collect_Site where ChannelID='1' and id not in(select ruleid from cjqueue) and cjstate=1 Order by sitename,ID";
return DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, sql, null);
}
/// <summary>
/// 根据cjqueue获取一条规则
/// </summary>
/// <returns></returns>
public DataTable GetOneRule(string top)
{
string Sql = "select "+top+" c.* from cjqueue q join nt_collect_site c on c.id=q.ruleid where c.cjstate=1 order by q.collecttime";
return DbHelper.ExecuteTable(DBConfig.CollectConString, CommandType.Text, Sql, null);
}
public void SiteCopy(int id)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
try
{
string Sql = "select * from " + Pre + "Collect_Site where ChannelID='" + Current.SiteID + "' and ID=" + id;
IDataReader rd = DbHelper.ExecuteReader(cn, CommandType.Text, Sql, null);
string snm = "", Column = "";
if (rd.Read())
{
snm = rd["SiteName"].ToString();
for (int i = 0; i < rd.FieldCount; i++)
{
string clnm = rd.GetName(i);
if (!(clnm.Equals("ID") || clnm.Equals("SiteName")))
{
Column += "," + clnm;
}
}
}
else
{
rd.Close();
throw new Exception("0%没有找到该记录");
}
rd.Close();
string snewnm = "复件 " + snm;
int n = 2;
while (Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, "select count(*) from " + Pre + "Collect_Site where SiteName='" + snewnm + "'", null)) > 0)
{
snewnm = "复件(" + n + ") " + snm;
n++;
}
Sql = "insert into " + Pre + "Collect_Site (SiteName" + Column + ") select '" + snewnm + "' as NewName" + Column + " from " + Pre + "Collect_Site where ChannelID='" + Current.SiteID + "' and ID=" + id;
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, null);
}
finally
{
if (cn != null && cn.State == ConnectionState.Open)
cn.Close();
}
}
public void FolderCopy(int id)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
try
{
string Sql = "select SiteFolder from " + Pre + "Collect_SiteFolder where ChannelID='" + Current.SiteID + "' and ID=" + id;
object snm = DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null);
if (snm == null)
throw new Exception("没有找到相关目录的记录");
int n = 2;
string snewnm = "复件 " + snm;
/*
if (Regex.Match(snm,@"^复件\s").Success)
{
snewnm = "复件(" + n + ")" + snm;
n++;
}
else if (Regex.Match(snm, @"^复件(/d)").Success)
{
n = int.Parse(Regex.Match(snm, @"(?<=复件\()\d+?(?=\).+)").Value);
n++;
snewnm = "复件(" + n + ")" + snm;
n++;
}
else
{
snewnm = "复件 " + snm;
}
*/
while (Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, "select count(*) from " + Pre + "Collect_SiteFolder where SiteFolder='" + snewnm + "'", null)) > 0)
{
snewnm = "复件(" + n + ") " + snm;
n++;
}
Sql = "insert into " + Pre + "Collect_SiteFolder (SiteFolder,SiteFolderDetail,ChannelID) select '" + snewnm + "' as NewName,SiteFolderDetail,ChannelID from " + Pre + "Collect_SiteFolder where ChannelID='" + Current.SiteID + "' and ID=" + id;
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, null);
}
finally
{
if (cn != null && cn.State == ConnectionState.Open)
cn.Close();
}
}
public void FolderDelete(int id)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
try
{
string Sql = "select count(*) from " + Pre + "Collect_Site where ChannelID='" + Current.SiteID + "' and Folder=" + id;
int n = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null));
if (n > 0)
throw new Exception("该栏目下有站点,不能删除!");
Sql = "Delete from " + Pre + "Collect_SiteFolder where ChannelID='" + Current.SiteID + "' and ID=" + id;
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, null);
}
finally
{
if (cn != null && cn.State == ConnectionState.Open)
cn.Close();
}
}
public void SiteDelete(int id)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
SqlTransaction tran = cn.BeginTransaction();
try
{
string[] Sql = new string[2];
DbHelper.ExecuteNonQuery(tran, CommandType.Text, "Delete from " + Pre + "Collect_RuleApply where SiteID=" + id, null);
DbHelper.ExecuteNonQuery(tran, CommandType.Text, "Delete from " + Pre + "Collect_Site where ChannelID='" + Current.SiteID + "' and ID=" + id, null);
tran.Commit();
}
catch
{
tran.Rollback();
throw;
}
finally
{
if (cn != null && cn.State == ConnectionState.Open)
cn.Close();
}
}
public DataTable GetFolder(int id, bool all)
{
string Sql = "select ID,SiteFolder,SiteFolderDetail from " + Pre + "Collect_SiteFolder where ChannelID='" + Current.SiteID + "'";
if (!all)
Sql += " and ID=" + id;
return DbHelper.ExecuteTable(DBConfig.CollectConString, CommandType.Text, Sql, null);
}
public DataTable GetSite(int id)
{
string Sql = "";
Sql = "select a.*,b.OldContent,b.ReContent,b.IgnoreCase from " + Pre + "Collect_Site a left join (" + Pre + "Collect_Rule b inner join " + Pre +
"Collect_RuleApply c on b.ID=c.RuleID) on c.SiteID=a.ID where a.ChannelID='1' and a.ID=" + id;
return DbHelper.ExecuteTable(DBConfig.CollectConString, CommandType.Text, Sql, null);
}
public int SiteAdd(CollectSiteInfo st)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
try
{
string Sql = "select count(*) from " + Pre + "Collect_Site where ChannelID='" + Current.SiteID + "' and SiteName=@SiteName";
SqlParameter parm = new SqlParameter("@SiteName", SqlDbType.NVarChar, 50);
parm.Value = st.SiteName;
int n = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, parm));
if (n > 0)
{
cn.Close();
throw new Exception("采集站点名称重复!");
}
Sql = "insert into " + Pre + "Collect_Site (";
Sql += "SiteName,objURL,Folder,SaveRemotePic,Audit,IsReverse,IsAutoPicNews,TextTF";
Sql += ",IsStyle,IsDIV,IsA,IsClass,IsFont,IsSpan,IsObject,IsIFrame,IsScript,Encode,ClassID,ChannelID";
Sql += ",IsAutoCollect,cjcount";
Sql += ") values (";
Sql += "@SiteName,@objURL,@Folder,@SaveRemotePic,@Audit,@IsReverse,@IsAutoPicNews,@TextTF";
Sql += ",@IsStyle,@IsDIV,@IsA,@IsClass,@IsFont,@IsSpan,@IsObject,@IsIFrame,@IsScript,@Encode,@ClassID,'" + Current.SiteID + "',";
Sql += "@IsAutoCollect,@cjcount)";
Sql += ";SELECT @@IDENTITY";
int result = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, GetParameters(st)));
return result;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
public int FolderAdd(string Name, string Description)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
string Sql = "select count(*) from " + Pre + "Collect_SiteFolder where ChannelID='" + Current.SiteID + "' and SiteFolder=@SiteFolder";
SqlParameter prm = new SqlParameter("@SiteFolder", SqlDbType.NVarChar, 50);
prm.Value = Name;
int n = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, prm));
if (n > 0)
{
cn.Close();
throw new Exception("栏目名称重复");
}
Sql = "insert into " + Pre + "Collect_SiteFolder (SiteFolder,SiteFolderDetail,ChannelID) values (@SiteFolder,@SiteFolderDetail,'" + Current.SiteID + "');SELECT @@IDENTITY";
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@SiteFolder", SqlDbType.NVarChar, 50);
param[0].Value = Name;
param[1] = new SqlParameter("@SiteFolderDetail", SqlDbType.NText);
param[1].Value = Description.Trim().Equals("") ? DBNull.Value : (object)Description;
n = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, param));
cn.Close();
return n;
}
public void SiteUpdate(CollectSiteInfo st, int step)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
try
{
SqlParameter[] param = null;
string Sql = "";
if (step == 1)
{
#region 第一步
Sql = "select count(*) from " + Pre + "Collect_Site where SiteName=@SiteName and ChannelID='" + Current.SiteID + "' and ID<>@ID";
SqlParameter[] parm = new SqlParameter[2];
parm[0] = new SqlParameter("@SiteName", SqlDbType.NVarChar, 50);
parm[0].Value = st.SiteName;
parm[1] = new SqlParameter("@ID", SqlDbType.Int);
parm[1].Value = st.ID;
int n = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, parm));
if (n > 0)
{
cn.Close();
throw new Exception("采集站点名称重复!");
}
Sql = "update " + Pre + "Collect_Site Set SiteName=@SiteName,objURL=@objURL,Folder=@Folder,ClassID=@ClassID,";
Sql += "SaveRemotePic=@SaveRemotePic,Audit=@Audit,IsReverse=@IsReverse,IsAutoPicNews=@IsAutoPicNews,TextTF=@TextTF,";
Sql += "IsStyle=@IsStyle,IsDIV=@IsDIV,IsA=@IsA,IsClass=@IsClass,IsFont=@IsFont,IsSpan=@IsSpan,";
Sql += "IsObject=@IsObject,IsIFrame=@IsIFrame,IsScript=@IsScript,Encode=@Encode,IsAutoCollect=@IsAutoCollect,cjcount=@cjcount";
Sql += " where ChannelID='" + Current.SiteID + "' and ID=" + st.ID;
param = GetParameters(st);
#endregion 第一步
}
else if (step == 2)
{
#region 第二步
Sql = "update " + Pre + "Collect_Site set ListSetting=@ListSetting,OtherPageSetting=@OtherPageSetting,";
Sql += "StartPageNum=@StartPageNum,EndPageNum=@EndPageNum,OtherType=@OtherType where ChannelID='" + Current.SiteID + "' and ID=" + st.ID;
param = new SqlParameter[5];
param[0] = new SqlParameter("@ListSetting", SqlDbType.NVarChar, 4000);
param[0].Value = st.ListSetting;
param[1] = new SqlParameter("@OtherPageSetting", SqlDbType.NVarChar, 4000);
param[1].Value = st.OtherPageSetting.Trim().Equals("") ? DBNull.Value : (object)st.OtherPageSetting;
param[2] = new SqlParameter("@StartPageNum", SqlDbType.Int);
param[2].Value = st.StartPageNum < 0 ? DBNull.Value : (object)st.StartPageNum;
param[3] = new SqlParameter("@EndPageNum", SqlDbType.Int);
param[3].Value = st.EndPageNum < 0 ? DBNull.Value : (object)st.EndPageNum;
param[4] = new SqlParameter("@OtherType", SqlDbType.Int);
param[4].Value = st.OtherType;
#endregion 第二步
}
else if (step == 3)
{
#region 第三步
Sql = "update " + Pre + "Collect_Site set LinkSetting=@LinkSetting where ChannelID='" + Current.SiteID + "' and ID=" + st.ID;
param = new SqlParameter[1];
param[0] = new SqlParameter("@LinkSetting", SqlDbType.NVarChar, 4000);
param[0].Value = st.LinkSetting;
#endregion 第三步
}
else if (step == 4)
{
#region 第四步
Sql = "Update " + Pre + "Collect_Site set PageTitleSetting=@PageTitleSetting,PagebodySetting=@PagebodySetting";
Sql += ",AuthorSetting=@AuthorSetting,SourceSetting=@SourceSetting,AddDateSetting=@AddDateSetting,HandSetAuthor=@HandSetAuthor";
Sql += ",HandSetSource=@HandSetSource,HandSetAddDate=@HandSetAddDate,OtherNewsType=@OtherNewsType";
Sql += ",OtherNewsPageSetting=@OtherNewsPageSetting where ChannelID='" + Current.SiteID + "' and ID=" + st.ID;
param = new SqlParameter[10];
param[0] = new SqlParameter("@PageTitleSetting", SqlDbType.NVarChar, 4000);
param[0].Value = st.PageTitleSetting;
param[1] = new SqlParameter("@PagebodySetting", SqlDbType.NVarChar, 4000);
param[1].Value = st.PagebodySetting;
param[2] = new SqlParameter("@AuthorSetting", SqlDbType.NVarChar, 4000);
param[2].Value = st.AuthorSetting.Equals("") ? DBNull.Value : (object)st.AuthorSetting;
param[3] = new SqlParameter("@SourceSetting", SqlDbType.NText);
param[3].Value = st.SourceSetting.Equals("") ? DBNull.Value : (object)st.SourceSetting;
param[4] = new SqlParameter("@AddDateSetting", SqlDbType.NText);
param[4].Value = st.AddDateSetting.Equals("") ? DBNull.Value : (object)st.AddDateSetting;
param[5] = new SqlParameter("@HandSetAuthor", SqlDbType.NVarChar, 100);
param[5].Value = st.HandSetAuthor.Equals("") ? DBNull.Value : (object)st.HandSetAuthor;
param[6] = new SqlParameter("@HandSetSource", SqlDbType.NVarChar, 100);
param[6].Value = st.HandSetSource.Equals("") ? DBNull.Value : (object)st.HandSetSource;
param[7] = new SqlParameter("@HandSetAddDate", SqlDbType.DateTime);
param[7].Value = (st.HandSetAddDate.Year < 1753) ? DBNull.Value : (object)st.HandSetAddDate;
param[8] = new SqlParameter("@OtherNewsType", SqlDbType.Int);
param[8].Value = st.OtherNewsType;
param[9] = new SqlParameter("@OtherNewsPageSetting", SqlDbType.NVarChar, 4000);
param[9].Value = st.OtherNewsPageSetting.Trim().Equals("") ? DBNull.Value : (object)st.OtherNewsPageSetting;
#endregion 第四步
}
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, param);
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
/// <summary>
/// 更新采集量
/// </summary>
/// <param name="id"></param>
/// <param name="allcount">外网的总数</param>
/// <param name="needcount">需要采集的量</param>
public int myCJcountUpdate(int id,int allcount,int needcount)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
string Sql = "update " + Pre + "Collect_Site set allcount=@allcount,needcount=@needcount where ID=" + id;
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@allcount", allcount);
param[1] = new SqlParameter("@needcount", needcount);
int i = DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, param);
cn.Close();
return i;
}
public int myCJNumUpdate(int id, int cjcount)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
string Sql = "update " + Pre + "Collect_Site set cjcount=@cjcount where ID=" + id;
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@cjcount", cjcount);
int i = DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, param);
cn.Close();
return i;
}
public int myCJTitleUpdate(int ruleid, string title)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
string Sql = "update " + Pre + "Collect_Site set topchapter=@topchapter where ID=" + ruleid;
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@topchapter", title);
int i = DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, param);
cn.Close();
return i;
}
public int mySetCJTime(string ruleid)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
string Sql = "update cjqueue set collecttime=getdate() where ruleid=" + ruleid;
int i = DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, null);
cn.Close();
return i;
}
public void FolderUpdate(int id, string Name, string Description)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
string Sql = "select count(*) from " + Pre + "Collect_SiteFolder where SiteFolder=@SiteFolder and ChannelID='" + Current.SiteID + "' and ID<>" + id;
SqlParameter prm = new SqlParameter("@SiteFolder", SqlDbType.NVarChar, 50);
prm.Value = Name;
int n = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, prm));
if (n > 0)
{
cn.Close();
throw new Exception("栏目名称重复");
}
Sql = "update " + Pre + "Collect_SiteFolder set SiteFolder=@SiteFolder,SiteFolderDetail=@SiteFolderDetail where ChannelID='" + Current.SiteID + "' and ID=" + id;
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@SiteFolder", SqlDbType.NVarChar, 50);
param[0].Value = Name;
param[1] = new SqlParameter("@SiteFolderDetail", SqlDbType.NText);
param[1].Value = Description.Trim().Equals("") ? DBNull.Value : (object)Description;
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, param);
cn.Close();
}
private SqlParameter[] GetParameters(CollectSiteInfo st)
{
SqlParameter[] pmt = new SqlParameter[21];
pmt[0] = new SqlParameter("@SiteName", SqlDbType.NVarChar, 50);
pmt[0].Value = st.SiteName;
pmt[1] = new SqlParameter("@objURL", SqlDbType.NVarChar, 250);
pmt[1].Value = st.objURL;
pmt[2] = new SqlParameter("@Folder", SqlDbType.Int);
pmt[2].Value = st.Folder < 1 ? DBNull.Value : (object)st.Folder;
pmt[3] = new SqlParameter("@SaveRemotePic", SqlDbType.Bit);
pmt[3].Value = st.SaveRemotePic;
pmt[4] = new SqlParameter("@Audit", SqlDbType.NVarChar, 10);
pmt[4].Value = st.Audit;
pmt[5] = new SqlParameter("@IsReverse", SqlDbType.Bit);
pmt[5].Value = st.IsReverse;
pmt[6] = new SqlParameter("@IsAutoPicNews", SqlDbType.Bit);
pmt[6].Value = st.IsAutoPicNews;
pmt[7] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 50);
pmt[7].Value = st.ClassID;
pmt[8] = new SqlParameter("@TextTF", SqlDbType.Bit);
pmt[8].Value = st.TextTF;
pmt[9] = new SqlParameter("@IsStyle", SqlDbType.Bit);
pmt[9].Value = st.IsStyle;
pmt[10] = new SqlParameter("@IsDIV", SqlDbType.Bit);
pmt[10].Value = st.IsDIV;
pmt[11] = new SqlParameter("@IsA", SqlDbType.Bit);
pmt[11].Value = st.IsA;
pmt[12] = new SqlParameter("@IsClass", SqlDbType.Bit);
pmt[12].Value = st.IsClass;
pmt[13] = new SqlParameter("@IsFont", SqlDbType.Bit);
pmt[13].Value = st.IsFont;
pmt[14] = new SqlParameter("@IsSpan", SqlDbType.Bit);
pmt[14].Value = st.IsSpan;
pmt[15] = new SqlParameter("@IsObject", SqlDbType.Bit);
pmt[15].Value = st.IsObject;
pmt[16] = new SqlParameter("@IsIFrame", SqlDbType.Bit);
pmt[16].Value = st.IsIFrame;
pmt[17] = new SqlParameter("@IsScript", SqlDbType.Bit);
pmt[17].Value = st.IsScript;
pmt[18] = new SqlParameter("@Encode", SqlDbType.NVarChar, 50);
pmt[18].Value = st.Encode;
pmt[19] = new SqlParameter("@IsAutoCollect", SqlDbType.Bit);
pmt[19].Value = st.IsAutoCollect;
pmt[20] = new SqlParameter("@cjcount", SqlDbType.Int);
pmt[20].Value = st.cjcount;
return pmt;
}
public DataTable GetRulePage(int PageIndex, int PageSize, out int RecordCount, out int PageCount)
{
return DbHelper.ExecutePage(DBConfig.CollectConString, "ID,RuleName,AddDate", Pre + "Collect_Rule where ChannelID='" + Current.SiteID + "'", "ID", "Order by ID", PageIndex, PageSize, out RecordCount, out PageCount, null);
}
public void RuleDelete(int id)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
SqlTransaction trans = cn.BeginTransaction();
try
{
string Sql = "delete from " + Pre + "Collect_RuleApply where RuleID=" + id;
DbHelper.ExecuteNonQuery(trans, CommandType.Text, Sql, null);
Sql = "delete from " + Pre + "Collect_Rule where ChannelID='" + Current.SiteID + "' and ID=" + id;
DbHelper.ExecuteNonQuery(trans, CommandType.Text, Sql, null);
trans.Commit();
}
catch
{
trans.Rollback();
throw;
}
finally
{
if (cn != null && cn.State == ConnectionState.Open)
cn.Close();
}
}
public int RuleAdd(string Name, string OldStr, string NewStr, int[] AppSites, bool IgnoreCase)
{
int id = 0;
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
string Sql = "select count(*) from " + Pre + "Collect_Rule where RuleName=@RuleName and ChannelID='" + Current.SiteID + "'";
SqlParameter param = new SqlParameter("@RuleName", SqlDbType.NVarChar, 50);
param.Value = Name;
int n = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, param));
if (n > 0)
{
cn.Close();
throw new Exception("规则名称重复");
}
SqlTransaction Trans = cn.BeginTransaction();
try
{
Sql = "insert into " + Pre + "Collect_Rule (RuleName,OldContent,ReContent,AddDate,IgnoreCase,ChannelID) values (@RuleName,@OldContent,@ReContent,@AddDate,@IgnoreCase,'" + Current.SiteID + "')";
Sql += ";SELECT @@IDENTITY";
SqlParameter[] parm = new SqlParameter[5];
parm[0] = new SqlParameter("@RuleName", SqlDbType.NVarChar, 50);
parm[0].Value = Name;
parm[1] = new SqlParameter("@OldContent", SqlDbType.NVarChar, 100);
parm[1].Value = OldStr;
parm[2] = new SqlParameter("@ReContent", SqlDbType.NVarChar, 100);
parm[2].Value = NewStr;
parm[3] = new SqlParameter("@AddDate", SqlDbType.DateTime);
parm[3].Value = DateTime.Now;
parm[4] = new SqlParameter("@IgnoreCase", SqlDbType.Bit);
parm[4].Value = IgnoreCase;
id = Convert.ToInt32(DbHelper.ExecuteScalar(Trans, CommandType.Text, Sql, parm));
if (AppSites != null && AppSites.Length > 0)
{
foreach (int stid in AppSites)
{
Sql = "delete from " + Pre + "Collect_RuleApply where SiteID=" + stid;
DbHelper.ExecuteNonQuery(Trans, CommandType.Text, Sql, null);
Sql = "insert into " + Pre + "Collect_RuleApply(SiteID,RuleID,RefreshTime) values (" + stid + "," + id + ",'" + DateTime.Now + "')";
DbHelper.ExecuteNonQuery(Trans, CommandType.Text, Sql, null);
}
}
Trans.Commit();
}
catch
{
Trans.Rollback();
throw;
}
finally
{
if (cn != null && cn.State == ConnectionState.Open)
cn.Close();
}
return id;
}
public void RuleUpdate(int RuleID, string Name, string OldStr, string NewStr, int[] AppSites, bool IgnoreCase)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
string Sql = "select count(*) from " + Pre + "Collect_Rule where RuleName=@RuleName and ChannelID='" + Current.SiteID + "' and ID<>" + RuleID;
SqlParameter param = new SqlParameter("@RuleName", SqlDbType.NVarChar, 50);
param.Value = Name;
int n = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, param));
if (n > 0)
{
cn.Close();
throw new Exception("规则名称重复");
}
SqlTransaction Trans = cn.BeginTransaction();
try
{
Sql = "update " + Pre + "Collect_Rule set RuleName=@RuleName,OldContent=@OldContent,ReContent=@ReContent,IgnoreCase=@IgnoreCase where ChannelID='" + Current.SiteID + "' and ID=" + RuleID;
SqlParameter[] parm = new SqlParameter[4];
parm[0] = new SqlParameter("@RuleName", SqlDbType.NVarChar, 50);
parm[0].Value = Name;
parm[1] = new SqlParameter("@OldContent", SqlDbType.NVarChar, 100);
parm[1].Value = OldStr;
parm[2] = new SqlParameter("@ReContent", SqlDbType.NVarChar, 100);
parm[2].Value = NewStr;
parm[3] = new SqlParameter("@IgnoreCase", SqlDbType.Bit);
parm[3].Value = IgnoreCase;
DbHelper.ExecuteNonQuery(Trans, CommandType.Text, Sql, parm);
Sql = "delete from " + Pre + "Collect_RuleApply where RuleID=" + RuleID;
DbHelper.ExecuteNonQuery(Trans, CommandType.Text, Sql, null);
if (AppSites != null && AppSites.Length > 0)
{
foreach (int stid in AppSites)
{
Sql = "delete from " + Pre + "Collect_RuleApply where SiteID=" + stid;
DbHelper.ExecuteNonQuery(Trans, CommandType.Text, Sql, null);
Sql = "insert into " + Pre + "Collect_RuleApply(SiteID,RuleID,RefreshTime) values (" + stid + "," + RuleID + ",'" + DateTime.Now + "')";
DbHelper.ExecuteNonQuery(Trans, CommandType.Text, Sql, null);
}
}
Trans.Commit();
}
catch
{
Trans.Rollback();
throw;
}
finally
{
if (cn != null && cn.State == ConnectionState.Open)
cn.Close();
}
}
public DataTable GetRule(int id)
{
string Sql = "select * from " + Pre + "Collect_Rule where ChannelID='" + Current.SiteID + "' and ID=" + id;
return DbHelper.ExecuteTable(DBConfig.CollectConString, CommandType.Text, Sql, null);
}
public DataTable SiteList()
{
string Sql = "select a.id,SiteName,RuleID from " + Pre + "Collect_Site a left outer join " + Pre + "Collect_RuleApply b on a.ID = b.SiteID where a.ChannelID='" + Current.SiteID + "'";
return DbHelper.ExecuteTable(DBConfig.CollectConString, CommandType.Text, Sql, null);
}
public string NewsAdd(CollectNewsInfo newsinfo)
{
string Sql = "insert into " + Pre + "Collect_News ([Title],[Links],[Author],[Source],[Content],[AddDate],[ImagesCount],[SiteID],[History],[ReviewTF],[CollectTime],[ChannelID],[ClassID]) values (";
Sql += "@Title,@Links,@Author,@Source,@Content,@AddDate,0,@SiteID,0,0,'" + DateTime.Now + "','1',@ClassID)select @@IDENTITY";
//DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, Sql, GetNewsParams(newsinfo));
object id = DbHelper.ExecuteScalar(DBConfig.CollectConString, CommandType.Text, Sql, GetNewsParams(newsinfo));
if (id != null) return id.ToString();
return "-1";
}
public bool TitleExist(string title)
{
string Sql = "select count(id) from " + Pre + "Collect_News where Title=@Title";
SqlParameter Param = new SqlParameter("@Title", title);
int n = Convert.ToInt32(DbHelper.ExecuteScalar(DBConfig.CollectConString, CommandType.Text, Sql, Param));
if (n > 0)
return true;
else
return false;
}
public DataTable GetNewsPage(int PageIndex, int PageSize, out int RecordCount, out int PageCount)
{
return DbHelper.ExecutePage(DBConfig.CollectConString, "a.ID,Title,AddDate,SiteName,History,CollectTime", Pre + "Collect_News a left join " + Pre + "Collect_Site b on a.SiteID=b.ID where a.ChannelID='" + Current.SiteID + "'", "a.ID", "Order by History asc,a.ID desc", PageIndex, PageSize, out RecordCount, out PageCount, null);
}
public void NewsDelete(string id)
{
string Sql = "";
try
{
Sql = "Delete from " + Pre + "Collect_News where ChannelID='" + Current.SiteID + "'";
}
catch (Exception e)
{
Sql = "Delete from " + Pre + "Collect_News where ChannelID='1'";
}
if (id.Equals("0"))
Sql += " and History=1";
else
Sql += " and ID in (" + id + ")";
DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, Sql, null);
}
public int myContentDelete(string ruleid)
{
string Sql = "";
try
{
Sql = "Delete from " + Pre + "Collect_News where ChannelID='" + Current.SiteID + "'";
}
catch (Exception e)
{
Sql = "Delete from " + Pre + "Collect_News where ChannelID='1'";
}
Sql += " and SiteID =" + ruleid;
return DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, Sql, null);
}
public CollectNewsInfo GetNews(int id)
{
CollectNewsInfo info = new CollectNewsInfo();
string Sql = "select [Title],[Links],[SiteID],[Author],[Source],[AddDate],[Content],[CollectTime],[ClassID] from " + Pre + "Collect_News where ChannelID='" + Current.SiteID + "' and ID=" + id;
IDataReader rd = DbHelper.ExecuteReader(DBConfig.CollectConString, CommandType.Text, Sql, null);
if (rd.Read())
{
info.Title = rd.GetString(0);
info.Links = rd.GetString(1);
info.SiteID = rd.GetInt32(2);
if (!rd.IsDBNull(3)) info.Author = rd.GetString(3);
if (!rd.IsDBNull(4)) info.Source = rd.GetString(4);
if (!rd.IsDBNull(5)) info.AddDate = rd.GetDateTime(5);
if (!rd.IsDBNull(6)) info.Content = rd.GetString(6);
info.CollectTime = rd.GetDateTime(7);
info.ClassID = rd.GetString(8);
}
rd.Close();
return info;
}
public void NewsUpdate(int id, CollectNewsInfo info)
{
string Sql = "update " + Pre + "Collect_News set [Title]=@Title,[Links]=@Links,[SiteID]=@SiteID,[Author]=@Author";
Sql += ",[Source]=@Source,[AddDate]=@AddDate,[Content]=@Content,[ClassID]=@ClassID where ChannelID='" + Current.SiteID + "' and ID=" + id;
DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, Sql, GetNewsParams(info));
}
private SqlParameter[] GetNewsParams(CollectNewsInfo info)
{
SqlParameter[] param = new SqlParameter[8];
param[0] = new SqlParameter("@Title", SqlDbType.NVarChar, 100);
param[0].Value = info.Title;
param[1] = new SqlParameter("@Links", SqlDbType.NVarChar, 200);
param[1].Value = info.Links;
param[2] = new SqlParameter("@Author", SqlDbType.NVarChar, 100);
param[2].Value = info.Author==null ? DBNull.Value : (object)info.Author;
param[3] = new SqlParameter("@Source", SqlDbType.NVarChar, 100);
param[3].Value = info.Source == null ? DBNull.Value : (object)info.Source;
param[4] = new SqlParameter("@Content", SqlDbType.NText);
param[4].Value = info.Content;
param[5] = new SqlParameter("@AddDate", SqlDbType.DateTime);
param[5].Value = info.AddDate.Year < 1753 ? DBNull.Value : (object)info.AddDate;
param[6] = new SqlParameter("@SiteID", SqlDbType.Int);
param[6].Value = info.SiteID;
param[7] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 12);
param[7].Value = info.ClassID;
return param;
}
#region 新闻入库
///////////////////////////新闻入库专用///////////////////////////////////////
private SqlConnection connetion;
private SqlConnection connetcms;
private int nStoreSucceed = 0;
private int nStoreFailed = 0;
public void StoreNews(bool UnStore, int[] id, out int nSucceed, out int nFailed)
{
nSucceed = 0;
nFailed = 0;
connetion = new SqlConnection(DBConfig.CollectConString);
connetcms = new SqlConnection(DBConfig.CmsConString);
string Sql = "select a.ID,a.Title,a.Links,a.Author,a.Source,a.Content,a.AddDate,a.RecTF,a.TodayNewsTF,a.MarqueeNews";
Sql += ",a.SBSNews,a.ReviewTF,a.ClassID,b.Audit,b.ID as CID,b.sitename as sitename from " + Pre + "Collect_News a inner join " + Pre + "Collect_Site b";
//Sql += " on a.ChannelID=b.ID where a.ChannelID='" + Current.SiteID + "'";
Sql += " on a.SiteID=b.ID where a.ChannelID='1'";
try
{
connetion.Open();
connetcms.Open();
if (UnStore)
{
Sql += " and History=0";
}
else
{
string strid = "";
for (int i = 0; i < id.Length; i++)
{
if (i > 0)
strid += ",";
strid += id[i].ToString();
}
Sql += " and a.id in (" + strid + ")";
}
Sql += "order by a.collecttime";
StoreBookBySQL(Sql);//////////
nSucceed = nStoreSucceed;
nFailed = nStoreFailed;
}
finally
{
StoreEnd();
}
}
private void StoreStep(string Sql)
{
DataTable dt = DbHelper.ExecuteTable(connetion, CommandType.Text, Sql, null);
CollectNewsInfo Info = new CollectNewsInfo();
foreach (DataRow r in dt.Rows)
{
try
{
int id = Convert.ToInt32(r["id"]);
string pname = r["Title"].ToString();
string bookid = r["ClassID"].ToString();
string mycontent = r["Content"].ToString();
string cid = r["cid"].ToString();
#region 注释
/*
string sAuthor = "";
if (r["Author"] != DBNull.Value) sAuthor = r["Author"].ToString();
string sSource = "";
if (r["Source"] != DBNull.Value) sSource = r["Source"].ToString();
DateTime dtAddDate = DateTime.Now;
if (r["AddDate"] != DBNull.Value) dtAddDate = (DateTime)r["AddDate"];
IsAudit = (int)r["Audit"];
string CheckSate = "3|1|1|1";
int IsLock = 1;
switch (IsAudit)
{
case 0:
CheckSate = "0|0|0|0";
IsLock = 0;
break;
case 1:
CheckSate = "1|1|0|0";
break;
case 2:
CheckSate = "2|1|1|0";
break;
}
#region 取新闻的默认值选项
#region 用于保存新闻的变量
string NewsPathRule = string.Empty;
string NewsFileRule = string.Empty;
byte isDelPoint = 0;
int Gpoint = 0;
int iPoint = 0;
string GroupNumber = string.Empty;
string FileExName = ".html";
string DataLib = Pre + "news";
string Temp = string.Empty;
string ClassEname = string.Empty;
#endregion 用于保存新闻的变量
Sql = "select NewsSavePath,NewsFileRule,isDelPoint,Gpoint,iPoint,GroupNumber,FileName,DataLib,ReadNewsTemplet,ClassEName";
Sql += " from " + Pre + "news_Class where ClassID='" + sClass + "'";
IDataReader rd = DbHelper.ExecuteReader(connetcms, CommandType.Text, Sql, null);
if (rd.Read())
{
#region 赋值
ClassEname = rd["ClassEName"].ToString();
if (rd["NewsSavePath"] != DBNull.Value)
NewsPathRule = rd["NewsSavePath"].ToString();
if (rd["NewsFileRule"] != DBNull.Value)
NewsFileRule = rd["NewsFileRule"].ToString();
if (rd["isDelPoint"] != DBNull.Value)
isDelPoint = Convert.ToByte(rd["isDelPoint"]);
if (rd["Gpoint"] != DBNull.Value)
Gpoint = Convert.ToInt32(rd["Gpoint"]);
if (rd["iPoint"] != DBNull.Value)
iPoint = Convert.ToInt32(rd["iPoint"]);
if (rd["GroupNumber"] != DBNull.Value)
GroupNumber = rd["GroupNumber"].ToString();
if (rd["FileName"] != DBNull.Value)
FileExName = rd["FileName"].ToString();
if (rd["DataLib"] != DBNull.Value)
DataLib = rd["DataLib"].ToString();
if (rd["ReadNewsTemplet"] != DBNull.Value)
Temp = rd["ReadNewsTemplet"].ToString();
#endregion 赋值
}
rd.Close();
#region 保存的文件名等的计算
string SavePath = ExChangeRule(NewsPathRule, sClass, ClassEname, AID);
string FileName = "";
ContentManage ct = new ContentManage();
DataTable ta = ct.sel_newsInfo(1);
if (ta != null && ta.Rows.Count > 0)
{
FileName = ta.Rows[0]["SaveNewsFilePath"].ToString();
}
if (FileName == "{@TitleName}")
{
FileName = NetCMS.Common.Public.ConvertE(sTitle);
}
else
{
FileName = ExChangeRule(FileName, sClass, ClassEname, AID);
}
string NewsID = NetCMS.Common.Rand.Number(12);
if (FileName == string.Empty)
FileName = NetCMS.Common.Rand.Number(12);
//while (Convert.ToInt32(DbHelper.ExecuteScalar(connetcms, CommandType.Text, "select count(ID) from " + Pre + "news where NewsID='" + NewsID + "' or FileName='" + FileName + "'", null)) > 0)
//{
// NewsID = NetCMS.Common.Rand.Number(12, true);
// //FileName = FileName + "_" + NetCMS.Common.Rand.Number(3, true);
//}
#endregion
#endregion 取新闻的默认值选项
Sql = "insert into " + Pre + "news (";
Sql += "[NewsID],[NewsType],[NewsTitle],[TitleITF],[URLaddress],[ClassID],[NewsPicTopline],[Author],[Souce],[Templet],[Content],";
Sql += "[CreatTime],[isLock],[SiteID],[Editor],[CheckStat],[NewsProperty],[Click],[FileName],[FileEXName],[isDelPoint],[Gpoint],";
Sql += "[iPoint],[GroupNumber],[ContentPicTF],[CommTF],[DiscussTF],[TopNum],[VoteTF],[isRecyle],[DataLib],[isVoteTF],[SavePath],";
Sql += "[isHtml],[isConstr],[Tags]";
Sql += ") values (";
Sql += "@NewsID,@NewsType,@NewsTitle,0,@URLaddress,@ClassID,0,@Author,@Souce,@Templet,@Content,";
Sql += "@CreatTime,@IsLock,@SiteID,@Editor,@CheckStat,@NewsProperty,0,@FileName,@FileEXName,@isDelPoint,@Gpoint,";
Sql += "@iPoint,@GroupNumber,0,1,0,0,0,0,@DataLib,0,@SavePath,";
Sql += "0,0,@Tags)";
*/
#endregion
Sql = "insert into chapter (";
Sql += "[pname],[bookid],[status],[addtime],[edittime],orderby)";
Sql += " select ";
Sql += "@pname,@bookid,0,getdate(),getdate(),max(pid)+1 from chapter ;select @@IDENTITY as newid;";
//'" + FileName + "','.html',0,0,0,0,1,1,0,1,0,'"+ Pre +"'News',0,0,0)";
SqlParameter[] parms = {
new SqlParameter("@pname",pname),
new SqlParameter("@bookid",bookid)
};
int pid = int.Parse(DbHelper.ExecuteScalar(connetcms, CommandType.Text, Sql, parms).ToString());//返回的pid,作为TContent内容表的pid
string strInsertTContent = "insert into TContent(pid,content) values(@pid,@mycontent)";
SqlParameter[] parms1 = {
new SqlParameter("@pid",pid),
new SqlParameter("@mycontent",mycontent.Replace("'", "''"))
};
DbHelper.ExecuteNonQuery(connetion, CommandType.Text, strInsertTContent, parms1);
//ExecuteScalar
//if (nStoreSucceed + 1 == dt.Rows.Count)//最后一条,修改入库总数,修改最新更新和最新章节
Sql = "update " + Pre + "Collect_Site set cjcount=cjcount+@cjcount,needcount=needcount-@needcount where classid = " + bookid;
SqlParameter[] parms2 = {
new SqlParameter("@cjcount",1),//增加入库数
new SqlParameter("@needcount",1)//减去需要采的数
};
DbHelper.ExecuteNonQuery(connetion, CommandType.Text, Sql, parms2);
Sql = "update book set edittime=getdate(),topchapter=@pid where bid=" + bookid;
SqlParameter[] parms3 = {
new SqlParameter("@pid",pid)
};
DbHelper.ExecuteNonQuery(connetion, CommandType.Text, Sql, parms3);
Sql = "update " + Pre + "Collect_News set History=1 where ID=" + id;
DbHelper.ExecuteNonQuery(connetion, CommandType.Text, Sql, null);
nStoreSucceed++;
}
catch(Exception err)
{
//错误日志,入库的时候
NetCMS.Common.Public.saveLogFiles(0,"collect","入库的时候失败",err.Message);
nStoreFailed++;
}
}
dt.Clear();
dt.Dispose();
}
private void StoreEnd()
{
if (connetion != null && connetion.State == ConnectionState.Open)
connetion.Close();
if (connetcms != null && connetcms.State == ConnectionState.Open)
connetcms.Close();
}
public void StoreOne(string newid)
{
string Sql = "select a.ID,a.Title,a.Links,a.Author,a.Source,a.Content,a.AddDate,a.RecTF,a.TodayNewsTF,a.MarqueeNews";
Sql += ",a.SBSNews,a.ReviewTF,a.ClassID,b.Audit,b.ID as CID from " + Pre + "Collect_News a inner join " + Pre + "Collect_Site b";
//Sql += " on a.ChannelID=b.ID where a.ChannelID='" + Current.SiteID + "'";
Sql += " on a.SiteID=b.ID where a.ChannelID='1' and a.id="+newid;
SqlConnection connetion = new SqlConnection(DBConfig.CollectConString);
SqlConnection connetcms = new SqlConnection(DBConfig.CmsConString);
DataTable dt = DbHelper.ExecuteTable(connetion, CommandType.Text, Sql, null);
CollectNewsInfo Info = new CollectNewsInfo();
foreach (DataRow r in dt.Rows)
{
try
{
int id = Convert.ToInt32(r["id"]);
string pname = r["Title"].ToString();
string bookid = r["ClassID"].ToString();
string mycontent = r["Content"].ToString();
string cid = r["cid"].ToString();
Sql = "insert into chapter (";
Sql += "[pname],[bookid],[status],[addtime],[edittime],orderby)";
Sql += " select ";
Sql += "@pname,@bookid,0,getdate(),getdate(),max(pid)+1 from chapter ;select @@IDENTITY as newid;";
//'" + FileName + "','.html',0,0,0,0,1,1,0,1,0,'"+ Pre +"'News',0,0,0)";
SqlParameter[] parms = {
new SqlParameter("@pname",pname),
new SqlParameter("@bookid",bookid)
};
int pid = int.Parse(DbHelper.ExecuteScalar(connetcms, CommandType.Text, Sql, parms).ToString());//返回的pid,作为TContent内容表的pid
string strInsertTContent = "insert into TContent(pid,content) values(@pid,@mycontent)";
SqlParameter[] parms1 = {
new SqlParameter("@pid",pid),
new SqlParameter("@mycontent",mycontent.Replace("'", "''"))
};
DbHelper.ExecuteNonQuery(connetion, CommandType.Text, strInsertTContent, parms1);
//ExecuteScalar
//if (nStoreSucceed + 1 == dt.Rows.Count)//最后一条,修改入库总数,修改最新更新和最新章节
Sql = "update " + Pre + "Collect_Site set cjcount=cjcount+@cjcount,needcount=needcount-@needcount where classid = " + bookid;
SqlParameter[] parms2 = {
new SqlParameter("@cjcount",1),//增加入库数
new SqlParameter("@needcount",1)//减去需要采的数
};
DbHelper.ExecuteNonQuery(connetion, CommandType.Text, Sql, parms2);
Sql = "update book set edittime=getdate(),topchapter=@pid where bid=" + bookid;
SqlParameter[] parms3 = {
new SqlParameter("@pid",pid)
};
DbHelper.ExecuteNonQuery(connetion, CommandType.Text, Sql, parms3);
Sql = "update " + Pre + "Collect_News set History=1 where ID=" + id;
DbHelper.ExecuteNonQuery(connetion, CommandType.Text, Sql, null);
}
catch (Exception err)
{
//错误日志,入库的时候
NetCMS.Common.Public.saveLogFiles(0, "collect", "入库的时候失败", err.Message);
}
}
dt.Clear();
dt.Dispose();
if (connetion != null && connetion.State == ConnectionState.Open)
{
connetion.Close();
}
if (connetcms != null && connetcms.State == ConnectionState.Open)
{
connetcms.Close();
}
}
public void StoreOneBook(string newid,string title,string catalogid,string descript,string author,string link)
{
SqlConnection connetcms = new SqlConnection(DBConfig.CmsConString);
try
{
string Sql = "";
Sql = "insert into book (";
Sql += "[bname],[catalogid],[catalogname],descript,author,curl,publishtime,status,[addtime],[edittime])";
Sql += " select @bname,@catalogid,cname,@descript,@author,@curl,getdate(),-1,getdate(),getdate() from catalog where cid=@catalogid";
//'" + FileName + "','.html',0,0,0,0,1,1,0,1,0,'"+ Pre +"'News',0,0,0)";
SqlParameter[] parms = {
new SqlParameter("@bname",title),
new SqlParameter("@catalogid",catalogid),
new SqlParameter("@descript",descript),
new SqlParameter("@author",author),
new SqlParameter("@curl",link)
};
DbHelper.ExecuteNonQuery(connetcms, CommandType.Text, Sql, parms);
Sql = "update " + Pre + "Collect_News set History=1 where ID=" + newid;
DbHelper.ExecuteNonQuery(connetion, CommandType.Text, Sql, null);
nStoreSucceed++;
}
catch (Exception err)
{
nStoreFailed++;
//错误日志,入库的时候
NetCMS.Common.Public.saveLogFiles(0, "collect", "书籍入库的时候失败", err.Message);
}
if (connetcms != null && connetcms.State == ConnectionState.Open)
{
connetcms.Close();
}
}
/// <summary>
/// 手动挑选几个入库
/// </summary>
/// <param name="Sql"></param>
public void StoreBookBySQL(string Sql)
{
SqlConnection connetion = new SqlConnection(DBConfig.CollectConString);
SqlConnection connetcms = new SqlConnection(DBConfig.CmsConString);
DataTable dt = DbHelper.ExecuteTable(connetion, CommandType.Text, Sql, null);
CollectNewsInfo Info = new CollectNewsInfo();
foreach (DataRow r in dt.Rows)
{
try
{
xfCreateTopic(r);
//xfCreatePost(r);
Sql = "update " + Pre + "Collect_News set History=1 where ID=" + r["id"].ToString();
DbHelper.ExecuteNonQuery(connetion, CommandType.Text, Sql, null);
nStoreSucceed++;
}
catch (Exception err)
{
nStoreFailed++;
//错误日志,入库的时候
NetCMS.Common.Public.saveLogFiles(0, "collect", "入库的时候失败", err.Message);
}
}
dt.Clear();
dt.Dispose();
if (connetion != null && connetion.State == ConnectionState.Open)
{
connetion.Close();
}
if (connetcms != null && connetcms.State == ConnectionState.Open)
{
connetcms.Close();
}
}
public void StoreOne22(string newid)
{
string Sql = "select a.ID,a.Title,a.Links,a.Author,a.Source,a.Content,a.AddDate,a.RecTF,a.TodayNewsTF,a.MarqueeNews";
Sql += ",a.SBSNews,a.ReviewTF,a.ClassID,b.Audit,b.ID as CID from " + Pre + "Collect_News a inner join " + Pre + "Collect_Site b";
//Sql += " on a.ChannelID=b.ID where a.ChannelID='" + Current.SiteID + "'";
Sql += " on a.SiteID=b.ID where a.ChannelID='1' and a.id=" + newid;
SqlConnection connetion = new SqlConnection(DBConfig.CollectConString);
SqlConnection connetcms = new SqlConnection(DBConfig.CmsConString);
DataTable dt = DbHelper.ExecuteTable(connetion, CommandType.Text, Sql, null);
CollectNewsInfo Info = new CollectNewsInfo();
foreach (DataRow r in dt.Rows)
{
try
{
Sql = "insert into book (";
Sql += "[bname],[catalogid],[catalogname],descript,author,curl,publishtime,status,[addtime],[edittime])";
Sql += " select @bname,@catalogid,cname,@descript,@author,@curl,getdate(),-1,getdate(),getdate() from catalog where cid=@catalogid";
//'" + FileName + "','.html',0,0,0,0,1,1,0,1,0,'"+ Pre +"'News',0,0,0)";
SqlParameter[] parms = {
new SqlParameter("@bname",r["Title"].ToString()),
new SqlParameter("@catalogid",r["ClassID"].ToString()),
new SqlParameter("@descript",r["Content"].ToString()),
new SqlParameter("@author",r["author"].ToString()),
new SqlParameter("@curl",r["links"].ToString())
};
DbHelper.ExecuteNonQuery(connetcms, CommandType.Text, Sql, parms);
Sql = "update " + Pre + "Collect_News set History=1 where ID=" + newid;
DbHelper.ExecuteNonQuery(connetion, CommandType.Text, Sql, null);
nStoreSucceed++;
}
catch (Exception err)
{
nStoreFailed++;
//错误日志,入库的时候
NetCMS.Common.Public.saveLogFiles(0, "collect", "入库的时候失败", err.Message);
}
}
dt.Clear();
dt.Dispose();
if (connetion != null && connetion.State == ConnectionState.Open)
{
connetion.Close();
}
if (connetcms != null && connetcms.State == ConnectionState.Open)
{
connetcms.Close();
}
}
private string ExChangeRule(string RuleStr, string classid, string classename, int autoid)
{
string RetVal = string.Empty;
if (RuleStr != null && RuleStr != string.Empty)
{
RetVal = RuleStr;
DateTime Now = DateTime.Now;
RetVal = Regex.Replace(RetVal, @"\{\@year02\}", Now.Year.ToString().Substring(2, 2), RegexOptions.Compiled | RegexOptions.IgnoreCase);
RetVal = Regex.Replace(RetVal, @"\{\@year04\}", Now.Year.ToString(), RegexOptions.Compiled | RegexOptions.IgnoreCase);
RetVal = Regex.Replace(RetVal, @"\{\@month\}", Now.Month.ToString(), RegexOptions.Compiled | RegexOptions.IgnoreCase);
RetVal = Regex.Replace(RetVal, @"\{\@day\}", Now.Day.ToString(), RegexOptions.Compiled | RegexOptions.IgnoreCase);
RetVal = Regex.Replace(RetVal, @"\{\@hour\}", Now.Hour.ToString(), RegexOptions.Compiled | RegexOptions.IgnoreCase);
RetVal = Regex.Replace(RetVal, @"\{\@minute\}", Now.Minute.ToString(), RegexOptions.Compiled | RegexOptions.IgnoreCase);
RetVal = Regex.Replace(RetVal, @"\{\@second\}", Now.Second.ToString(), RegexOptions.Compiled | RegexOptions.IgnoreCase);
RetVal = Regex.Replace(RetVal, @"\{\@ClassId\}", classid, RegexOptions.Compiled | RegexOptions.IgnoreCase);
RetVal = Regex.Replace(RetVal, @"\{\@EName\}", classename, RegexOptions.Compiled | RegexOptions.IgnoreCase);
Regex reg = new Regex(@"\{\@Ram(?<m>\d+)_(?<n>\d+)\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
Match match = reg.Match(RetVal);
while (match.Success)
{
int m = Convert.ToInt32(match.Groups["m"].Value);
int n = Convert.ToInt32(match.Groups["n"].Value);
string s = match.Value;
string rnd = string.Empty;
switch (n)
{
case 0:
rnd = NetCMS.Common.Rand.Number(m);
break;
case 1:
rnd = NetCMS.Common.Rand.Str_char(m);
break;
case 2:
rnd = NetCMS.Common.Rand.Str(m);
break;
}
RetVal = RetVal.Replace(s, rnd);
match = reg.Match(RetVal);
}
RetVal = Regex.Replace(RetVal, @"\{\@自动编号ID\}", autoid.ToString(), RegexOptions.Compiled | RegexOptions.IgnoreCase);
}
return RetVal;
}
#endregion 新闻入库
/// <summary>
/// 修改并同时删除cjqueue中的记录
/// </summary>
/// <param name="ruleid"></param>
/// <returns></returns>
public int myCJAutoUpdate(int ruleid)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
string Sql = "update " + Pre + "Collect_Site set cjstate=(case when cjstate=0 then 1 else (case when cjstate=1 then 2 else 0 end) end) where ID=" + ruleid;
int i = DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, null);
DelAutoCollectRules();
GetAutoCollectRules();
cn.Close();
return i;
}
/// <summary>
/// 设置采集状态
/// </summary>
/// <param name="ruleid"></param>
/// <param name="cjstate"></param>
/// <returns></returns>
public int myCJStateUpdate(int ruleid,int cjstate)
{
SqlConnection cn = new SqlConnection(DBConfig.CollectConString);
cn.Open();
string Sql = "update " + Pre + "Collect_Site set cjstate=2 where ID=" + ruleid;
int i = DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, null);
cn.Close();
return i;
}
public int DelAutoCollectRules()
{
string sql = "delete from cjqueue where ruleid in(";
sql += "select ID from NT_Collect_Site where ChannelID='1' and cjstate=0)";
return DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, sql, null);
}
/// <summary>
/// 创建主题
/// </summary>
private void xfCreateTopic(DataRow r)
{
string Sql = "";
Discuz.Entity.TopicInfo topicInfo = new Discuz.Entity.TopicInfo();
//需要获取 fid=classid,title,content,
topicInfo.Fid = int.Parse(r["classid"].ToString());
topicInfo.Iconid = 0;
topicInfo.Title = r["Title"].ToString();
topicInfo.Typeid = 0;
topicInfo.Price = 0;
topicInfo.Poster = "一抹残阳";
topicInfo.Posterid = 2;
topicInfo.Postdatetime = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
topicInfo.Lastpost = topicInfo.Postdatetime;
topicInfo.Lastpostid = 2;
topicInfo.Lastposter = "一抹残阳";
topicInfo.Views = 0;
topicInfo.Replies = 0;
topicInfo.Displayorder = 0;
topicInfo.Highlight = "";
topicInfo.Digest = 0;
topicInfo.Rate = 0;
topicInfo.Hide = 0;
topicInfo.Attachment = 0;
topicInfo.Moderated = 0;
topicInfo.Closed = 0;
topicInfo.Magic = 0;
topicInfo.Special = 0;
topicInfo.Attention = 0;
//'" + FileName + "','.html',0,0,0,0,1,1,0,1,0,'"+ Pre +"'News',0,0,0)";
SqlParameter[] parms = {
new SqlParameter("@fid",topicInfo.Fid),
new SqlParameter("@iconid",topicInfo.Iconid),
new SqlParameter("@title",topicInfo.Title),
new SqlParameter("@typeid",topicInfo.Typeid),
new SqlParameter("@readperm",topicInfo.Readperm),
new SqlParameter("@price", topicInfo.Price),
new SqlParameter("@poster",topicInfo.Poster),
new SqlParameter("@posterid",topicInfo.Posterid),
new SqlParameter("@postdatetime",DateTime.Parse(topicInfo.Postdatetime)),
new SqlParameter("@lastpost",topicInfo.Lastpost),
//new SqlParameter("@lastpostid",topicInfo.Lastpostid),
new SqlParameter("@lastposter",topicInfo.Lastposter),
new SqlParameter("@views",topicInfo.Views),
new SqlParameter("@replies",topicInfo.Replies),
new SqlParameter("@displayorder",topicInfo.Displayorder),
new SqlParameter("@highlight",topicInfo.Highlight),
new SqlParameter("@digest",topicInfo.Digest),
new SqlParameter("@rate",topicInfo.Rate),
new SqlParameter("@hide",topicInfo.Hide),
new SqlParameter("@attachment",topicInfo.Attachment),
new SqlParameter("@moderated",topicInfo.Moderated),
new SqlParameter("@closed",topicInfo.Closed),
new SqlParameter("@magic",topicInfo.Magic),
new SqlParameter("@special",topicInfo.Special),
new SqlParameter("@attention",topicInfo.Attention)
};
Sql = "insert into dnt_topics ([fid],[iconid],[title],typeid,readperm,price,poster,posterid,[postdatetime],[lastpost],lastpostid,lastposter,"+
"views,replies,displayorder,digest,rate,hide,attachment,moderated,closed,magic,special,attention)";
Sql += " select top 1 @fid,@iconid,@title,@typeid,@readperm,@price,@poster,@posterid,@postdatetime,@lastpost,0,@lastposter," +
"@views,@replies,@displayorder,@digest,@rate,@hide,@attachment,@moderated,@closed,@magic,@special,@attention from dnt_topics;select @@IDENTITY as newid; ";
int tid = int.Parse(DbHelper.ExecuteScalar(DBConfig.CollectConString, CommandType.Text, Sql, parms).ToString());
topicInfo.Tid = tid;
StringBuilder sb1 = new StringBuilder();
sb1.Append("UPDATE [dnt_statistics] SET [totaltopic]=[totaltopic] + 1");
DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, sb1.ToString(), null);
sb1.Remove(0, sb1.Length);
sb1.Append("UPDATE [dnt_forums] SET [topics] = [topics] + 1,[curtopics] = [curtopics] + 1 WHERE [fid] = " + topicInfo.Fid);
DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, sb1.ToString(), null);
sb1.Remove(0, sb1.Length);
sb1.Append("INSERT INTO [dnt_mytopics]([tid],[uid],[dateline]) VALUES(@topicid, @posterid, @postdatetime)");
SqlParameter[] p1 = {
new SqlParameter("@topicid",topicInfo.Tid),
new SqlParameter("@posterid",topicInfo.Posterid),
new SqlParameter("@postdatetime",DateTime.Parse(topicInfo.Postdatetime))
};
DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, sb1.ToString(), p1);
xfCreatePost(topicInfo,r["content"].ToString());
}
/// <summary>
/// 创建帖子
/// </summary>
private void xfCreatePost(Discuz.Entity.TopicInfo topicinfo,string content)
{
Discuz.Entity.PostInfo postInfo = new Discuz.Entity.PostInfo();
postInfo.Fid = topicinfo.Fid;
postInfo.Tid = topicinfo.Tid;
postInfo.Parentid = 0;
postInfo.Poster = topicinfo.Poster;
postInfo.Posterid = topicinfo.Posterid;
postInfo.Title = topicinfo.Title;
postInfo.Topictitle = topicinfo.Title;
postInfo.Postdatetime = topicinfo.Postdatetime;
postInfo.Message = content;
postInfo.Ip = "127.0.0.1";
postInfo.Lastedit = topicinfo.Postdatetime;
postInfo.Usesig = 1;
postInfo.Invisible = 0;
postInfo.Htmlon = 1;
postInfo.Smileyoff = 1;
postInfo.Bbcodeoff = 1;
postInfo.Parseurloff = 1;
postInfo.Attachment = 0;
postInfo.Rate = 0;
postInfo.Ratetimes = 0;
StringBuilder sb1 = new StringBuilder();
sb1.Append("DELETE FROM [dnt_postid] WHERE DATEDIFF(n, postdatetime, GETDATE()) >5");
DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, sb1.ToString(), null);
sb1.Remove(0, sb1.Length);
sb1.Append("INSERT INTO [dnt_postid] ([postdatetime]) VALUES(GETDATE());select @@IDENTITY as newid;");
int postid = int.Parse(DbHelper.ExecuteScalar(DBConfig.CollectConString, CommandType.Text, sb1.ToString(), null).ToString());
postInfo.Pid = postid;
SqlParameter[] parms = {
new SqlParameter("@pid",postInfo.Pid),
new SqlParameter("@fid",postInfo.Fid),
new SqlParameter("@tid",postInfo.Tid),
new SqlParameter("@parentid",postInfo.Parentid),
new SqlParameter("@layer",postInfo.Layer),
new SqlParameter("@poster",postInfo.Poster),
new SqlParameter("@posterid",postInfo.Posterid),
new SqlParameter("@title",postInfo.Title),
//new SqlParameter("@topictitle",postInfo.Topictitle),
new SqlParameter("@postdatetime", DateTime.Parse(postInfo.Postdatetime)),
new SqlParameter("@message",postInfo.Message),
new SqlParameter("@ip",postInfo.Ip),
new SqlParameter("@lastedit",postInfo.Lastedit),
new SqlParameter("@invisible",postInfo.Invisible),
new SqlParameter("@usesig",postInfo.Usesig),
new SqlParameter("@htmlon",postInfo.Htmlon),
new SqlParameter("@smileyoff",postInfo.Smileyoff),
new SqlParameter("@bbcodeoff",postInfo.Bbcodeoff),
new SqlParameter("@parseurloff",postInfo.Parseurloff),
new SqlParameter("@attachment",postInfo.Attachment),
new SqlParameter("@rate",postInfo.Rate),
new SqlParameter("@ratetimes",postInfo.Ratetimes)
};
string Sql = "";
Sql = "insert into dnt_posts1 (pid,[fid],tid,parentid,layer,poster,posterid,title,postdatetime,message,ip,lastedit,invisible,usesig,htmlon,smileyoff,bbcodeoff,parseurloff" +
",attachment,rate,ratetimes)";
Sql += " select top 1 @pid,@fid,@tid,@parentid,@layer,@poster,@posterid,@title,@postdatetime,@message,@ip,@lastedit,@invisible,@usesig,@htmlon,@smileyoff,@bbcodeoff,@parseurloff" +
",@attachment,@rate,@ratetimes from dnt_posts1";
DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, Sql, parms);
string fidlist = AddParentForumCount(postInfo.Fid);
sb1.Remove(0, sb1.Length);
sb1.Append("UPDATE [dnt_statistics] SET [totalpost]=[totalpost] + 1");
DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, sb1.ToString(), null);
sb1.Remove(0, sb1.Length);
sb1.Append("UPDATE [dnt_forums] SET [posts]=[posts] + 1,[todayposts]=CASE WHEN DATEDIFF(day, [lastpost], GETDATE())=0 THEN [todayposts] + 1 ELSE 1 END,");
sb1.Append("[lasttid]=@tid,[lasttitle]=@topictitle,[lastpost]=@postdatetime,[lastposter]=@poster,[lastposterid]=@posterid ");
sb1.Append(" WHERE fid IN (SELECT [item] FROM [dnt_split](@fidlist, ','))");
SqlParameter[] param1 = {
new SqlParameter("@tid",postInfo.Tid),new SqlParameter("@topictitle",postInfo.Title),new SqlParameter("@postdatetime",postInfo.Postdatetime),new SqlParameter("@poster",postInfo.Poster),
new SqlParameter("@posterid",postInfo.Posterid),new SqlParameter("@fidlist",fidlist)
};
DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, sb1.ToString(), param1);
sb1.Remove(0, sb1.Length);
sb1.Append("UPDATE [dnt_users] SET [lastpost] = @postdatetime, [lastpostid] = @postid, [lastposttitle] = @title, [posts] = [posts] + 1, ");
sb1.Append("[lastactivity] = GETDATE() WHERE [uid] = @posterid ");
SqlParameter[] param2 = {
new SqlParameter("@postdatetime",postInfo.Postdatetime),new SqlParameter("@postid",postInfo.Pid),new SqlParameter("@title",postInfo.Title),
new SqlParameter("@posterid",postInfo.Posterid)
};
DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, sb1.ToString(), param2);
sb1.Remove(0, sb1.Length);
sb1.Append("UPDATE [dnt_topics] SET [lastpostid]="+postInfo.Pid+" WHERE [tid]="+postInfo.Tid);
DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, sb1.ToString(), null);
sb1.Remove(0, sb1.Length);
sb1.Append("INSERT [dnt_myposts]([uid], [tid], [pid], [dateline]) VALUES(@posterid, @tid, @postid, @postdatetime)");
SqlParameter[] param3 = {
new SqlParameter("@posterid",postInfo.Posterid),new SqlParameter("@tid",postInfo.Tid),new SqlParameter("@postid",postInfo.Pid),
new SqlParameter("@postdatetime",postInfo.Postdatetime)
};
DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, sb1.ToString(), param3);
}
///////////////////////////////////////
public ForumInfo GetForumInfo(int fid, bool clone)
{
if (fid < 1)
return null;
List<ForumInfo> forumList = GetForumList();
if (forumList == null)
return null;
foreach (ForumInfo foruminfo in forumList)
{
if (foruminfo.Fid == fid)
{
foruminfo.Pathlist = foruminfo.Pathlist.Replace("a><a", "a> » <a");
return clone ? foruminfo.Clone() : foruminfo;
}
}
return null;
}
public List<ForumInfo> GetForumList()
{
List<ForumInfo> forumlist = new List<ForumInfo>();
DataTable dt = GetForumsTable();
if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
ForumInfo forum = new ForumInfo();
forum.Fid = TypeConverter.StrToInt(dr["fid"].ToString(), 0);
forum.Parentid = TypeConverter.StrToInt(dr["parentid"].ToString(), 0);
forum.Layer = TypeConverter.StrToInt(dr["layer"].ToString(), 0);
forum.Pathlist = dr["pathlist"].ToString();
forum.Parentidlist = dr["parentidlist"].ToString();
forum.Subforumcount = TypeConverter.StrToInt(dr["subforumcount"].ToString(), 0);
forum.Name = dr["name"].ToString();
forum.Status = TypeConverter.StrToInt(dr["status"].ToString(), 0);
forum.Colcount = TypeConverter.StrToInt(dr["colcount"].ToString(), 0);
forum.Displayorder = TypeConverter.StrToInt(dr["displayorder"].ToString(), 0);
forum.Templateid = TypeConverter.StrToInt(dr["templateid"].ToString(), 0);
forum.Topics = TypeConverter.StrToInt(dr["topics"].ToString(), 0);
forum.CurrentTopics = TypeConverter.StrToInt(dr["curtopics"].ToString(), 0);
forum.Posts = TypeConverter.StrToInt(dr["posts"].ToString(), 0);
//当前版块的最后发帖日期为空,则表示今日发帖数为0
if (string.IsNullOrEmpty(dr["lastpost"].ToString()))
dr["todayposts"] = 0;
else
{
//当系统日期与最发发帖日期不同时,则表示今日发帖数为0
if (Convert.ToDateTime(dr["lastpost"]).ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd"))
dr["todayposts"] = 0;
}
forum.Todayposts = TypeConverter.StrToInt(dr["todayposts"].ToString(), 0);
forum.Lasttid = TypeConverter.StrToInt(dr["lasttid"].ToString(), 0);
forum.Lasttitle = dr["lasttitle"].ToString();
forum.Lastpost = dr["lastpost"].ToString();
forum.Lastposterid = TypeConverter.StrToInt(dr["lastposterid"].ToString(), 0);
forum.Lastposter = dr["lastposter"].ToString();
forum.Allowsmilies = TypeConverter.StrToInt(dr["allowsmilies"].ToString(), 0);
forum.Allowrss = TypeConverter.StrToInt(dr["allowrss"].ToString(), 0);
forum.Allowhtml = TypeConverter.StrToInt(dr["allowhtml"].ToString(), 0);
forum.Allowbbcode = TypeConverter.StrToInt(dr["allowbbcode"].ToString(), 0);
forum.Allowimgcode = TypeConverter.StrToInt(dr["allowimgcode"].ToString(), 0);
forum.Allowblog = TypeConverter.StrToInt(dr["allowblog"].ToString(), 0);
forum.Istrade = TypeConverter.StrToInt(dr["istrade"].ToString(), 0);
forum.Allowpostspecial = TypeConverter.StrToInt(dr["allowpostspecial"].ToString(), 0);
forum.Allowspecialonly = TypeConverter.StrToInt(dr["allowspecialonly"].ToString(), 0);
forum.Alloweditrules = TypeConverter.StrToInt(dr["alloweditrules"].ToString(), 0);
forum.Allowthumbnail = TypeConverter.StrToInt(dr["allowthumbnail"].ToString(), 0);
forum.Allowtag = TypeConverter.StrToInt(dr["allowtag"].ToString(), 0);
forum.Recyclebin = TypeConverter.StrToInt(dr["recyclebin"].ToString(), 0);
forum.Modnewposts = TypeConverter.StrToInt(dr["modnewposts"].ToString(), 0);
forum.Modnewtopics = TypeConverter.StrToInt(dr["modnewtopics"].ToString(), 0);
forum.Jammer = TypeConverter.StrToInt(dr["jammer"].ToString(), 0);
forum.Disablewatermark = TypeConverter.StrToInt(dr["disablewatermark"].ToString(), 0);
forum.Inheritedmod = TypeConverter.StrToInt(dr["inheritedmod"].ToString(), 0);
forum.Autoclose = TypeConverter.StrToInt(dr["autoclose"].ToString(), 0);
forum.Password = dr["password"].ToString();
forum.Icon = dr["icon"].ToString();
forum.Postcredits = dr["postcredits"].ToString();
forum.Replycredits = dr["replycredits"].ToString();
forum.Redirect = dr["redirect"].ToString();
forum.Attachextensions = dr["attachextensions"].ToString();
forum.Rules = dr["rules"].ToString();
forum.Topictypes = dr["topictypes"].ToString();
forum.Viewperm = dr["viewperm"].ToString();
forum.Postperm = dr["postperm"].ToString();
forum.Replyperm = dr["replyperm"].ToString();
forum.Getattachperm = dr["getattachperm"].ToString();
forum.Postattachperm = dr["postattachperm"].ToString();
forum.Moderators = dr["moderators"].ToString();
forum.Description = dr["description"].ToString();
forum.Applytopictype = TypeConverter.StrToInt(dr["applytopictype"] == DBNull.Value ? "0" : dr["applytopictype"].ToString(), 0);
forum.Postbytopictype = TypeConverter.StrToInt(dr["postbytopictype"] == DBNull.Value ? "0" : dr["postbytopictype"].ToString(), 0);
forum.Viewbytopictype = TypeConverter.StrToInt(dr["viewbytopictype"] == DBNull.Value ? "0" : dr["viewbytopictype"].ToString(), 0);
forum.Topictypeprefix = TypeConverter.StrToInt(dr["topictypeprefix"] == DBNull.Value ? "0" : dr["topictypeprefix"].ToString(), 0);
forum.Permuserlist = dr["permuserlist"].ToString();
forum.Seokeywords = dr["seokeywords"].ToString();
forum.Seodescription = dr["seodescription"].ToString();
forum.Rewritename = dr["rewritename"].ToString();
forumlist.Add(forum);
}
}
return forumlist;
}
DataTable GetForumsTable()
{
StringBuilder sql = new StringBuilder();
sql.Append(" SELECT [f].[fid],[f].[parentid],[f].[layer],[f].[pathlist],[f].[parentidlist],[f].[subforumcount],");
sql.Append("[f].[name],[f].[status],[f].[colcount],[f].[displayorder],[f].[templateid],[f].[topics],[f].[curtopics],");
sql.Append("[f].[posts],[f].[todayposts],[f].[lasttid],[f].[lasttitle],[f].[lastpost],[f].[lastposterid],");
sql.Append("[f].[lastposter],[f].[allowsmilies],[f].[allowrss],[f].[allowhtml],[f].[allowbbcode],");
sql.Append("[f].[allowimgcode],[f].[allowblog],[f].[istrade],[f].[allowpostspecial],[f].[allowspecialonly],");
sql.Append("[f].[alloweditrules],[f].[allowthumbnail],[f].[allowtag],[f].[recyclebin],[f].[modnewposts],");
sql.Append("[f].[modnewtopics],[f].[jammer],[f].[disablewatermark],[f].[inheritedmod],[f].[autoclose],");
sql.Append("[ff].[password],[ff].[icon],[ff].[postcredits],[ff].[replycredits],[ff].[redirect],");
sql.Append("[ff].[attachextensions],[ff].[rules],[ff].[topictypes],[ff].[viewperm],[ff].[postperm],");
sql.Append("[ff].[replyperm],[ff].[getattachperm],[ff].[postattachperm],[ff].[moderators],[ff].[description],");
sql.Append("[ff].[applytopictype],[ff].[postbytopictype],[ff].[viewbytopictype],[ff].[topictypeprefix],");
sql.Append("[ff].[permuserlist],[ff].[seokeywords],[ff].[seodescription],[ff].[rewritename] ");
sql.Append("FROM [dnt_forums] AS [f] LEFT JOIN [dnt_forumfields] AS [ff] ");
sql.Append("ON [f].[fid]=[ff].[fid] ORDER BY [f].[displayorder]");
return DbHelper.ExecuteTable(DBConfig.CollectConString, CommandType.Text, sql.ToString(), null);
}
private string AddParentForumCount(int forumid)
{
Discuz.Entity.ForumInfo forum = GetForumInfo(forumid, true);
try
{
StringBuilder sql = new StringBuilder();
sql.Append("UPDATE [dnt_forums] SET [topics] = [topics] + @topics WHERE [fid] IN (SELECT [item] FROM [dnt_split](@fpidlist, ','))");
SqlParameter[] parms = {
new SqlParameter("@topics",1),
new SqlParameter("@fpidlist",forum.Parentidlist)
};
DbHelper.ExecuteNonQuery(DBConfig.CollectConString, CommandType.Text, sql.ToString(), parms);
return forum.Parentidlist;
}
catch (Exception err)
{
NetCMS.Common.Public.saveLogFiles(0, "AddParentForumCount()", "板块" + forumid.ToString() + "=" + forum.Parentidlist, err.Message);
}
return "";
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Collect.cs | C# | asf20 | 88,934 |
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Data;
using System.Collections.Generic;
using System.Data.SqlClient;
using NetCMS.DALFactory;
using NetCMS.Model;
using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Survey : DbBase, ISurvey
{
#region ManageVote.aspx
public DataTable sel_voteById(int idt, int flag)
{
#region
string Sql = null;
if (flag == 0)//setClass.aspx
{
Sql = "Select vid,ClassName,Description From " + Pre + "vote_Class where SiteID='" + NetCMS.Global.Current.SiteID + "' and vid=" + idt;
}
else if (flag == 1)//setClass.aspx
{
Sql = "Select TID From " + Pre + "Vote_Topic where vid=" + idt + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)//setItem.aspx
{
Sql = "Select TID,IID,ItemName,ItemMode,PicSrc,DisColor,VoteCount,ItemDetail From " + Pre + "vote_Item where IID=" + idt + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 3)//setSteps.aspx
{
Sql = "Select SID,TIDS,Steps,TIDU From " + Pre + "vote_Steps where SiteID='" + NetCMS.Global.Current.SiteID + "' and SID=" + idt;
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
#endregion
}
public string GetVoteTitle(int tid)
{
string Sql = "Select [Title] From " + Pre + "Vote_Topic where SiteID='" + NetCMS.Global.Current.SiteID + "' and TID=" + tid;
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, null));
}
public IList<VoteItemInfo> GetItemsByTopic(int tid)
{
IList<VoteItemInfo> list = new List<VoteItemInfo>();
string SiteID = "0";
if (!NetCMS.Global.Current.IsTimeout())
{
SiteID = NetCMS.Global.Current.SiteID;
}
string Sql = "Select [IID],[TID],[ItemName],[ItemMode],[PicSrc],[DisColor],[VoteCount],[ItemDetail],[SiteID] From " + Pre + "vote_Item where TID = " + tid + " and SiteID='" + SiteID + "' order by IID asc";
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, null);
while (rd.Read())
{
VoteItemInfo info = new VoteItemInfo();
info.IID = rd.GetInt32(0);
info.TID = rd.GetInt32(1);
if (!rd.IsDBNull(2)) info.ItemName = rd.GetString(2);
if (!rd.IsDBNull(3)) info.ItemMode = rd.GetByte(3);
if (!rd.IsDBNull(4)) info.PicSrc = rd.GetString(4);
if (!rd.IsDBNull(5)) info.DisColor = rd.GetString(5);
if (!rd.IsDBNull(6)) info.VoteCount = rd.GetInt32(6);
if (!rd.IsDBNull(7)) info.ItemDetail = rd.GetString(7);
if (!rd.IsDBNull(8)) info.SiteID = rd.GetString(8);
list.Add(info);
}
rd.Close();
return list;
}
public VoteTopicInfo GetTopic(int tid)
{
VoteTopicInfo info = new VoteTopicInfo();
info.TID = 0;
string SiteID = "0";
if (!NetCMS.Global.Current.IsTimeout())
{
SiteID = NetCMS.Global.Current.SiteID;
}
string Sql = "Select [TID],[VID],[Title],[Type],[DisMode],[StartDate],[EndDate],[ItemMode],[SiteID],[AllowFillIn],[SeriesMode]";
Sql += " From " + Pre + "Vote_Topic where TID = " + tid + " and SiteID='" + SiteID + "'";
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, null);
if (rd.Read())
{
info.TID = rd.GetInt32(0);
info.VID = rd.GetInt32(1);
info.Title = rd.GetString(2);
if (!rd.IsDBNull(3)) info.Type = rd.GetByte(3);
if (!rd.IsDBNull(5)) info.DisMode = rd.GetByte(4);
if (!rd.IsDBNull(6)) info.StartDate = rd.GetDateTime(5);
if (!rd.IsDBNull(7)) info.EndDate = rd.GetDateTime(6);
if (!rd.IsDBNull(8)) info.ItemMode = rd.GetByte(7);
if (!rd.IsDBNull(10)) info.SiteID = rd.GetString(8);
info.AllowFillIn = rd.GetBoolean(9);
info.SeriesMode = rd.GetByte(10);
}
rd.Close();
return info;
}
public object GetLastVoteTimeByIP(int TID, string IPAddr, string UserNum)
{
string SiteID = "0";
if (UserNum != null && UserNum.Trim() != string.Empty)
{
SiteID = NetCMS.Global.Current.SiteID;
}
string Sql = "select top 1 VoteTime from " + Pre + "vote_Manage where TID=" + TID + " and VoteIp=@VoteIp and SiteID='" + SiteID + "'";
SqlParameter[] Param;
if (UserNum != null && UserNum.Trim() != string.Empty)
{
Sql += " and UserNumber=@UserNumber";
Param = new SqlParameter[]{new SqlParameter("@VoteIp", IPAddr),new SqlParameter("@UserNumber", UserNum)};
}
else
{
Param = new SqlParameter[]{new SqlParameter("@VoteIp", IPAddr)};
}
Sql += " order by VoteTime desc";
return DbHelper.ExecuteScalar(CommandType.Text, Sql, Param);
}
public string GetVoteItemName(int iid)
{
string Sql = "Select ItemName From " + Pre + "vote_Item where IID=" + iid + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, null));
}
public DataTable sel_voteByStr(string str, int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "Select Title,TID From " + Pre + "Vote_Topic where Title like '%" + str + "%' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "Select TID From " + Pre + "Vote_Topic where vid in(" + str + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "Select ClassName,VID From " + Pre + "vote_Class where ClassName like '%" + str + "%' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
#endregion
}
public int Del_voteManage(int RID, int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "Delete From " + Pre + "vote_Manage where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "Delete From " + Pre + "vote_Manage where rid=" + RID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "Delete From " + Pre + "vote_Item where iid=" + RID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 3)
{
Sql = "Delete From " + Pre + "vote_Steps where sid=" + RID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
public bool Del_voteSql(int VID, int flag)
{
#region 删除Vote相关信息
string Sql = null;
if (flag == 0)
{
Sql = "Delete From " + Pre + "vote_Class where vid=" + VID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "Delete From " + Pre + "Vote_Topic where vid=" + VID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "Delete From " + Pre + "vote_Item where TID=" + VID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 3)
{
Sql = "Delete From " + Pre + "vote_Steps where TIDS=" + VID + " or TIDU=" + VID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 4)
{
Sql = "Delete From " + Pre + "vote_Manage where TID=" + VID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 5)
{
Sql = "Delete From " + Pre + "Vote_Topic where tid=" + VID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
int i = DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
if (i == 0)
{
return false;
}
else
{
return true;
}
#endregion
}
public void del_voteInfoSql(string CheckboxArray, bool flag)
{
#region
string Sql = null;
if (flag)
{
Sql = "Delete From " + Pre + "vote_Class where vid in(" + CheckboxArray + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else
{
Sql = "Delete From " + Pre + "Vote_Topic where vid in(" + CheckboxArray + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
public void del_strVoteSql(int tid, int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "Delete From " + Pre + "vote_Item where TID in(" + tid + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "Delete From " + Pre + "vote_Steps where TIDS in(" + tid + ") or TIDU in(" + tid + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "Delete From " + Pre + "vote_Manage where TID in(" + tid + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
public bool del_VoteInfo(int flag)
{
#region 删除
string Table = null;
if (flag == 0)
{
Table = "vote_Class";
}
else if (flag == 1)
{
Table = "Vote_Topic";
}
else if (flag == 2)
{
Table = "vote_Item";
}
else if (flag == 3)
{
Table = "vote_Steps";
}
string Sql = "Delete From " + Pre + Table + " where SiteID='" + NetCMS.Global.Current.SiteID + "'";
int i = DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
if (i == 0)
{
return false;
}
else
{
return true;
}
#endregion
}
public DataTable sel_voteInfo(int flag)
{
#region
string Sql = null;
if (flag == 0)//setItem.aspx
{
Sql = "Select a.VID,a.ClassName,b.TID,b.Title From " + Pre + "vote_Class as a inner join " + Pre + "Vote_Topic as b on a.VID=b.VID and a.SiteID='" + NetCMS.Global.Current.SiteID + "' and b.SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)//setParam.aspx
{
Sql = "Select * From " + Pre + "vote_Param";
}
else if (flag == 2)//setSteps.aspx
{
Sql = "Select TID,Title From " + Pre + "Vote_Topic where isSteps=1 and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 3)//setTitle.aspx
{
Sql = "Select VID,ClassName From " + Pre + "vote_Class where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
#endregion
}
public int del_InfoVote(int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "Delete From " + Pre + "setSteps where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "Delete From " + Pre + "Vote_Topic where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
public int del_voteSql(string CheckboxArray, int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "Delete From " + Pre + "Vote_Topic where tid in(" + CheckboxArray + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "Delete From " + Pre + "vote_Item where TID in(" + CheckboxArray + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "Delete From " + Pre + "vote_Steps where TIDS in(" + CheckboxArray + ") or TIDU in(" + CheckboxArray + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 3)
{
Sql = "Delete From " + Pre + "vote_manage where TID in(" + CheckboxArray + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 4)
{
Sql = "Delete From " + Pre + "vote_Steps where sid in(" + CheckboxArray + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 5)
{
Sql = "Delete From " + Pre + "vote_Manage where rid in(" + CheckboxArray + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 6)
{
Sql = "Delete From " + Pre + "vote_Item where iid in(" + CheckboxArray + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
public string GetUserName(string usernum)
{//从会员表中取会员名
string Sql = "Select UserName From " + Pre + "sys_User where UserNum=@UserNum and SiteID='" + NetCMS.Global.Current.SiteID + "'";
SqlParameter Param = new SqlParameter("@UserNum", usernum);
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, Param));
}
#endregion
#region setClass.aspx
public int Add(string Str_ClassName, string Str_Description, string SiteID)
{
SqlParameter[] Param = new SqlParameter[3];
Param[0] = new SqlParameter("@Str_ClassName", SqlDbType.NVarChar, 20);
Param[0].Value = Str_ClassName;
Param[1] = new SqlParameter("@Str_Description", SqlDbType.NVarChar, 50);
Param[1].Value = Str_Description;
Param[2] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
Param[2].Value = SiteID;
string Sql = "Insert into " + Pre + "vote_Class (ClassName,Description,SiteID) Values(@Str_ClassName,@Str_Description,@SiteID)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, Param);
}
public int Update_Str_InSql(string Str_ClassNameE, string Str_DescriptionE, int VID)
{
SqlParameter[] Param = new SqlParameter[3];
Param[0] = new SqlParameter("@Str_ClassNameE", SqlDbType.NVarChar, 20);
Param[0].Value = Str_ClassNameE;
Param[1] = new SqlParameter("@Str_DescriptionE", SqlDbType.NVarChar, 50);
Param[1].Value = Str_DescriptionE;
Param[2] = new SqlParameter("@VID", SqlDbType.Int, 4);
Param[2].Value = VID;
string Sql = "Update " + Pre + "vote_Class Set ClassName=@Str_ClassNameE,Description=@Str_DescriptionE where vid=@VID and SiteID='" + NetCMS.Global.Current.SiteID + "'";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, Param);
}
#endregion
#region setItem.aspx
public int EditItem(VoteItemInfo info)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
string Sql = "select count(IID) from " + Pre + "Vote_Item where ItemName=@ItemName";
if (info.IID > 0)
{
Sql += " and IID<>" + info.IID;
}
SqlParameter Pm = new SqlParameter("@ItemName", info.ItemName);
int n = (int)DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, Pm);
if (n > 0)
throw new Exception("该投票标题已经存在!");
Sql = "Insert into " + Pre + "Vote_Item ([TID],[ItemName],[ItemMode],[PicSrc],[DisColor],[VoteCount],[ItemDetail],[SiteID]) ";
Sql += " Values (@TID,@ItemName,@ItemMode,@PicSrc,@DisColor,@VoteCount,@ItemDetail,@SiteID)";
if (info.IID > 0)
{
Sql = "Update " + Pre + "Vote_Item Set TID=@TID,ItemName=@ItemName,ItemMode=@ItemMode,";
Sql += "PicSrc=@PicSrc,DisColor=@DisColor,VoteCount=@VoteCount,ItemDetail=@ItemDetail,SiteID=@SiteID where SiteID='" + NetCMS.Global.Current.SiteID + "' and IID=" + info.IID;
}
SqlParameter[] Param = new SqlParameter[8];
Param[0] = new SqlParameter("@TID", SqlDbType.Int);
Param[0].Value = info.TID;
Param[1] = new SqlParameter("@ItemName", SqlDbType.NVarChar, 200);
Param[1].Value = info.ItemName;
Param[2] = new SqlParameter("@ItemMode", SqlDbType.TinyInt);
Param[2].Value = info.ItemMode;
Param[3] = new SqlParameter("@PicSrc", SqlDbType.NVarChar, 200);
if (info.PicSrc == string.Empty)
Param[3].Value = DBNull.Value;
else
Param[3].Value = info.PicSrc;
Param[4] = new SqlParameter("@DisColor", SqlDbType.NVarChar, 7);
if (info.DisColor == string.Empty)
Param[4].Value = DBNull.Value;
else
Param[4].Value = info.DisColor;
Param[5] = new SqlParameter("@VoteCount", SqlDbType.Int);
Param[5].Value = info.VoteCount;
Param[6] = new SqlParameter("@ItemDetail", SqlDbType.NVarChar, 255);
if (info.ItemDetail == string.Empty)
Param[6].Value = DBNull.Value;
else
Param[6].Value = info.ItemDetail;
Param[7] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
Param[7].Value = info.SiteID;
return DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, Param);
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
#endregion
#region setParam.aspx
public int Update_Str_InSqls(int IPtime, byte IsReg, string IpLimit)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
string Sql = "select count(SysID) from " + Pre + "vote_Param where SiteID='" + NetCMS.Global.Current.SiteID + "'";
int n = (int)DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null);
if (n > 0)
Sql = "Update " + Pre + "vote_Param Set IPtime=@IPtime,IsReg=@IsReg,IpLimit=@IpLimit where SiteID=@SiteID";
else
{
Sql = "insert into " + Pre + "vote_Param (IPtime,IsReg,IpLimit,SiteID) values (";
Sql += "@IPtime,@IsReg,@IpLimit,@SiteID)";
}
SqlParameter[] Param = new SqlParameter[4];
Param[0] = new SqlParameter("@IPtime", SqlDbType.Int);
Param[0].Value = IPtime;
Param[1] = new SqlParameter("@IsReg", SqlDbType.TinyInt);
Param[1].Value = IsReg;
Param[2] = new SqlParameter("@IpLimit", SqlDbType.NText);
if (IpLimit.Trim() == string.Empty)
Param[2].Value = DBNull.Value;
Param[2].Value = IpLimit;
Param[3] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
Param[3].Value = NetCMS.Global.Current.SiteID;
return DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, Param);
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
#endregion
#region setSteps.aspx
public int sel_Str_CheckSql(string Str_vote_CNameSe, string Str_vote_CNameUse)
{
string Sql = "Select count(*) From " + Pre + "vote_Steps Where TIDS='" + Str_vote_CNameSe + "' and TIDU='" + Str_vote_CNameUse + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
return (int)DbHelper.ExecuteScalar(CommandType.Text, Sql, null);
}
public int Add_Str_InSql(string Str_vote_CNameSe, string Str_vote_CNameUse, string Str_StepsN, string SiteID)
{
string Sql = "Insert into " + Pre + "vote_Steps (TIDS,TIDU,Steps,SiteID) Values('" + Str_vote_CNameSe + "','" + Str_vote_CNameUse + "','" + Str_StepsN + "','" + SiteID + "')";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public int update_voteSteps(string Str_votecnameEditse, string Str_votecnameEditue, string Str_NumEdit, int SID)
{
string Sql = "Update " + Pre + "vote_Steps Set TIDS='" + Str_votecnameEditse + "',TIDU='" + Str_votecnameEditue + "',Steps='" + Str_NumEdit + "' where SiteID='" + NetCMS.Global.Current.SiteID + "' and sid=" + SID;
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
#endregion
#region setTitle.aspx
public int EditTopic(VoteTopicInfo info)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
string Sql = "select count(TID) from " + Pre + "Vote_Topic where Title=@Title";
if (info.TID > 0)
{
Sql += " and TID<>" + info.TID;
}
SqlParameter Pm = new SqlParameter("@Title", info.Title);
int n = (int)DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, Pm);
if (n > 0)
throw new Exception("该投票标题已经存在!");
Sql = "Insert into " + Pre + "Vote_Topic (VID,Title,Type,DisMode,StartDate,EndDate,ItemMode,SiteID,AllowFillIn,SeriesMode) ";
Sql += " Values (@VID,@Title,@Type,@DisMode,@StartDate,@EndDate,@ItemMode,@SiteID,@AllowFillIn,@SeriesMode)";
if (info.TID > 0)
{
Sql = "Update " + Pre + "Vote_Topic Set VID=@VID,Title=@Title,Type=@Type,DisMode=@DisMode,";
Sql += "StartDate=@StartDate,EndDate=@EndDate,ItemMode=@ItemMode,AllowFillIn=@AllowFillIn,SeriesMode=@SeriesMode where SiteID='" + NetCMS.Global.Current.SiteID + "' and tid=" + info.TID;
}
SqlParameter[] Param = new SqlParameter[10];
Param[0] = new SqlParameter("@VID", SqlDbType.Int);
Param[0].Value = info.VID;
Param[1] = new SqlParameter("@Title", SqlDbType.NVarChar, 50);
Param[1].Value = info.Title;
Param[2] = new SqlParameter("@Type", SqlDbType.TinyInt);
Param[2].Value = info.Type;
Param[3] = new SqlParameter("@SeriesMode", SqlDbType.TinyInt);
Param[3].Value = info.SeriesMode;
Param[4] = new SqlParameter("@DisMode", SqlDbType.TinyInt);
Param[4].Value = info.DisMode;
Param[5] = new SqlParameter("@StartDate", SqlDbType.DateTime);
Param[5].Value = info.StartDate;
Param[6] = new SqlParameter("@EndDate", SqlDbType.DateTime);
Param[6].Value = info.EndDate;
Param[7] = new SqlParameter("@ItemMode", SqlDbType.TinyInt);
Param[7].Value = info.ItemMode;
Param[8] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
Param[8].Value = info.SiteID;
Param[9] = new SqlParameter("@AllowFillIn", SqlDbType.Bit);
if (info.AllowFillIn)
Param[9].Value = 1;
else
Param[9].Value = 0;
return DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, Param);
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
#endregion
public void add_voteManage(int[] SelIID, int tid, string othercontent, string strvip, string UserNum)
{
string Sql;
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
if (othercontent.Trim() != string.Empty)
{
Sql = "select Type,AllowFillIn from " + Pre + "Vote_Topic where TID=" + tid;
IDataReader rd = DbHelper.ExecuteReader(cn, CommandType.Text, Sql, null);
if (rd.Read())
{
if (!rd.GetBoolean(1))
othercontent = string.Empty;
if (rd.GetByte(0) == 0 && SelIID.Length > 0)
othercontent = string.Empty;
}
rd.Close();
}
SqlTransaction tran = cn.BeginTransaction();
try
{
foreach (int id in SelIID)
{
if (id == 0 && othercontent.Trim() == string.Empty)
continue;
Sql = "Insert into " + Pre + "vote_Manage (IID,TID,OtherContent,VoteIp,VoteTime,UserNumber,SiteID) Values (@IID,@TID,@OtherContent,@VoteIp,'" + DateTime.Now + "',@UserNumber,@SiteID)";
SqlParameter[] Param = new SqlParameter[6];
Param[0] = new SqlParameter("@IID", SqlDbType.Int);
Param[0].Value = id;
Param[1] = new SqlParameter("@TID", SqlDbType.Int);
Param[1].Value = tid;
Param[2] = new SqlParameter("@OtherContent", SqlDbType.NVarChar, 50);
if (othercontent.Trim() == string.Empty)
Param[2].Value = DBNull.Value;
else
Param[2].Value = othercontent;
Param[3] = new SqlParameter("@VoteIp", SqlDbType.NVarChar, 15);
Param[3].Value = strvip;
Param[4] = new SqlParameter("@UserNumber", SqlDbType.NVarChar, 15);
if (UserNum == null || UserNum.Trim() == string.Empty)
Param[4].Value = DBNull.Value;
else
Param[4].Value = UserNum;
Param[5] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
if (NetCMS.Global.Current.IsTimeout())
Param[5].Value = "0";
else
Param[5].Value = NetCMS.Global.Current.SiteID;
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, Param);
}
tran.Commit();
}
catch
{
tran.Rollback();
throw;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
public int sel_IP()
{
int PageError = 0;
string IPLIST = "";
string LoginIP = NetCMS.Global.Current.ClientIP;
string IPSQL = "select IpLimit from " + Pre + "vote_Param";
object IPDT = DbHelper.ExecuteScalar(CommandType.Text, IPSQL, null);
if (IPDT != null && IPDT != DBNull.Value)
{
IPLIST = IPDT.ToString();
if (IPLIST != "" && IPLIST != null)
{
int IPTF = 0;
string[] arrIP = IPLIST.Split(new Char[] { '|' });
for (int i = 0; i < arrIP.Length; i++)
{
if (arrIP[i].IndexOf('*') >= 0)
{
string strIP = arrIP[i];
string[] IPR = strIP.Split(new Char[] { '.' });
string[] IPR1 = LoginIP.Split(new Char[] { '.' });
if (IPR[2] == "*")
{
if (IPR1[0] + IPR1[1] == IPR[0] + IPR[1])
{
IPTF = 1;
}
}
else if (IPR[3] == "*")
{
if (IPR1[0] + IPR1[1] + IPR1[2] == IPR[0] + IPR[1] + IPR[2])
{
IPTF = 1;
}
}
}
else
{
if (arrIP[i].ToString() == LoginIP.ToString())
{
IPTF = 1;
}
}
}
if (IPTF == 1)
{
PageError = 1;
}
}
}
return PageError;
}
public DataTable GetVoteStat(int tid, out int totalvote)
{
totalvote = 0;
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
string SiteID = "0";
try
{
SiteID = NetCMS.Global.Current.SiteID;
}
catch
{
}
string Sql = "select count(rid) from " + Pre + "vote_Manage where tid=" + tid;
totalvote = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null));
Sql = "select sum(VoteCount) from " + Pre + "vote_Item where tid=" + tid;
object obj = DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null);
if (obj != null && obj != DBNull.Value)
totalvote += (int)obj;
Sql = "SELECT a.TID, a.IID, a.ItemName, a.ItemMode, a.PicSrc, a.DisColor,";
Sql += "a.VoteCount, a.ItemDetail, COUNT(b.RID) AS Result FROM " + Pre + "vote_Item a LEFT OUTER JOIN ";
Sql += Pre + "vote_manage b ON a.TID = b.TID AND a.IID = b.IID where a.tid=" + tid;
Sql += " GROUP BY a.TID, a.IID, a.ItemName, a.ItemMode, a.PicSrc, a.DisColor,a.VoteCount, a.ItemDetail";
return DbHelper.ExecuteTable(cn, CommandType.Text, Sql, null);
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
}
}
/*
*/ | 0575kaoshicj | trunk/NetCMS.DALSQLServer/Survey.cs | C# | asf20 | 33,581 |
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Text;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using NetCMS.DALFactory;
using NetCMS.Model;
using NetCMS.Common;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Site : DbBase, ISite
{
private SqlTransaction Trans;
public int Add(STSite site, string CurrentSiteID, out string SiteID)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
SiteID = Rand.Number(12);
while (true)
{
string SqlRptID = "select count(*) from " + Pre + "News_site where ChannelID='" + SiteID + "'";
int RcdCount = (int)DbHelper.ExecuteScalar(cn, CommandType.Text, SqlRptID, null);
if (RcdCount < 1)
break;
else
SiteID = NetCMS.Common.Rand.Number(12, true);
}
string SqlRptEnm = "select count(*) from " + Pre + "News_site where EName='" + site.EName + "'";
int n = (int)DbHelper.ExecuteScalar(cn, CommandType.Text, SqlRptEnm, null);
if (n > 0)
{
throw new Exception("对不起,该英文名称已被别的频道所使用!");
}
string SqlRptCnm = "select count(*) from " + Pre + "News_site where CName='" + site.CName + "'";
n = (int)DbHelper.ExecuteScalar(cn, CommandType.Text, SqlRptCnm, null);
if (n > 0)
{
throw new Exception("对不起,该中文名称已被别的频道所使用!");
}
string Sql = "insert into " + Pre + "News_site (";
Sql += "ChannelID,CName,EName,ParentID,ChannCName,isLock,IsURL,Urladdress,DataLib,IndexTemplet,ClassTemplet,ReadNewsTemplet,SpecialTemplet,Domain,";
Sql += "isCheck,Keywords,Descript,ContrTF,ShowNaviTF,UpfileType,UpfileSize,NaviContent,NaviPicURL,SaveType,PicSavePath,SaveFileType,";
Sql += "SaveDirPath,SaveDirRule,SaveFileRule,NaviPosition,IndexEXName,ClassEXName,NewsEXName,SpecialEXName,classRefeshNum,infoRefeshNum,";
Sql += "DelNum,SpecialNum,isDelPoint,Gpoint,iPoint,GroupNumber,CreatTime,SiteID";
Sql += ") values ('" + SiteID + "',";
Sql += "@CName,@EName,'0',@ChannCName,@isLock,@IsURL,@Urladdress,@DataLib,@IndexTemplet,@ClassTemplet,@ReadNewsTemplet,@SpecialTemplet,@Domain,";
Sql += "@isCheck,@Keywords,@Descript,@ContrTF,@ShowNaviTF,@UpfileType,@UpfileSize,@NaviContent,@NaviPicURL,@SaveType,@PicSavePath,@SaveFileType,";
Sql += "@SaveDirPath,@SaveDirRule,@SaveFileRule,@NaviPosition,@IndexEXName,@ClassEXName,@NewsEXName,@SpecialEXName,@classRefeshNum,@infoRefeshNum,";
Sql += "@DelNum,@SpecialNum,@isDelPoint,@Gpoint,@iPoint,@GroupNumber";
Sql += ",'" + DateTime.Now + "','" + CurrentSiteID + "')";
Sql += ";SELECT @@IDENTITY";
SqlParameter[] param = GetParameters(site);
int result = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, param));
return result;
}
finally
{
if (cn != null && cn.State == ConnectionState.Open)
cn.Close();
}
}
public bool Delete(string id, out Exception e, out string[] DelFiles)
{
bool flag = false;
DelFiles = null;
e = null;
id = "'" + id + "'";
if (id.IndexOf(",") > 0)
id = id.Replace(",", "','");
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
ArrayList FilePath = new ArrayList();
FilePath.Clear();
try
{
ArrayList NewsTable = this.GetNewsTables(cn);
for (int i = 0; i < NewsTable.Count; i++)
{
string SqlPath = "select SavePath,FileName,FileEXName from " + NewsTable[i].ToString() + " where SiteID in (" + id + ")";
IDataReader rd = DbHelper.ExecuteReader(cn, CommandType.Text, SqlPath, null);
while (rd.Read())
{
if (!rd.IsDBNull(0) && !rd.IsDBNull(1) && !rd.IsDBNull(2))
{
string filepath = rd.GetString(0) + rd.GetString(1) + rd.GetString(2);
FilePath.Add(filepath);
}
}
rd.Close();
}
DelFiles = (string[])FilePath.ToArray(typeof(string));
Trans = cn.BeginTransaction();
for (int i = 0; i < NewsTable.Count; i++)
{
string SqlDelNews = "delete from " + NewsTable[i].ToString() + " where SiteID in (" + id + ")";
DbHelper.ExecuteNonQuery(Trans, CommandType.Text, SqlDelNews, null);
}
string SqlDelSpc = "delete from " + Pre + "News_special where SiteID in (" + id + ")";
DbHelper.ExecuteNonQuery(Trans, CommandType.Text, SqlDelSpc, null);
string SqlDelCls = "delete from " + Pre + "News_Class where SiteID in (" + id + ")";
DbHelper.ExecuteNonQuery(Trans, CommandType.Text, SqlDelCls, null);
string SqlDelSt = "delete from " + Pre + "News_site where ChannelID in (" + id + ")";
DbHelper.ExecuteNonQuery(Trans, CommandType.Text, SqlDelSt, null);
Trans.Commit();
flag = true;
}
catch (Exception ex)
{
Trans.Rollback();
e = ex;
flag = false;
}
finally
{
if (cn != null && cn.State == ConnectionState.Open)
cn.Close();
}
return flag;
}
public void Update(int id, STSite site)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
string SqlEnm = "select count(*) from " + Pre + "News_site where Id<>" + id + " and EName='" + site.EName + "'";
int n = (int)DbHelper.ExecuteScalar(cn, CommandType.Text, SqlEnm, null);
if (n > 0)
{
throw new Exception("对不起,该英文名称已被别的频道所使用");
}
string SqlCnm = "select count(*) from " + Pre + "News_site where Id<>" + id + " and CName='" + site.CName + "'";
n = (int)DbHelper.ExecuteScalar(cn, CommandType.Text, SqlCnm, null);
if (n > 0)
{
throw new Exception("对不起,该中文名称已被别的频道所使用");
}
string Sql = "update " + Pre + "News_site set CName=@CName,ChannCName=@ChannCName,isLock=@isLock,IsURL=@IsURL,Urladdress=@Urladdress,";
Sql += "DataLib=@DataLib,IndexTemplet=@IndexTemplet,ClassTemplet=@ClassTemplet,ReadNewsTemplet=@ReadNewsTemplet,SpecialTemplet=@SpecialTemplet,";
Sql += "Domain=@Domain,isCheck=@isCheck,Keywords=@Keywords,Descript=@Descript,ContrTF=ContrTF,ShowNaviTF=@ShowNaviTF,";
Sql += "UpfileType=@UpfileType,UpfileSize=@UpfileSize,NaviContent=@NaviContent,NaviPicURL=@NaviPicURL,SaveType=@SaveType,PicSavePath=@PicSavePath,";
Sql += "SaveFileType=@SaveFileType,SaveDirPath=@SaveDirPath,SaveDirRule=@SaveDirRule,SaveFileRule=@SaveFileRule,NaviPosition=@NaviPosition,IndexEXName=@IndexEXName,";
Sql += "ClassEXName=@ClassEXName,NewsEXName=@NewsEXName,SpecialEXName=@SpecialEXName,classRefeshNum=@classRefeshNum,infoRefeshNum=@infoRefeshNum,DelNum=@DelNum,";
Sql += "SpecialNum=@SpecialNum,isDelPoint=@isDelPoint,Gpoint=@Gpoint,iPoint=@iPoint,GroupNumber=@GroupNumber where Id=" + id;
SqlParameter[] param = GetParameters(site);
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, param);
}
catch
{
if (cn != null && cn.State == ConnectionState.Open)
cn.Close();
throw;
}
}
public void Recyle(string id)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
ArrayList NewsTable = this.GetNewsTables(cn);
SqlTransaction tran = cn.BeginTransaction();
try
{
string SqlSite = "update " + Pre + "News_site set isRecyle=1 where ChannelID = '" + id + "'";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, SqlSite, null);
string SqlClass = "update " + Pre + "News_Class set isRecyle=1 where SiteID = '" + id + "'";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, SqlClass, null);
string SqlSpecial = "update " + Pre + "News_special set isRecyle=1 where SiteID = '" + id + "'";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, SqlSpecial, null);
for (int i = 0; i < NewsTable.Count; i++)
{
string SqlNews = "update " + NewsTable[i] + " set isRecyle=1 where SiteID = '" + id + "'";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, SqlNews, null);
}
tran.Commit();
cn.Close();
}
catch (SqlException e)
{
tran.Rollback();
cn.Close();
throw e;
}
}
public DataTable List(SiteType sttype)
{
string Sql = "select ChannelID,CName from " + Pre + "news_site";
if (sttype == SiteType.External)
Sql += " where IsURL=1";
else if (sttype == SiteType.System)
Sql += " where IsURL=0";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
/// <summary>
/// 得到站点列表
/// </summary>
/// <returns></returns>
public IDataReader siteList()
{
string Sql = "select ChannelID,CName,ChannCName from " + Pre + "news_site where ParentID='0' and isURL=0 and isLock=0 and isRecyle=0 " + NetCMS.Common.Public.getCHStr() + " order by id asc";
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
public DataTable GetSingle(int id)
{
string Sql = "select * from " + Pre + "News_site where Id=" + id;
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public DataTable GetSiteInfo(string ChannelID)
{
string Sql = "select * from " + Pre + "News_site where ChannelID='" + ChannelID + "'";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
private ArrayList GetNewsTables(SqlConnection connection)
{
ArrayList NewsTable = new ArrayList();
NewsTable.Clear();
IDataReader rd = DbHelper.ExecuteReader(connection, CommandType.Text, "select TableName from " + Pre + "sys_NewsIndex", null);
while (rd.Read())
{
NewsTable.Add(rd.GetString(0));
}
rd.Close();
return NewsTable;
}
private SqlParameter[] GetParameters(STSite st)
{
SqlParameter[] param = new SqlParameter[40];
param[0] = new SqlParameter("@GroupNumber", SqlDbType.NText);
param[0].Value = st.GroupNumber.Equals("") ? DBNull.Value : (object)st.GroupNumber;
param[1] = new SqlParameter("@CName", SqlDbType.NVarChar, 50);
param[1].Value = st.CName;
param[2] = new SqlParameter("@EName", SqlDbType.NVarChar, 50);
param[2].Value = st.EName;
param[3] = new SqlParameter("@ChannCName", SqlDbType.NVarChar, 50);
param[3].Value = st.ChannCName;
param[4] = new SqlParameter("@isLock", SqlDbType.TinyInt);
param[4].Value = st.isLock;
param[5] = new SqlParameter("@IsURL", SqlDbType.TinyInt);
param[5].Value = st.IsURL;
param[6] = new SqlParameter("@Urladdress", SqlDbType.NVarChar, 200);
param[6].Value = st.Urladdress.Equals("") ? DBNull.Value : (object)st.Urladdress;
param[7] = new SqlParameter("@DataLib", SqlDbType.NVarChar, 20);
param[7].Value = st.DataLib;
param[8] = new SqlParameter("@IndexTemplet", SqlDbType.NVarChar, 200);
param[8].Value = st.IndexTemplet.Equals("") ? DBNull.Value : (object)st.IndexTemplet;
param[9] = new SqlParameter("@ClassTemplet", SqlDbType.NVarChar, 200);
param[9].Value = st.ClassTemplet.Equals("") ? DBNull.Value : (object)st.ClassTemplet;
param[10] = new SqlParameter("@ReadNewsTemplet", SqlDbType.NVarChar, 200);
param[10].Value = st.ReadNewsTemplet.Equals("") ? DBNull.Value : (object)st.ReadNewsTemplet;
param[11] = new SqlParameter("@SpecialTemplet", SqlDbType.NVarChar, 200);
param[11].Value = st.SpecialTemplet.Equals("") ? DBNull.Value : (object)st.SpecialTemplet;
param[12] = new SqlParameter("@Domain", SqlDbType.NVarChar, 100);
param[12].Value = st.Domain;
param[13] = new SqlParameter("@isCheck", SqlDbType.TinyInt);
param[13].Value = st.isCheck.Equals(-1) ? DBNull.Value : (object)st.isCheck;
param[14] = new SqlParameter("@Keywords", SqlDbType.NVarChar, 100);
param[14].Value = st.Keywords;
param[15] = new SqlParameter("@Descript", SqlDbType.NVarChar, 200);
param[15].Value = st.Descript;
param[16] = new SqlParameter("@ContrTF", SqlDbType.TinyInt);
param[16].Value = st.ContrTF;
param[17] = new SqlParameter("@ShowNaviTF", SqlDbType.TinyInt);
param[17].Value = st.ShowNaviTF.Equals("") ? DBNull.Value : (object)st.ShowNaviTF;
param[18] = new SqlParameter("@UpfileType", SqlDbType.NVarChar, 150);
param[18].Value = st.UpfileType.Equals("") ? DBNull.Value : (object)st.UpfileType;
param[19] = new SqlParameter("@UpfileSize", SqlDbType.Int);
param[19].Value = st.UpfileSize.Equals(-1) ? DBNull.Value : (object)st.UpfileSize;
param[20] = new SqlParameter("@NaviContent", SqlDbType.NVarChar, 255);
param[20].Value = st.NaviContent;
param[21] = new SqlParameter("@NaviPicURL", SqlDbType.NVarChar, 200);
param[21].Value = st.NaviPicURL;
param[22] = new SqlParameter("@SaveType", SqlDbType.TinyInt);
param[22].Value = st.SaveType.Equals(-1) ? DBNull.Value : (object)st.SaveType;
param[23] = new SqlParameter("@PicSavePath", SqlDbType.NVarChar, 100);
param[23].Value = st.PicSavePath.Equals("") ? DBNull.Value : (object)st.PicSavePath;
param[24] = new SqlParameter("@SaveFileType", SqlDbType.TinyInt);
param[24].Value = st.SaveFileType.Equals(-1) ? DBNull.Value : (object)st.SaveFileType;
param[25] = new SqlParameter("@SaveDirPath", SqlDbType.NVarChar, 100);
param[25].Value = st.SaveDirPath.Equals("") ? DBNull.Value : (object)st.SaveDirPath;
param[26] = new SqlParameter("@SaveDirRule", SqlDbType.NVarChar, 200);
param[26].Value = st.SaveDirRule.Equals("") ? DBNull.Value : (object)st.SaveDirRule;
param[27] = new SqlParameter("@SaveFileRule", SqlDbType.NVarChar, 100);
param[27].Value = st.SaveFileRule.Equals("") ? DBNull.Value : (object)st.SaveFileRule;
param[28] = new SqlParameter("@NaviPosition", SqlDbType.NVarChar, 255);
param[28].Value = st.NaviPosition.Equals("") ? DBNull.Value : (object)st.NaviPosition;
param[29] = new SqlParameter("@IndexEXName", SqlDbType.NVarChar, 6);
param[29].Value = st.IndexEXName.Equals("") ? DBNull.Value : (object)st.IndexEXName;
param[30] = new SqlParameter("@ClassEXName", SqlDbType.NVarChar, 6);
param[30].Value = st.ClassEXName.Equals("") ? DBNull.Value : (object)st.ClassEXName;
param[31] = new SqlParameter("@NewsEXName", SqlDbType.NVarChar, 6);
param[31].Value = st.NewsEXName.Equals("") ? DBNull.Value : (object)st.NewsEXName;
param[32] = new SqlParameter("@SpecialEXName", SqlDbType.NVarChar, 6);
param[32].Value = st.SpecialEXName.Equals("") ? DBNull.Value : (object)st.SpecialEXName;
param[33] = new SqlParameter("@classRefeshNum", SqlDbType.Int);
param[33].Value = st.classRefeshNum < 1 ? 800 : (object)st.classRefeshNum;
param[34] = new SqlParameter("@infoRefeshNum", SqlDbType.Int);
param[34].Value = st.infoRefeshNum < 1 ? 100 : (object)st.infoRefeshNum;
param[35] = new SqlParameter("@DelNum", SqlDbType.Int);
param[35].Value = st.DelNum < 1 ? 200 : (object)st.DelNum;
param[36] = new SqlParameter("@SpecialNum", SqlDbType.Int);
param[36].Value = st.SpecialNum < 1 ? 500 : (object)st.SpecialNum;
param[37] = new SqlParameter("@isDelPoint", SqlDbType.TinyInt);
param[37].Value = st.isDelPoint;
param[38] = new SqlParameter("@Gpoint", SqlDbType.Int);
param[38].Value = st.Gpoint < 0 ? DBNull.Value : (object)st.Gpoint;
param[39] = new SqlParameter("@iPoint", SqlDbType.Int);
param[39].Value = st.iPoint < 0 ? DBNull.Value : (object)st.iPoint;
return param;
}
public int getsiteClassCount(string siteid)
{
string sql = "select count(id) from " + Pre + "news_class where SiteID='" + siteid + "' and isRecyle=0 and islock=0";
return (int)DbHelper.ExecuteScalar(CommandType.Text, sql, null);
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Site.cs | C# | asf20 | 18,987 |
//======================================================
//== (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 NetCMS.Common;
using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Arealist : DbBase, IArealist
{
#region arealist.aspx
public DataTable sel_sysCity(string Cid,bool flag)
{
#region
string Sql = null;
SqlParameter param = new SqlParameter("@Cid",Cid);
if (flag)
{
Sql = "Select Cid,cityName,creatTime From " + Pre + "Sys_City Where Pid=@Cid and SiteID='" + NetCMS.Global.Current.SiteID + "' order by OrderID desc,id desc";
}
else
{
Sql = "select cityName,OrderID,Pid from " + Pre + "Sys_City where Cid=@Cid and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
#endregion
}
public DataTable sel_sysCityInfo(int flag)
{
#region
string Sql = null;
if (flag==0)
{
Sql = "select Cid,cityName,Pid from " + Pre + "Sys_City where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if(flag==1)
{
Sql = "select Cid,cityName from " + Pre + "Sys_City where Pid='0' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "select Cid from " + Pre + "Sys_City";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
#endregion
}
public int del_sysCity(string ID,int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "delete " + Pre + "Sys_City where (Cid='" + ID + "'and Pid='0') or Pid='" + ID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "delete " + Pre + "Sys_City where Cid='" + ID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "delete " + Pre + "Sys_City where Cid='" + ID + "'";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
#endregion
#region arealist_add.aspx
public int Add(string Cid, string cityName, DateTime creatTime, int orderID)
{
string Sql = "insert into " + Pre + "Sys_City(Cid,cityName,Pid,creatTime,SiteID,orderID) values('" + Cid + "','" + cityName + "','0','" + creatTime + "','" + NetCMS.Global.Current.SiteID + "'," + orderID + ")";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public int sel_nameTF(string aName)
{
int intflg = 0;
SqlParameter param = new SqlParameter("@Name",aName);
string Sql = "select id from " + Pre + "Sys_City where cityName=@Name";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (dt != null)
{
if (dt.Rows.Count > 0) { intflg = 1; }
dt.Clear(); dt.Dispose();
}
return intflg;
}
#endregion
#region Arealist.cs
public int add_sysCity(string Pid, string Cid, string cityName, DateTime creatTime, int orderID)
{
string Sql = "insert into " + Pre + "Sys_City(Pid,Cid,cityName,creatTime,SiteID,orderID) values('" + Pid + "','" + Cid + "','" + cityName + "','" + creatTime + "','" + NetCMS.Global.Current.SiteID + "'," + orderID + ")";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
#endregion
#region arealist_upc.aspx
public int Update(string Pid, string cityName, DateTime creatTime, string cids, int OrderID)
{
SqlParameter[] param = new SqlParameter[5];
param[0] = new SqlParameter("@Pid", SqlDbType.NVarChar,12);
param[0].Value = Pid;
param[1] = new SqlParameter("@cityName", SqlDbType.NVarChar,30);
param[1].Value = cityName;
param[2] = new SqlParameter("@creatTime", SqlDbType.DateTime, 8);
param[2].Value = creatTime;
param[3] = new SqlParameter("@cids", SqlDbType.NVarChar, 12);
param[3].Value = cids;
param[4] = new SqlParameter("@OrderID", SqlDbType.Int,4);
param[4].Value = OrderID;
string Sql = "update " + Pre + "Sys_City set Pid=@Pid,cityName=@cityName,creatTime=@creatTime,OrderID=@OrderID where Cid=@cids and SiteID='" + NetCMS.Global.Current.SiteID + "'";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion
#region arealist_upp.aspx
public int Update_sysCity(string cityName, DateTime creatTime, string Cids, int orderID)
{
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@cityName", SqlDbType.NVarChar, 30);
param[0].Value = cityName;
param[1] = new SqlParameter("@creatTime", SqlDbType.DateTime, 8);
param[1].Value = creatTime;
param[2] = new SqlParameter("@Cids", SqlDbType.NVarChar, 12);
param[2].Value = Cids;
param[3] = new SqlParameter("@orderID", SqlDbType.Int, 4);
param[3].Value = orderID;
string Sql = "update " + Pre + "Sys_City set cityName=@cityName,creatTime=@creatTime,orderID=@orderID where Cid=@Cids and SiteID='" + NetCMS.Global.Current.SiteID + "'";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion
}
} | 0575kaoshicj | trunk/NetCMS.DALSQLServer/Arealist.cs | C# | asf20 | 6,427 |
//======================================================
//== (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.DALFactory;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Search : DbBase, ISearch
{
/// <summary>
/// 查询分页
/// </summary>
/// <param name="PageIndex">当前页</param>
/// <param name="PageSize">每页显示多少条</param>
/// <param name="RecordCount">记录总数</param>
/// <param name="PageCount">页数</param>
/// <param name="si">实体类</param>
/// <returns>返回数据表</returns>
public DataTable SearchGetPage(string DTable,int PageIndex, int PageSize, out int RecordCount, out int PageCount, NetCMS.Model.SearchInfo si)
{
string allFields = "*";
string tablesAndWhere = " " + Pre + "News Where isLock=0 And isRecyle=0";
if (DTable != string.Empty)
{
tablesAndWhere = " " + DTable + " Where isLock=0";
}
string indexField = "ID";
string orderField = "Order By ID Desc";
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@Key", SqlDbType.NVarChar, 100);
if (si.tags != null && si.tags != "")
{
param[0].Value = "%" + si.tags + "%";
if (si.type == "tag")
{
tablesAndWhere += " And Tags Like CONVERT(Nvarchar(100), @Key)";
}
else if (si.type == "edit")
{
tablesAndWhere += " And editor Like CONVERT(Nvarchar(18), @Key)";
}
else if (si.type == "author")
{
tablesAndWhere += " And author Like CONVERT(Nvarchar(100), @Key)";
}
else
{
if (DTable != string.Empty)
{
tablesAndWhere += " And ((Title Like CONVERT(Nvarchar(100), @Key)) Or (Author Like CONVERT(Nvarchar(100), @Key)) Or (Souce Like CONVERT(Nvarchar(100), @Key)) Or (Tags Like CONVERT(Nvarchar(100), @Key)) Or (Content Like CONVERT(Nvarchar(100), @Key)))";
}
else
{
tablesAndWhere += " And ((NewsTitle Like CONVERT(Nvarchar(100), @Key)) Or (sNewsTitle Like CONVERT(Nvarchar(100), @Key)) Or (Author Like CONVERT(Nvarchar(100), @Key)) Or (Souce Like CONVERT(Nvarchar(100), @Key)) Or (Tags Like CONVERT(Nvarchar(100), @Key)) Or (Content Like CONVERT(Nvarchar(100), @Key)))";
}
}
}
else
{
param[0].Value = "";
}
param[1] = new SqlParameter("@Pdate", SqlDbType.Int, 4);
if (si.date != null && si.date != "" && si.date != "0")
{
param[1].Value = int.Parse(si.date);
tablesAndWhere += " And DateDiff(Day,CreatTime ,getdate())<@Pdate";
}
else
{
param[1].Value = 0;
}
param[2] = new SqlParameter("@classid", SqlDbType.NVarChar, 12);
if (si.classid != null && si.classid != "")
{
param[2].Value = si.classid;
tablesAndWhere += " And ClassID=@classid";
}
else
{
param[2].Value = "";
}
return DbHelper.ExecutePage(allFields, tablesAndWhere, indexField, orderField, PageIndex, PageSize, out RecordCount, out PageCount, param);
}
/// <summary>
/// 取得栏目参数中的新闻保存路径
/// </summary>
/// <param name="ClassID">栏目编号</param>
/// <returns>返回新闻保存路径</returns>
public string getSaveClassframe(string ClassID)
{
string path = "";
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string Sql = "Select SaveClassframe,SavePath From " + Pre + "news_Class Where ClassID=@ClassID";
IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, Sql, param);
if (dr.Read())
{
path = dr.GetString(1) + "/" + dr.GetString(0);
}
dr.Close(); dr.Dispose();
return path;
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Search.cs | C# | asf20 | 4,893 |
//======================================================
//== (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 NetCMS.Common;
using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Discuss : DbBase, IDiscuss
{
public DataTable sel_discussInfo(string Id, int flag)
{
#region
SqlParameter param = new SqlParameter("@Id", Id);
string Sql = null;
if (flag == 0)
{
Sql = "select UserName,SiteID,cPoint,aPoint,iPoint,gPoint,ePoint,aPoint,RegTime,UserFace,userFacesize from " + Pre + "sys_User where UserNum=@Id";
}
else if (flag == 1)
{
string _ClassID = Id;
if (Id == "")
_ClassID = "";
else
_ClassID = " and indexnumber=@Id";
Sql = "select DcID,Cname from " + Pre + "user_DiscussClass where UserNum='" + NetCMS.Global.Current.UserNum + "' " + _ClassID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "select Cname,DcID from " + Pre + "user_DiscussClass where indexnumber=@Id";
}
else if (flag == 3)
{
Sql = "select GroupCreatNum,GroupSize,GroupPerNum,GroupTF from " + Pre + "user_Group where GroupNumber=@Id";
}
else if (flag == 4)
{
Sql = "select Fundwarehouse,Cname,Authoritymoney,UserName,Browsenumber,D_Content,Creatime,ClassID,Authority,D_anno from " + Pre + "user_Discuss where DisID=@Id";
}
else if (flag == 5)
{
Sql = "select Cutofftime,Anum,Activesubject,ActivePlace,ActiveExpense,ActivePlan,Contactmethod,CreaTime,UserName,ALabel from " + Pre + "user_DiscussActive where AId=@Id";
}
else if (flag == 6)
{
Sql = "Select PhotoalbumName,PhotoalbumID From " + Pre + "User_Photoalbum where isDisPhotoalbum=1 And DisID=@Id and UserName='" + NetCMS.Global.Current.UserNum + "'";
}
else if (flag == 7)//discussphoto_up.aspx
{
Sql = "select PhotoName,PhotoalbumID,PhotoContent,PhotoUrl,UserNum from " + Pre + "User_Photo where PhotoID=@Id";
}
else if (flag == 8)//discussphoto_up.aspx
{
Sql = "Select PhotoalbumName,PhotoalbumID From " + Pre + "User_Photoalbum where substring(PhotoalbumJurisdiction,1,1) = '1' And DisID=@Id";
}
else if (flag == 9)//discussPhotoalbum.aspx
{
Sql = "Select ClassName,ClassID From " + Pre + "user_PhotoalbumClass where isDisclass=1 and DisID=@Id";
}
else if (flag == 10)//discussPhotoalbumlist.aspx
{
Sql = "select UserNum from " + Pre + "User_DiscussMember where DisID=@Id";
}
else if (flag == 11)//discussPhotoalbumlist.aspx
{
Sql = "select PhotoalbumUrl,UserName,PhotoalbumName from " + Pre + "User_Photoalbum where PhotoalbumID=@Id";
}
else if (flag == 12)//discussTopi_commentary.aspx
{
Sql = "select VoteTF,voteTime,DtID,title,Content,creatTime,UserNum from " + Pre + "User_DiscussTopic where DtID=@Id";
}
else if (flag == 13)//discussTopi_commentary.aspx
{
Sql = "select VoteID,VoteNum,Voteitem,votegenre,CreaTime from " + Pre + "User_Vote where DtID=@Id";
}
else if (flag == 14)
{
Sql = "Select DtID,title,Content,creatTime,UserNum From " + Pre + "User_DiscussTopic where DtID=@Id and UserNum='" + NetCMS.Global.Current.UserNum + "'";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
#endregion
}
public DataTable sel_disTable(int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "select AId,UserNum,PId from " + Pre + "user_DiscussActiveMember ";
}
else if (flag == 1)
{
Sql = "select DcID from " + Pre + "User_DiscussClass";
}
else if (flag == 2)
{
Sql = "select DcID,Cname from " + Pre + "user_DiscussClass where indexnumber='0'";
}
else if (flag == 3)
{
Sql = "select DisID,UserNum,Member from " + Pre + "User_DiscussMember ";
}
else if (flag == 4)
{
Sql = "select cPointParam,aPointparam from " + Pre + "sys_PramUser";
}
else if (flag == 5)
{
Sql = "select DisID from " + Pre + "user_Discuss";
}
else if (flag == 6)
{
Sql = "select DtID from " + Pre + "User_DiscussTopic";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
#endregion
}
public int sel_getDiscuss(string Str,int flag)
{
#region
SqlParameter param = new SqlParameter("@Str", Str);
string Sql = null;
if (flag == 0)
{
Sql = "select count(id) from " + Pre + "user_Discuss where Cname=@Str";
}
else if (flag == 1)
{
Sql = "select count(*) from " + Pre + "user_Discuss where UserName=@Str";
}
else if (flag == 2)
{
Sql = "select count(ID) from " + Pre + "user_DiscussActiveMember where Aid=@Str";
}
else if (flag == 3)
{
Sql = "select count(ID) from " + Pre + "user_DiscussMember where DisID=@Str";
}
else if (flag == 4)
{
Sql = "select count(*) from " + Pre + "user_Vote where VoteID=@Str";
}
else if (flag == 5)
{
Sql = "select VoteTF from " + Pre + "User_DiscussTopic where DtID=@Str ";
}
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
#endregion
}
public int sel_userInfo(string AId,int flag)
{
#region
SqlParameter param = new SqlParameter("@AId", AId);
string Sql = null;
if (flag == 0)
{
Sql = "select sum(ParticipationNum) from " + Pre + "user_DiscussActiveMember where AId=@AId";
}
else if (flag == 1)//discussTopi_view.aspx
{
Sql = "select sum(VoteNum) from " + Pre + "User_Vote where DtID=@AId";
}
object dir = DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
if (dir != null && dir != DBNull.Value)
{
return Convert.ToInt32(dir);
}
else { return 0; }
#endregion
}
public string sel_disInfoStr(string VoteID,int flag)
{
#region
SqlParameter param = new SqlParameter("@VoteID", VoteID);
string Sql = null;
if (flag == 0)
{
Sql = "select VoteNum from " + Pre + "User_Vote where VoteID=@VoteID";
}
else if (flag == 1)
{
Sql = "select UserName from " + Pre + "User_Discuss where DisID=@VoteID";
}
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
#endregion
}
public int del_userDiscuss(string ID,int flag)
{
#region
SqlParameter param = new SqlParameter("@ID", ID);
string Sql = null;
if (flag == 0)//message_discussclass.aspx
{
Sql = " delete " + Pre + "User_DiscussClass where DcID=@ID and SiteID=" + NetCMS.Global.Current.SiteID + "";
}
else if (flag == 1)//message_userdiscuss_list.aspx
{
Sql = "delete " + Pre + "user_Discuss where DisID=@ID and SiteID=" + NetCMS.Global.Current.SiteID + "";
}
else if (flag == 2)
{
Sql = " delete " + Pre + "user_DiscussActiveMember where Aid=@ID";
}
else if (flag == 3)
{
Sql = " delete " + Pre + "user_DiscussActive where Aid=@ID";
}
else if(flag==4)//discussactijoin_list.aspx
{
Sql = " delete " + Pre + "user_DiscussActiveMember where PId=@ID";
}
else if (flag == 5)//discussManageestablish_list.aspx
{
Sql = " delete " + Pre + "user_DiscussMember where DisID=@ID";
}
else if (flag == 6)
{
Sql = " delete " + Pre + "user_Discuss where DisID=@ID";
}
else if (flag == 7)//discussManagejoin_list.aspx
{
Sql = " delete " + Pre + "user_DiscussMember where Member=@ID and UserNum='" + NetCMS.Global.Current.UserNum + "'";
}
else if (flag == 8)//discussphoto.aspx
{
Sql = "delete " + Pre + "User_Photo where PhotoID=@ID";
}
else if (flag == 9)//discussPhotoalbumlist.aspx
{
Sql = " delete " + Pre + "User_Photoalbum where PhotoalbumID=@ID";
}
else if (flag == 10)
{
Sql = " delete " + Pre + "User_Photo where PhotoalbumID=@ID";
}
else if (flag == 11)//discussTopi_del.aspx
{
Sql = "delete " + Pre + "User_DiscussTopic where DtID=@ID";
}
else if (flag == 12)//discussTopi_del.aspx
{
Sql = "delete " + Pre + "User_DiscussTopic where ParentID=@ID";
}
else if (flag == 13)//discussTopi_del.aspx
{
Sql = "delete " + Pre + "User_Vote where DtID=@ID";
}
else if (flag == 14)//discussTopi_list.aspx
{
Sql = "delete " + Pre + "User_DiscussTopic where DtID=@ID and UserNum='" + NetCMS.Global.Current.UserNum + "'";
}
return (int)DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public int update_discussInfo(DateTime tm, string hidd,int flag)
{
#region
string Sql = null;
if (flag == 0)//discussTopi_commentary.aspx
{
Sql = "update " + Pre + "User_Vote set CreaTime='" + tm + "' where VoteID in (" + hidd + ")";
}
else if (flag == 1)
{
SqlParameter param = new SqlParameter("@VoteID", hidd);
Sql = "update " + Pre + "User_Vote set CreaTime='" + tm + "' where VoteID=@VoteID";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
public int update_sysUserInfo(int cPoint2, int aPoint2, string UserNum, int flag)
{
#region
string Sql = null;
if (flag == 0)//add_discussManage.aspx
{
Sql = "update " + Pre + "sys_User set cPoint='" + cPoint2 + "',aPoint='" + aPoint2 + "' where UserNum='" + UserNum + "'";
}
else if (flag == 1)//discuss_Manageadd.aspx
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
Sql = "update " + Pre + "sys_User set iPoint=iPoint-" + cPoint2 + ",gPoint=gPoint-" + aPoint2 + " where UserNum=@UserNum";
}
else if (flag == 2)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
Sql = "update " + Pre + "sys_User set iPoint=iPoint-" + cPoint2 + ",gPoint=gPoint-" + aPoint2 + " where UserNum=@UserNum";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
public int sel_disInfo(string UserNum, string DisID,int flag)
{
#region
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@UserNum", UserNum), new SqlParameter("@DisID", DisID) };
string Sql = null;
if (flag == 0)
{
Sql = "select count(*) from " + Pre + "User_DiscussMember where UserNum=@UserNum and DisID=@DisID";
}
else if (flag == 1)//discussphotoclass.aspx
{
Sql = "select count(UserName) from " + Pre + "User_PhotoalbumClass where UserName=@UserNum and ClassID=@DisID";
}
return (int)DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
#endregion
}
public int update_userDis(string Fundwarehouse1, string DisID)
{
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@Fundwarehouse", Fundwarehouse1), new SqlParameter("@DisID", DisID) };
string Sql = "update " + Pre + "user_Discuss set Fundwarehouse=@Fundwarehouse where DisID=@DisID";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public int add_discussInfo(STDiscuss DIS)
{
string Sql = "insert into " + Pre + "user_Discuss(DisID,Cname,Authority,Authoritymoney,UserName,Browsenumber,D_Content,D_anno,Creatime,ClassID,Fundwarehouse,GroupSize,GroupPerNum,SiteID) values(@DisID,@Cname,@Authority,@Authoritymoney,@UserName,0,@D_Content,@D_anno,@Creatime,@ClassID,@Fundwarehouse,@GroupSize,@GroupPerNum,@SiteID)";
SqlParameter[] parm = selDiscuss(DIS);
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
public string sel_discussStr()
{
string Sql= "select AId from " + Pre + "user_DiscussActive";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, null));
}
#region message_discussacti.aspx
public int add_userDiscuss(STDiscussActive DA)
{
string Sql ="Insert Into " + Pre + "user_DiscussActive(Activesubject,ActivePlace,ActiveExpense,Anum,ActivePlan,Contactmethod,Cutofftime,CreaTime,AId,UserName,ALabel,siteID) values(@Activesubject,@ActivePlace,@ActiveExpense,@Anum,@ActivePlan,@Contactmethod,@Cutofftime,@CreaTime,@AId,@UserName1,@ALabel,@siteID)";
SqlParameter[] parm = GetDiscussActive(DA);
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
private SqlParameter[] GetDiscussActive(STDiscussActive DA)
{
#region
SqlParameter[] parm = new SqlParameter[12];
parm[0] = new SqlParameter("@Activesubject", SqlDbType.NVarChar, 50);
parm[0].Value = DA.Activesubject;
parm[1] = new SqlParameter("@ActivePlace", SqlDbType.NVarChar, 200);
parm[1].Value = DA.ActivePlace;
parm[2] = new SqlParameter("@ActiveExpense", SqlDbType.NVarChar, 50);
parm[2].Value = DA.ActiveExpense;
parm[3] = new SqlParameter("@Anum", SqlDbType.Int, 4);
parm[3].Value = DA.Anum;
parm[4] = new SqlParameter("@ActivePlan", SqlDbType.NVarChar, 50);
parm[4].Value = DA.ActivePlan;
parm[5] = new SqlParameter("@Contactmethod", SqlDbType.NVarChar, 50);
parm[5].Value = DA.Contactmethod;
parm[6] = new SqlParameter("@Cutofftime", SqlDbType.DateTime);
parm[6].Value = DA.Cutofftime;
parm[7] = new SqlParameter("@CreaTime", SqlDbType.DateTime);
parm[7].Value = DA.CreaTime;
parm[8] = new SqlParameter("@AId", SqlDbType.NVarChar, 18);
parm[8].Value = DA.AId;
parm[9] = new SqlParameter("@UserName1", SqlDbType.NVarChar, 50);
parm[9].Value = DA.UserName;
parm[10] = new SqlParameter("@ALabel", SqlDbType.Int, 4);
parm[10].Value = DA.ALabel;
parm[11] = new SqlParameter("@siteID", SqlDbType.NVarChar, 50);
parm[11].Value = DA.siteID;
return parm;
#endregion
}
#endregion
#region message_discussacti_list.aspx
public int Delete(string ID, string SiteID)
{
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@ID", ID), new SqlParameter("@SiteID", SiteID) };
string Sql = " delete " + Pre + "user_DiscussActive where AId=@ID and SiteID=@SiteID";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion
#region message_discussclass_add.aspx
public int add_disClass(string DcID, string Cname, string Content, string indexnumber, string SiteID)
{
#region
SqlParameter[] param = new SqlParameter[5];
param[0] = new SqlParameter("@DcID", SqlDbType.NVarChar, 50);
param[0].Value = DcID;
param[1] = new SqlParameter("@Cname", SqlDbType.NVarChar, 50);
param[1].Value = Cname;
param[2] = new SqlParameter("@Content", SqlDbType.NVarChar, 200);
param[2].Value = Content;
param[3] = new SqlParameter("@indexnumber", SqlDbType.NVarChar, 50);
param[3].Value = indexnumber;
param[4] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[4].Value = SiteID;
string Sql = "insert into " + Pre + "User_DiscussClass(DcID,Cname,Content,indexnumber,SiteID) values(@DcID,@Cname,@Content,@indexnumber,@SiteID)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
public void getsClassDel(string ID,int flag)
{
#region
SqlParameter param = new SqlParameter("@DcID", ID);
string Sql = null;
if (flag == 0)
{
Sql = "delete from " + Pre + "user_DiscussClass where UserNum='" + NetCMS.Global.Current.UserNum + "' and DcID=@DcID and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if(flag==1)
{
Sql = "update " + Pre + "User_Discuss set Browsenumber=Browsenumber+1 where DisID=@DcID";
}
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
private SqlParameter[] selDiscuss(STDiscuss DIS)
{
#region
SqlParameter[] parm = new SqlParameter[13];
parm[0] = new SqlParameter("@DisID", SqlDbType.NVarChar, 12);
parm[0].Value = DIS.DisID;
parm[1] = new SqlParameter("@Cname", SqlDbType.NVarChar, 100);
parm[1].Value = DIS.Cname;
parm[2] = new SqlParameter("@Authority", SqlDbType.NVarChar, 12);
parm[2].Value = DIS.Authority;
parm[3] = new SqlParameter("@Authoritymoney", SqlDbType.NVarChar, 12);
parm[3].Value = DIS.Authoritymoney;
parm[4] = new SqlParameter("@UserName", SqlDbType.NVarChar, 15);
parm[4].Value = DIS.UserNames;
parm[5] = new SqlParameter("@D_Content", SqlDbType.NVarChar, 200);
parm[5].Value = DIS.D_Content;
parm[6] = new SqlParameter("@D_anno", SqlDbType.NVarChar, 200);
parm[6].Value = DIS.D_anno;
parm[7] = new SqlParameter("@Creatime", SqlDbType.DateTime, 8);
parm[7].Value = DIS.Creatimes;
parm[8] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 50);
parm[8].Value = DIS.ClassID;
parm[9] = new SqlParameter("@Fundwarehouse", SqlDbType.NVarChar, 50);
parm[9].Value = DIS.Fundwarehouse;
parm[10] = new SqlParameter("@GroupSize", SqlDbType.Int, 4);
parm[10].Value = DIS.GroupSize;
parm[11] = new SqlParameter("@GroupPerNum", SqlDbType.Int, 4);
parm[11].Value = DIS.GroupPerNum;
parm[12] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
parm[12].Value = DIS.SiteID;
return parm;
#endregion
}
public int add_Ghistory(string GhID, string UserNum, int Authority3, int Authority2, DateTime Creatime)
{
#region
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@GhID", SqlDbType.NVarChar, 12);
param[0].Value = GhID;
param[1] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
param[1].Value = UserNum;
string Sql = "insert into " + Pre + "User_Ghistory(GhID,UserNUM,Gpoint,iPoint,ghtype,Money,CreatTime) values(@GhID,@UserNum," + Authority3 + "," + Authority2 + ",0,0,'" + Creatime + "')";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public int add_disMember(string Member, string DisID, string UserNum, DateTime Creatime)
{
#region
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@Member",SqlDbType.NVarChar,12);
param[0].Value = Member;
param[1] = new SqlParameter("@DisID", SqlDbType.NVarChar,12);
param[1].Value = DisID;
param[2] = new SqlParameter("@UserNum" ,SqlDbType.NVarChar,12);
param[2].Value = UserNum;
string Sql = "insert into " + Pre + "User_DiscussMember(Member,DisID,UserNum,Creatime) values(@Member,@DisID,@UserNum,'" + Creatime + "')";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#region discussacti_add.aspx(CommandType.Text, Sql, param);
public int add_disActiveMember(string Telephone, int ParticipationNum, int isCompanion, string UserNum, string AIds, string PId, DateTime CreaTime)
{
#region
SqlParameter[] param = new SqlParameter[7];
param[0] = new SqlParameter("@Telephone", SqlDbType.NVarChar, 18);
param[0].Value = Telephone;
param[1] = new SqlParameter("@ParticipationNum", SqlDbType.Int, 4);
param[1].Value = ParticipationNum;
param[2] = new SqlParameter("@isCompanion", SqlDbType.Int, 4);
param[2].Value = isCompanion;
param[3] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 18);
param[3].Value = UserNum;
param[4] = new SqlParameter("@AIds", SqlDbType.NVarChar, 18);
param[4].Value = AIds;
param[5] = new SqlParameter("@PId", SqlDbType.NVarChar, 18);
param[5].Value = PId;
param[6] = new SqlParameter("@CreaTime", SqlDbType.DateTime);
param[6].Value = CreaTime;
string Sql = "Insert Into " + Pre + "user_DiscussActiveMember(Telephone,ParticipationNum,isCompanion,UserNum,AId,PId,CreaTime) values(@Telephone,@ParticipationNum,@isCompanion,@UserNum,@AIds,@PId,@CreaTime)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region discussacti_up.aspx
public int update_disActive(string Activesubject, string ActivePlace, string ActiveExpense, int Anum, string ActivePlan, string Contactmethod, DateTime Cutofftime, DateTime CreaTime, int ALabel, string AIds)
{
#region
SqlParameter[] param = new SqlParameter[10];
param[0] = new SqlParameter("@Activesubject", SqlDbType.NVarChar, 50);
param[0].Value = Activesubject;
param[1] = new SqlParameter("@ActivePlace", SqlDbType.NVarChar, 50);
param[1].Value = ActivePlace;
param[2] = new SqlParameter("@ActiveExpense", SqlDbType.NVarChar, 50);
param[2].Value = ActiveExpense;
param[3] = new SqlParameter("@Anum", SqlDbType.Int, 4);
param[3].Value = Anum;
param[4] = new SqlParameter("@ActivePlan", SqlDbType.NVarChar, 200);
param[4].Value = ActivePlan;
param[5] = new SqlParameter("@Contactmethod", SqlDbType.NVarChar, 50);
param[5].Value = Contactmethod;
param[6] = new SqlParameter("@Cutofftime", SqlDbType.DateTime,8);
param[6].Value = Cutofftime;
param[7] = new SqlParameter("@CreaTime", SqlDbType.DateTime,8);
param[7].Value = CreaTime;
param[8] = new SqlParameter("@ALabel", SqlDbType.Int, 4);
param[8].Value = ALabel;
param[9] = new SqlParameter("@AIds", SqlDbType.NVarChar,18);
param[9].Value = AIds;
string Sql = "update " + Pre + "user_DiscussActive set Activesubject=@Activesubject,ActivePlace=@ActivePlace," +
"ActiveExpense=@ActiveExpense,Anum=@Anum,ActivePlan=@ActivePlan,Contactmethod=@Contactmethod," +
"Cutofftime=@Cutofftime,CreaTime=@CreaTime,ALabel=@ALabel where AId=@AIds";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region discussManage_DC.aspx
public string sel_userDisClass(string DcID, string indexnumber)
{
#region
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@DcID", DcID), new SqlParameter("@indexnumber", indexnumber) };
string _str = "栏目不存在.";
string Sql = null;
if (indexnumber == "@")
{
Sql = "select Cname from " + Pre + "user_DiscussClass where DcID=@DcID";
}
else
{
Sql = "select Cname from " + Pre + "user_DiscussClass where DcID=@DcID and indexnumber=@indexnumber";
}
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
_str = dt.Rows[0]["Cname"].ToString();
}
dt.Clear(); dt.Dispose();
}
return _str;
#endregion
}
#endregion
#region discusssubclass_add.aspx
public int add_discussClass(string DcID, string Cname, string Content, string indexnumber,bool flag)
{
#region
SqlParameter[] param = new SqlParameter[4] ;
param[0] = new SqlParameter("@DcID", SqlDbType.NVarChar, 50);
param[0].Value = DcID;
param[1] = new SqlParameter("@Cname", SqlDbType.NVarChar,50);
param[1].Value = Cname;
param[2] = new SqlParameter("@Content", SqlDbType.NVarChar,200);
param[2].Value = Content;
param[3] = new SqlParameter("@indexnumber", SqlDbType.NVarChar,50);
param[3].Value = indexnumber;
string Sql = null;
if (flag)
{
Sql = "insert into " + Pre + "User_DiscussClass(DcID,Cname,Content,indexnumber,SiteID,UserNum) values(@DcID,@Cname,@Content,@indexnumber,'" + NetCMS.Global.Current.SiteID + "','" + NetCMS.Global.Current.UserNum + "')";
}
else
{
Sql = "insert into " + Pre + "user_Vote(DtID,VoteID,votegenre,VoteNum,Voteitem) values(@DcID,@Cname,@Content,0,@indexnumber)";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region discussTopi_add.aspx
public int add_discussTopic(string DtID, string Title, string Content, int source, string DtUrl, string UserNum, DateTime creatTime, DateTime voteTime, string DisID)
{
#region
SqlParameter[] param = new SqlParameter[9];
param[0] = new SqlParameter("@DtID", SqlDbType.NVarChar, 12);
param[0].Value = DtID;
param[1] = new SqlParameter("@Title", SqlDbType.NVarChar, 200);
param[1].Value = Title;
param[2] = new SqlParameter("@Content", SqlDbType.NText);
param[2].Value = Content;
param[3] = new SqlParameter("@source", SqlDbType.Int, 4);
param[3].Value = source;
param[4] = new SqlParameter("@DtUrl", SqlDbType.NVarChar, 50);
param[4].Value = DtUrl;
param[5] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
param[5].Value = UserNum;
param[6] = new SqlParameter("@creatTime", SqlDbType.DateTime, 8);
param[6].Value = creatTime;
param[7] = new SqlParameter("@voteTime", SqlDbType.DateTime, 8);
param[7].Value = voteTime;
param[8] = new SqlParameter("@DisID", SqlDbType.NVarChar, 18);
param[8].Value = DisID;
string Sql = "insert into " + Pre + "User_DiscussTopic(DtID,Title,Content,source,DtUrl,UserNum,ParentID,creatTime,voteTime,DisID,VoteTF) values(@DtID,@Title,@Content,@source,@DtUrl,@UserNum,'0',@creatTime,@voteTime,@DisID,0)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region discussTopi_ballot.aspx
public int add_userDiscussTopic(string DtID, string Title, string Content, string UserNum, DateTime creatTime, DateTime voteTime, string DisID)
{
#region
SqlParameter[] param = new SqlParameter[7];
param[0] = new SqlParameter("@DtID", SqlDbType.NVarChar, 12);
param[0].Value = DtID;
param[1] = new SqlParameter("@Title", SqlDbType.NVarChar, 200);
param[1].Value = Title;
param[2] = new SqlParameter("@Content", SqlDbType.NText);
param[2].Value = Content;
param[3] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
param[3].Value = UserNum;
param[4] = new SqlParameter("@creatTime", SqlDbType.DateTime, 8);
param[4].Value = creatTime;
param[5] = new SqlParameter("@voteTime", SqlDbType.DateTime, 8);
param[5].Value = voteTime;
param[6] = new SqlParameter("@DisID", SqlDbType.NVarChar, 18);
param[6].Value = DisID;
string Sql = "insert into " + Pre + "User_DiscussTopic(DtID,Title,Content,source,UserNum,ParentID,creatTime," +
"voteTime,DisID,VoteTF) values(@DtID,@Title,@Content,0,@UserNum,'0',@creatTime,@voteTime,@DisID,1)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region discussTopi_commentary.aspx
public void add_userDisTopic(NetCMS.Model.STADDDiscuss uc)
{
string Sql = "insert into " + Pre + "User_DiscussTopic(DtID,Title,Content,UserNum,ParentID,creatTime,DisID) values(@DtID,@Title,@Content,@UserNum,@ParentID,@creatTime,@DisID)";
SqlParameter[] parm = Add_Parameters(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
private SqlParameter[] Add_Parameters(NetCMS.Model.STADDDiscuss uc1)
{
#region
SqlParameter[] param = new SqlParameter[7];
param[0] = new SqlParameter("@DtID", SqlDbType.NVarChar, 12);
param[0].Value = uc1.DtID;
param[1] = new SqlParameter("@Title", SqlDbType.NVarChar, 200);
param[1].Value = uc1.Title;
param[2] = new SqlParameter("@Content", SqlDbType.NText);
param[2].Value = uc1.Content;
param[3] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
param[3].Value = uc1.UserNum;
param[4] = new SqlParameter("@ParentID", SqlDbType.NVarChar, 12);
param[4].Value = uc1.ParentID;
param[5] = new SqlParameter("@creatTime", SqlDbType.DateTime, 8);
param[5].Value = uc1.creatTime;
param[6] = new SqlParameter("@DisID", SqlDbType.NVarChar, 18);
param[6].Value = uc1.DisID;
return param;
#endregion
}
public int update_userVote(int VoteNumsel, string VoteID)
{
SqlParameter param = new SqlParameter("@VoteID", VoteID);
string Sql = "update " + Pre + "User_Vote set VoteNum='" + VoteNumsel + "' where VoteID=@VoteID";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public void updateTopicDtID(string DtID, string title, string content)
{
#region
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@DtID", SqlDbType.NVarChar, 12);
param[0].Value = DtID;
param[1] = new SqlParameter("@title", SqlDbType.NVarChar, 200);
param[1].Value = title;
param[2] = new SqlParameter("@content", SqlDbType.NText);
param[2].Value = content;
string Sql = "update " + Pre + "User_DiscussTopic set title=@title,content=@content where DtID=@DtID and UserNum='" + NetCMS.Global.Current.UserNum + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region disFundwarehouse.aspx
public int add_userGhistory(string GhID, string UserNum, int gPoint1, int iPoint1, DateTime Creatime)
{
#region
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@GhID", SqlDbType.NVarChar, 12);
param[0].Value = GhID;
param[1] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
param[1].Value = UserNum;
param[2] = new SqlParameter("@gPoint1", SqlDbType.Int, 4);
param[2].Value = gPoint1;
param[3] = new SqlParameter("@iPoint1", SqlDbType.Int, 4);
param[3].Value = iPoint1;
param[3] = new SqlParameter("@Creatime", SqlDbType.DateTime, 8);
param[3].Value = Creatime;
string Sql = "insert into " + Pre + "User_Ghistory(GhID,UserNUM,Gpoint,iPoint,ghtype,Money,CreatTime) values(@GhID,@UserNum,@gPoint1,@iPoint1,0,0,@Creatime)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public int add_userDisCon(string Fundwarehouse2, string UserNum, string DisID, DateTime Creatime)
{
#region
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@Fundwarehouse2", SqlDbType.NVarChar, 50);
param[0].Value = Fundwarehouse2;
param[1] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 12);
param[1].Value = UserNum;
param[2] = new SqlParameter("@DisID", SqlDbType.NVarChar, 12);
param[2].Value = DisID;
param[3] = new SqlParameter("@Creatime", SqlDbType.DateTime, 8);
param[3].Value = Creatime;
string Sql = "insert into " + Pre + "User_DiscussContribute(Membermoney,Member,DisID,Creatime) values(@Fundwarehouse2,@UserNum,@DisID,@Creatime)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region up_discussManage.aspx
public DataTable sel_userDiscuss(string DID, string UserName)
{
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@DisID", DID), new SqlParameter("@UserName", UserName) };
string Sql = "select Cname,Authority,Authoritymoney,D_Content,D_anno,ClassID from " + Pre + "user_Discuss where DisID=@DisID and UserName=@UserName";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
public int update_userDis(string Cname, string Authority, string Authoritymoney, string D_Content, string D_anno, DateTime Creatime, string ClassID, string Did, string UserName1)
{
#region
SqlParameter[] param = new SqlParameter[9];
param[0] = new SqlParameter("@Cname",SqlDbType.NVarChar,100);
param[0].Value = Cname;
param[1] = new SqlParameter("@Authority",SqlDbType.NVarChar,12);
param[1].Value = Authority;
param[2] = new SqlParameter("@Authoritymoney",SqlDbType.NVarChar,12);
param[2].Value = Authoritymoney;
param[3] = new SqlParameter("@D_Content",SqlDbType.NVarChar,200);
param[3].Value = D_Content;
param[4] = new SqlParameter("@D_anno",SqlDbType.NVarChar,200);
param[4].Value = D_anno;
param[5] = new SqlParameter("@Creatime",SqlDbType.DateTime,8);
param[5].Value = Creatime;
param[6] = new SqlParameter("@ClassID",SqlDbType.NVarChar,50);
param[6].Value = ClassID;
param[7] = new SqlParameter("@Did",SqlDbType.NVarChar,50);
param[7].Value = Did;
param[8] = new SqlParameter("@UserName1",SqlDbType.NVarChar,15);
param[8].Value = UserName1;
string Sql = "update " + Pre + "user_Discuss set Cname=@Cname,Authority=@Authority,Authoritymoney=@Authoritymoney,D_Content=@D_Content,D_anno=@D_anno,Creatime=@Creatime,ClassID=@ClassID where DisID=@Did and UserName=@UserName1";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Discuss.cs | C# | asf20 | 38,981 |
//======================================================
//== (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.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
class UserAdapt : DbBase, IUserAdapt
{
public bool isExist(string username)
{
SqlParameter param = new SqlParameter("@username", username);
string sql = "select count(UserName) from " + Pre + "sys_User where UserName=@username";
if (Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param)) != 0)
{
return true;
}
else
{
return false;
}
}
public string getUserNumByUserName(string username)
{
SqlParameter param = new SqlParameter("@username", username);
string sql = "select UserNum from " + Pre + "sys_User where UserName=@username";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/UserAdapt.cs | C# | asf20 | 1,459 |
//======================================================
//== (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.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class UserMisc : DbBase, IUserMisc
{
public DataTable getSiteList()
{
string Sql = "select ID,ChannelID,CName from " + Pre + "news_site where IsURL=0 and isRecyle=0 and isLock=0 order by id asc";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
#region 菜单部分
public IDataReader Navilist(string UserNum)
{
string getS = "";
string SQLTF = "select am_ID from " + Pre + "api_Navi where am_position='99999' and siteID='" + NetCMS.Global.Current.SiteID + "' ";
object obj = DbHelper.ExecuteScalar(CommandType.Text, SQLTF, null);
if (obj != null)
{
getS = " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else
{
getS = " and SiteID='0'";
}
string Sql = "select am_ID,am_ClassID,Am_position,am_Name,am_FilePath,am_target,am_type,siteID,userNum,isSys,mainURL From " + Pre + "api_Navi where Am_position='00000' " + getS + " order by am_orderID asc,am_ID desc";
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
public DataTable sel_Misc(string UserNum,int flag)
{
#region
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = null;
if (flag == 0)
{
Sql = "Select logID,Title,Content,userNum,LogDateTime From " + Pre + "user_userlogs Where (DATEDIFF(d, LogDateTime, getdate())<=datenum) and Usernum=@UserNum and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "Select id,Rec_UserNum From " + Pre + "user_message Where Rec_UserNum=@UserNum and isRead=0 and isRdel=0 and isRecyle=0 order by id desc";
}
else if (flag == 2)
{
Sql = "select UserNum,NickName,RealName,birthday,Userinfo,UserFace,userFacesize,email,UserName,Sex,marriage,UserGroupNumber,iPoint,gPoint,cPoint,ePoint,aPoint,RegTime,OnlineTime,OnlineTF,LoginNumber,Mobile,BindTF,PassQuestion,PassKey,CertType,CertNumber,Email,isOpen,isLock from " + Pre + "sys_User where UserNum=@UserNum";
}
else if (flag == 3)
{
Sql = "select Nation,nativeplace,character,orgSch,job,education,Lastschool,UserFan,UserNum,id from " + Pre + "sys_userfields where UserNum=@UserNum";
}
else if (flag == 4)
{
Sql = "select province,City,Address,Postcode,FaTel,WorkTel,Fax,QQ,MSN,id from " + Pre + "sys_userfields where UserNum=@UserNum " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 5)
{
Sql = "select GroupNumber from " + Pre + "user_Group where GroupNumber=@UserNum";
}
else if (flag == 6)
{
Sql = "select id from " + Pre + "sys_user where UserGroupNumber=@UserNum";
}
else if (flag == 7)
{
Sql = "Select am_id,api_IdentID,am_ClassID,Am_position,am_Name,Am_Ename,am_FilePath,am_target,am_ParentID,am_type,am_orderID,isSys From " + Pre + "API_Navi where am_ParentID=@UserNum and SiteID='" + NetCMS.Global.Current.SiteID + "' order by am_orderID desc,am_id asc";
}
else if (flag == 8)
{
Sql = "Select am_ClassID From " + Pre + "API_Navi Where am_ClassID=@UserNum and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 9)
{
Sql = "Select am_id,api_IdentID,am_ClassID,Am_position,am_Name,Am_Ename,am_FilePath,am_target,am_ParentID,am_type,am_orderID,siteid,isSys From " + Pre + "API_Navi where SiteID='" + NetCMS.Global.Current.SiteID + "' " + UserNum + " order by am_orderID asc,am_ID desc";
}
else if (flag == 10)
{
Sql = "Select am_id,api_IdentID,am_ClassID,Am_position,am_Name,Am_Ename,am_FilePath,am_target,am_ParentID,am_type,am_orderID,isSys,popCode From " + Pre + "API_Navi where am_ParentID=@UserNum and SiteID='" + NetCMS.Global.Current.SiteID + "' order by am_orderID desc,am_id desc";
}
else if (flag == 11)
{
Sql = "Select Id From " + Pre + "API_Qmenu Where QmID=@UserNum";
}
else if (flag == 12)
{
Sql = "select * from " + Pre + "sys_userfields where UserNum=@UserNum";
}
else if (flag == 13)
{
Sql = "select ID,Ccid,cName,Content from " + Pre + "user_ConstrClass where UserNum=@UserNum order by id desc";
}
else if (flag == 14)
{
Sql = "select ID,ClassName from " + Pre + "user_URLClass where UserNum=@UserNum order by id desc";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
#endregion
}
public IDataReader ShortcutList(string UserNum, int _num)
{
SqlParameter[] param = new SqlParameter[]
{
new SqlParameter("@UserNum", UserNum),
new SqlParameter("@_num", _num)
};
string Sql = "Select id,QMID,qName,FilePath,usernum,siteid From " + Pre + "API_Qmenu where ismanage=@_num and (UserNum=@UserNum or UserNum='0') order by OrderID desc,id desc";
return DbHelper.ExecuteReader(CommandType.Text, Sql, param);
}
public IDataReader menuNavilist(string stype, string UserNum)
{
SqlParameter[] param = new SqlParameter[]{
new SqlParameter("@stype", stype),
new SqlParameter("@UserNum", UserNum)
};
string getS = "";
string SQLTF = "select am_ID from " + Pre + "api_Navi where am_ParentID=@stype and siteID='" + NetCMS.Global.Current.SiteID + "' ";
object obj = DbHelper.ExecuteScalar(CommandType.Text, SQLTF, param);
if (obj != null)
{
getS = " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else
{
getS = " and SiteID='0'";
}
string Sql = "Select am_ID,am_ClassID,Am_position,am_Name,am_FilePath,am_target,am_type,siteID,userNum,isSys,popCode From " + Pre + "api_Navi where am_ParentID=@stype " + getS + " order by am_orderID asc,am_ID desc";
return DbHelper.ExecuteReader(CommandType.Text, Sql, param);
}
/// <summary>
/// 插入菜单新记录
/// </summary>
/// <param name="uc2"></param>
public void addUpdate_manageMenu(NetCMS.Model.UserInfo7 uc2,int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "insert into " + Pre + "API_Navi (";
Sql += "api_IdentID,am_ClassID,Am_position,am_Name,am_FilePath,am_target,am_ParentID,am_type,am_creatTime,am_orderID,[isSys],siteID,userNum,popCode";
Sql += ") values (";
Sql += "@api_IdentID,@am_ClassID,@Am_position,@am_Name,@am_FilePath,@am_target,@am_ParentID,@am_type,@am_creatTime,@am_orderID,@isSys,'" + NetCMS.Global.Current.SiteID + "',@userNum,@popCode)";
}
else if (flag == 1)
{
Sql = "Update " + Pre + "API_Navi set am_ParentID=@am_ParentID,Am_position=@Am_position,am_Name=@am_Name,am_FilePath=@am_FilePath,am_target=@am_target,am_type=@am_type,am_orderID=@am_orderID,isSys=@isSys,popCode=@popCode where am_ID=" + uc2.am_ID + " " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 2)
{
Sql = "Update " + Pre + "API_Navi set am_Name=@am_Name,am_orderID=@am_orderID,popCode=@popCode where am_ID=" + uc2.am_ID + " " + NetCMS.Common.Public.getSessionStr() + "";
}
SqlParameter[] parm = InsertManageMenuParameters(uc2);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
#endregion
}
/// <summary>
/// 获取UserInfo7构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] InsertManageMenuParameters(NetCMS.Model.UserInfo7 uc1)
{
#region
SqlParameter[] param = new SqlParameter[15];
param[0] = new SqlParameter("@api_IdentID", SqlDbType.NVarChar, 30);
param[0].Value = uc1.api_IdentID;
param[1] = new SqlParameter("@am_ClassID", SqlDbType.NVarChar, 12);
param[1].Value = uc1.am_ClassID;
param[2] = new SqlParameter("@Am_position", SqlDbType.NVarChar, 5);
param[2].Value = uc1.Am_position;
param[3] = new SqlParameter("@am_Name", SqlDbType.NVarChar, 20);
param[3].Value = uc1.am_Name;
param[4] = new SqlParameter("@am_FilePath", SqlDbType.NVarChar, 200);
param[4].Value = uc1.am_FilePath;
param[5] = new SqlParameter("@am_target", SqlDbType.NVarChar, 20);
param[5].Value = uc1.am_target;
param[6] = new SqlParameter("@am_ParentID", SqlDbType.NVarChar, 12);
param[6].Value = uc1.am_ParentID;
param[7] = new SqlParameter("@am_type", SqlDbType.TinyInt, 1);
param[7].Value = uc1.am_type;
param[8] = new SqlParameter("@am_creatTime", SqlDbType.DateTime, 8);
param[8].Value = uc1.am_creatTime;
param[9] = new SqlParameter("@am_orderID", SqlDbType.Int, 4);
param[9].Value = uc1.am_orderID;
param[10] = new SqlParameter("@isSys", SqlDbType.TinyInt, 1);
param[10].Value = uc1.isSys;
param[11] = new SqlParameter("@siteID", SqlDbType.NVarChar, 12);
param[11].Value = uc1.siteID;
param[12] = new SqlParameter("@userNum", SqlDbType.NVarChar, 12);
param[12].Value = uc1.userNum;
param[13] = new SqlParameter("@am_ID", SqlDbType.Int, 4);
param[13].Value = uc1.am_ID;
param[14] = new SqlParameter("@popCode", SqlDbType.NVarChar, 50);
param[14].Value = uc1.popCode;
return param;
#endregion
}
/// <summary>
/// 获取UserInfo7构造1
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] InsertManageMenuParameters1(NetCMS.Model.UserInfo7 uc1)
{
#region
SqlParameter[] param = new SqlParameter[10];
param[0] = new SqlParameter("@Am_position", SqlDbType.NVarChar, 5);
param[0].Value = uc1.Am_position;
param[1] = new SqlParameter("@am_Name", SqlDbType.NVarChar, 20);
param[1].Value = uc1.am_Name;
param[2] = new SqlParameter("@am_FilePath", SqlDbType.NVarChar, 200);
param[2].Value = uc1.am_FilePath;
param[3] = new SqlParameter("@am_target", SqlDbType.NVarChar, 20);
param[3].Value = uc1.am_target;
param[4] = new SqlParameter("@am_ParentID", SqlDbType.NVarChar, 12);
param[4].Value = uc1.am_ParentID;
param[5] = new SqlParameter("@am_type", SqlDbType.TinyInt, 1);
param[5].Value = uc1.am_type;
param[6] = new SqlParameter("@am_orderID", SqlDbType.Int, 4);
param[6].Value = uc1.am_orderID;
param[7] = new SqlParameter("@isSys", SqlDbType.TinyInt, 1);
param[7].Value = uc1.isSys;
param[8] = new SqlParameter("@am_ID", SqlDbType.Int, 4);
param[8].Value = uc1.am_ID;
param[9] = new SqlParameter("@popCode", SqlDbType.NVarChar, 50);
param[9].Value = uc1.popCode;
return param;
#endregion
}
/// <summary>
/// 获取UserInfo7构造2
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] InsertManageMenuParameters2(NetCMS.Model.UserInfo7 uc1)
{
#region
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@am_Name", SqlDbType.NVarChar, 20);
param[0].Value = uc1.am_Name;
param[1] = new SqlParameter("@am_orderID", SqlDbType.Int, 4);
param[1].Value = uc1.am_orderID;
param[2] = new SqlParameter("@am_ID", SqlDbType.Int, 4);
param[2].Value = uc1.am_ID;
param[3] = new SqlParameter("@popCode", SqlDbType.NVarChar, 50);
param[3].Value = uc1.popCode;
return param;
#endregion
}
/// <summary>
/// 删除快揭菜单
/// </summary>
/// <param name="Qid"></param>
public void QShortcutdel(int Qid, int _num)
{
string str_sql = "delete From " + Pre + "API_Qmenu where id=" + Qid + " and UserNum='" + NetCMS.Global.Current.UserNum + "' and ismanage=" + _num + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
}
/// <summary>
/// 获取快捷菜单的列表(管理员)
/// </summary>
/// <returns></returns>
public IDataReader QShortcutList(int _num)
{
string Sql = "Select id,QMID,qName,FilePath,usernum,siteid,orderid From " + Pre + "API_Qmenu where (UserNum='" + NetCMS.Global.Current.UserNum + "' or UserNum='0') and ismanage=" + _num + " and SiteID='" + NetCMS.Global.Current.SiteID + "' order by OrderID desc,id desc";
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
/// <summary>
/// 插入快捷菜单新记录
/// </summary>
/// <param name="uc2"></param>
public void addUpdate_QMenu(NetCMS.Model.UserInfo8 uc2,bool flag)
{
#region
string Sql = null;
SqlParameter[] parm;
if (flag)
{
Sql = "insert into " + Pre + "API_Qmenu (";
Sql += "QmID,qName,FilePath,Ismanage,OrderID,usernum,SiteID";
Sql += ") values (";
Sql += "@QmID,@qName,@FilePath,@Ismanage,@OrderID,@usernum,'" + NetCMS.Global.Current.SiteID + "')";
parm = InsertQMenuParameters(uc2);
}
else
{
Sql = "Update " + Pre + "API_Qmenu set qName=@qName,FilePath=@FilePath,OrderID=@OrderID where ID=" + uc2.Id + " and UserNum='" + NetCMS.Global.Current.UserNum + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
parm = new SqlParameter[3];
parm[0] = new SqlParameter("@qName", SqlDbType.NVarChar, 50);
parm[0].Value = uc2.qName;
parm[1] = new SqlParameter("@FilePath", SqlDbType.NVarChar, 200);
parm[1].Value = uc2.FilePath;
parm[2] = new SqlParameter("@OrderID", SqlDbType.Int, 4);
parm[2].Value = uc2.OrderID;
}
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
#endregion
}
/// <summary>
/// 获取UserInfo8构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] InsertQMenuParameters(NetCMS.Model.UserInfo8 uc1)
{
#region
SqlParameter[] param = new SqlParameter[8];
param[0] = new SqlParameter("@QmID", SqlDbType.NVarChar, 12);
param[0].Value = uc1.QmID;
param[1] = new SqlParameter("@qName", SqlDbType.NVarChar, 50);
param[1].Value = uc1.qName;
param[2] = new SqlParameter("@FilePath", SqlDbType.NVarChar, 200);
param[2].Value = uc1.FilePath;
param[3] = new SqlParameter("@Ismanage", SqlDbType.TinyInt, 1);
param[3].Value = uc1.Ismanage;
param[4] = new SqlParameter("@OrderID", SqlDbType.Int, 4);
param[4].Value = uc1.OrderID;
param[5] = new SqlParameter("@usernum", SqlDbType.NVarChar, 15);
param[5].Value = uc1.usernum;
param[6] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[6].Value = uc1.SiteID;
param[7] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[7].Value = uc1.Id;
return param;
#endregion
}
/// <summary>
/// 获取UserInfo8构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] InsertQMenuParameters1(NetCMS.Model.UserInfo8 uc1)
{
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@qName", SqlDbType.NVarChar, 50);
param[0].Value = uc1.qName;
param[1] = new SqlParameter("@FilePath", SqlDbType.NVarChar, 200);
param[1].Value = uc1.FilePath;
param[2] = new SqlParameter("@OrderID", SqlDbType.Int, 4);
param[2].Value = uc1.OrderID;
param[3] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[3].Value = uc1.Id;
return param;
}
#endregion 菜单部分
#region 会员列表部分
public DataTable sel_sysInfos(int Uid,int flag)
{
#region
string Sql = null;
SqlParameter param = new SqlParameter("@nID", Uid); ;
if (flag == 0)
{
Sql = "select UserGroupNumber,UserNum,NickName,RealName,birthday,Userinfo,UserFace,userFacesize,email,sex,marriage,isopen,id,CertType,CertNumber,ipoint,gpoint,cpoint,epoint,apoint,RegTime,onlineTime,LoginNumber,LoginLimtNumber,lastIP,LastLoginTime,SiteID,islock,isadmin,isIDcard,UserName,IDcardFiles from " + Pre + "sys_User where id=@nID" + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 1)
{
Sql = "select CharLenContent,CharHTML,CharTF from " + Pre + "user_group a," + Pre + "sys_user b where b.id=@nID and b.UserGroupNumber=a.GroupNumber";
}
else if (flag == 2)
{
Sql = "select PassQuestion,PassKey from " + Pre + "sys_User where ID=@nID";
}
else if (flag == 3)
{
Sql = "select id,GroupNumber,GroupName,iPoint,Gpoint,Rtime,LenCommContent,CommCheckTF,PostCommTime,upfileType,upfileNum,upfileSize,DayUpfilenum,ContrNum,DicussTF,PostTitle,ReadUser,MessageNum,MessageGroupNum,IsCert,CharTF,CharHTML,CharLenContent,RegMinute,PostTitleHTML,DelSelfTitle,DelOTitle,EditSelfTitle,EditOtitle,ReadTitle,MoveSelfTitle,MoveOTitle,TopTitle,GoodTitle,LockUser,UserFlag,CheckTtile,IPTF,EncUser,OCTF,StyleTF,UpfaceSize,GIChange,GTChageRate,LoginPoint,RegPoint,GroupTF,GroupSize,GroupPerNum,GroupCreatNum,CreatTime,siteID,Discount from " + Pre + "user_Group where id=@nID" + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 4)
{
Sql = "select id,title,content,getpoint,GroupNumber from " + Pre + "user_news where id=@nID" + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 5)
{
Sql = "Select am_id,api_IdentID,am_ClassID,Am_position,am_Name,Am_Ename,am_FilePath,am_target,am_ParentID,am_type,am_orderID,isSys,popCode From " + Pre + "API_Navi where am_id=@nID and SiteID='" + NetCMS.Global.Current.SiteID + "' order by am_orderID desc,am_id desc";
}
else if (flag == 6)
{
Sql = "Select QmID,qName,FilePath,Ismanage,OrderID,usernum,siteID From " + Pre + "API_Qmenu Where ID=@nID and UserNum = '" + NetCMS.Global.Current.UserNum + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 7)
{
Sql = "Select QmID From " + Pre + "API_Qmenu Where UserNum='" + NetCMS.Global.Current.UserNum + "' and ismanage=@nID and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 8)
{
Sql = "select id,CardNumber,CardPassWord,Money,Point,TimeOutDate,isLock,isUse,isBuy From " + Pre + "user_card where id=@nID and SiteID = '" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 9)
{
Sql = "select * from " + Pre + "user_URL where ID=@nID";
}
else if (flag == 10)
{
Sql = "select * from " + Pre + "user_URL where ClassID=@nID order by id desc";
}
else if (flag == 11)
{
Sql = "select * from " + Pre + "user_URLClass where ID=@nID";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
#endregion
}
public void UpdateUserSafe(int Uid, string PassQuestion, string PassKey, string password)
{
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@PassQuestion", SqlDbType.NVarChar, 20);
param[0].Value = PassQuestion;
param[1] = new SqlParameter("@PassKey", SqlDbType.NVarChar, 20);
param[1].Value = NetCMS.Common.Input.MD5(PassKey);
param[2] = new SqlParameter("@password", SqlDbType.NVarChar, 32);
param[2].Value = NetCMS.Common.Input.MD5(password);
string str_sql = "Update " + Pre + "sys_User set PassQuestion=@PassQuestion,PassKey=@PassKey,UserPassword=@password where id=" + Uid + NetCMS.Common.Public.getSessionStr() + "";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, param);
}
public void UpdateUserInfoIDCard(int Uid, string _temp)
{
string str_sql = "update " + Pre + "sys_user " + _temp + " where id=" + Uid + NetCMS.Common.Public.getSessionStr() + "";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
}
/// <summary>
/// 得到是否是管理员
/// </summary>
/// <returns>1是,0否</returns>
public int getisAdmin()
{
int intflg = 0;
string Sql = "select isAdmin from " + Pre + "sys_User where UserNum='" + NetCMS.Global.Current.UserNum + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (dt != null)
{
if (dt.Rows.Count > 0) { intflg = int.Parse(dt.Rows[0]["isAdmin"].ToString()); }
dt.Clear(); dt.Dispose();
}
return intflg;
}
/// <summary>
/// 更新基本资料
/// </summary>
/// <param name="uc"></param>
public void UpdateUserInfoBase(NetCMS.Model.UserInfo uc)
{
string str_sql = "Update " + Pre + "sys_User set NickName=@NickName,RealName=@RealName,sex=@sex,birthday=@birthday,Userinfo=@Userinfo,UserFace=@UserFace,userFacesize=@userFacesize,marriage=@marriage,isopen=@isopen,UserGroupNumber=@UserGroupNumber,email=@email where id=" + uc.Id + " " + NetCMS.Common.Public.getSessionStr() + "";
SqlParameter[] parm = GetUserInfoParameters(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, parm);
}
/// <summary>
/// 获取UserInfo构造
/// </summary>
/// <param name="uc"></param>
/// <returns></returns>
private SqlParameter[] GetUserInfoParameters(NetCMS.Model.UserInfo uc)
{
SqlParameter[] param = new SqlParameter[11];
param[0] = new SqlParameter("@NickName", SqlDbType.NVarChar, 12);
param[0].Value = uc.NickName;
param[1] = new SqlParameter("@RealName", SqlDbType.NVarChar, 20);
param[1].Value = uc.RealName;
param[2] = new SqlParameter("@sex", SqlDbType.TinyInt, 1);
param[2].Value = uc.sex;
param[3] = new SqlParameter("@birthday", SqlDbType.DateTime, 8);
param[3].Value = uc.birthday;
param[4] = new SqlParameter("@Userinfo", SqlDbType.NText);
param[4].Value = uc.Userinfo;
param[5] = new SqlParameter("@UserFace", SqlDbType.NVarChar, 220);
param[5].Value = uc.UserFace;
param[6] = new SqlParameter("@userFacesize", SqlDbType.NVarChar, 8);
param[6].Value = uc.userFacesize;
param[7] = new SqlParameter("@marriage", SqlDbType.TinyInt, 1);
param[7].Value = uc.marriage;
param[8] = new SqlParameter("@isopen", SqlDbType.TinyInt, 1);
param[8].Value = uc.isopen;
param[9] = new SqlParameter("@UserGroupNumber", SqlDbType.NVarChar, 12);
param[9].Value = uc.UserGroupNumber;
param[10] = new SqlParameter("@email", SqlDbType.NVarChar, 220);
param[10].Value = uc.email;
return param;
}
/// <summary>
/// 更新基本资料第2表
/// </summary>
/// <param name="uc1"></param>
public void addUpdate_userFields(NetCMS.Model.UserInfo1 uc1, bool flag)
{
string str_sql = null;
if (flag)
{
str_sql = "Update " + Pre + "sys_userfields set Nation=@Nation,nativeplace=@nativeplace,character=@character,UserFan=@UserFan,orgSch=@orgSch,job=@job,education=@education,Lastschool=@Lastschool where UserNum=@UserNum";
}
else// 如果基本资料第2表,则插入新记录
{
str_sql = "insert into " + Pre + "sys_userfields (";
str_sql += "UserNum,Nation,nativeplace,character,UserFan,orgSch,job,education,Lastschool";
str_sql += ") values (";
str_sql += "@UserNum,@Nation,@nativeplace,@character,@UserFan,@orgSch,@job,@education,@Lastschool)";
}
SqlParameter[] parm = GetUserInfoParameters1(uc1);
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, parm);
}
/// <summary>
/// 获取UserInfo1构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] GetUserInfoParameters1(NetCMS.Model.UserInfo1 uc1)
{
SqlParameter[] param = new SqlParameter[9];
param[0] = new SqlParameter("@Nation", SqlDbType.NVarChar, 12);
param[0].Value = uc1.Nation;
param[1] = new SqlParameter("@nativeplace", SqlDbType.NVarChar, 20);
param[1].Value = uc1.nativeplace;
param[2] = new SqlParameter("@character", SqlDbType.NText);
param[2].Value = uc1.character;
param[3] = new SqlParameter("@UserFan", SqlDbType.NText);
param[3].Value = uc1.UserFan;
param[4] = new SqlParameter("@orgSch", SqlDbType.NVarChar, 10);
param[4].Value = uc1.orgSch;
param[5] = new SqlParameter("@job", SqlDbType.NVarChar, 30);
param[5].Value = uc1.job;
param[6] = new SqlParameter("@education", SqlDbType.NVarChar, 20);
param[6].Value = uc1.education;
param[7] = new SqlParameter("@Lastschool", SqlDbType.NVarChar, 80);
param[7].Value = uc1.Lastschool;
param[8] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
param[8].Value = uc1.UserNum;
return param;
}
/// <summary>
/// 更新基本资料第2表
/// </summary>
/// <param name="uc1"></param>
public void addUpdate_fields(NetCMS.Model.UserInfo2 uc1,bool flag)
{
#region
string str_sql = null;
if (flag)
{
str_sql = "Update " + Pre + "sys_userfields set province=@province,City=@City,Address=@Address,Postcode=@Postcode,FaTel=@FaTel,WorkTel=@WorkTel,Fax=@Fax,QQ=@QQ,MSN=@MSN where UserNum=@UserNum";
}
else
{
str_sql = "insert into " + Pre + "sys_userfields (";
str_sql += "UserNum,province,City,Address,Postcode,FaTel,WorkTel,Fax,QQ,MSN";
str_sql += ") values (";
str_sql += "@UserNum,@province,@City,@Address,@Postcode,@FaTel,@WorkTel,@Fax,@QQ,@MSN)";
}
SqlParameter[] parm = GetUserInfoContactParameters1(uc1);
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, parm);
#endregion
}
private SqlParameter[] GetUserInfoContactParameters1(NetCMS.Model.UserInfo2 uc1)
{
#region
SqlParameter[] param = new SqlParameter[10];
param[0] = new SqlParameter("@province", SqlDbType.NVarChar, 20);
param[0].Value = uc1.province;
param[1] = new SqlParameter("@City", SqlDbType.NVarChar, 20);
param[1].Value = uc1.City;
param[2] = new SqlParameter("@Address", SqlDbType.NVarChar, 50);
param[2].Value = uc1.Address;
param[3] = new SqlParameter("@Postcode", SqlDbType.NVarChar, 10);
param[3].Value = uc1.Postcode;
param[4] = new SqlParameter("@FaTel", SqlDbType.NVarChar, 30);
param[4].Value = uc1.FaTel;
param[5] = new SqlParameter("@WorkTel", SqlDbType.NVarChar, 30);
param[5].Value = uc1.WorkTel;
param[6] = new SqlParameter("@Fax", SqlDbType.NVarChar, 30);
param[6].Value = uc1.Fax;
param[7] = new SqlParameter("@QQ", SqlDbType.NVarChar, 30);
param[7].Value = uc1.QQ;
param[8] = new SqlParameter("@MSN", SqlDbType.NVarChar, 150);
param[8].Value = uc1.MSN;
param[9] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
param[9].Value = uc1.UserNum;
return param;
#endregion
}
/// <summary>
/// 如果基本资料状态表
/// </summary>
/// <param name="uc2"></param>
public void UpdateUserInfoBaseStat(NetCMS.Model.UserInfo3 uc)
{
string str_sql = "Update " + Pre + "sys_user set UserGroupNumber=@UserGroupNumber,islock=@islock,isadmin=@isadmin,CertType=@CertType,CertNumber=@CertNumber,ipoint=@ipoint,gpoint=@gpoint,cpoint=@cpoint,epoint=@epoint,apoint=@apoint,onlineTime=@onlineTime,RegTime=@RegTime,LastLoginTime=@LastLoginTime,LoginNumber=@LoginNumber,LoginLimtNumber=@LoginLimtNumber,lastIP=@lastIP,SiteID=@SiteID where Id=" + uc.Id + "";
SqlParameter[] parm = GetUserInfoBaseStatParameters1(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, parm);
}
private SqlParameter[] GetUserInfoBaseStatParameters1(NetCMS.Model.UserInfo3 uc1)
{
#region
SqlParameter[] param = new SqlParameter[17];
param[0] = new SqlParameter("@UserGroupNumber", SqlDbType.NVarChar, 12);
param[0].Value = uc1.UserGroupNumber;
param[1] = new SqlParameter("@islock", SqlDbType.TinyInt, 1);
param[1].Value = uc1.islock;
param[2] = new SqlParameter("@isadmin", SqlDbType.TinyInt, 1);
param[2].Value = uc1.isadmin;
param[3] = new SqlParameter("@CertType", SqlDbType.NVarChar, 15);
param[3].Value = uc1.CertType;
param[4] = new SqlParameter("@CertNumber", SqlDbType.NVarChar, 20);
param[4].Value = uc1.CertNumber;
param[5] = new SqlParameter("@ipoint", SqlDbType.Int, 4);
param[5].Value = uc1.ipoint;
param[6] = new SqlParameter("@gpoint", SqlDbType.Int, 4);
param[6].Value = uc1.gpoint;
param[7] = new SqlParameter("@cpoint", SqlDbType.Int, 4);
param[7].Value = uc1.cpoint;
param[8] = new SqlParameter("@epoint", SqlDbType.Int, 4);
param[8].Value = uc1.epoint;
param[9] = new SqlParameter("@apoint", SqlDbType.Int, 4);
param[9].Value = uc1.apoint;
param[10] = new SqlParameter("@onlineTime", SqlDbType.Int, 4);
param[10].Value = uc1.onlineTime;
param[11] = new SqlParameter("@RegTime", SqlDbType.DateTime, 8);
param[11].Value = uc1.RegTime;
param[12] = new SqlParameter("@LastLoginTime", SqlDbType.DateTime, 8);
param[12].Value = uc1.LastLoginTime;
param[13] = new SqlParameter("@LoginNumber", SqlDbType.Int, 4);
param[13].Value = uc1.LoginNumber;
param[14] = new SqlParameter("@LoginLimtNumber", SqlDbType.Int, 4);
param[14].Value = uc1.LoginLimtNumber;
param[15] = new SqlParameter("@lastIP", SqlDbType.NVarChar, 16);
param[15].Value = uc1.lastIP;
param[16] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[16].Value = uc1.SiteID;
return param;
#endregion
}
/// <summary>
///更新手机号码
/// </summary>
/// <param name="uc2"></param>
public void updateMobile(string _MobileNumber, int BindTF)
{
SqlParameter param = new SqlParameter("@Mobile", _MobileNumber);
string Sql = "Update " + Pre + "sys_User set mobile=@Mobile,BindTF=" + BindTF + " where UserNum='" + NetCMS.Global.Current.UserNum + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion 会员列表部分
#region 会员组部分
public void del_User(int Gid,int flag)
{
#region
string str_sql = null;
SqlParameter param = null;
if (flag == 0)
{
rootPublic pd = new rootPublic();
//更新相应的会员数据会员组
string SQL = "Update " + Pre + "sys_user set UserGroupNumber='0' where UserGroupNumber='" + pd.getGidGroupNumber(Gid) + "' " + NetCMS.Common.Public.getSessionStr() + "";
DbHelper.ExecuteNonQuery(CommandType.Text, SQL, null);
str_sql = "Delete From " + Pre + "user_Group where id=" + Gid + " " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 1)
{
param = new SqlParameter("@Qid", Gid);
str_sql = "delete From " + Pre + "API_Navi where am_id=@Qid and UserNum='" + NetCMS.Global.Current.UserNum + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
str_sql = "delete from " + Pre + "user_URL where ID =" + Gid + " and UserNum='" + NetCMS.Global.Current.UserNum + "'";
}
else if (flag == 3)
{
string Sql = "delete from " + Pre + "user_URLClass where ID =" + Gid + " and UserNum='" + NetCMS.Global.Current.UserNum + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
str_sql = "delete from " + Pre + "user_URL where ClassID =" + Gid + " and UserNum='" + NetCMS.Global.Current.UserNum + "'";
}
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, param);
#endregion
}
public DataTable sel_GroupListStr(int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "select id,GroupNumber,Discount,GroupName,iPoint,Gpoint,CreatTime,Rtime from " + Pre + "user_Group where 1=1 " + NetCMS.Common.Public.getSessionStr() + " order by id desc";
}
else if (flag == 1)
{
Sql = "select onpayType,O_userName,O_key,O_sendurl,O_returnurl,O_md5,O_other1,O_other2,O_other3 from " + Pre + "sys_PramUser where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "Select am_id,api_IdentID,am_ClassID,Am_position,am_Name,Am_Ename,am_FilePath,am_target,am_ParentID,am_type,am_orderID,isSys From " + Pre + "API_Navi where Am_position='00000' and SiteID='" + NetCMS.Global.Current.SiteID + "' order by am_orderID desc,am_id asc";
}
else if (flag == 3)
{
Sql = "Select am_id,api_IdentID,am_ClassID,Am_position,am_Name,Am_Ename,am_FilePath,am_target,am_ParentID,am_type,am_orderID,isSys,popCode From " + Pre + "API_Navi where Am_position='00000' and SiteID='" + NetCMS.Global.Current.SiteID + "' order by am_orderID desc,am_id desc";
}
else if (flag == 4)
{
Sql = "select isIDcard,IDcardFiles,ID,BindTF from " + Pre + "sys_User where UserNum='" + NetCMS.Global.Current.UserNum + "'";
}
else if (flag == 5)
{
Sql = "select DisTinct Money from " + Pre + "user_Card where isBuy=0 and isUse=0 and isLock=0 and SiteID='" + NetCMS.Global.Current.SiteID + "' and TimeOutDate>'" + DateTime.Now + "' and Money>0 order by Money asc";
}
else if (flag == 6)
{
Sql = "select LTitle,Lpicurl,iPoint from " + Pre + "sys_UserLevel order by id asc";
}
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return rdr;
#endregion
}
/// <summary>
/// 插入新会员组
/// </summary>
/// <param name="uc2"></param>
public void addUpdate_Group(NetCMS.Model.UserInfo4 uc2,bool flag)
{
#region
string Sql = null;
if (flag)
{
Sql = "Insert Into " + Pre + "user_Group(GroupNumber,GroupName,iPoint,Gpoint,Rtime,LenCommContent,CommCheckTF,PostCommTime,upfileType,upfileNum,upfileSize,DayUpfilenum,ContrNum,DicussTF,PostTitle,ReadUser,MessageNum,MessageGroupNum,IsCert,CharTF,CharHTML,CharLenContent,RegMinute,PostTitleHTML,DelSelfTitle,DelOTitle,EditSelfTitle,EditOtitle,ReadTitle,MoveSelfTitle,MoveOTitle,TopTitle,GoodTitle,LockUser,UserFlag,CheckTtile,IPTF,EncUser,OCTF,StyleTF,UpfaceSize,GIChange,GTChageRate,LoginPoint,RegPoint,GroupTF,GroupSize,GroupPerNum,GroupCreatNum,CreatTime,siteID,Discount";
Sql += ") Values(";
Sql += "@GroupNumber,@GroupName,@iPoint,@Gpoint,@Rtime,@LenCommContent,@CommCheckTF,@PostCommTime,@upfileType,@upfileNum,@upfileSize,@DayUpfilenum,@ContrNum,@DicussTF,@PostTitle,@ReadUser,@MessageNum,@MessageGroupNum,@IsCert,@CharTF,@CharHTML,@CharLenContent,@RegMinute,@PostTitleHTML,@DelSelfTitle,@DelOTitle,@EditSelfTitle,@EditOtitle,@ReadTitle,@MoveSelfTitle,@MoveOTitle,@TopTitle,@GoodTitle,@LockUser,@UserFlag,@CheckTtile,@IPTF,@EncUser,@OCTF,@StyleTF,@UpfaceSize,@GIChange,@GTChageRate,@LoginPoint,@RegPoint,@GroupTF,@GroupSize,@GroupPerNum,@GroupCreatNum,@CreatTime,@siteID,@Discount)";
}
else
{
Sql = "Update " + Pre + "user_Group set GroupName=@GroupName,iPoint=@iPoint,Gpoint=@Gpoint,Rtime=@Rtime,LenCommContent=@LenCommContent,CommCheckTF=@CommCheckTF,PostCommTime=@PostCommTime,upfileType=@upfileType,upfileNum=@upfileNum,upfileSize=@upfileSize,DayUpfilenum=@DayUpfilenum,ContrNum=@ContrNum,DicussTF=@DicussTF,PostTitle=@PostTitle,ReadUser=@ReadUser,MessageNum=@MessageNum,MessageGroupNum=@MessageGroupNum,IsCert=@IsCert,CharTF=@CharTF,CharHTML=@CharHTML,CharLenContent=@CharLenContent,RegMinute=@RegMinute,PostTitleHTML=@PostTitleHTML,DelSelfTitle=@DelSelfTitle,DelOTitle=@DelOTitle,EditSelfTitle=@EditSelfTitle,EditOtitle=@EditOtitle,ReadTitle=@ReadTitle,MoveSelfTitle=@MoveSelfTitle,MoveOTitle=@MoveOTitle,TopTitle=@TopTitle,GoodTitle=@GoodTitle,LockUser=@LockUser,UserFlag=@UserFlag,CheckTtile=@CheckTtile,IPTF=@IPTF,EncUser=@EncUser,OCTF=@OCTF,StyleTF=@StyleTF,UpfaceSize=@UpfaceSize,GIChange=@GIChange,GTChageRate=@GTChageRate,LoginPoint=@LoginPoint,RegPoint=@RegPoint,GroupTF=@GroupTF,GroupSize=@GroupSize,GroupPerNum=@GroupPerNum,GroupCreatNum=@GroupCreatNum,Discount=@Discount where id=" + uc2.gID + "";
}
SqlParameter[] parm = InsertGroupParameters(uc2);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
#endregion
}
/// <summary>
/// 获取UserInfo4构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] InsertGroupParameters(NetCMS.Model.UserInfo4 uc1)
{
#region
SqlParameter[] param = new SqlParameter[52];
param[0] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[0].Value = uc1.SiteID;
param[1] = new SqlParameter("@GroupNumber", SqlDbType.NVarChar, 12);
param[1].Value = uc1.GroupNumber;
param[2] = new SqlParameter("@GroupName", SqlDbType.NVarChar, 50);
param[2].Value = uc1.GroupName;
param[3] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
param[3].Value = uc1.iPoint;
param[4] = new SqlParameter("@Gpoint", SqlDbType.Int, 4);
param[4].Value = uc1.Gpoint;
param[5] = new SqlParameter("@Rtime", SqlDbType.Int, 4);
param[5].Value = uc1.Rtime;
param[6] = new SqlParameter("@LenCommContent", SqlDbType.Int, 4);
param[6].Value = uc1.LenCommContent;
param[7] = new SqlParameter("@CommCheckTF", SqlDbType.TinyInt, 1);
param[7].Value = uc1.CommCheckTF;
param[8] = new SqlParameter("@PostCommTime", SqlDbType.Int, 4);
param[8].Value = uc1.PostCommTime;
param[9] = new SqlParameter("@upfileType", SqlDbType.NVarChar, 200);
param[9].Value = uc1.upfileType;
param[10] = new SqlParameter("@upfileNum", SqlDbType.Int, 4);
param[10].Value = uc1.upfileNum;
param[11] = new SqlParameter("@upfileSize", SqlDbType.Int, 4);
param[11].Value = uc1.upfileSize;
param[12] = new SqlParameter("@DayUpfilenum", SqlDbType.Int, 4);
param[12].Value = uc1.DayUpfilenum;
param[13] = new SqlParameter("@ContrNum", SqlDbType.Int, 4);
param[13].Value = uc1.ContrNum;
param[14] = new SqlParameter("@DicussTF", SqlDbType.TinyInt, 1);
param[14].Value = uc1.DicussTF;
param[15] = new SqlParameter("@PostTitle", SqlDbType.TinyInt, 1);
param[15].Value = uc1.PostTitle;
param[16] = new SqlParameter("@ReadUser", SqlDbType.TinyInt, 1);
param[16].Value = uc1.ReadUser;
param[17] = new SqlParameter("@MessageNum", SqlDbType.Int, 4);
param[17].Value = uc1.MessageNum;
param[18] = new SqlParameter("@MessageGroupNum", SqlDbType.NVarChar, 15);
param[18].Value = uc1.MessageGroupNum;
param[19] = new SqlParameter("@IsCert", SqlDbType.TinyInt, 1);
param[19].Value = uc1.IsCert;
param[20] = new SqlParameter("@CharTF", SqlDbType.TinyInt, 1);
param[20].Value = uc1.CharTF;
param[21] = new SqlParameter("@CharHTML", SqlDbType.TinyInt, 1);
param[21].Value = uc1.CharHTML;
param[22] = new SqlParameter("@CharLenContent", SqlDbType.Int, 4);
param[22].Value = uc1.CharLenContent;
param[23] = new SqlParameter("@RegMinute", SqlDbType.Int, 4);
param[23].Value = uc1.RegMinute;
param[24] = new SqlParameter("@PostTitleHTML", SqlDbType.TinyInt, 1);
param[24].Value = uc1.PostTitleHTML;
param[25] = new SqlParameter("@DelSelfTitle", SqlDbType.TinyInt, 1);
param[25].Value = uc1.DelSelfTitle;
param[26] = new SqlParameter("@DelOTitle", SqlDbType.TinyInt, 1);
param[26].Value = uc1.DelOTitle;
param[27] = new SqlParameter("@EditSelfTitle", SqlDbType.TinyInt, 1);
param[27].Value = uc1.EditSelfTitle;
param[28] = new SqlParameter("@EditOtitle", SqlDbType.TinyInt, 1);
param[28].Value = uc1.EditOtitle;
param[29] = new SqlParameter("@ReadTitle", SqlDbType.TinyInt, 1);
param[29].Value = uc1.ReadTitle;
param[30] = new SqlParameter("@MoveSelfTitle", SqlDbType.TinyInt, 1);
param[30].Value = uc1.MoveSelfTitle;
param[31] = new SqlParameter("@MoveOTitle", SqlDbType.TinyInt, 1);
param[31].Value = uc1.MoveOTitle;
param[32] = new SqlParameter("@TopTitle", SqlDbType.TinyInt, 1);
param[32].Value = uc1.TopTitle;
param[33] = new SqlParameter("@GoodTitle", SqlDbType.TinyInt, 1);
param[33].Value = uc1.GoodTitle;
param[34] = new SqlParameter("@LockUser", SqlDbType.TinyInt, 1);
param[34].Value = uc1.LockUser;
param[35] = new SqlParameter("@UserFlag", SqlDbType.NVarChar, 100);
param[35].Value = uc1.UserFlag;
param[36] = new SqlParameter("@CheckTtile", SqlDbType.TinyInt, 1);
param[36].Value = uc1.CheckTtile;
param[37] = new SqlParameter("@IPTF", SqlDbType.TinyInt, 1);
param[37].Value = uc1.IPTF;
param[38] = new SqlParameter("@EncUser", SqlDbType.TinyInt, 1);
param[38].Value = uc1.EncUser;
param[39] = new SqlParameter("@OCTF", SqlDbType.TinyInt, 1);
param[39].Value = uc1.OCTF;
param[40] = new SqlParameter("@StyleTF", SqlDbType.TinyInt, 1);
param[40].Value = uc1.StyleTF;
param[41] = new SqlParameter("@UpfaceSize", SqlDbType.Int, 4);
param[41].Value = uc1.UpfaceSize;
param[42] = new SqlParameter("@GIChange", SqlDbType.NVarChar, 10);
param[42].Value = uc1.GIChange;
param[43] = new SqlParameter("@GTChageRate", SqlDbType.NVarChar, 30);
param[43].Value = uc1.GTChageRate;
param[44] = new SqlParameter("@LoginPoint", SqlDbType.NVarChar, 20);
param[44].Value = uc1.LoginPoint;
param[45] = new SqlParameter("@RegPoint", SqlDbType.NVarChar, 20);
param[45].Value = uc1.RegPoint;
param[46] = new SqlParameter("@GroupTF", SqlDbType.TinyInt, 1);
param[46].Value = uc1.GroupTF;
param[47] = new SqlParameter("@GroupSize", SqlDbType.Int, 4);
param[47].Value = uc1.GroupSize;
param[48] = new SqlParameter("@GroupPerNum", SqlDbType.Int, 4);
param[48].Value = uc1.GroupPerNum;
param[49] = new SqlParameter("@GroupCreatNum", SqlDbType.Int, 4);
param[49].Value = uc1.GroupCreatNum;
param[50] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[50].Value = uc1.CreatTime;
param[51] = new SqlParameter("@Discount", SqlDbType.Float, 8);
param[51].Value = uc1.Discount;
return param;
#endregion
}
/// <summary>
/// 获取UserInfo4构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] updateGroupEditParameters(NetCMS.Model.UserInfo4 uc1)
{
#region
SqlParameter[] param = new SqlParameter[50];
param[0] = new SqlParameter("@gID", SqlDbType.Int, 4);
param[0].Value = uc1.gID;
param[1] = new SqlParameter("@GroupCreatNum", SqlDbType.Int, 4);
param[1].Value = uc1.GroupCreatNum;
param[2] = new SqlParameter("@GroupName", SqlDbType.NVarChar, 50);
param[2].Value = uc1.GroupName;
param[3] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
param[3].Value = uc1.iPoint;
param[4] = new SqlParameter("@Gpoint", SqlDbType.Int, 4);
param[4].Value = uc1.Gpoint;
param[5] = new SqlParameter("@Rtime", SqlDbType.Int, 4);
param[5].Value = uc1.Rtime;
param[6] = new SqlParameter("@LenCommContent", SqlDbType.Int, 4);
param[6].Value = uc1.LenCommContent;
param[7] = new SqlParameter("@CommCheckTF", SqlDbType.TinyInt, 1);
param[7].Value = uc1.CommCheckTF;
param[8] = new SqlParameter("@PostCommTime", SqlDbType.Int, 4);
param[8].Value = uc1.PostCommTime;
param[9] = new SqlParameter("@upfileType", SqlDbType.NVarChar, 200);
param[9].Value = uc1.upfileType;
param[10] = new SqlParameter("@upfileNum", SqlDbType.Int, 4);
param[10].Value = uc1.upfileNum;
param[11] = new SqlParameter("@upfileSize", SqlDbType.Int, 4);
param[11].Value = uc1.upfileSize;
param[12] = new SqlParameter("@DayUpfilenum", SqlDbType.Int, 4);
param[12].Value = uc1.DayUpfilenum;
param[13] = new SqlParameter("@ContrNum", SqlDbType.Int, 4);
param[13].Value = uc1.ContrNum;
param[14] = new SqlParameter("@DicussTF", SqlDbType.TinyInt, 1);
param[14].Value = uc1.DicussTF;
param[15] = new SqlParameter("@PostTitle", SqlDbType.TinyInt, 1);
param[15].Value = uc1.PostTitle;
param[16] = new SqlParameter("@ReadUser", SqlDbType.TinyInt, 1);
param[16].Value = uc1.ReadUser;
param[17] = new SqlParameter("@MessageNum", SqlDbType.Int, 4);
param[17].Value = uc1.MessageNum;
param[18] = new SqlParameter("@MessageGroupNum", SqlDbType.NVarChar, 15);
param[18].Value = uc1.MessageGroupNum;
param[19] = new SqlParameter("@IsCert", SqlDbType.TinyInt, 1);
param[19].Value = uc1.IsCert;
param[20] = new SqlParameter("@CharTF", SqlDbType.TinyInt, 1);
param[20].Value = uc1.CharTF;
param[21] = new SqlParameter("@CharHTML", SqlDbType.TinyInt, 1);
param[21].Value = uc1.CharHTML;
param[22] = new SqlParameter("@CharLenContent", SqlDbType.Int, 4);
param[22].Value = uc1.CharLenContent;
param[23] = new SqlParameter("@RegMinute", SqlDbType.Int, 4);
param[23].Value = uc1.RegMinute;
param[24] = new SqlParameter("@PostTitleHTML", SqlDbType.TinyInt, 1);
param[24].Value = uc1.PostTitleHTML;
param[25] = new SqlParameter("@DelSelfTitle", SqlDbType.TinyInt, 1);
param[25].Value = uc1.DelSelfTitle;
param[26] = new SqlParameter("@DelOTitle", SqlDbType.TinyInt, 1);
param[26].Value = uc1.DelOTitle;
param[27] = new SqlParameter("@EditSelfTitle", SqlDbType.TinyInt, 1);
param[27].Value = uc1.EditSelfTitle;
param[28] = new SqlParameter("@EditOtitle", SqlDbType.TinyInt, 1);
param[28].Value = uc1.EditOtitle;
param[29] = new SqlParameter("@ReadTitle", SqlDbType.TinyInt, 1);
param[29].Value = uc1.ReadTitle;
param[30] = new SqlParameter("@MoveSelfTitle", SqlDbType.TinyInt, 1);
param[30].Value = uc1.MoveSelfTitle;
param[31] = new SqlParameter("@MoveOTitle", SqlDbType.TinyInt, 1);
param[31].Value = uc1.MoveOTitle;
param[32] = new SqlParameter("@TopTitle", SqlDbType.TinyInt, 1);
param[32].Value = uc1.TopTitle;
param[33] = new SqlParameter("@GoodTitle", SqlDbType.TinyInt, 1);
param[33].Value = uc1.GoodTitle;
param[34] = new SqlParameter("@LockUser", SqlDbType.TinyInt, 1);
param[34].Value = uc1.LockUser;
param[35] = new SqlParameter("@UserFlag", SqlDbType.NVarChar, 100);
param[35].Value = uc1.UserFlag;
param[36] = new SqlParameter("@CheckTtile", SqlDbType.TinyInt, 1);
param[36].Value = uc1.CheckTtile;
param[37] = new SqlParameter("@IPTF", SqlDbType.TinyInt, 1);
param[37].Value = uc1.IPTF;
param[38] = new SqlParameter("@EncUser", SqlDbType.TinyInt, 1);
param[38].Value = uc1.EncUser;
param[39] = new SqlParameter("@OCTF", SqlDbType.TinyInt, 1);
param[39].Value = uc1.OCTF;
param[40] = new SqlParameter("@StyleTF", SqlDbType.TinyInt, 1);
param[40].Value = uc1.StyleTF;
param[41] = new SqlParameter("@UpfaceSize", SqlDbType.Int, 4);
param[41].Value = uc1.UpfaceSize;
param[42] = new SqlParameter("@GIChange", SqlDbType.NVarChar, 10);
param[42].Value = uc1.GIChange;
param[43] = new SqlParameter("@GTChageRate", SqlDbType.NVarChar, 30);
param[43].Value = uc1.GTChageRate;
param[44] = new SqlParameter("@LoginPoint", SqlDbType.NVarChar, 20);
param[44].Value = uc1.LoginPoint;
param[45] = new SqlParameter("@RegPoint", SqlDbType.NVarChar, 20);
param[45].Value = uc1.RegPoint;
param[46] = new SqlParameter("@GroupTF", SqlDbType.TinyInt, 1);
param[46].Value = uc1.GroupTF;
param[47] = new SqlParameter("@GroupSize", SqlDbType.Int, 4);
param[47].Value = uc1.GroupSize;
param[48] = new SqlParameter("@GroupPerNum", SqlDbType.Int, 4);
param[48].Value = uc1.GroupPerNum;
param[49] = new SqlParameter("@Discount", SqlDbType.Float, 8);
param[49].Value = uc1.Discount;
return param;
#endregion
}
#endregion 会员组部分
#region 公告部分
public void del_userNews(string Aid,int flag)
{
string Sql = null;
SqlParameter param =null;
if (flag == 0)
{
Sql = "Delete From " + Pre + "user_news where id in(" + Aid + ") " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 1)
{
Sql = "Delete From " + Pre + "user_card where id in(" + Aid + ")" + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 2)
{
param = new SqlParameter("@ClassID", Aid);
Sql = "delete From " + Pre + "API_Navi where am_ParentID=@ClassID and UserNum='" + NetCMS.Global.Current.UserNum + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public void update_userInfo(string Aid, string lockstr,int flag)
{
string Sql = null;
if(flag==0)
{
Sql="update " + Pre + "user_news " + lockstr + " where id in(" + Aid + ") " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 1)
{
if (lockstr == "000000000")
{
string _Tmpstr = "";
_Tmpstr = " set TimeOutDate='1900-1-1'";
Sql = "update " + Pre + "user_card " + _Tmpstr + " where id in(" + Aid + ") " + NetCMS.Common.Public.getSessionStr() + "";
}
else
{
Sql = "update " + Pre + "user_card " + lockstr + " where id in(" + Aid + ") " + NetCMS.Common.Public.getSessionStr() + "";
}
}
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 则插入新记录公告
/// </summary>
/// <param name="uc2"></param>
public void addUpdate_Announce(NetCMS.Model.UserInfo5 uc2,bool flag)
{
#region
string Sql = null;
if (flag)
{
Sql = "insert into " + Pre + "user_news (";
Sql += "newsID,Title,content,creatTime,GroupNumber,getPoint,SiteId,isLock";
Sql += ") values (";
Sql += "@newsID,@Title,@content,@creatTime,@GroupNumber,@getPoint,@SiteId,0)";
}
else
{
Sql = "update " + Pre + "user_news set Title=@Title,content=@content,GroupNumber=@GroupNumber,getPoint=@getPoint where Id=" + uc2.Id + " " + NetCMS.Common.Public.getSessionStr() + "";
}
SqlParameter[] parm = GetAnnounceParameters(uc2);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
#endregion
}
/// <summary>
/// 获取UserInfo5构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] GetAnnounceParameters(NetCMS.Model.UserInfo5 uc1)
{
#region
SqlParameter[] param = new SqlParameter[9];
param[0] = new SqlParameter("@newsID", SqlDbType.NVarChar, 12);
param[0].Value = uc1.newsID;
param[1] = new SqlParameter("@Title", SqlDbType.NVarChar, 50);
param[1].Value = uc1.Title;
param[2] = new SqlParameter("@content", SqlDbType.NText);
param[2].Value = uc1.content;
param[3] = new SqlParameter("@creatTime", SqlDbType.DateTime, 8);
param[3].Value = uc1.creatTime;
param[4] = new SqlParameter("@GroupNumber", SqlDbType.NVarChar, 12);
param[4].Value = uc1.GroupNumber;
param[5] = new SqlParameter("@getPoint", SqlDbType.NVarChar, 50);
param[5].Value = uc1.getPoint;
param[6] = new SqlParameter("@SiteId", SqlDbType.NVarChar, 12);
param[6].Value = uc1.SiteId;
param[7] = new SqlParameter("@isLock", SqlDbType.TinyInt, 1);
param[7].Value = uc1.isLock;
param[8] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[8].Value = uc1.Id;
return param;
#endregion
}
/// <summary>
/// 获取UserInfo5构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] UpdateAnnounceParameters(NetCMS.Model.UserInfo5 uc1)
{
#region
SqlParameter[] param = new SqlParameter[5];
param[0] = new SqlParameter("@Title", SqlDbType.NVarChar, 50);
param[0].Value = uc1.Title;
param[1] = new SqlParameter("@content", SqlDbType.NText);
param[1].Value = uc1.content;
param[2] = new SqlParameter("@GroupNumber", SqlDbType.NVarChar, 12);
param[2].Value = uc1.GroupNumber;
param[3] = new SqlParameter("@getPoint", SqlDbType.NVarChar, 50);
param[3].Value = uc1.getPoint;
param[4] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[4].Value = uc1.Id;
return param;
#endregion
}
#endregion 公告部分
#region 点卡
public DataTable GetPage(string _islock, string _isuse, string _isbuy, string _timeout, string _SiteID, string cardnumber, string cardpassword, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
#region
string QSQL = "";
if (cardnumber != "" && cardnumber != null)
{
QSQL += " and CardNumber = '" + cardnumber.ToString() + "'";
}
if (cardpassword != "" && cardpassword != null)
{
QSQL += " and CardPassWord = '" + cardpassword.ToString() + "'";
}
if (_islock != "" && _islock != null)
{
QSQL += " and isLock = " + int.Parse(_islock.ToString()) + "";
}
if (_isuse != "" && _isuse != null)
{
QSQL += " and isUse = " + int.Parse(_isuse.ToString()) + "";
}
if (_isbuy != "" && _isbuy != null)
{
QSQL += " and isBuy = " + int.Parse(_isbuy.ToString()) + "";
}
if (_timeout != "" && _timeout != null)
{
if (_timeout.ToString() == "1")
{
QSQL += " and TimeOutDate <= '" + System.DateTime.Now + "'";
}
else
{
QSQL += " and TimeOutDate > '" + System.DateTime.Now + "'";
}
}
if (_SiteID != "" && _SiteID != null)
{
if (NetCMS.Global.Current.SiteID == "0")
{
QSQL += " and SiteID='" + _SiteID + "'";
}
else
{
QSQL += " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
}
else
{
QSQL += " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
string AllFields = "id,CaID,CardNumber,CardPassWord,creatTime,Money,Point,isBuy,isUse,isLock,UserNum,SiteId,TimeOutDate";
string Condition = Pre + "user_Card where 1=1 " + QSQL;
string IndexField = "ID";
string OrderFields = "order by Id Desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, null);
#endregion
}
/// <summary>
/// 得到编号是否重复
/// </summary>
/// <param name="CardNumber"></param>
/// <returns></returns>
public object getCardNumberTF(string CardNumber)
{
SqlParameter param = new SqlParameter("@CardNumber", CardNumber);
string Sql = "select CardNumber from " + Pre + "user_card where CardNumber=@CardNumber";
return DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
}
/// <summary>
/// 点卡密码是否重复
/// </summary>
/// <param name="CardPass"></param>
/// <returns></returns>
public bool getCardPassTF(string CardPass)
{
SqlParameter param = new SqlParameter("@CardPass", CardPass);
bool flg = false;
string Sql = "select id from " + Pre + "user_card where CardPassWord=@CardPass";
object obj = DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
if (obj != null)
{
flg = true;
}
return flg;
}
public void addUpdate_card(NetCMS.Model.IDCARD uc,int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "Insert Into " + Pre + "user_card(CaID,CardNumber,CardPassWord,creatTime,[Money],Point,isBuy,isUse,isLock,UserNum,siteID,TimeOutDate) Values(@CaID,@CardNumber,@CardPassWord,@creatTime,@Money,@Point,@isBuy,@isUse,@isLock,@UserNum,@siteID,@TimeOutDate)";
}
else if (flag == 1)
{
Sql = "Update " + Pre + "user_card set CardPassWord=@CardPassWord,[Money]=@Money,Point=@Point,isBuy=@isBuy,isUse=@isUse,isLock=@isLock,TimeOutDate=@TimeOutDate where Id=" + uc.Id + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
SqlParameter[] parm = insertCardRParameters(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
#endregion
}
/// <summary>
/// 获取IDCARD构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] insertCardRParameters(NetCMS.Model.IDCARD uc1)
{
#region
SqlParameter[] param = new SqlParameter[13];
param[0] = new SqlParameter("@CaID", SqlDbType.NVarChar, 12);
param[0].Value = uc1.CaID;
param[1] = new SqlParameter("@CardNumber", SqlDbType.NVarChar, 30);
param[1].Value = uc1.CardNumber;
param[2] = new SqlParameter("@CardPassWord", SqlDbType.NVarChar, 150);
param[2].Value = uc1.CardPassWord;
param[3] = new SqlParameter("@creatTime", SqlDbType.DateTime, 8);
param[3].Value = uc1.creatTime;
param[4] = new SqlParameter("@Money", SqlDbType.Int, 4);
param[4].Value = uc1.Money;
param[5] = new SqlParameter("@Point", SqlDbType.Int, 4);
param[5].Value = uc1.Point;
param[6] = new SqlParameter("@isBuy", SqlDbType.TinyInt, 1);
param[6].Value = uc1.isBuy;
param[7] = new SqlParameter("@isUse", SqlDbType.TinyInt, 1);
param[7].Value = uc1.isUse;
param[8] = new SqlParameter("@isLock", SqlDbType.TinyInt, 1);
param[8].Value = uc1.isLock;
param[9] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
param[9].Value = uc1.UserNum;
param[10] = new SqlParameter("@siteID", SqlDbType.NVarChar, 12);
param[10].Value = uc1.siteID;
param[11] = new SqlParameter("@TimeOutDate", SqlDbType.DateTime, 8);
param[11].Value = uc1.TimeOutDate;
param[12] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[12].Value = uc1.Id;
return param;
#endregion
}
/// <summary>
/// 获取IDCARD1构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] UpdateCardRParameters(NetCMS.Model.IDCARD uc1)
{
#region
SqlParameter[] param = new SqlParameter[8];
param[0] = new SqlParameter("@CardPassWord", SqlDbType.NVarChar, 150);
param[0].Value = uc1.CardPassWord;
param[1] = new SqlParameter("@Money", SqlDbType.Int, 4);
param[1].Value = uc1.Money;
param[2] = new SqlParameter("@Point", SqlDbType.Int, 4);
param[2].Value = uc1.Point;
param[3] = new SqlParameter("@isBuy", SqlDbType.TinyInt, 1);
param[3].Value = uc1.isBuy;
param[4] = new SqlParameter("@isUse", SqlDbType.TinyInt, 1);
param[4].Value = uc1.isUse;
param[5] = new SqlParameter("@isLock", SqlDbType.TinyInt, 1);
param[5].Value = uc1.isLock;
param[6] = new SqlParameter("@TimeOutDate", SqlDbType.DateTime, 8);
param[6].Value = uc1.TimeOutDate;
param[7] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[7].Value = uc1.Id;
return param;
#endregion
}
/// <summary>
/// 删除所有点卡
/// </summary>
public void delALLCARD()
{
string Sql = "Delete From " + Pre + "user_card where SiteID = " + NetCMS.Global.Current.SiteID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
#endregion 点卡
#region 在线支付开始
/// <summary>
/// 更新
/// </summary>
/// <param name="uc2"></param>
public void UpdateOnlinePay(NetCMS.Model.UserInfo6 uc2)
{
string Sql = "";
string SQLTF = "select ID from " + Pre + "sys_PramUser where SiteID='" + NetCMS.Global.Current.SiteID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, SQLTF, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
Sql = "Update " + Pre + "sys_PramUser set onpayType=@onpayType,O_userName=@O_userName,o_key=@o_key,O_sendurl=@O_sendurl,O_returnurl=@O_returnurl,O_md5=@O_md5,O_other1=@O_other1,O_other2=@O_other2,O_other3=@O_other3 where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else
{
Sql = "Insert Into " + Pre + "sys_PramUser(onpayType,O_userName,o_key,O_sendurl,O_returnurl,O_md5,O_other1,O_other2,O_other3,SiteID) Values(@onpayType,@O_userName,@o_key,@O_sendurl,@O_returnurl,@O_md5,@O_other1,@O_other2,@O_other3,'" + NetCMS.Global.Current.SiteID + "')";
}
}
SqlParameter[] parm = UpdateOnlinePayParameters(uc2);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
/// <summary>
/// 获取UserInfo6构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] UpdateOnlinePayParameters(NetCMS.Model.UserInfo6 uc1)
{
SqlParameter[] param = new SqlParameter[9];
param[0] = new SqlParameter("@o_userName", SqlDbType.NVarChar, 100);
param[0].Value = uc1.O_userName;
param[1] = new SqlParameter("@o_key", SqlDbType.NVarChar, 128);
param[1].Value = uc1.O_key;
param[2] = new SqlParameter("@o_sendurl", SqlDbType.NVarChar, 220);
param[2].Value = uc1.O_sendurl;
param[3] = new SqlParameter("@o_returnurl", SqlDbType.NVarChar, 220);
param[3].Value = uc1.O_returnurl;
param[4] = new SqlParameter("@o_md5", SqlDbType.NVarChar, 128);
param[4].Value = uc1.O_md5;
param[5] = new SqlParameter("@o_other1", SqlDbType.NVarChar, 220);
param[5].Value = uc1.O_other1;
param[6] = new SqlParameter("@o_other2", SqlDbType.NVarChar, 220);
param[6].Value = uc1.O_other2;
param[7] = new SqlParameter("@o_other3", SqlDbType.NVarChar, 220);
param[7].Value = uc1.O_other3;
param[8] = new SqlParameter("@Id", SqlDbType.NVarChar, 128);
param[8].Value = uc1.Id;
param[8] = new SqlParameter("@onpayType", SqlDbType.TinyInt, 1);
param[8].Value = uc1.onpayType;
return param;
}
#endregion 在线支付结束
#region 会员前台部分
public string sel_userGroup(string GroupNumber,int flag)
{
SqlParameter param = new SqlParameter("@ID", GroupNumber);
string Sql = null;
if (flag==0)
{
Sql = "Select GIChange From " + Pre + "user_Group where GroupNumber=@ID";
}
else if (flag == 1)
{
Sql = "select top 1 PhotoUrl from " + Pre + "user_Photo where PhotoalbumID=@ID order by id desc";
}
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
public int getPasswordTF(string password)
{
SqlParameter param = new SqlParameter("@password", password);
int flg = 1;
string md5Pwd = NetCMS.Common.Input.MD5(password);
string Sql = "select UserPassword from " + Pre + "sys_User where UserNum='" + NetCMS.Global.Current.UserNum + "' and UserPassword=@password";
object obj = DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
if (obj != null)
{
flg = 0;
}
return flg;
}
/// <summary>
/// 取消认证
/// </summary>
/// <param name="uc2"></param>
public void ResetICard()
{
string Sql = "update " + Pre + "sys_User set IDcardFiles='',isIDcard=0 where UserNum='" + NetCMS.Global.Current.UserNum + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 保存上传图片
/// </summary>
/// <param name="uc2"></param>
public void SaveDataICard(string f_IDcardFiles)
{
SqlParameter param = new SqlParameter("@f_IDcardFiles", f_IDcardFiles);
string Sql = "update " + Pre + "sys_User set IDcardFiles=@f_IDcardFiles,isIDcard=0 where UserNum='" + NetCMS.Global.Current.UserNum + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion 会员前台部分结束
public int sel_picnum(string PhotoalbumID)
{
SqlParameter param = new SqlParameter("@PhotoalbumID", PhotoalbumID);
string Sql = "select count(id) from " + Pre + "user_Photo where PhotoalbumID=@PhotoalbumID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
#region 投稿
public DataTable getConstrID(string ConID, string UserNum)
{
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@ConID", ConID), new SqlParameter("@UserNum", UserNum) };
string Sql = "select ID,Title,Content,creatTime,Source,Tags,Author,PicURL from " + Pre + "user_Constr where UserNum=@UserNum and ConID=@ConID and isuserdel=0 and SiteID='" + NetCMS.Global.Current.SiteID + "' order by id desc";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
#endregion 投稿
public string getAdminPopandSupper(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string strflg = "0|netcms";
string Sql = "select isSuper,PopList from " + Pre + "sys_admin where UserNum=@UserNum";
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, param);
if (rd.Read())
{
strflg = rd.GetByte(0).ToString() + "|";
if (!rd.IsDBNull(1))
strflg += rd.GetString(1);
strflg += "netcms";
}
rd.Close();
return strflg;
}
//URL
public void updateURL(string URLName, string URL, string URLColor, string ClassID, string Content, int NUM, int ID)
{
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@URLName", URLName), new SqlParameter("@URL", URL), new SqlParameter("@URLColor", URLColor), new SqlParameter("@ClassID", ClassID), new SqlParameter("@Content", Content) };
string Sql = "";
if (NUM == 0)
{
Sql = "Insert Into " + Pre + "user_URL(URLName,URL,URLColor,ClassID,Content,CreatTime,UserNum) Values(@URLName,@URL,@URLColor,@ClassID,@Content,'" + DateTime.Now + "','" + NetCMS.Global.Current.UserNum + "')";
}
else
{
Sql = "update " + Pre + "user_URL set URLName=@URLName,URL=@URL,URLColor=@URLColor,ClassID=@ClassID,Content=@Content where id=" + ID + " and UserNum='" + NetCMS.Global.Current.UserNum + "'";
}
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public void updateClass(string ClassName, int NUM, int ID)
{
SqlParameter param = new SqlParameter("@ClassName", ClassName);
string Sql = "";
if (NUM == 0)
{
Sql = "Insert Into " + Pre + "user_URLClass(ClassName,ParentID,UserNum) Values(@ClassName,0,'" + NetCMS.Global.Current.UserNum + "')";
}
else
{
Sql = "update " + Pre + "user_URLClass set ClassName=@ClassName where id=" + ID + " and UserNum='" + NetCMS.Global.Current.UserNum + "'";
}
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
}
} | 0575kaoshicj | trunk/NetCMS.DALSQLServer/UserMisc.cs | C# | asf20 | 77,481 |
//======================================================
//== (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 Special : DbBase, ISpecial
{
private string SiteID;
public Special()
{
SiteID = NetCMS.Global.Current.SiteID;
}
public DataTable getChildList(string classid)
{
string str_Sql = "Select Id,SpecialID,SpecialCName,CreatTime,isLock From " + Pre + "news_special " +
"Where isRecyle=0 and ParentID='" + classid + "' and SiteID='" + SiteID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public void Lock(string id)
{
string idstr = NetCMS.Common.Input.CutComma(getChildId(id));
string str_sql = "Update " + Pre + "news_special Set isLock=1 where SpecialID In(" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
}
public void UnLock(string id)
{
bool tempTF = getParentlockTF(id);
if (tempTF == false)
{
string str_sql = "Update " + Pre + "news_special Set isLock=0 where SpecialID='" + id + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
}
else
{
throw new Exception("当前专题的父专题被锁定,要想解锁此专题请先解锁此专题的父专题!");
}
}
public void PDel(string id)
{
string tempid = getIDStr(id);
string str_Sql = "Update " + Pre + "news_special Set isRecyle=1 Where SpecialID in (" + tempid + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void PDels(string id)
{
string tempid = getIDStr(id);
string str_Sql = "Delete From " + Pre + "news_special where SpecialID in (" + tempid + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void PLock(string id)
{
string tempid = getIDStr(id);
string str_sql = "Update " + Pre + "news_special Set isLock=1 where SpecialID In (" + tempid + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
}
public void PUnLock(string id)
{
string[] arr_id = id.Split(',');
string temp_id = "";
string temp_id1 = "";
bool locktf = false;
for (int i = 0; i < arr_id.Length; i++)
{
temp_id = arr_id[i].Replace("'", "");
locktf = getParentlockTF(temp_id); //检测父类的状态是否被锁定
if (locktf == false)
temp_id1 += "'" + temp_id + "',";
}
temp_id1 = NetCMS.Common.Input.CutComma(temp_id1);
if (temp_id1 == null || temp_id1 == "" || temp_id1 == string.Empty)
throw new Exception("选中专题的父专题被锁定,请先解锁此专题的父专题!");
string str_sql = "Update " + Pre + "news_special Set isLock=0 where SpecialID In(" + temp_id1 + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
}
public string getSpicaelNewsNum(string id)
{
string str_Sql = "Select Count(Id) From " + Pre + "special_news Where SpecialID='" + id + "'";
int result = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, str_Sql, null));
return result.ToString();
}
public string Add(NetCMS.Model.SpecialInfo sci)
{
int result = 0;
string SpecialID = "";
string checkSql = "";
int recordCount = 0;
SpecialID = NetCMS.Common.Rand.Number(12);
while (true)
{
checkSql = "select count(*) from " + Pre + "news_special where SpecialID='" + SpecialID + "'";
recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
if (recordCount < 1)
break;
else
SpecialID = NetCMS.Common.Rand.Number(12, true);
}
checkSql = "select count(*) from " + Pre + "news_special where SpecialCName='" + sci.SpecialCName + "'";
recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
if (recordCount > 0)
{
throw new Exception("专题中文名称重复,请重新添加!");
}
checkSql = "select count(*) from " + Pre + "news_special where specialEName='" + sci.specialEName + "'";
recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
if (recordCount > 0)
{
throw new Exception("专题英文名称重复,请重新添加!");
}
string str_Sql = "Insert Into " + Pre + "news_special(SpecialID,SpecialCName,specialEName,ParentID," +
"[Domain],isDelPoint,Gpoint,iPoint,GroupNumber,saveDirPath,SavePath,FileName,FileEXName," +
"NaviPicURL,NaviContent,SiteID,Templet,isLock,isRecyle,CreatTime,NaviPosition" +
") Values('" + SpecialID + "',@SpecialCName,@specialEName,@ParentID,@Domain," +
"@isDelPoint,@Gpoint,@iPoint,@GroupNumber,@saveDirPath,@SavePath,@FileName,@FileEXName," +
"@NaviPicURL,@NaviContent,@SiteID,@Templet,@isLock,@isRecyle,@CreatTime,@NaviPosition)";
SqlParameter[] param = GetSpecialParameters(sci);
result = DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, param);
return result + "|" + SpecialID;
}
public int Edit(NetCMS.Model.SpecialInfo sci)
{
int result = 0;
string checkSql = "";
int recordCount = 0;
checkSql = "select count(*) from " + Pre + "news_special Where SpecialID!='" + sci.SpecialID + "' " +
" And SpecialCName='" + sci.SpecialCName + "'";
recordCount = (int)DbHelper.ExecuteScalar( CommandType.Text, checkSql, null);
if (recordCount > 0)
{
throw new Exception("专题中文名称重复,请重新修改!");
}
string Sql = "Update " + Pre + "news_special Set SpecialCName=@SpecialCName," +
"[Domain]=@Domain,isDelPoint=@isDelPoint,Gpoint=@Gpoint,iPoint=@iPoint," +
"GroupNumber=@GroupNumber,saveDirPath=@saveDirPath,SavePath=@SavePath," +
"FileName=@FileName,FileEXName=@FileEXName,NaviPicURL=@NaviPicURL," +
"NaviContent=@NaviContent,Templet=@Templet,NaviPosition=@NaviPosition " +
"Where SpecialID=@SpecialID";
SqlParameter[] param = GetSpecialParameters(sci);
result = DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
return result;
}
public DataTable getSpeacilInfo(string id)
{
string str_Sql = "Select SpecialID,SpecialCName,specialEName,ParentID,[Domain],isDelPoint,Gpoint,iPoint,GroupNumber,FileName," +
"FileEXName,NaviPicURL,NaviContent,Templet,isLock,isRecyle,SavePath,saveDirPath,NaviPosition From " +
Pre + "news_special Where SiteID='" + NetCMS.Global.Current.SiteID + "' And SpecialID='" + id + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
protected string getChildId(string id)
{
string str_Sql = "Select SpecialID,ParentID From " + Pre + "news_special Where SiteID='" + SiteID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
string idstr = "'" + id + "'," + getRecursion(dt, id);
return idstr;
}
protected string getRecursion(DataTable dt, string PID)
{
DataRow[] row = null;
string idstr = "";
row = dt.Select("ParentID='" + PID + "'");
if (row.Length < 1)
return idstr;
else
{
foreach (DataRow r in row)
{
idstr += "'" + r[0].ToString() + "',";
idstr += getRecursion(dt, r[0].ToString());
}
}
return idstr;
}
protected bool getParentlockTF(string id)
{
bool LockTF = false;
id = getParentID(id);
string str_sql = "Select ParentID,isLock From " + Pre + "news_special where SpecialID='" + id + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_sql, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
if (dt.Rows[0]["isLock"].ToString() == "1")
LockTF = true;
else
LockTF = getParentlockTF(dt.Rows[0]["ParentID"].ToString());
}
dt.Dispose();
dt.Clear();
}
return LockTF;
}
protected string getParentID(string id)
{
string str_parentid = id;
string str_sql = "Select ParentID From " + Pre + "news_special where SpecialID='" + id + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_sql, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
str_parentid = dt.Rows[0]["ParentID"].ToString();
dt.Clear();
dt.Dispose();
}
return str_parentid;
}
public DataTable getSpecialFileInfo(string id)
{
string tempid = getIDStr(id);
string str_Sql = "Select SpecialID,ParentID,specialEName,SavePath,saveDirPath,FileName,FileEXName From " + Pre +
"news_special where SpecialID in(" + tempid + ")";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
protected string getIDStr(string id)
{
string[] arr_id = id.Split(',');
string temp_id = "";
string temp_id1 = "";
for (int i = 0; i < arr_id.Length; i++)
{
temp_id = arr_id[i].Replace("'", "");
temp_id1 += getChildId(temp_id);
}
temp_id1 = NetCMS.Common.Input.CutComma(temp_id1);
return temp_id1;
}
private SqlParameter[] GetSpecialParameters(NetCMS.Model.SpecialInfo sc)
{
SqlParameter[] param = new SqlParameter[21];
param[0] = new SqlParameter("@SpecialID", SqlDbType.NVarChar, 12);
param[0].Value = sc.SpecialID;
param[1] = new SqlParameter("@SpecialCName", SqlDbType.NVarChar, 50);
param[1].Value = sc.SpecialCName;
param[2] = new SqlParameter("@specialEName", SqlDbType.NVarChar, 50);
param[2].Value = sc.specialEName;
param[3] = new SqlParameter("@ParentID", SqlDbType.NVarChar, 12);
param[3].Value = sc.ParentID;
param[4] = new SqlParameter("@Domain", SqlDbType.NVarChar, 100);
param[4].Value = sc.Domain;
param[5] = new SqlParameter("@isDelPoint", SqlDbType.TinyInt, 1);
param[5].Value = sc.isDelPoint;
param[6] = new SqlParameter("@Gpoint", SqlDbType.Int, 4);
param[6].Value = sc.Gpoint;
param[7] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
param[7].Value = sc.iPoint;
param[8] = new SqlParameter("@GroupNumber", SqlDbType.NText);
param[8].Value = sc.GroupNumber;
param[9] = new SqlParameter("@saveDirPath", SqlDbType.NVarChar, 100);
param[9].Value = sc.saveDirPath;
param[10] = new SqlParameter("@SavePath", SqlDbType.NVarChar, 100);
param[10].Value = sc.SavePath;
param[11] = new SqlParameter("@FileName", SqlDbType.NVarChar, 100);
param[11].Value = sc.FileName;
param[12] = new SqlParameter("@FileEXName", SqlDbType.NVarChar, 6);
param[12].Value = sc.FileEXName;
param[13] = new SqlParameter("@NaviPicURL", SqlDbType.NVarChar, 200);
param[13].Value = sc.NaviPicURL;
param[14] = new SqlParameter("@NaviContent", SqlDbType.NVarChar, 255);
param[14].Value = sc.NaviContent;
param[15] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[15].Value = sc.SiteID;
param[16] = new SqlParameter("@Templet", SqlDbType.NVarChar, 200);
param[16].Value = sc.Templet;
param[17] = new SqlParameter("@isLock", SqlDbType.TinyInt, 1);
param[17].Value = sc.isLock;
param[18] = new SqlParameter("@isRecyle", SqlDbType.TinyInt, 1);
param[18].Value = sc.isRecyle;
param[19] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[19].Value = sc.CreatTime;
param[20] = new SqlParameter("@NaviPosition", SqlDbType.NVarChar,255);
param[20].Value = sc.NaviPosition;
return param;
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Special.cs | C# | asf20 | 14,306 |
//======================================================
//== (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.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class User : DbBase, IUser
{
public DataTable CheckUser(string UserName, string Pwd)
{
string md5Pwd = NetCMS.Common.Input.MD5(Pwd);
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@UserName", UserName), new SqlParameter("@Pwd", md5Pwd) };
string Sql = "select userName,UserPassword,isAdmin,islock,UserNum,SiteID from " + Pre + "sys_User where UserName=@UserName and UserPassword=@Pwd";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
public DataTable CheckManage(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "select UserNum,isSuper,adminGroupNumber,PopList,OnlyLogin,isChannel,isLock,SiteID,isChSupper,Iplimited,verCode from " + Pre + "sys_admin where UserNum=@UserNum";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
#region 登陆限制开始
///// <summary>
///// 查找是否有此管理员
///// </summary>
///// <param name="strUserName"></param>
///// <returns></returns>
//public DataTable CheckUserTF(string strUserName)
//{
// string Sql = "select id from " + Pre + "sys_User where UserName='" + UserName + "' and isAdmin=1";
// DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
// return dt;
//}
///// <summary>
///// 开始读取管理员是否有限制
///// </summary>
///// <param name="UserNum"></param>
///// <returns></returns>
//public DataTable readAdminlimit(string UserNum)
//{
// string Sql = "select LimitType from " + Pre + "sys_admin where UserNum='" + UserNum + "'";
// DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
// return dt;
//}
///// <summary>
///// 检查是否有登陆记录
///// </summary>
///// <param name="UserNum"></param>
///// <returns></returns>
//public int loginNumTF(string UserNum)
//{
// int intflg = 0;
// string Sql = "select id from " + Pre + "sys_loginnum where UserNum='" + UserNum + "'";
// DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
// if (dt != null)
// {
// if (dt.Rows.Count > 0){intflg = 1;}
// dt.Clear(); dt.Dispose();
// }
//}
///// <summary>
///// 得到已经登陆的次数。
///// </summary>
///// <param name="UserNum"></param>
///// <returns></returns>
//public int getLoginNum(string UserNum)
//{
// int intflg = 0;
// string Sql = "select loginNum from " + Pre + "sys_loginnum where UserNum='" + UserNum + "'";
// DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
// if (dt != null)
// {
// if (dt.Rows.Count > 0) { intflg = int.Parse(dt.Rows[0]["loginNum"].ToString()); }
// dt.Clear(); dt.Dispose();
// }
//}
///// <summary>
///// 插入登陆记录
///// </summary>
///// <param name="UserNum"></param>
//public void insertLoginNum(string UserNum)
//{
// string Sql = "insert into " + Pre + "sys_loginnum(";
// Sql += "UserNum,loginNum,creatTime";
// Sql += ") values (";
// Sql += "'" + UserNum + "',1,'" + DateTime.Now + "')";
// DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
//}
#endregion 登陆限制结束
#region 管理员验证
public int Managestate(string strUserNum)
{
int flg = 1;
if (strUserNum != null)
{
}
return flg;
}
#endregion 管理员验证
#region 日历
public void UserLogsDels(int LId)
{
string Sql = "Delete From " + Pre + "user_userlogs where id=" + LId + " and UserNum = '" + NetCMS.Global.Current.UserNum + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public DataTable getUserLogsValue(int LID)
{
string Sql = "Select id,title,Content,LogDateTime,dateNum From " + Pre + "user_userlogs Where ID=" + LID + " and UserNum='" + NetCMS.Global.Current.UserNum + "'";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public DataTable getUserLogsRecord(string LogID)
{
SqlParameter param = new SqlParameter("@LogID", LogID);
string Sql = "Select logID From " + Pre + "user_userlogs Where logID=@LogID";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
public DataTable getCountselt(string UserName)
{
SqlParameter param = new SqlParameter("@UserName", UserName);
string Sql = "select count(*) from " + Pre + "user_Requestinformation where bUsername=@UserName";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
public DataTable getIschick(string UserName)
{
SqlParameter param = new SqlParameter("@UserName", UserName);
string Sql = "select ischick from " + Pre + "User_Requestinformation where bUsername=@UserName";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
public DataTable isAdminUser(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "select isAdmin from " + Pre + "sys_User where UserNum=@UserNum";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
/// <summary>
/// 则插入新记录日历
/// </summary>
/// <param name="uc2"></param>
public void InsertUserLogs(NetCMS.Model.UserLog1 uc2)
{
string Sql = "insert into " + Pre + "user_userlogs(";
Sql += "LogID,title,content,creatTime,dateNum,LogDateTime,usernum,SiteID";
Sql += ") values (";
Sql += "@LogID,@title,@content,@creatTime,@dateNum,@LogDateTime,@usernum,'" + NetCMS.Global.Current.SiteID + "')";
SqlParameter[] parm = InsertUserLogsParameters(uc2);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
/// <summary>
/// 获取UserLog1构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] InsertUserLogsParameters(NetCMS.Model.UserLog1 uc1)
{
SqlParameter[] param = new SqlParameter[8];
param[0] = new SqlParameter("@LogID", SqlDbType.NVarChar, 12);
param[0].Value = uc1.LogID;
param[1] = new SqlParameter("@title", SqlDbType.NVarChar, 50);
param[1].Value = uc1.title;
param[2] = new SqlParameter("@content", SqlDbType.NText);
param[2].Value = uc1.content;
param[3] = new SqlParameter("@creatTime", SqlDbType.DateTime, 8);
param[3].Value = uc1.creatTime;
param[4] = new SqlParameter("@dateNum", SqlDbType.SmallInt, 2);
param[4].Value = uc1.dateNum;
param[5] = new SqlParameter("@LogDateTime", SqlDbType.DateTime, 8);
param[5].Value = uc1.LogDateTime;
param[6] = new SqlParameter("@usernum", SqlDbType.NVarChar, 15);
param[6].Value = uc1.usernum;
param[7] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[7].Value = uc1.Id;
return param;
}
/// <summary>
/// 则更新记录日历
/// </summary>
/// <param name="uc2"></param>
public void UpdateUserLogs(NetCMS.Model.UserLog1 uc2)
{
string Sql = "update " + Pre + "user_userlogs set title=@title,content=@content,dateNum=@dateNum,LogDateTime=@LogDateTime where Id=" + uc2.Id + " and userNum='" + NetCMS.Global.Current.UserNum + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
SqlParameter[] parm = UpdateUserLogsParameters(uc2);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
/// <summary>
/// 获取UserLog1构造
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] UpdateUserLogsParameters(NetCMS.Model.UserLog1 uc1)
{
SqlParameter[] param = new SqlParameter[5];
param[0] = new SqlParameter("@title", SqlDbType.NVarChar, 50);
param[0].Value = uc1.title;
param[1] = new SqlParameter("@content", SqlDbType.NText);
param[1].Value = uc1.content;
param[2] = new SqlParameter("@dateNum", SqlDbType.SmallInt, 2);
param[2].Value = uc1.dateNum;
param[3] = new SqlParameter("@LogDateTime", SqlDbType.DateTime, 8);
param[3].Value = uc1.LogDateTime;
param[4] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[4].Value = uc1.Id;
return param;
}
#endregion 日历
#region 会员好友添加检查
public DataTable sel_isAdmin(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string selectUserName = "select isAdmin from " + Pre + "sys_User where UserNum=@UserNum";
return DbHelper.ExecuteTable(CommandType.Text, selectUserName, param);
}
#endregion
/// <summary>
/// 查询用户密码是否正确
/// </summary>
/// <param name="UserNum"></param>
/// <returns></returns>
public string sel_pwd(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "Select UserPassword From " + Pre + "sys_User where UserNum=@UserNum";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
/// <summary>
/// 登陆会员所在的会员组的过期时间
/// </summary>
/// <param name="GroupName"></param>
/// <returns></returns>
public int sel_Rtime(string GroupName)
{
SqlParameter param = new SqlParameter("@GroupName", GroupName);
string Sql = "select Rtime from " + Pre + "user_Group where GroupNumber=@GroupName";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
/// <summary>
/// 得到用户所在的会员组编号
/// </summary>
/// <param name="UserNum"></param>
/// <returns></returns>
public string sel_UserGroupNumber(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "select UserGroupNumber from " + Pre + "sys_user where UserNum=@UserNum";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
/// <summary>
/// 前台会员注册
/// </summary>
public int sel_ChannelID(string SiteID)
{
SqlParameter param = new SqlParameter("@SiteID", SiteID);
string Sql = "select count(*) from " + Pre + "news_site where ChannelID=@SiteID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
int IUser.GetUncheckFriendsCount(string UserName)
{
SqlParameter param = new SqlParameter("@bUsername", UserName);
string Sql = "select count(*) from " + Pre + "User_Requestinformation where bUsername=@bUsername and ischick=1";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
/// <summary>
/// 注册会员协议
/// </summary>
/// <param name="SiteID"></param>
/// <returns></returns>
public DataTable sel_RegContent(string SiteID)
{
string Sql = "select RegContent,regItem,returnemail,returnmobile,RegTF from " + Pre + "sys_PramUser";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
/// <summary>
/// 得到用户名是否被占用
/// </summary>
/// <param name="ID"></param>
/// <returns></returns>
public int sel_username(string ID)
{
SqlParameter param = new SqlParameter("@UserName", ID);
string Sql = "select Id from " + Pre + "sys_User where UserName=@UserName";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
/// <summary>
/// 得到会员编号是否重复
/// </summary>
/// <returns></returns>
public string sel_um()
{
string Sql = "select UserNum from " + Pre + "sys_User";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, null));
}
public string sel_UserGroupNumbers(string SiteID)
{
string Sql = "select RegGroupNumber from " + Pre + "sys_PramUser";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, null));
}
public int sel_getUserMobileBindTF(string Moblie)
{
SqlParameter param = new SqlParameter("@Moblie", Moblie);
int intflg = 0;
string Sql = "select ID from " + Pre + "sys_User where BindTF=1 and mobile=@Moblie";
object obj = DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
if (obj != null && obj != DBNull.Value)
{
intflg = 1;
}
return intflg;
}
/// <summary>
/// 捆绑手机
/// </summary>
/// <param name="UserName"></param>
public void sel_updateMobileBindTF(string UserName)
{
SqlParameter param = new SqlParameter("@UserName", UserName);
string Sql = "Update " + Pre + "sys_User set BindTF=1 where UserName=@UserName";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
/// <summary>
/// 得到手机验证码
/// </summary>
/// <param name="UserName"></param>
/// <returns></returns>
public bool sel_getUserMobileCode(string UserName, out string mobile, out string mobilecode)
{
mobile = string.Empty;
mobilecode = string.Empty;
bool flag = false;
SqlParameter param = new SqlParameter("@UserName", UserName);
string Sql = "select isMobile,mobile,MobileCode from " + Pre + "sys_User where UserName=@UserName";
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, param);
if (rd.Read())
{
if (!rd.IsDBNull(0) && rd.GetByte(0) != 0X00)
flag = true;
if (!rd.IsDBNull(1))
mobile = rd.GetString(1);
if (!rd.IsDBNull(2))
mobilecode = rd.GetString(2);
}
rd.Close();
return flag;
}
/// <summary>
/// 更新手机状态
/// </summary>
/// <param name="UserName"></param>
/// <returns></returns>
public int sel_updateUserMobileStat(string UserName)
{
SqlParameter param = new SqlParameter("@UserName", UserName);
string Sql = "update " + Pre + "sys_User Set isMobile=1 where UserName=@UserName";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
/// <summary>
/// 创建用户到数据库中
/// </summary>
/// <param name="su"></param>
/// <returns></returns>
public int Add_User(NetCMS.Model.User ui)
{
SqlParameter[] param = getUserInfo(ui);
string Sql = "Insert Into " + Pre + "sys_User (UserNum,UserName,UserPassword,NickName,RealName,isAdmin," +
"UserGroupNumber,PassQuestion,PassKey,CertType,CertNumber,Email,mobile,Sex,birthday,Userinfo," +
"UserFace,userFacesize,marriage,iPoint,gPoint,cPoint,ePoint,aPoint,isLock,RegTime,LastLoginTime," +
"OnlineTime,OnlineTF,LoginNumber,FriendClass,LoginLimtNumber,LastIP,SiteID,Addfriend,isOpen," +
"ParmConstrNum,isIDcard,IDcardFiles,Addfriendbs,EmailATF,EmailCode,isMobile,BindTF,MobileCode) " +
"Values" +
"(@UserNum,@UserName,@UserPassword,@NickName,@RealName,@isAdmin,@UserGroupNumber,@PassQuestion," +
"@PassKey,@CertType,@CertNumber,@Email,@mobile,@Sex,@birthday,@Userinfo,@UserFace,@userFacesize," +
"@marriage,@iPoint,@gPoint,@cPoint,@ePoint,@aPoint,@isLock,@RegTime,@LastLoginTime,@OnlineTime," +
"@OnlineTF,@LoginNumber,@FriendClass,@LoginLimtNumber,@LastIP,@SiteID,@Addfriend,@isOpen," +
"@ParmConstrNum,@isIDcard,@IDcardFiles,@Addfriendbs,@EmailATF,@EmailCode,@isMobile,@BindTF,@MobileCode)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
/// <summary>
/// 创建用户附表
/// </summary>
/// <param name="suf"></param>
/// <param name="UserNum"></param>
/// <returns></returns>
public int Add_userfields(NetCMS.Model.UserFields ufi)
{
SqlParameter[] param = getUuserfields(ufi);
string Sql = "insert into " + Pre + "sys_userfields (UserNum,province,City,Address,Postcode,FaTel,WorkTel," +
"QQ,MSN,Fax,character,UserFan,Nation,nativeplace,Job,education,Lastschool,orgSch) " +
"values" +
"(@userNum,@province,@City,@Address,@Postcode,@FaTel,@WorkTel,@QQ,@MSN,@Fax,@character,@UserFan," +
"@Nation,@nativeplace,@Job,@education,@Lastschool,@orgSch)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
/// <summary>
/// 插入收入支出历史
/// </summary>
/// <param name="ugi"></param>
/// <returns></returns>
public int Add_Ghistory(NetCMS.Model.UserGhistory ugi)
{
SqlParameter[] param = getUserGhistory(ugi);
string Sql = "insert into " + Pre + "User_Ghistory(GhID,ghtype,Gpoint,iPoint,Money,CreatTime,UserNUM,gtype," +
"content,SiteID) values(@GhID,@ghtype,@Gpoint,@iPoint,@Money,@CreatTime,@userNum,@gtype,@content,@SiteID)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
private SqlParameter[] getUserGhistory(NetCMS.Model.UserGhistory ugi)
{
SqlParameter[] parm = new SqlParameter[11];
parm[0] = new SqlParameter("@id", SqlDbType.Int, 4);
parm[0].Value = ugi.Id;
parm[1] = new SqlParameter("@GhID", SqlDbType.NVarChar, 12);
parm[1].Value = ugi.GhID;
parm[2] = new SqlParameter("@ghtype", SqlDbType.Int, 4);
parm[2].Value = ugi.ghtype;
parm[3] = new SqlParameter("@Gpoint", SqlDbType.Int, 4);
parm[3].Value = ugi.Gpoint;
parm[4] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
parm[4].Value = ugi.iPoint;
parm[5] = new SqlParameter("@Money", SqlDbType.Money, 8);
parm[5].Value = ugi.Money;
parm[6] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
parm[6].Value = ugi.CreatTime;
parm[7] = new SqlParameter("@userNum", SqlDbType.NVarChar, 12);
parm[7].Value = ugi.userNum;
parm[8] = new SqlParameter("@gtype", SqlDbType.Int, 4);
parm[8].Value = ugi.gtype;
parm[9] = new SqlParameter("@content", SqlDbType.NText);
parm[9].Value = ugi.content;
parm[10] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
parm[10].Value = ugi.SiteID;
return parm;
}
private SqlParameter[] getUuserfields(NetCMS.Model.UserFields ufi)
{
SqlParameter[] parm = new SqlParameter[19];
parm[0] = new SqlParameter("@id", SqlDbType.Int, 4);
parm[0].Value = ufi.ID;
parm[1] = new SqlParameter("@userNum", SqlDbType.NVarChar, 15);
parm[1].Value = ufi.userNum;
parm[2] = new SqlParameter("@province", SqlDbType.NVarChar, 20);
parm[2].Value = ufi.province;
parm[3] = new SqlParameter("@City", SqlDbType.NVarChar, 20);
parm[3].Value = ufi.City;
parm[4] = new SqlParameter("@Address", SqlDbType.NVarChar, 50);
parm[4].Value = ufi.Address;
parm[5] = new SqlParameter("@Postcode", SqlDbType.NVarChar, 10);
parm[5].Value = ufi.Postcode;
parm[6] = new SqlParameter("@FaTel", SqlDbType.NVarChar, 30);
parm[6].Value = ufi.FaTel;
parm[7] = new SqlParameter("@WorkTel", SqlDbType.NVarChar, 30);
parm[7].Value = ufi.WorkTel;
parm[8] = new SqlParameter("@QQ", SqlDbType.NVarChar, 30);
parm[8].Value = ufi.QQ;
parm[9] = new SqlParameter("@MSN", SqlDbType.NVarChar, 150);
parm[9].Value = ufi.MSN;
parm[10] = new SqlParameter("@Fax", SqlDbType.NVarChar, 30);
parm[10].Value = ufi.Fax;
parm[11] = new SqlParameter("@character", SqlDbType.NText);
parm[11].Value = ufi.character;
parm[12] = new SqlParameter("@UserFan", SqlDbType.NText);
parm[12].Value = ufi.UserFan;
parm[13] = new SqlParameter("@Nation", SqlDbType.NVarChar, 12);
parm[13].Value = ufi.Nation;
parm[14] = new SqlParameter("@nativeplace", SqlDbType.NVarChar, 20);
parm[14].Value = ufi.nativeplace;
parm[15] = new SqlParameter("@Job", SqlDbType.NVarChar, 30);
parm[15].Value = ufi.Job;
parm[16] = new SqlParameter("@education", SqlDbType.NVarChar, 20);
parm[16].Value = ufi.education;
parm[17] = new SqlParameter("@Lastschool", SqlDbType.NVarChar, 80);
parm[17].Value = ufi.Lastschool;
parm[18] = new SqlParameter("@orgSch", SqlDbType.NVarChar, 10);
parm[18].Value = ufi.orgSch;
return parm;
}
public string sel_setPoint(string SiteID)
{
string _str = "0|0";
string Sql = "select setPoint from " + Pre + "sys_PramUser";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
_str = rdr.Rows[0]["setPoint"].ToString();
if (_str.IndexOf('|') == -1)
{
_str = "0|0";
}
}
rdr.Clear(); rdr.Dispose();
}
return _str;
}
public DataTable sel_reg(string SiteID)
{
string Sql = "select RegContent,regItem from " + Pre + "sys_PramUser";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
/// <summary>
/// 读取会员所在组允许上传的图片类型及大小
/// </summary>
/// <param name="groupNumber"></param>
public string getuserUpFile(string groupNumber)
{
SqlParameter param = new SqlParameter("@groupNumber", groupNumber);
string _STR = "jpg,gif,jpeg,bmp,png,swf,rar,zip|500|3";
string Sql = "select upfileType,upfileSize,DayUpfilenum from " + Pre + "user_Group where GroupNumber=@groupNumber";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
_STR = dt.Rows[0]["upfileType"].ToString() + "|" + dt.Rows[0]["upfileSize"].ToString() + "|" + dt.Rows[0]["DayUpfilenum"].ToString();
}
dt.Clear(); dt.Dispose();
}
return _STR;
}
/// <summary>
/// 得到用户注册时间
/// </summary>
/// <param name="UserNum"></param>
/// <returns></returns>
public string getRegTime(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string flg = "3000-1-1";
string SQL = "select RegTime from " + Pre + "sys_user where UserNum=@UserNum";
object obj = DbHelper.ExecuteScalar(CommandType.Text, SQL, param);
if (obj != null && obj != DBNull.Value)
{
flg = obj.ToString();
}
return flg;
}
/// <summary>
/// 得到会员的文章
/// </summary>
/// <param name="UserNum"></param>
/// <returns></returns>
public DataTable getContent(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "select top 6 id,ConID,ClassID,Title,Content,creatTime,PicURL,isCheck from " + Pre + "user_Constr where UserNum=@UserNum order by id desc";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
/// <summary>
/// 得到会员的讨论组
/// </summary>
/// <param name="UserNum"></param>
/// <returns></returns>
public DataTable getGroup(string UserName)
{
SqlParameter param = new SqlParameter("@UserName", UserName);
string Sql = "select top 6 DisID,Cname,D_Content,Creatime from " + Pre + "user_Discuss where UserName=@UserName order by id desc";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
#region 得到wap
public DataTable getWapParam()
{
string Sql = "select top 1 WapTF,WapPath,WapDomain,WapLastNum from " + Pre + "sys_Pramother";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public IDataReader getWapContent(string SiteID)
{
SqlParameter param = new SqlParameter("@SiteID", SiteID);
string Sql = "select id,NewsID,NewsTitle,CreatTime from " + Pre + "News where substring(NewsProperty,13,1)='1' and siteID=@SiteID order by id desc";
return DbHelper.ExecuteReader(CommandType.Text, Sql, param);
}
#endregion wap结束
/// <summary>
/// 构造会员参数
/// </summary>
/// <param name="ui">会员实体类</param>
/// <returns></returns>
public SqlParameter[] getUserInfo(NetCMS.Model.User ui)
{
SqlParameter[] parm = new SqlParameter[46];
parm[0] = new SqlParameter("@Id", SqlDbType.Int, 4);
parm[0].Value = ui.Id;
parm[1] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
parm[1].Value = ui.UserNum;
parm[2] = new SqlParameter("@UserName", SqlDbType.NVarChar, 18);
parm[2].Value = ui.UserName;
parm[3] = new SqlParameter("@UserPassword", SqlDbType.NVarChar, 32);
parm[3].Value = ui.UserPassword;
parm[4] = new SqlParameter("@NickName", SqlDbType.NVarChar, 20);
parm[4].Value = ui.NickName;
parm[5] = new SqlParameter("@RealName", SqlDbType.NVarChar, 20);
parm[5].Value = ui.RealName;
parm[6] = new SqlParameter("@isAdmin", SqlDbType.Int, 4);
parm[6].Value = ui.isAdmin;
parm[7] = new SqlParameter("@UserGroupNumber", SqlDbType.NVarChar, 12);
parm[7].Value = ui.UserGroupNumber;
parm[8] = new SqlParameter("@PassQuestion", SqlDbType.NVarChar, 20);
parm[8].Value = ui.PassQuestion;
parm[9] = new SqlParameter("@PassKey", SqlDbType.NVarChar, 20);
parm[9].Value = ui.PassKey;
parm[10] = new SqlParameter("@CertType", SqlDbType.NVarChar, 15);
parm[10].Value = ui.CertType;
parm[11] = new SqlParameter("@CertNumber", SqlDbType.NVarChar, 20);
parm[11].Value = ui.CertNumber;
parm[12] = new SqlParameter("@Email", SqlDbType.NVarChar, 220);
parm[12].Value = ui.Email;
parm[13] = new SqlParameter("@mobile", SqlDbType.NVarChar, 15);
parm[13].Value = ui.mobile;
parm[14] = new SqlParameter("@Sex", SqlDbType.Int, 4);
parm[14].Value = ui.Sex;
parm[15] = new SqlParameter("@birthday", SqlDbType.DateTime, 8);
parm[15].Value = ui.birthday;
parm[16] = new SqlParameter("@Userinfo", SqlDbType.NText);
parm[16].Value = ui.Userinfo;
parm[17] = new SqlParameter("@UserFace", SqlDbType.NVarChar, 220);
parm[17].Value = ui.UserFace;
parm[18] = new SqlParameter("@userFacesize", SqlDbType.NVarChar, 8);
parm[18].Value = ui.userFacesize;
parm[19] = new SqlParameter("@marriage", SqlDbType.Int, 4);
parm[19].Value = ui.marriage;
parm[20] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
parm[20].Value = ui.iPoint;
parm[21] = new SqlParameter("@gPoint", SqlDbType.Int, 4);
parm[21].Value = ui.gPoint;
parm[22] = new SqlParameter("@cPoint", SqlDbType.Int, 4);
parm[22].Value = ui.cPoint;
parm[23] = new SqlParameter("@ePoint", SqlDbType.Int, 4);
parm[23].Value = ui.ePoint;
parm[24] = new SqlParameter("@aPoint", SqlDbType.Int, 4);
parm[24].Value = ui.aPoint;
parm[25] = new SqlParameter("@isLock", SqlDbType.Int, 4);
parm[25].Value = ui.isLock;
parm[26] = new SqlParameter("@RegTime", SqlDbType.DateTime, 8);
parm[26].Value = ui.RegTime;
parm[27] = new SqlParameter("@LastLoginTime", SqlDbType.DateTime, 8);
parm[27].Value = ui.LastLoginTime;
parm[28] = new SqlParameter("@OnlineTime", SqlDbType.Int, 4);
parm[28].Value = ui.OnlineTime;
parm[29] = new SqlParameter("@OnlineTF", SqlDbType.Int, 4);
parm[29].Value = ui.OnlineTF;
parm[30] = new SqlParameter("@LoginNumber", SqlDbType.Int, 4);
parm[30].Value = ui.LoginNumber;
parm[31] = new SqlParameter("@FriendClass", SqlDbType.NVarChar, 50);
parm[31].Value = ui.FriendClass;
parm[32] = new SqlParameter("@LoginLimtNumber", SqlDbType.Int, 4);
parm[32].Value = ui.LoginLimtNumber;
parm[33] = new SqlParameter("@LastIP", SqlDbType.NVarChar, 16);
parm[33].Value = ui.LastIP;
parm[34] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
parm[34].Value = ui.SiteID;
parm[35] = new SqlParameter("@Addfriend", SqlDbType.Int, 4);
parm[35].Value = ui.Addfriend;
parm[36] = new SqlParameter("@isOpen", SqlDbType.Int, 4);
parm[36].Value = ui.isOpen;
parm[37] = new SqlParameter("@ParmConstrNum", SqlDbType.Int, 4);
parm[37].Value = ui.ParmConstrNum;
parm[38] = new SqlParameter("@isIDcard", SqlDbType.Int, 4);
parm[38].Value = ui.isIDcard;
parm[39] = new SqlParameter("@IDcardFiles", SqlDbType.NVarChar, 220);
parm[39].Value = ui.IDcardFiles;
parm[40] = new SqlParameter("@Addfriendbs", SqlDbType.Int, 4);
parm[40].Value = ui.Addfriendbs;
parm[41] = new SqlParameter("@EmailATF", SqlDbType.Int, 4);
parm[41].Value = ui.EmailATF;
parm[42] = new SqlParameter("@EmailCode", SqlDbType.NVarChar, 32);
parm[42].Value = ui.EmailCode;
parm[43] = new SqlParameter("@isMobile", SqlDbType.Int, 4);
parm[43].Value = ui.isMobile;
parm[44] = new SqlParameter("@BindTF", SqlDbType.Int, 4);
parm[44].Value = ui.BindTF;
parm[45] = new SqlParameter("@MobileCode", SqlDbType.NVarChar, 32);
parm[45].Value = ui.MobileCode;
return parm;
}
/// <summary>
/// 取得会员信息(如果传值会员自动编号为0的话,则用随机编号取值)
/// </summary>
/// <param name="UserNum">会员随机编号</param>
/// <param name="ID">会员自动编号</param>
/// <returns></returns>
public NetCMS.Model.User UserInfo(string UserNum, int ID)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "";
if (ID != 0)
Sql = "Select * From " + Pre + "SYS_USER Where ID=" + ID;
else
Sql = "Select * From " + Pre + "SYS_USER Where UserNum=@UserNum";
NetCMS.Model.User ui = new NetCMS.Model.User();
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, param);
while (rd.Read())
{
ui.Id = Convert.ToInt32(rd["ID"]);
ui.UserNum = Convert.ToString(rd["UserNum"]);
ui.UserName = Convert.ToString(rd["UserName"]);
ui.UserPassword = Convert.ToString(rd["UserPassword"]);
if (rd["NickName"] == DBNull.Value) { ui.NickName = ""; } else { ui.NickName = Convert.ToString(rd["NickName"]); }
if (rd["RealName"] == DBNull.Value) { ui.RealName = ""; } else { ui.RealName = Convert.ToString(rd["RealName"]); }
ui.isAdmin = Convert.ToByte(rd["isAdmin"]);
ui.UserGroupNumber = Convert.ToString(rd["UserGroupNumber"]);
if (rd["PassQuestion"] == DBNull.Value) { ui.PassQuestion = ""; } else { ui.PassQuestion = Convert.ToString(rd["PassQuestion"]); }
if (rd["PassKey"] == DBNull.Value) { ui.PassKey = ""; } else { ui.PassKey = Convert.ToString(rd["PassKey"]); }
if (rd["CertType"] == DBNull.Value) { ui.CertType = ""; } else { ui.CertType = Convert.ToString(rd["CertType"]); }
if (rd["CertNumber"] == DBNull.Value) { ui.CertNumber = ""; } else { ui.CertNumber = Convert.ToString(rd["CertNumber"]); }
if (rd["Email"] == DBNull.Value) { ui.Email = ""; } else { ui.Email = Convert.ToString(rd["Email"]); }
if (rd["mobile"] == DBNull.Value) { ui.mobile = ""; } else { ui.mobile = Convert.ToString(rd["mobile"]); }
if (rd["Sex"] == DBNull.Value) { ui.Sex = 0; } else { ui.Sex = Convert.ToByte(rd["Sex"]); }
if (rd["birthday"] == DBNull.Value) { ui.birthday = Convert.ToDateTime("1980-11-11"); } else { ui.birthday = Convert.ToDateTime(rd["birthday"]); }
if (rd["Userinfo"] == DBNull.Value) { ui.Userinfo = ""; } else { ui.Userinfo = Convert.ToString(rd["Userinfo"]); }
if (rd["UserFace"] == DBNull.Value) { ui.UserFace = ""; } else { ui.UserFace = Convert.ToString(rd["UserFace"]); }
if (rd["userFacesize"] == DBNull.Value) { ui.userFacesize = ""; } else { ui.userFacesize = Convert.ToString(rd["userFacesize"]); }
if (rd["marriage"] == DBNull.Value) { ui.marriage = 0; } else { ui.marriage = Convert.ToByte(rd["marriage"]); }
ui.iPoint = Convert.ToInt32(rd["iPoint"]);
ui.gPoint = Convert.ToInt32(rd["gPoint"]);
ui.cPoint = Convert.ToInt32(rd["cPoint"]);
ui.ePoint = Convert.ToInt32(rd["ePoint"]);
ui.aPoint = Convert.ToInt32(rd["aPoint"]);
ui.isLock = Convert.ToByte(rd["isLock"]);
ui.RegTime = Convert.ToDateTime(rd["RegTime"]);
if (rd["LastLoginTime"] == DBNull.Value) { ui.LastLoginTime = DateTime.Now; } else { ui.LastLoginTime = Convert.ToDateTime(rd["LastLoginTime"]); }
ui.OnlineTime = Convert.ToInt32(rd["OnlineTime"]);
ui.OnlineTF = Convert.ToInt32(rd["OnlineTF"]);
ui.LoginNumber = Convert.ToInt32(rd["LoginNumber"]);
if (rd["FriendClass"] == DBNull.Value) { ui.FriendClass = ""; } else { ui.FriendClass = Convert.ToString(rd["FriendClass"]); }
if (rd["LoginLimtNumber"] == DBNull.Value) { ui.LoginLimtNumber = 0; } else { ui.LoginLimtNumber = Convert.ToInt32(rd["LoginLimtNumber"]); }
if (rd["LastIP"] == DBNull.Value) { ui.LastIP = ""; } else { ui.LastIP = Convert.ToString(rd["LastIP"]); }
if (rd["SiteID"] == DBNull.Value) { ui.SiteID = ""; } else { ui.SiteID = Convert.ToString(rd["SiteID"]); }
if (rd["Addfriend"] == DBNull.Value) { ui.Addfriend = "2"; } else { ui.Addfriend = Convert.ToString(rd["Addfriend"]); }
if (rd["isOpen"] == DBNull.Value) { ui.isOpen = 0; } else { ui.isOpen = Convert.ToByte(rd["isOpen"]); }
if (rd["ParmConstrNum"] == DBNull.Value) { ui.ParmConstrNum = 0; } else { ui.ParmConstrNum = Convert.ToInt32(rd["ParmConstrNum"]); }
if (rd["isIDcard"] == DBNull.Value) { ui.isIDcard = 0; } else { ui.isIDcard = Convert.ToByte(rd["isIDcard"]); }
if (rd["IDcardFiles"] == DBNull.Value) { ui.IDcardFiles = ""; } else { ui.IDcardFiles = Convert.ToString(rd["IDcardFiles"]); }
if (rd["Addfriendbs"] == DBNull.Value) { ui.Addfriendbs = 0; } else { ui.Addfriendbs = Convert.ToByte(rd["Addfriendbs"]); }
if (rd["EmailATF"] == DBNull.Value) { ui.EmailATF = 0; } else { ui.EmailATF = Convert.ToByte(rd["EmailATF"]); }
if (rd["EmailCode"] == DBNull.Value) { ui.EmailCode = ""; } else { ui.EmailCode = Convert.ToString(rd["EmailCode"]); }
if (rd["isMobile"] == DBNull.Value) { ui.isMobile = 0; } else { ui.isMobile = Convert.ToByte(rd["isMobile"]); }
if (rd["BindTF"] == DBNull.Value) { ui.BindTF = 0; } else { ui.BindTF = Convert.ToByte(rd["BindTF"]); }
if (rd["MobileCode"] == DBNull.Value) { ui.MobileCode = ""; } else { ui.MobileCode = Convert.ToString(rd["MobileCode"]); }
}
rd.Close();
return ui;
}
/// <summary>
/// 取得会员附加信息
/// </summary>
/// <param name="UserNum">用户编号</param>
/// <returns></returns>
public NetCMS.Model.UserFields UserFields(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "Select * From " + Pre + "sys_userfields Where UserNum=@UserNum";
NetCMS.Model.UserFields ui = new NetCMS.Model.UserFields();
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, param);
while (rd.Read())
{
ui.ID = Convert.ToInt32(rd["ID"]);
ui.userNum = Convert.ToString(rd["userNum"]);
if (rd["province"] == DBNull.Value) { ui.province = ""; } else { ui.province = Convert.ToString(rd["province"]); }
if (rd["City"] == DBNull.Value) { ui.City = ""; } else { ui.City = Convert.ToString(rd["City"]); }
if (rd["Address"] == DBNull.Value) { ui.Address = ""; } else { ui.Address = Convert.ToString(rd["Address"]); }
if (rd["Postcode"] == DBNull.Value) { ui.Postcode = ""; } else { ui.Postcode = Convert.ToString(rd["Postcode"]); }
if (rd["FaTel"] == DBNull.Value) { ui.FaTel = ""; } else { ui.FaTel = Convert.ToString(rd["FaTel"]); }
if (rd["WorkTel"] == DBNull.Value) { ui.WorkTel = ""; } else { ui.WorkTel = Convert.ToString(rd["WorkTel"]); }
if (rd["QQ"] == DBNull.Value) { ui.QQ = ""; } else { ui.QQ = Convert.ToString(rd["QQ"]); }
if (rd["MSN"] == DBNull.Value) { ui.MSN = ""; } else { ui.MSN = Convert.ToString(rd["MSN"]); }
if (rd["Fax"] == DBNull.Value) { ui.Fax = ""; } else { ui.Fax = Convert.ToString(rd["Fax"]); }
if (rd["character"] == DBNull.Value) { ui.character = ""; } else { ui.character = Convert.ToString(rd["character"]); }
if (rd["UserFan"] == DBNull.Value) { ui.UserFan = ""; } else { ui.UserFan = Convert.ToString(rd["UserFan"]); }
if (rd["Nation"] == DBNull.Value) { ui.Nation = ""; } else { ui.Nation = Convert.ToString(rd["Nation"]); }
if (rd["nativeplace"] == DBNull.Value) { ui.nativeplace = ""; } else { ui.nativeplace = Convert.ToString(rd["nativeplace"]); }
if (rd["Job"] == DBNull.Value) { ui.Job = ""; } else { ui.Job = Convert.ToString(rd["Job"]); }
if (rd["education"] == DBNull.Value) { ui.education = ""; } else { ui.education = Convert.ToString(rd["education"]); }
if (rd["Lastschool"] == DBNull.Value) { ui.Lastschool = ""; } else { ui.Lastschool = Convert.ToString(rd["Lastschool"]); }
if (rd["orgSch"] == DBNull.Value) { ui.orgSch = ""; } else { ui.orgSch = Convert.ToString(rd["orgSch"]); }
}
rd.Close();
return ui;
}
/// <summary>
/// 取得会员组信息
/// </summary>
/// <param name="GroupNumber">会员组随机编号</param>
/// <returns></returns>
public NetCMS.Model.UserGroup UserGroup(string GroupNumber)
{
SqlParameter param = new SqlParameter("@GroupNumber", GroupNumber);
string Sql = "Select * From " + Pre + "user_Group Where GroupNumber=@GroupNumber";
NetCMS.Model.UserGroup ugi = new NetCMS.Model.UserGroup();
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, param);
while (rd.Read())
{
ugi.Id = Convert.ToInt32(rd["ID"]);
if (rd["GroupNumber"] == DBNull.Value) { ugi.GroupNumber = ""; } else { ugi.GroupNumber = Convert.ToString(rd["GroupNumber"]); }
if (rd["GroupName"] == DBNull.Value) { ugi.GroupName = ""; } else { ugi.GroupName = Convert.ToString(rd["GroupName"]); }
if (rd["iPoint"] == DBNull.Value) { ugi.iPoint = 0; } else { ugi.iPoint = Convert.ToInt32(rd["iPoint"]); }
if (rd["Gpoint"] == DBNull.Value) { ugi.Gpoint = 0; } else { ugi.Gpoint = Convert.ToInt32(rd["Gpoint"]); }
if (rd["Rtime"] == DBNull.Value) { ugi.Rtime = 0; } else { ugi.Rtime = Convert.ToInt32(rd["Rtime"]); }
if (rd["Discount"] == DBNull.Value) { ugi.Discount = 0; } else { ugi.Discount = Convert.ToDouble(rd["Discount"]); }
if (rd["LenCommContent"] == DBNull.Value) { ugi.LenCommContent = 0; } else { ugi.LenCommContent = Convert.ToInt32(rd["LenCommContent"]); }
if (rd["CommCheckTF"] == DBNull.Value) { ugi.CommCheckTF = 0; } else { ugi.CommCheckTF = Convert.ToByte(rd["CommCheckTF"]); }
if (rd["PostCommTime"] == DBNull.Value) { ugi.PostCommTime = 0; } else { ugi.PostCommTime = Convert.ToInt32(rd["PostCommTime"]); }
if (rd["upfileType"] == DBNull.Value) { ugi.upfileType = ""; } else { ugi.upfileType = Convert.ToString(rd["upfileType"]); }
if (rd["upfileNum"] == DBNull.Value) { ugi.upfileNum = 0; } else { ugi.upfileNum = Convert.ToInt32(rd["upfileNum"]); }
if (rd["upfileSize"] == DBNull.Value) { ugi.upfileSize = 0; } else { ugi.upfileSize = Convert.ToInt32(rd["upfileSize"]); }
if (rd["DayUpfilenum"] == DBNull.Value) { ugi.DayUpfilenum = 0; } else { ugi.DayUpfilenum = Convert.ToInt32(rd["DayUpfilenum"]); }
if (rd["ContrNum"] == DBNull.Value) { ugi.ContrNum = 0; } else { ugi.ContrNum = Convert.ToInt32(rd["ContrNum"]); }
if (rd["DicussTF"] == DBNull.Value) { ugi.DicussTF = 0; } else { ugi.DicussTF = Convert.ToByte(rd["DicussTF"]); }
if (rd["PostTitle"] == DBNull.Value) { ugi.PostTitle = 0; } else { ugi.PostTitle = Convert.ToByte(rd["PostTitle"]); }
if (rd["ReadUser"] == DBNull.Value) { ugi.ReadUser = 0; } else { ugi.ReadUser = Convert.ToByte(rd["ReadUser"]); }
if (rd["MessageNum"] == DBNull.Value) { ugi.MessageNum = 0; } else { ugi.MessageNum = Convert.ToInt32(rd["MessageNum"]); }
if (rd["MessageGroupNum"] == DBNull.Value) { ugi.MessageGroupNum = ""; } else { ugi.MessageGroupNum = Convert.ToString(rd["MessageGroupNum"]); }
if (rd["IsCert"] == DBNull.Value) { ugi.IsCert = 0; } else { ugi.IsCert = Convert.ToByte(rd["IsCert"]); }
if (rd["CharTF"] == DBNull.Value) { ugi.CharTF = 0; } else { ugi.CharTF = Convert.ToByte(rd["CharTF"]); }
if (rd["CharHTML"] == DBNull.Value) { ugi.CharHTML = 0; } else { ugi.CharHTML = Convert.ToByte(rd["CharHTML"]); }
if (rd["CharLenContent"] == DBNull.Value) { ugi.CharLenContent = 0; } else { ugi.CharLenContent = Convert.ToInt32(rd["CharLenContent"]); }
if (rd["RegMinute"] == DBNull.Value) { ugi.RegMinute = 0; } else { ugi.RegMinute = Convert.ToInt32(rd["RegMinute"]); }
if (rd["PostTitleHTML"] == DBNull.Value) { ugi.PostTitleHTML = 0; } else { ugi.PostTitleHTML = Convert.ToByte(rd["PostTitleHTML"]); }
if (rd["DelSelfTitle"] == DBNull.Value) { ugi.DelSelfTitle = 0; } else { ugi.DelSelfTitle = Convert.ToByte(rd["DelSelfTitle"]); }
if (rd["DelOTitle"] == DBNull.Value) { ugi.DelOTitle = 0; } else { ugi.DelOTitle = Convert.ToByte(rd["DelOTitle"]); }
if (rd["EditSelfTitle"] == DBNull.Value) { ugi.EditSelfTitle = 0; } else { ugi.EditSelfTitle = Convert.ToByte(rd["EditSelfTitle"]); }
if (rd["EditOtitle"] == DBNull.Value) { ugi.EditOtitle = 0; } else { ugi.EditOtitle = Convert.ToByte(rd["EditOtitle"]); }
if (rd["ReadTitle"] == DBNull.Value) { ugi.ReadTitle = 0; } else { ugi.ReadTitle = Convert.ToByte(rd["ReadTitle"]); }
if (rd["MoveSelfTitle"] == DBNull.Value) { ugi.MoveSelfTitle = 0; } else { ugi.MoveSelfTitle = Convert.ToByte(rd["MoveSelfTitle"]); }
if (rd["MoveOTitle"] == DBNull.Value) { ugi.MoveOTitle = 0; } else { ugi.MoveOTitle = Convert.ToByte(rd["MoveOTitle"]); }
if (rd["TopTitle"] == DBNull.Value) { ugi.TopTitle = 0; } else { ugi.TopTitle = Convert.ToByte(rd["TopTitle"]); }
if (rd["GoodTitle"] == DBNull.Value) { ugi.GoodTitle = 0; } else { ugi.GoodTitle = Convert.ToByte(rd["GoodTitle"]); }
if (rd["LockUser"] == DBNull.Value) { ugi.LockUser = 0; } else { ugi.LockUser = Convert.ToByte(rd["LockUser"]); }
if (rd["UserFlag"] == DBNull.Value) { ugi.UserFlag = ""; } else { ugi.UserFlag = Convert.ToString(rd["UserFlag"]); }
if (rd["CheckTtile"] == DBNull.Value) { ugi.CheckTtile = 0; } else { ugi.CheckTtile = Convert.ToByte(rd["CheckTtile"]); }
if (rd["IPTF"] == DBNull.Value) { ugi.IPTF = 0; } else { ugi.IPTF = Convert.ToByte(rd["IPTF"]); }
if (rd["EncUser"] == DBNull.Value) { ugi.EncUser = 0; } else { ugi.EncUser = Convert.ToByte(rd["EncUser"]); }
if (rd["OCTF"] == DBNull.Value) { ugi.OCTF = 0; } else { ugi.OCTF = Convert.ToByte(rd["OCTF"]); }
if (rd["StyleTF"] == DBNull.Value) { ugi.StyleTF = 0; } else { ugi.StyleTF = Convert.ToByte(rd["StyleTF"]); }
if (rd["UpfaceSize"] == DBNull.Value) { ugi.UpfaceSize = 0; } else { ugi.UpfaceSize = Convert.ToInt32(rd["UpfaceSize"]); }
if (rd["GIChange"] == DBNull.Value) { ugi.GIChange = ""; } else { ugi.GIChange = Convert.ToString(rd["GIChange"]); }
if (rd["GTChageRate"] == DBNull.Value) { ugi.GTChageRate = ""; } else { ugi.GTChageRate = Convert.ToString(rd["GTChageRate"]); }
if (rd["LoginPoint"] == DBNull.Value) { ugi.LoginPoint = ""; } else { ugi.LoginPoint = Convert.ToString(rd["LoginPoint"]); }
if (rd["RegPoint"] == DBNull.Value) { ugi.RegPoint = ""; } else { ugi.RegPoint = Convert.ToString(rd["RegPoint"]); }
if (rd["GroupTF"] == DBNull.Value) { ugi.GroupTF = 0; } else { ugi.GroupTF = Convert.ToByte(rd["GroupTF"]); }
if (rd["GroupSize"] == DBNull.Value) { ugi.GroupSize = 0; } else { ugi.GroupSize = Convert.ToInt32(rd["GroupSize"]); }
if (rd["GroupPerNum"] == DBNull.Value) { ugi.GroupPerNum = 0; } else { ugi.GroupPerNum = Convert.ToInt32(rd["GroupPerNum"]); }
if (rd["GroupCreatNum"] == DBNull.Value) { ugi.GroupCreatNum = 0; } else { ugi.GroupCreatNum = Convert.ToInt32(rd["GroupCreatNum"]); }
if (rd["CreatTime"] == DBNull.Value) { ugi.CreatTime = DateTime.Now; } else { ugi.CreatTime = Convert.ToDateTime(rd["CreatTime"]); }
if (rd["SiteID"] == DBNull.Value) { ugi.SiteID = ""; } else { ugi.SiteID = Convert.ToString(rd["SiteID"]); }
}
rd.Close();
return ugi;
}
/// <summary>
/// 取得站点会员参数
/// </summary>
/// <param name="SiteID">站点编号</param>
/// <returns></returns>
public NetCMS.Model.UserParam UserParam(string SiteID)
{
SqlParameter param = new SqlParameter("@SiteID", SiteID);
string Sql = "Select * From " + Pre + "sys_PramUser Where SiteID='0'";
NetCMS.Model.UserParam upi = new NetCMS.Model.UserParam();
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, param);
while (rd.Read())
{
upi.ID = Convert.ToInt32(rd["ID"]);
if (rd["RegGroupNumber"] == DBNull.Value) { upi.RegGroupNumber = ""; } else { upi.RegGroupNumber = Convert.ToString(rd["RegGroupNumber"]); }
if (rd["ConstrTF"] == DBNull.Value) { upi.ConstrTF = 0; } else { upi.ConstrTF = Convert.ToByte(rd["ConstrTF"]); }
if (rd["RegTF"] == DBNull.Value) { upi.RegTF = 0; } else { upi.RegTF = Convert.ToByte(rd["RegTF"]); }
if (rd["UserLoginCodeTF"] == DBNull.Value) { upi.UserLoginCodeTF = 0; } else { upi.UserLoginCodeTF = Convert.ToByte(rd["UserLoginCodeTF"]); }
if (rd["CommCodeTF"] == DBNull.Value) { upi.CommCodeTF = 0; } else { upi.CommCodeTF = Convert.ToByte(rd["CommCodeTF"]); }
if (rd["CommCheck"] == DBNull.Value) { upi.CommCheck = 0; } else { upi.CommCheck = Convert.ToByte(rd["CommCheck"]); }
if (rd["SendMessageTF"] == DBNull.Value) { upi.SendMessageTF = 0; } else { upi.SendMessageTF = Convert.ToByte(rd["SendMessageTF"]); }
if (rd["UnRegCommTF"] == DBNull.Value) { upi.UnRegCommTF = 0; } else { upi.UnRegCommTF = Convert.ToByte(rd["UnRegCommTF"]); }
if (rd["CommHTMLLoad"] == DBNull.Value) { upi.CommHTMLLoad = 0; } else { upi.CommHTMLLoad = Convert.ToByte(rd["CommHTMLLoad"]); }
if (rd["Commfiltrchar"] == DBNull.Value) { upi.Commfiltrchar = ""; } else { upi.Commfiltrchar = Convert.ToString(rd["Commfiltrchar"]); }
if (rd["IPLimt"] == DBNull.Value) { upi.IPLimt = ""; } else { upi.IPLimt = Convert.ToString(rd["IPLimt"]); }
if (rd["GpointName"] == DBNull.Value) { upi.GpointName = ""; } else { upi.GpointName = Convert.ToString(rd["GpointName"]); }
if (rd["LoginLock"] == DBNull.Value) { upi.LoginLock = ""; } else { upi.LoginLock = Convert.ToString(rd["LoginLock"]); }
if (rd["LevelID"] == DBNull.Value) { upi.LevelID = ""; } else { upi.LevelID = Convert.ToString(rd["LevelID"]); }
if (rd["RegContent"] == DBNull.Value) { upi.RegContent = ""; } else { upi.RegContent = Convert.ToString(rd["RegContent"]); }
if (rd["setPoint"] == DBNull.Value) { upi.setPoint = ""; } else { upi.setPoint = Convert.ToString(rd["setPoint"]); }
if (rd["regItem"] == DBNull.Value) { upi.regItem = ""; } else { upi.regItem = Convert.ToString(rd["regItem"]); }
if (rd["returnemail"] == DBNull.Value) { upi.returnemail = 0; } else { upi.returnemail = Convert.ToByte(rd["returnemail"]); }
if (rd["returnmobile"] == DBNull.Value) { upi.returnmobile = 0; } else { upi.returnmobile = Convert.ToByte(rd["returnmobile"]); }
if (rd["onpayType"] == DBNull.Value) { upi.onpayType = 0; } else { upi.onpayType = Convert.ToByte(rd["onpayType"]); }
if (rd["o_userName"] == DBNull.Value) { upi.o_userName = ""; } else { upi.o_userName = Convert.ToString(rd["o_userName"]); }
if (rd["o_key"] == DBNull.Value) { upi.o_key = ""; } else { upi.o_key = Convert.ToString(rd["o_key"]); }
if (rd["o_sendurl"] == DBNull.Value) { upi.o_sendurl = ""; } else { upi.o_sendurl = Convert.ToString(rd["o_sendurl"]); }
if (rd["o_returnurl"] == DBNull.Value) { upi.o_returnurl = ""; } else { upi.o_returnurl = Convert.ToString(rd["o_returnurl"]); }
if (rd["o_md5"] == DBNull.Value) { upi.o_md5 = ""; } else { upi.o_md5 = Convert.ToString(rd["o_md5"]); }
if (rd["o_other1"] == DBNull.Value) { upi.o_other1 = ""; } else { upi.o_other1 = Convert.ToString(rd["o_other1"]); }
if (rd["o_other2"] == DBNull.Value) { upi.o_other2 = ""; } else { upi.o_other2 = Convert.ToString(rd["o_other2"]); }
if (rd["o_other3"] == DBNull.Value) { upi.o_other3 = ""; } else { upi.o_other3 = Convert.ToString(rd["o_other3"]); }
if (rd["GhClass"] == DBNull.Value) { upi.GhClass = 0; } else { upi.GhClass = Convert.ToByte(rd["GhClass"]); }
if (rd["cPointParam"] == DBNull.Value) { upi.cPointParam = ""; } else { upi.cPointParam = Convert.ToString(rd["cPointParam"]); }
if (rd["aPointparam"] == DBNull.Value) { upi.aPointparam = ""; } else { upi.aPointparam = Convert.ToString(rd["aPointparam"]); }
if (rd["SiteID"] == DBNull.Value) { upi.SiteID = ""; } else { upi.SiteID = Convert.ToString(rd["SiteID"]); }
}
rd.Close();
return upi;
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/User.cs | C# | asf20 | 56,100 |
//======================================================
//== (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 Style : DbBase, IStyle
{
private string SiteID;
public Style()
{
SiteID = NetCMS.Global.Current.SiteID;
}
public int sytleClassAdd(NetCMS.Model.StyleClassInfo sc)
{
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_styleclass 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_styleclass where Sname='" + sc.Sname + "'";
recordCount = (int)DbHelper.ExecuteScalar(Conn, CommandType.Text, checkSql, null);
if (recordCount > 0)
{
throw new Exception("样式分类名称重复,如果不存在,回收站中也可能存在此样式分类!");
}
string Sql = "insert into " + Pre + "sys_styleclass (";
Sql += "ClassID,Sname,CreatTime,SiteID,isRecyle";
Sql += ") values ('" + ClassID + "',";
Sql += "@Sname,@CreatTime,'" + SiteID + "',@isRecyle)";
SqlParameter[] param = GetstyleClassParameters(sc);
result = DbHelper.ExecuteNonQuery(Conn, CommandType.Text, Sql, param);
}
finally
{
if (Conn != null && Conn.State == ConnectionState.Open)
Conn.Close();
}
return result;
}
public int styleNametf(string CName)
{
string checkSql = "select count(*) from " + Pre + "sys_LabelStyle Where StyleName='" + CName + "' and isRecyle=0";
int recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
return recordCount;
}
public int styleClassEdit(NetCMS.Model.StyleClassInfo sc)
{
int result = 0;
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
try
{
string checkSql = "";
int recordCount = 0;
checkSql = "select count(*) from " + Pre + "sys_styleclass Where ClassID!='" + sc.ClassID + "' And Sname='" + sc.Sname + "' and isRecyle=0";
recordCount = (int)DbHelper.ExecuteScalar(Conn, CommandType.Text, checkSql, null);
if (recordCount > 0)
{
throw new Exception("样式分类名称重复!");
}
string Sql = "Update " + Pre + "sys_styleclass Set Sname='" + sc.Sname + "'";
Sql += " Where ClassID='" + sc.ClassID + "'";
SqlParameter[] param = GetstyleClassParameters(sc);
result = DbHelper.ExecuteNonQuery(Conn, CommandType.Text, Sql, param);
}
finally
{
if (Conn != null && Conn.State == ConnectionState.Open)
Conn.Close();
}
return result;
}
public void styleClassDel(string id)
{
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
SqlTransaction tran = Conn.BeginTransaction();
try
{
string str_style = "Delete From " + Pre + "sys_styleclass Where ClassID='" + id + "' And SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_style, null);
string str_styleClass = "Delete From " + Pre + "sys_LabelStyle Where ClassID='" + id + "' And SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_styleClass, null);
tran.Commit();
Conn.Close();
}
catch (SqlException e)
{
tran.Rollback();
Conn.Close();
throw e;
}
}
public void styleClassRDel(string id)
{
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
SqlTransaction tran = Conn.BeginTransaction();
try
{
string str_style = "Update " + Pre + "sys_LabelStyle Set isRecyle=1 Where ClassID='" + id + "' And SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_style, null);
string str_styleClass = "Update " + Pre + "sys_styleclass Set isRecyle=1 Where ClassID='" + id + "' And SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_styleClass, null);
tran.Commit();
Conn.Close();
}
catch (SqlException e)
{
tran.Rollback();
Conn.Close();
throw e;
}
}
public int styleAdd(NetCMS.Model.StyleInfo sc)
{
int result = 0;
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
try
{
string checkSql = "";
int recordCount = 0;
string styleID = NetCMS.Common.Rand.Number(12);
while (true)
{
checkSql = "select count(*) from " + Pre + "sys_LabelStyle where styleID='" + styleID + "'";
recordCount = (int)DbHelper.ExecuteScalar(Conn, CommandType.Text, checkSql, null);
if (recordCount < 1)
break;
else
styleID = NetCMS.Common.Rand.Number(12, true);
}
checkSql = "select count(*) from " + Pre + "sys_LabelStyle where StyleName='" + sc.StyleName + "' and isRecyle=0";
recordCount = (int)DbHelper.ExecuteScalar(Conn, CommandType.Text, checkSql, null);
if (recordCount > 0)
{
throw new Exception("样式名称重复!");
}
string Sql = "insert into " + Pre + "sys_LabelStyle (";
Sql += "styleID,ClassID,StyleName,Content,Description,CreatTime,isRecyle,SiteID";
Sql += ") values ('" + styleID + "',";
Sql += "@ClassID,@StyleName,@Content,@Description,@CreatTime,@isRecyle,'" + SiteID + "')";
SqlParameter[] param = GetstyleParameters(sc);
result = DbHelper.ExecuteNonQuery(Conn, CommandType.Text, Sql, param);
}
finally
{
if (Conn != null && Conn.State == ConnectionState.Open)
Conn.Close();
}
return result;
}
public int styleEdit(NetCMS.Model.StyleInfo sc)
{
int result = 0;
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
try
{
string checkSql = "";
int recordCount = 0;
checkSql = "select count(*) from " + Pre + "sys_LabelStyle Where styleID!='" + sc.styleID + "' And styleName='" + sc.StyleName + "'";
recordCount = (int)DbHelper.ExecuteScalar(Conn, CommandType.Text, checkSql, null);
if (recordCount > 0)
{
throw new Exception("样式名称重复,请重新修改!");
}
string Sql = "Update " + Pre + "sys_LabelStyle Set ClassID=@ClassID,StyleName=@StyleName,Content=@Content,Description=@Description";
Sql += " Where styleID='" + sc.styleID + "'";
SqlParameter[] param = GetstyleParameters(sc);
result = DbHelper.ExecuteNonQuery(Conn, CommandType.Text, Sql, param);
}
finally
{
if (Conn != null && Conn.State == ConnectionState.Open)
Conn.Close();
}
return result;
}
public void styleDel(string id)
{
SqlParameter param = new SqlParameter("@id", id);
string str_sql = "Delete From " + Pre + "sys_LabelStyle Where styleID=@id And SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, param);
}
public void styleRdel(string id)
{
SqlParameter param = new SqlParameter("@id", id);
string str_sql = "Update " + Pre + "sys_LabelStyle Set isRecyle=1 Where ID=@id And SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, param);
}
public DataTable getstyleClassInfo(string id)
{
string str_Sql = "Select Sname From " + Pre + "sys_styleclass Where ClassID='" + id + "' And SiteID='" + SiteID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getstyleInfo(string id)
{
string str_Sql = "Select ClassID,StyleName,Content,Description From " + Pre + "sys_LabelStyle Where SiteID='" + SiteID + "' And styleID='" + id + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable styledefine()
{
string str_Sql = "Select defineCname,defineColumns From " + Pre + "define_data Where SiteID='" + SiteID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable styleClassList()
{
string str_Sql = "Select ClassID,Sname From " + Pre + "sys_styleclass Where SiteID='" + SiteID + "' And isRecyle=0";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
private SqlParameter[] GetstyleParameters(NetCMS.Model.StyleInfo sc)
{
SqlParameter[] param = new SqlParameter[6];
param[0] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 12);
param[0].Value = sc.ClassID;
param[1] = new SqlParameter("@StyleName", SqlDbType.NVarChar, 30);
param[1].Value = sc.StyleName;
param[2] = new SqlParameter("@Content", SqlDbType.NText);
param[2].Value = sc.Content;
param[3] = new SqlParameter("@Description", SqlDbType.NVarChar, 200);
param[3].Value = sc.Description;
param[4] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[4].Value = sc.CreatTime;
param[5] = new SqlParameter("@isRecyle", SqlDbType.TinyInt, 1);
param[5].Value = sc.isRecyle;
return param;
}
private SqlParameter[] GetstyleClassParameters(NetCMS.Model.StyleClassInfo sc)
{
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@Sname", SqlDbType.NVarChar, 30);
param[0].Value = sc.Sname;
param[1] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[1].Value = sc.CreatTime;
param[2] = new SqlParameter("@isRecyle", SqlDbType.TinyInt, 1);
param[2].Value = sc.isRecyle;
return param;
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Style.cs | C# | asf20 | 12,656 |
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using NetCMS.Config;
using NetCMS.DALProfile;
namespace NetCMS.DALSQLServer
{
public class DbBase : IDbBase
{
DbCommand IDbBase.CreateCommand()
{
return new SqlCommand();
}
DbConnection IDbBase.CreateConnection()
{
return new SqlConnection();
}
DbDataAdapter IDbBase.CreateDataAdapter()
{
return new SqlDataAdapter();
}
DbParameter IDbBase.CreateParameter()
{
return new SqlParameter();
}
protected string Pre;
public DbBase()
{
Pre = DBConfig.TableNamePrefix;
DbHelper.Provider = this;
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/DbBase.cs | C# | asf20 | 1,180 |
//======================================================
//== (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 System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Text.RegularExpressions;
using NetCMS.Model;
using NetCMS.DALFactory;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Pagination : DbBase, IPagination
{
//分页查询列表,第一个字段必须是不重复的索引字段,必须有order by 索引字段语句
//频道管理列表
protected string[] manage_news_site_list = { "Id", "Id,ChannelID,CName,EName,ChannCName,IsURL,isLock,Domain,ContrTF,ShowNaviTF", "News_site where isRecyle=0 and (ParentID='" + NetCMS.Global.Current.SiteID + "' or ChannelID='" + NetCMS.Global.Current.SiteID + "')", "order by Id desc" };
protected string[] user_constr_constraccount ={ "id", "id,ConID,bankName,bankaccount,bankcard,bankRealName", "sys_userother where UserNum=@UserNum", "order by id desc" };
protected string[] user_constr_constrclass ={ "id", "id,Ccid,cName,creatTime", "user_ConstrClass where UserNum=@UserNum", "order by Id desc" };
protected string[] user_constr_constrlist ={ "id", "id,ConID,Title,creatTime,ClassID,isCheck,Tags", "user_Constr where UserNum=@UserNum", "order by Id desc" };
protected string[] user_constr_constrlistpass ={ "id", "id,ConID,Title,creatTime,ClassID,ispass", "user_Constr where UserNum=@UserNum and ispass=1 ", "order by Id desc" };
protected string[] user_constr_constrmoney ={ "id", "id,Money,payTime,constrPayID", "user_constrPay where UserNum=@UserNum", "order by id desc" };
protected string[] manage_label_style_1 ={ "id", "id,ClassID,Sname,CreatTime,isRecyle", "sys_styleclass where SiteID=@SiteID and isRecyle=0", "order by Id desc" };
protected string[] manage_label_style_2 ={ "id", "id,styleID,StyleName,CreatTime,Content", "sys_LabelStyle where ClassID=@ClassID and isRecyle=0 and SiteID=@SiteID", "order by Id desc" };
protected string[] manage_label_style_3 ={ "id", "id,styleID,StyleName,CreatTime,Content", "sys_LabelStyle where StyleName like cast(@Keyword as nvarchar) and isRecyle=0 and SiteID=@SiteID", "order by Id desc" };
protected string[] user_friend_friendlist_1 ={ "id", "id,FriendUserNum,UserNum,bUserNum,UserName,CreatTime", "User_Friend where UserNum=@UserNum and HailFellow=@HailFellow", "order by Id desc" };
protected string[] user_friend_friendlist_2 ={ "id", "id,FriendUserNum,UserNum,bUserNum,UserName,CreatTime", "User_Friend where UserNum=@UserNum", "order by Id desc" };
protected string[] user_friend_friendmanage ={ "id", "id,HailFellow,FriendName,CreatTime", "User_FriendClass where UserNum=@UserNum or gdfz='1'", "order by Id desc" };
protected string[] user_info_announce ={ "id", "id,title,Content,creatTime,islock,getPoint,GroupNumber", "user_news where SiteID=@SiteID and islock=0", "order by Id desc" };
protected string[] user_info_collection_1 ={ "id", "id,FID,Infotitle,CreatTime,datalib,ChID", "api_faviate where UserNum=@UserNum and APIID=@Api", "order by Id desc" };
protected string[] user_info_collection_2 ={ "id", "id,FID,Infotitle,CreatTime,datalib,ChID", "api_faviate where UserNum=@UserNum ", "order by Id desc" };
protected string[] user_info_history_1 ={ "id", "id,GhID,ghtype,Gpoint,iPoint,Money,CreatTime,UserNUM,gtype,content", "user_Ghistory where UserNUM=@UserNum and ghtype = 0", "order by id desc" };
protected string[] user_info_history_2 ={ "id", "id,GhID,ghtype,Gpoint,iPoint,Money,CreatTime,UserNUM,gtype,content", "user_Ghistory where UserNUM=@UserNum and ghtype = 1", "order by id desc" };
protected string[] user_info_history_3 ={ "id", "id,GhID,ghtype,Gpoint,iPoint,Money,CreatTime,UserNUM,gtype,content", "user_Ghistory where UserNUM=@UserNum and gtype=@gtype", "order by id desc" };
protected string[] user_info_history_4 ={ "id", "id,GhID,ghtype,Gpoint,iPoint,Money,CreatTime,UserNUM,gtype,content", "user_Ghistory where UserNUM=@UserNum ", "order by id desc" };
protected string[] manage_label_SysLabel_List_1 ={ "id", "id,ClassID,ClassName,CreatTime,Content,isRecyle", "sys_LabelClass Where isRecyle=0 And SiteID=@SiteID", "order by Id desc" };
protected string[] manage_label_SysLabel_List_2 ={ "id", "id,LabelID,Label_Name,CreatTime,Description,Label_Content", "sys_Label Where isRecyle=0 And isBack=0 And SiteID=@SiteID And ClassID=@ClassID", "order by Id desc" };
protected string[] manage_label_SysLabel_List_3 ={ "id", "id,LabelID,Label_Name,CreatTime,Description,Label_Content", "sys_Label Where isRecyle=0 And isBack=0 And isSys=0 and SiteID=@SiteID and (Label_Name like cast(@Keyword as nvarchar) or Description like cast(@Keyword as nvarchar))", "order by Id desc" };
protected string[] manage_label_syslabel_bak ={ "id", "id,LabelID,Label_Name,CreatTime", "sys_Label Where SiteID=@SiteID And isRecyle=0 And isBack=1", "order by Id desc" };
protected string[] user_Rss_RssFeed_1 ={ "id", "id,ClassID,ClassCName,ClassEName,ParentID", "news_Class where ParentID='0' and isURL=0 and isRecyle=0 and isLock=0 and isPage=0 and SiteID=@SiteID", "order by Id desc" };
protected string[] user_Rss_RssFeed_2 ={ "id", "id,ClassID,ClassCName,ClassEName,ParentID", "news_Class where ParentID=@ParentID and isURL=0 and isRecyle=0 and isLock=0 and isPage=0 and SiteID=@SiteID", "order by Id desc" };
protected string[] manage_Sys_admin_list = { "a.Id", "a.Id,a.UserNum,b.RealName,b.Email,a.isSuper,a.isLock", "sys_admin a left join sys_User b on a.UserNum=b.UserNum Where b.isAdmin=1 and a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by a.Id desc" };
protected string[] manage_Sys_admin_list_1 = { "a.Id", "a.Id,a.UserNum,b.RealName,b.Email,a.isSuper,a.isLock", "sys_admin a left join sys_User b on a.UserNum=b.UserNum Where b.isAdmin=1 and a.SiteID=@SiteID", "order by a.Id desc" };
protected string[] user_photo_photo ={ "id", "id,PhotoID,PhotoName,PhotoTime,UserNum,PhotoContent,PhotoalbumID,PhotoUrl", "user_photo where PhotoalbumID=@PhotoalbumID", "order by ID desc" };
protected string[] user_photo_Photoalbumlist ={ "id", "id,PhotoalbumName,PhotoalbumID,UserName,Creatime,pwd", "User_Photoalbum where isDisPhotoalbum=0 and UserName=@UserNum", "order by ID desc" };
protected string[] user_photo_photoclass ={ "id", "id,ClassID,ClassName,Creatime,UserName", "user_PhotoalbumClass where isDisclass=0 and UserName=@UserNum", "order by Id desc" };
protected string[] manage_Sys_admin_group ={ "id", "id,adminGroupNumber,GroupName,CreatTime", "sys_AdminGroup Where SiteID=@SiteID", "order by Id desc" };
//地区管理
protected string[] manage_user_arealist ={ "id", "id,Cid,cityName,creatTime", "Sys_City where Pid='0' and SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by OrderId desc,ID desc" };
protected string[] manage_user_arealist_City ={ "id", "id,Cid,cityName,creatTime", "Sys_City where Pid=@Cid and SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by Id desc" };
protected string[] manage_user_discussacti_list_1 ={ "id", "id,AId,Activesubject,UserName,CreaTime,ActiveExpense", "user_DiscussActive where 1=1 and Activesubject like cast(@titlem as nvarchar) and siteID = @RequestSiteId", "order by Id desc" };
protected string[] manage_user_discussacti_list_2 ={ "id", "id,AId,Activesubject,UserName,CreaTime,ActiveExpense", "user_DiscussActive where 1=1 and Activesubject like cast(@titlem as nvarchar)", "order by Id desc" };
//投稿后台
protected string[] manage_Contribution_Constr_chicklist ={ "id", "id,ConID,Title,creatTime,UserNum,Source,Tags,Author,ispass,Contrflg", "User_Constr where substring(Contrflg,3,1) = '1' and isadmidel=0 and isCheck=1 and ispass=0 and SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by Id desc" };
protected string[] manage_Contribution_Constr_List ={ "id", "id,ConID,Title,creatTime,Source,Tags,Contrflg,Author,ispass", "User_Constr where substring(Contrflg,3,1) = '1' and isadmidel=0 and isCheck=0 and ispass=0 and SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by Id desc" };
protected string[] manage_news_Special_List ={ "id", "id,SpecialID,SpecialCName,isLock,CreatTime", "news_special Where SiteID=@SiteID and isRecyle=0 and ParentID='0'", "order by Id Desc" };
//公告
protected string[] manage_user_announce ={ "id", "id,title,Content,creatTime,islock,getPoint,GroupNumber,SiteID", "user_news where SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by Id Desc" };
//好友验证
protected string[] user_Requestinformation ={ "id", "id,qUsername,bUsername,datatime,Content,ischick", "user_Requestinformation where bUsername='" + NetCMS.Global.Current.UserName + "' and ischick=1", "order by Id Desc" };
protected string[] manage_user_announce_1 ={ "id", "id,title,Content,creatTime,islock,getPoint,GroupNumber,SiteID", "user_news where SiteID=@SiteID", "order by Id Desc" };
//稿酬级别
protected string[] manage_Contribution_Constr_SetParamlist ={ "id", "id,PCId,ConstrPayName,gPoint,iPoint,money,Gunit", "sys_ParmConstr where SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by Id Desc" };
//稿酬
protected string[] manage_Contribution_paymentannals ={ "id", "id,constrPayID,userNum,Money,payTime,PayAdmin", "user_constrPay where SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by id Desc" };
//logs
protected string[] user_manage_logs_1 = { "id", "id,logID,Title,Content,creatTime,dateNum,LogDateTime,UserNum,SiteID", "user_userlogs Where UserNum='" + NetCMS.Global.Current.UserNum + "'", "order by creatTime desc,id desc" };
//网址收藏
protected string[] user_info_url = { "id", "id,ClassID,URLName,URL,URLColor,CreatTime,Content", "user_URL where UserNum='" + NetCMS.Global.Current.UserNum + "'", "order by id desc" };
protected string[] user_info_url_1 = { "id", "id,ClassID,URLName,URL,URLColor,CreatTime,Content", "user_URL where ClassID=@ClassID and UserNum='" + NetCMS.Global.Current.UserNum + "'", "order by id desc" };
protected string[] manage_user_discussclass_1 ={ "id", "id,DcID,Cname,Content", "User_DiscussClass where indexnumber='0' and Cname like cast(@titlem as nvarchar) and siteID = @RequestSiteId", "order by Id desc" };
protected string[] manage_user_discussclass_2 ={ "id", "id,DcID,Cname,Content", "User_DiscussClass where indexnumber='0' and Cname like cast(@titlem as nvarchar)", "order by Id desc" };
protected string[] manage_user_discussclass_3 ={ "id", "id,DcID,Cname,Content", "User_DiscussClass where indexnumber='0' and Cname like cast(@titlem as nvarchar) and SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by Id desc" };
protected string[] manage_user_discuss_1 ={ "id", "id,DisID,Cname,UserName,Creatime,Authoritymoney", "user_Discuss where siteID = @RequestSiteId and Cname like cast(@titlem as nvarchar)", "order by Id desc" };
protected string[] manage_user_discuss_2 ={ "id", "id,DisID,Cname,UserName,Creatime,Authoritymoney", "user_Discuss where Cname like cast(@titlem as nvarchar) and SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by Id desc" };
protected string[] user_message_Message_box_1 ={ "Id", "Id,Mid,Title,content,UserNum,Send_DateTime,LevelFlag,FileTF,isRead", "user_Message where Rec_UserNum=@UserNum and isRdel=0 and isRecyle=0", "order by Id desc" };
protected string[] user_message_Message_box_2 ={ "id", "id,Mid,Title,content,UserNum,Send_DateTime,LevelFlag,FileTF,isRead", "user_Message where UserNum=@UserNum and issDel=0 and issRecyle=0", "order by Id desc" };
protected string[] user_message_Message_box_3 ={ "id", "id,Mid,Title,content,UserNum,Send_DateTime,LevelFlag,FileTF,isRead", "user_Message where UserNum=@UserNum and SortType=1 and issDel=0 and issRecyle=0", "order by Id desc" };
protected string[] user_message_Message_box_4 ={ "id", "id,Mid,Title,content,UserNum,Send_DateTime,LevelFlag,FileTF,isRead", "user_Message where ((Rec_UserNum=@UserNum and isRecyle=1) or (UserNum=@UserNum and issRecyle=1)) and issDel=0", "order by Id desc" };
protected string[] user_discuss_discussacti_list ={ "id", "id,AId,Activesubject,UserName,CreaTime,ActiveExpense", "user_DiscussActive", "order by Id desc" };
protected string[] user_discuss_discussactiestablish_list ={ "id", "id,AId,Activesubject,UserName,CreaTime", "user_DiscussActive where UserName=@cjUserName", "order by Id desc" };
protected string[] user_discuss_discussactijoin_list = { "a.Id", "a.Id,a.AId,Activesubject,a.UserName,b.CreaTime,b.PId", "user_DiscussActive a inner join user_DiscussActiveMember b on a.AId=b.AId", "order by a.Id desc" };
protected string[] user_discuss_discussManage_list ={ "id", "id,DisID,Cname,UserName,Creatime,Authoritymoney,Browsenumber", "user_Discuss where SUBSTRING(Authority, 1, 1) = '1'", "order by Id desc" };
protected string[] user_discuss_discussManageestablish_list ={ "id", "id,DisID,Cname,UserName,Creatime,Browsenumber", "user_Discuss where UserName=@UserName", "order by Id desc" };
protected string[] user_discuss_discussManagejoin_list = { "a.Id", "a.Id,a.DisID,Cname,a.UserName,b.Creatime,b.Member,a.Browsenumber", "user_Discuss a inner join user_DiscussMember b on a.DisID=b.DisID where b.UserNum=@UserNum", "order by a.Id desc" };
protected string[] user_discuss_discussPhotoalbumlist ={ "id", "id,PhotoalbumName,PhotoalbumID,UserName,Creatime,pwd", "User_Photoalbum where isDisPhotoalbum=1 and DisID=@DisID", "order by ID desc" };
//新闻栏目
protected string[] manage_news_class_list ={ "id", "id,ClassID,ClassCName,ClassEname,ParentID,OrderID,IsURL,IsLock,[Domain],NaviShowtf,isPage", "News_Class where isRecyle!=1 and ParentID='0' " + NetCMS.Common.Public.getSessionStr() + "", "order by OrderID Desc,id desc" };
protected string[] manage_news_class_list_1 ={ "id", "id,ClassID,ClassCName,ClassEname,ParentID,OrderID,IsURL,IsLock,[Domain],NaviShowtf,isPage", "News_Class where isRecyle!=1 and ParentID='0' and SiteID=@SiteID", "order by OrderID Desc,id desc" };
//讨论组
protected string[] user_discuss_discussphotoclass ={ "id", "id,ClassID,ClassName,Creatime,UserName", "user_PhotoalbumClass where isDisclass=1 and DisID=@DisID", "order by Id desc" };
protected string[] user_discuss_discussTopi_commentary ={ "id", "id,creatTime,DtID,ParentID,UserNum", "User_DiscussTopic where ParentID=@DtIDs or (ParentID='0' and DtID=@DtIDs)", "order by creatTime asc,id asc" };
protected string[] user_discuss_discussTopi_list ={ "id", "id,VoteTF,DtID,Title,UserNum,creatTime", "User_DiscussTopic where ParentID='0' and DisID=@DisID", "order by Id desc" };
protected string[] user_info_applyads = { "AdID", "AdID,adName,adType,ClickNum,ShowNum,creatTime,isLock,TimeOutDay", "ads Where CusID=@CusID ", "order by ID" };
protected string[] General_manage_1 ={ "id", "id,Cname,gType,URL,EmailURL,isLock,SiteID", "news_Gen where SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by ID desc" };
protected string[] General_manage_2 ={ "id", "id,Cname,gType,URL,EmailURL,isLock,SiteID", "news_Gen where SiteID='" + NetCMS.Global.Current.SiteID + "' and gType=@gType", "order by ID desc" };
protected string[] user_discuss_discussphoto ={ "id", "id,PhotoID,PhotoName,PhotoTime,UserNum,PhotoContent,PhotoalbumID,PhotoUrl", "user_photo where PhotoalbumID=@PhotoalbumID", "order by ID desc" };
protected string[] manage_news_SortPage ={ "id", "id,ClassID,ClassCName,ClassEname,ParentID,OrderID", "News_Class where isRecyle!=1 and ParentID='0' and ModelID='0'", "order by OrderID desc" };
//自由标签
protected string[] manage_label_FreeLabel_List ={ "id", "id,LabelID,LabelName,LabelSQL,StyleContent,Description,CreatTime,SiteID", "sys_LabelFree where SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by ID desc" };
//PSF
protected string[] manage_publish_psf ={ "id", "id,psfID,psfName,LocalDir,RemoteDir,isSub,CreatTime,isRecyle,SiteID", "sys_PSF where isRecyle=0 and SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by ID desc" };
//计划任务
protected string[] manage_publish_siteTask ={ "id", "id,taskID,TaskName,isIndex,ClassID,News,TimeSet,CreatTime,SiteID", "sys_SiteTask where SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by ID desc" };
protected string[] Manage_Stat_View_1 ={ "id", "id,statid,classname", "stat_class where SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by ID desc" };
protected string[] Manage_Stat_View_2 ={ "id", "id,vtime,vwhere,vwidth,vOS,vsoft,vpage", "stat_Info where classid=@viewid and SiteID=@SiteID ", "order by ID desc" };
//常规列表
protected string[] configuration_system_Genlist_1 ={ "id", "Cname", "News_Gen where gType=@gType and isLock=0 and SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by Id desc" };
//友情连接------------------后台分类
protected string[] manage_Friend_Friend_List_1 ={ "id", "id,ClassID,ClassCName,Content", "friend_class where ParentID='0' and SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by ID desc" };
protected string[] manage_Friend_Friend_List_2 ={ "id", "id,Name,ClassID,Type,Author,Url,Lock,isAdmin", "friend_link where SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by ID desc" };
//友情连接------------------前台
protected string[] user_friend_friend ={ "id", "id,Name,ClassID,Type,Author,Url,Lock,isAdmin", "friend_link where Author='" + NetCMS.Global.Current.UserNum + "'", "order by ID desc" };
//归档
protected string[] manage_news_History_Manage ={ "id", "id,NewsTitle,NewsType,Author,Souce,oldTime,CheckStat,isLock,DataLib", "old_News", "order by ID desc" };
//调查
protected string[] manage_survey_ManageVote ={ "Rid", "Rid,IID,TID,OtherContent,VoteIp,VoteTime,UserNumber,SiteID", "vote_Manage where SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by RID desc" };
protected string[] manage_survey_setClass_1 ={ "vid", "vid,ClassName,Description", "vote_Class WHERE SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by vid desc" };
protected string[] manage_survey_setClass_2 ={ "vid", "vid,ClassName,Description", "vote_Class where VID like cast(@VID as nvarchar) and SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by vid desc" };
protected string[] manage_survey_setClass_3 ={ "vid", "vid,ClassName,Description", "vote_Class where ClassName like cast(@ClassName as nvarchar) and SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by vid desc" };
protected string[] manage_survey_setClass_4 ={ "vid", "vid,ClassName,Description", "vote_Class where Description like cast(@Description as nvarchar) and SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by vid desc" };
//调查选项
protected string[] manage_survey_VoteItem_1 ={ "a.TID", "a.TID,IID,ItemName,a.ItemMode,PicSrc,DisColor,VoteCount,ItemDetail,Title", "vote_Item a inner join Vote_Topic b on a.TID=b.TID where a.TID like cast(@TID as nvarchar) and a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by a.TID desc" };
protected string[] manage_survey_VoteItem_2 ={ "a.TID", "a.TID,IID,ItemName,a.ItemMode,PicSrc,DisColor,VoteCount,ItemDetail,Title", "vote_Item a inner join Vote_Topic b on a.TID=b.TID where a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by a.TID desc" };
protected string[] manage_survey_VoteItem_3 ={ "a.TID", "a.TID,IID,ItemName,a.ItemMode,PicSrc,DisColor,VoteCount,ItemDetail,Title", "vote_Item a inner join Vote_Topic b on a.TID=b.TID where ItemName like cast(@ItemName as nvarchar) and a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by a.TID desc" };
protected string[] manage_survey_VoteItem_4 ={ "a.TID", "a.TID,IID,ItemName,a.ItemMode,PicSrc,DisColor,VoteCount,ItemDetail,Title", "vote_Item a inner join Vote_Topic b on a.TID=b.TID where PicSrc like cast(@PicSrc as nvarchar) and a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by a.TID desc" };
protected string[] manage_survey_VoteItem_5 ={ "a.TID", "a.TID,IID,ItemName,a.ItemMode,PicSrc,DisColor,VoteCount,ItemDetail,Title", "vote_Item a inner join Vote_Topic b on a.TID=b.TID where DisColor like cast(@DisColor as nvarchar) and a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by a.TID desc" };
protected string[] manage_survey_VoteItem_6 ={ "a.TID", "a.TID,IID,ItemName,a.ItemMode,PicSrc,DisColor,VoteCount,ItemDetail,Title", "vote_Item a inner join Vote_Topic b on a.TID=b.TID where VoteCount like cast(@VoteCount as nvarchar) and a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by a.TID desc" };
protected string[] manage_survey_VoteItem_7 ={ "a.TID", "a.TID,IID,ItemName,a.ItemMode,PicSrc,DisColor,VoteCount,ItemDetail,Title", "vote_Item a inner join Vote_Topic b on a.TID=b.TID where ItemDetail like cast(@ItemDetail as nvarchar) and a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by a.TID desc" };
//投票主题
protected string[] manage_survey_VoteTopic_1 ={ "TID", "TID,a.VID,Title,Type,DisMode,StartDate,EndDate,ItemMode,ClassName", "Vote_Topic a inner join Vote_Class b on a.VID=b.VID where a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by TID desc" };
protected string[] manage_survey_VoteTopic_2 ={ "TID", "TID,a.VID,Title,Type,DisMode,StartDate,EndDate,ItemMode,ClassName", "Vote_Topic a inner join Vote_Class b on a.VID=b.VID where Title like cast(@Title as nvarchar) and a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by TID desc" };
protected string[] manage_survey_VoteTopic_3 ={ "TID", "TID,a.VID,Title,Type,DisMode,StartDate,EndDate,ItemMode,ClassName", "Vote_Topic a inner join Vote_Class b on a.VID=b.VID where a.VID like cast(@VID as nvarchar) and a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by TID desc" };
protected string[] manage_survey_VoteTopic_4 ={ "TID", "TID,a.VID,Title,Type,DisMode,StartDate,EndDate,ItemMode,ClassName", "Vote_Topic a inner join Vote_Class b on a.VID=b.VID where StartDate like cast(@StartDate as nvarchar) and a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by TID desc" };
protected string[] manage_survey_VoteTopic_5 ={ "TID", "TID,a.VID,Title,Type,DisMode,StartDate,EndDate,ItemMode,ClassName", "Vote_Topic a inner join Vote_Class b on a.VID=b.VID where EndDate like cast(@EndDate as nvarchar) and a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by TID desc" };
protected string[] manage_survey_VoteTopic_6 ={ "TID", "TID,a.VID,Title,Type,DisMode,StartDate,EndDate,ItemMode,ClassName", "Vote_Topic a inner join Vote_Class b on a.VID=b.VID where ItemMode like cast(@ItemMode as nvarchar) and a.SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by TID desc" };
//自定义字段
protected string[] manage_Sys_DefineTable_Manage = { "DefineId", "DefineId,DefineInfoId,DefineName,ParentInfoId", "define_class where ParentInfoId='0' and SiteID='" + NetCMS.Global.Current.SiteID + "'", "order by DefineId desc" };
//前台显示文章
protected string[] user_ShowUser_1 = { "id", "ConID,id,Title,creatTime,ClassID", "user_Constr where UserNum=@UserNum and ClassID=@ClassID and isuserdel=0", "order by Id desc" };
protected string[] user_ShowUser_1_1 = { "id", "ConID,id,Title,creatTime,ClassID", "user_Constr where UserNum=@UserNum and isuserdel=0", "order by Id desc" };
protected string[] user_ShowUser_2 ={ "id", "id,PhotoalbumName,PhotoalbumID,pwd", "User_Photoalbum where isDisPhotoalbum=0 and UserName=@UserNum", "order by ID desc" };
//显示相册
protected string[] user_show_showphoto ={ "id", "id,PhotoID,PhotoName,PhotoTime,UserNum,PhotoContent,PhotoalbumID,PhotoUrl", "user_photo where PhotoalbumID=@PhotoalbumID", "order by ID desc" };
//模型列表
protected string[] manage_channel_list ={ "a.id", "a.id,a.channelName,a.channelDescript,a.channelItem,a.channelEItem,a.islock,a.isHTML,a.DataLib,a.issys,a.binddomain,(select channelName from " + UIConfig.dataRe + "sys_channel b where b.id=a.parentID) as cNames", "sys_channel a", "order by a.ID desc" };
protected string[] manage_channel_value ={ "id", "id,OrderID,CName,EName,ChID,islock,isUser,vType,vLength,fieldLength,isNulls,isSearch,vHeight,HTMLedit", "sys_channelvalue where ChID=@ChID", "order by OrderID desc,id DESC" };
//频道管理
protected string[] manage_channel_class_list ={ "id", "id,ChID,ParentID,OrderID,classCName,classEName,isPage,isLock,isDelPoint", "sys_channelclass where ParentID=@ParentID and ChID=@ChID", "order by OrderID desc,id DESC" };
protected string[] manage_channel_Special_list ={ "id", "id,ChID,ParentID,OrderID,specialCName,specialEName,isRec,isLock", "sys_channelspecial where ParentID=@ParentID and ChID=@ChID", "order by OrderID desc,id DESC" };
//自定义表单管理
protected string[] manage_sys_customform ={ "id", "id,formname,formtablename,memo", "customform", "order by id DESC" };
//自定义表单字段
protected string[] manage_sys_customform_item ={ "id", "id,formid,seriesnumber,fieldname,itemname,itemtype,case isnotnull when 1 then '是' else '否' end as notnull", "customform_item where formid=@formid", "order by seriesnumber" };
/// <summary>
/// 获取SQL语句
/// </summary>
/// <param name="PageName"></param>
/// <returns></returns>
protected string[] GetSqlSentence(string PageName)
{
string PageType = PageName.Substring(0, PageName.Length - 5);
FieldInfo fi = this.GetType().GetField(PageType, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase);
if (fi == null)
throw new Exception("没有找到SQL");
return (string[])fi.GetValue(this);
}
/// <summary>
/// 执行分页
/// </summary>
/// <param name="PageName"></param>
/// <param name="PageIndex"></param>
/// <param name="PageSize"></param>
/// <param name="RecordCount"></param>
/// <param name="PageCount"></param>
/// <param name="SqlCondition"></param>
/// <returns></returns>
public DataTable GetPage(string PageName, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
try
{
string[] Sql = GetSqlSentence(PageName);
string IndexField = Sql[0];
string AllFields = Sql[1];
string Condition = Sql[2];
string OrderFields = Sql[3];
Condition = Pre + Condition;
if (Condition.ToLower().IndexOf(" join ") > 0)
Condition = Condition.Replace(" join ", " join " + Pre);
List<SqlParameter> param = new List<SqlParameter>();
if (SqlCondition != null && SqlCondition.Length > 0)
{
int n = SqlCondition.Length;
for (int i = 0; i < n; i++)
{
if (SqlCondition[i].name != null && SqlCondition[i].name != string.Empty)
{
SqlParameter p = new SqlParameter(SqlCondition[i].name, SqlDbType.Variant);
p.Value = SqlCondition[i].value;
param.Add(p);
}
}
}
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, param.ToArray());
}
catch (SqlException e)
{
throw e;
}
catch (Exception e)
{
throw new Exception("用于分页的SQL语句无效:" + e.Message);
}
}
/// <summary>
/// 以附加SQL语句分页
/// </summary>
/// <param name="PageName"></param>
/// <param name="PageIndex"></param>
/// <param name="PageSize"></param>
/// <param name="RecordCount"></param>
/// <param name="PageCount"></param>
/// <param name="SqlCondition"></param>
/// <param name="blur"></param>
/// <returns></returns>
public DataTable GetPage(string PageName, int PageIndex, int PageSize, out int RecordCount, out int PageCount,bool blur, params SQLConditionInfo[] SqlCondition)
{
try
{
string[] Sql = GetSqlSentence(PageName);
string IndexField = Sql[0];
string AllFields = Sql[1];
string Condition = Sql[2];
string OrderFields = Sql[3];
Condition = Pre + Condition;
if (Condition.ToLower().IndexOf(" join ") > 0)
Condition = Condition.Replace(" join ", " join " + Pre);
List<SqlParameter> param = new List<SqlParameter>();
if (SqlCondition != null && SqlCondition.Length > 0)
{
int n = SqlCondition.Length;
for (int i = 0; i < n; i++)
{
if (SqlCondition[i].name != null && SqlCondition[i].name != string.Empty)
{
SqlParameter p = new SqlParameter(SqlCondition[i].name, SqlDbType.Variant);
p.Value = SqlCondition[i].value;
param.Add(p);
}
}
}
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, param.ToArray());
}
catch (SqlException e)
{
throw e;
}
catch (Exception e)
{
throw new Exception("用于分页的SQL语句无效:" + e.Message);
}
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Pagination.cs | C# | asf20 | 31,328 |
//======================================================
//== (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 NetCMS.Common;
using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Mycom : DbBase, IMycom
{
#region usermycom_Look.aspx
public DataTable sel_apiCommentary(string Commid,int flag)
{
#region
SqlParameter param = new SqlParameter("@Commid", Commid);
string Sql = null;
if (flag == 0)
{
Sql = "select Title,Content,IP,UserNum,creatTime from " + Pre + "api_commentary where Commid=@Commid " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 1)
{
Sql = "select DelSelfTitle,DelOTitle from " + Pre + "user_Group where GroupNumber=@Commid";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
#endregion
}
public int Update(string Title, string Contents, DateTime CreatTime, string Commid)
{
#region
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@Title", SqlDbType.NVarChar, 200);
param[0].Value = Title;
param[1] = new SqlParameter("@Contents", SqlDbType.NText);
param[1].Value = Contents;
param[2] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[2].Value = CreatTime;
param[3] = new SqlParameter("@Commid", SqlDbType.NVarChar, 12);
param[3].Value = Commid;
string Sql = "update " + Pre + "api_commentary set Title=@Title,Content=@Contents,creatTime=@CreatTime where Commid=@Commid " + NetCMS.Common.Public.getSessionStr() + "";
return (int)DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public DataTable GetPage(string UserNum2, string GoodTitle2, string UserNum, string title, string Um, string dtm1, string dtm2, string isCheck, string islock, string SiteID, string infoID, string APIID, string DTable, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
#region
if (UserNum2 == null) UserNum2 = "";
if (UserNum == null) UserNum = "";
if (title == null)title = "";
if (Um == null) Um = "";
if (isCheck == null) isCheck = "";
if (islock == null) islock = "";
if (SiteID == null) SiteID = "";
if (infoID == null) infoID = "";
if (APIID == null) APIID = "";
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@UserNum2", UserNum2), new SqlParameter("@UserNum", UserNum), new SqlParameter("@title", title), new SqlParameter("@Um", Um), new SqlParameter("@dtm1", dtm1), new SqlParameter("@dtm2", dtm2), new SqlParameter("@isCheck", isCheck), new SqlParameter("@islock", islock), new SqlParameter("@SiteID", SiteID), new SqlParameter("@infoID", infoID), new SqlParameter("@APIID", APIID) };
string QSQL = "";
if (UserNum != "" && UserNum != null)
QSQL = " and UserNum=@UserNum";
if (title != "" && title != null)
QSQL += " and Title like '%" + title + "%'";
if (dtm1 != "" && dtm1 != null && dtm2 != "" && dtm2 != null)
{
DateTime dtms1 = DateTime.Parse(dtm1);
DateTime dtms2 = DateTime.Parse(dtm2);
QSQL += " and creatTime >= '" + dtms1 + "' and creatTime <= '" + dtms1 + "'";
}
if (isCheck != "" && isCheck != null && isCheck != "0")
{
QSQL += " and isCheck=@isCheck";
}
if (islock != "" && islock != null && islock != "0")
{
QSQL += " and islock=@islock";
}
string GT = null;
if (GoodTitle2 != null && GoodTitle2 != "")
GT = " and GoodTitle='1'";
string um = null;
if (UserNum2 != null && UserNum2 != "")
um = " and UserNum=@UserNum2";
string siteID1 = "";
if (NetCMS.Global.Current.SiteID != "0")
siteID1 = " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
else
{
if (SiteID != "" && SiteID != null)
siteID1 = " and SiteID=@SiteID";
}
if (infoID != string.Empty && infoID != null)
QSQL += " and InfoID=@infoID";
if (APIID != string.Empty && APIID != null)
QSQL += " and APIID=@APIID";
if (DTable != string.Empty && DTable != null)
QSQL += " and DataLib = '" + DTable + "'";
string AllFields = "Commid,Title,InfoID,APIID,creatTime,isCheck,UserNum,islock,OrderID,GoodTitle,datalib,Content";
string Condition = "" + Pre + "api_commentary where 1=1 " + QSQL + siteID1 + um + GT + "";
string IndexField = "ID";
string OrderFields = "order by OrderID Desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, param);
#endregion
}
public string sel_newsClass(string InfoID, string datalib)
{
#region
SqlParameter param = new SqlParameter("@NewsID", InfoID);
string Sql = "select a.NewsType,a.URLaddress,a.SavePath,a.FileName,a.FileEXName,a.isDelPoint,a.NewsTitle,b.savepath as savepath1,b.SaveClassframe from " + datalib + " a," + Pre + "news_class b where a.NewsID=@NewsID and a.classid=b.classid";
IDataReader dt = DbHelper.ExecuteReader(CommandType.Text, Sql, param);
string URL = "";
string NewsTitle = "";
string dimm = NetCMS.Config.UIConfig.dirDumm;
if (dimm.Trim() != string.Empty)
{
dimm = "/" + dimm;
}
if (dt.Read())
{
NewsTitle = dt["NewsTitle"].ToString(); ;
if (dt["NewsType"].ToString() != "2")
{
if (dt["isDelPoint"].ToString() == "0")
{
URL = dimm + "/" + dt["savepath1"] + "/" + dt["SaveClassframe"] + "/" + dt["SavePath"] + "/" + dt["FileName"] + dt["FileEXName"];
}
else
{
URL = dimm + "/content.aspx?id=" + InfoID + "";
}
URL = URL.Replace("//", "/");
}
else
{
URL = dt["URLaddress"].ToString();
}
dt.Close();
}
return "<a href=\"" + URL + "\" class=\"list_link\" target=\"_blank\">" + NewsTitle + "</a>";
#endregion
}
public string sel_Info(string UserNum,int flag)
{
#region
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = null;
if (flag == 0)
{
Sql = "select UserGroupNumber from " + Pre + "sys_user where UserNum=@UserNum";
}
else if (flag == 1)
{
Sql = "select GoodTitle from " + Pre + "api_commentary where Commid=@UserNum and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "select isCheck from " + Pre + "api_commentary where Commid=@UserNum " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 3)
{
Sql = "select OrderID from " + Pre + "api_commentary where Commid=@UserNum " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 4)
{
Sql = "select islock from " + Pre + "api_commentary where Commid=@UserNum " + NetCMS.Common.Public.getSessionStr() + "";
}
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
#endregion
}
public void Delete(string Commid)
{
SqlParameter param = new SqlParameter("@Commid", Commid);
string Sql = "delete " + Pre + "api_commentary where Commid=@Commid " + NetCMS.Common.Public.getSessionStr() + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public int update_apiCommentary(int OrderID, string Commid,int flag)
{
#region
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@OrderID", SqlDbType.Int, 4);
param[0].Value = OrderID;
param[1] = new SqlParameter("@Commid", SqlDbType.NVarChar, 12);
param[1].Value = Commid;
string Sql = null;
if (flag == 0)
{
Sql = "update " + Pre + "api_commentary set OrderID=@OrderID where Commid=@Commid " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 1)
{
Sql = "update " + Pre + "api_commentary set islock=@OrderID where Commid=Commid" + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 2)
{
Sql = "update " + Pre + "api_commentary set isCheck=@OrderID where Commid=@Commid " + NetCMS.Common.Public.getSessionStr() + "";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public void update_commentary(int GoodTitle, string Commid)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@GoodTitle", SqlDbType.Int, 1);
param[0].Value = GoodTitle;
param[1] = new SqlParameter("@Commid", SqlDbType.NVarChar, 12);
param[1].Value = Commid;
string Sql = "update " + Pre + "api_commentary set GoodTitle=@GoodTitle where Commid=@Commid " + NetCMS.Common.Public.getSessionStr() + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Mycom.cs | C# | asf20 | 10,969 |
//======================================================
//== (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 Recyle : DbBase, IRecyle
{
private string SiteID = NetCMS.Global.Current.SiteID;
public Recyle()
{
}
public DataTable getList(string type)
{
string str_Sql = GetSql(type);
string str_TName = Pre + "news";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
if (type == "NList")
{
DataTable dv = getNewsTable();
if (dv != null)
{
for (int i = 0; i < dv.Rows.Count; i++)
{
string str_TempName = dv.Rows[i][0].ToString();
if (str_TempName.ToUpper() != str_TName.ToUpper())
{
str_Sql = "Select Id,NewsID,NewsTitle From " + dv.Rows[i][0].ToString() + " Where isRecyle=1 and " +
"SiteID='" + SiteID + "'";
DataTable dc = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
dt.Merge(dc);
}
}
}
}
return dt;
}
protected string GetSql(string type)
{
string str_Sql = "";
switch (type)
{
case "NCList": //新闻栏目列表
str_Sql = "Select Id,ClassID,ClassCName From " + Pre + "news_Class Where isRecyle=1 and SiteID='" + SiteID + "'";
break;
case "NList": //新闻列表
str_Sql = "Select Id,NewsID,NewsTitle From " + Pre + "news Where isRecyle=1 and SiteID='" + SiteID + "'";
break;
case "CList": //频道列表
str_Sql = "Select Id,ChannelID,CName From " + Pre + "news_site Where isRecyle=1 and SiteID='" + SiteID + "'";
break;
case "SList": //专题列表
str_Sql = "Select Id,SpecialID,SpecialCName From " + Pre + "news_special Where isRecyle=1 and SiteID='" + SiteID + "'";
break;
case "LCList": //标签栏目列表
str_Sql = "Select Id,ClassID,ClassName From " + Pre + "sys_LabelClass Where isRecyle=1 and SiteID='" + SiteID + "'";
break;
case "LList": //标签列表
str_Sql = "Select Id,LabelID,Label_Name From " + Pre + "sys_Label Where isRecyle=1 and SiteID='" + SiteID + "'";
break;
case "StCList": //样式栏目列表
str_Sql = "Select Id,ClassID,Sname From " + Pre + "sys_styleclass Where isRecyle=1 and SiteID='" + SiteID + "'";
break;
case "StList": //样式列表
str_Sql = "Select Id,styleID,StyleName From " + Pre + "sys_LabelStyle Where isRecyle=1 and SiteID='" + SiteID + "'";
break;
case "PSFList": //PSF结点列表
str_Sql = "Select Id,psfID,psfName From " + Pre + "sys_PSF Where isRecyle=1 and SiteID='" + SiteID + "'";
break;
}
return str_Sql;
}
public void RallNCList()
{
string str_Sql = "Update " + Pre + "news_Class Set isRecyle=0 Where SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void RallNList(string classid)
{
DataTable dt = getNewsTable();
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string tbname = dt.Rows[i][0].ToString();
string str_Sql = "Select NewsID,ClassID,NewsProperty,NewsType,DataLib From " + tbname + " Where isRecyle=1 And SiteID='" + SiteID + "' And isRecyle=1";
DataTable dv = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
if (dv != null)
{
for (int j = 0; j < dv.Rows.Count; j++)
{
string str_Sql1 = "";
string newsclassid = dv.Rows[j]["ClassID"].ToString();
string newsid = dv.Rows[j]["NewsID"].ToString();
string Prot = dv.Rows[j]["NewsProperty"].ToString();
string[] getProt = Prot.Split(',');
int isRec = int.Parse(getProt[0]);
int isMarquee = int.Parse(getProt[1]);
int isHOT = int.Parse(getProt[2]);
int isFilt = int.Parse(getProt[3]);
int isTT = int.Parse(getProt[4]);
int isAnnouce = int.Parse(getProt[5]);
int isWap = int.Parse(getProt[6]);
int isJC = int.Parse(getProt[7]);
//string sTF = "select id from " + Pre + "news_temp where NewsID='" + newsid + "' and DataLib='" + dv.Rows[j]["DataLib"].ToString() + "' order by id desc";
//DataTable dtTF = DbHelper.ExecuteTable(CommandType.Text, sTF, null);
//if (dtTF != null)
//{
// if (dtTF.Rows.Count == 0)
// {
int NewsType = int.Parse(dv.Rows[j]["NewsType"].ToString());
DateTime CreatTime = DateTime.Parse(dv.Rows[j]["CreatTime"].ToString());
int isConstr = 0;
if (NetCMS.Common.Input.IsInteger(dv.Rows[j]["isConstr"].ToString()))
{
isConstr = int.Parse(dv.Rows[j]["isConstr"].ToString());
}
string ClassID = "";
if (checkParIsDel(newsclassid, "news_Class") == true) { ClassID = classid; }
else { ClassID = dv.Rows[j]["ClassID"].ToString(); }
//string Sql = "insert into " + Pre + "news_temp (NewsID,DataLib,NewsType,CreatTime,IsRec,isHot,isTT,isAnnounce,isMarQuee,isConstr,isJC,isWap,isFilt,ClassID)";
//Sql += " VALUES ('" + newsid + "','" + dv.Rows[j]["DataLib"].ToString() + "'," + NewsType + ",'" + CreatTime + "'," + isRec + "," + isHOT + "," + isTT + "," + isAnnouce + "," + isMarquee + "," + isConstr + "," + isJC + "," + isWap + "," + isFilt + ",'" + ClassID + "')";
//DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
// }
// dtTF.Clear(); dtTF.Dispose();
//}
//删除多余的信息
RandFirst:
//string SqlTf = "select ID from " + Pre + "news_temp order by id desc";
//DataTable rTF = DbHelper.ExecuteTable(CommandType.Text, SqlTf, null);
//if (rTF.Rows.Count > 3000)
//{
// string SQL1 = "delete from " + Pre + "news_temp where id=(select top 1 id from " + Pre + "news_temp order by id asc)";
// DbHelper.ExecuteNonQuery(CommandType.Text, SQL1, null);
// rTF.Clear(); rTF.Dispose();
// goto RandFirst;
//}
if (checkParIsDel(newsclassid, "news_Class") == true)
{
str_Sql1 = "Update " + tbname + " Set isRecyle=0,ClassID='" + classid + "' Where SiteID='" + SiteID + "' and NewsID='" + newsid + "'";
}
else
{
str_Sql1 = "Update " + tbname + " Set isRecyle=0 Where SiteID='" + SiteID + "' and NewsID='" + newsid + "'";
}
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
raDComment(newsid, false);
}
dv.Clear();
dv.Dispose();
}
}
dt.Clear();
dt.Dispose();
}
}
public void RallCList()
{
string str_Sql = "Update " + Pre + "news_site Set isRecyle=0 Where SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void RallSList()
{
string str_Sql = "Update " + Pre + "news_special Set isRecyle=0 Where SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void RallLCList()
{
string str_Sql = "Update " + Pre + "sys_LabelClass Set isRecyle=0 Where SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void RallLList(string classid)
{
string str_Sql = "Select LabelID,ClassID From " + Pre + "sys_Label Where isRecyle=1 And SiteID='" + SiteID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
if (dt != null)
{
string str_Sql1 = "";
for (int i = 0; i < dt.Rows.Count; i++)
{
string labelclassid = dt.Rows[i]["ClassID"].ToString();
string labelid = dt.Rows[i]["LabelID"].ToString();
if (checkParIsDel(labelclassid, "sys_LabelClass") == true)
str_Sql1 = "Update " + Pre + "sys_Label Set isRecyle=0,ClassID='" + classid + "' Where SiteID='" + SiteID + "' And LabelID='" + labelid + "'";
else
str_Sql1 = "Update " + Pre + "sys_Label Set isRecyle=0 Where SiteID='" + SiteID + "' And LabelID='" + labelid + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
}
dt.Clear();
dt.Dispose();
}
}
public void RallStCList()
{
string str_Sql = "Update " + Pre + "sys_styleclass Set isRecyle=0 Where SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void RallStList(string classid)
{
string str_Sql = "Select styleID,ClassID From " + Pre + "sys_styleclass Where isRecyle=1 And SiteID='" + SiteID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
if (dt != null)
{
string str_Sql1 = "";
for (int i = 0; i < dt.Rows.Count; i++)
{
string styleclassid = dt.Rows[i]["ClassID"].ToString();
string styleid = dt.Rows[i]["styleID"].ToString();
if (checkParIsDel(styleclassid, "sys_styleclass") == true)
str_Sql1 = "Update " + Pre + "sys_LabelStyle Set isRecyle=0,ClassID='" + classid + "' Where SiteID='" + SiteID + "' And styleID='" + styleid + "'";
else
str_Sql1 = "Update " + Pre + "sys_LabelStyle Set isRecyle=0 Where SiteID='" + SiteID + "' And styleID='" + styleid + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
}
dt.Clear();
dt.Dispose();
}
}
public void RallPSFList()
{
string str_Sql = "Update " + Pre + "sys_PSF Set isRecyle=0 Where SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
//---------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------
public void DallNCList()
{
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
SqlTransaction tran = Conn.BeginTransaction();
try
{
DataTable dt = getNewsTable();
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string tbname = dt.Rows[i][0].ToString();
string str_Sql = "Delete From " + tbname + " Where ClassID In (Select ClassID " +
"From " + Pre + "news_Class Where SiteID='" + SiteID + "' And isRecyle=1)";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql, null);
string str_Sql1 = "Delete From " + Pre + "news_Class Where SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql1, null);
}
tran.Commit();
dt.Clear(); dt.Dispose();
}
Conn.Close();
}
catch (SqlException e)
{
tran.Rollback();
Conn.Close();
throw e;
}
}
public void DallNList()
{
DataTable dt = getNewsTable();
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string tbname = dt.Rows[i][0].ToString();
string str_Sql = "Delete From " + tbname + " Where SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
dt.Clear(); dt.Dispose();
}
}
public void DallCList()
{
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
SqlTransaction tran = Conn.BeginTransaction();
try
{
DataTable dt = getNewsTable();
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string tbname = dt.Rows[i][0].ToString();
string str_Sql = "Delete From " + Pre + "API_commentary Where InfoID In(" +
"Select NewsID From " + tbname + " Where SiteID In(" +
"Select ChannelID From " + Pre + " news_site Where isRecyle=1 And SiteID='" + SiteID + "'))";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql, null);
string str_Sql1 = "Delete From " + tbname + " Where SiteID In(" +
"Select ChannelID From " + Pre + " news_site Where isRecyle=1 And SiteID='" + SiteID + "')";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql1, null);
string str_Sql2 = "Delete From " + Pre + "news_Class Where SiteID In(" +
"Select ChannelID From " + Pre + " news_site Where isRecyle=1 And SiteID='" + SiteID + "')";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql2, null);
string str_Sql3 = "Delete From " + Pre + "news_special Where SiteID In(" +
"Select ChannelID From " + Pre + " news_site Where isRecyle=1 And SiteID='" + SiteID + "')";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql3, null);
string str_Sql4 = "Delete From " + Pre + "news_site Where isRecyle=1 And SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql4, null);
}
tran.Commit();
}
Conn.Close();
}
catch (SqlException e)
{
tran.Rollback();
Conn.Close();
throw e;
}
}
public void DallSList()
{
string Sql = "Delete From " + Pre + "special_news Where SpecialID In (Select SpecialID From " + Pre + "news_special Where isRecyle=1 And SiteID='" + SiteID + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
string str_Sql = "Delete From " + Pre + "news_special Where isRecyle=1 And SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void DallLCList()
{
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
SqlTransaction tran = Conn.BeginTransaction();
try
{
string str_Sql = "Delete From " + Pre + "sys_Label Where ClassID In (Select ClassID " +
"From " + Pre + "sys_LabelClass Where SiteID='" + SiteID + "' And isRecyle=1)";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql, null);
string str_Sql1 = "Delete From " + Pre + "sys_LabelClass Where SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql1, null);
tran.Commit();
Conn.Close();
}
catch (SqlException e)
{
tran.Rollback();
Conn.Close();
throw e;
}
}
public void DallLList()
{
string str_Sql = "Delete From " + Pre + "sys_Label Where isRecyle=1 And SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void DallStCList()
{
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
SqlTransaction tran = Conn.BeginTransaction();
try
{
string str_Sql = "Delete From " + Pre + "sys_LabelStyle Where ClassID In (Select" +
" ClassID From " + Pre + "sys_styleclass Where SiteID='" + SiteID + "' And isRecyle=1)";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql, null);
string str_Sql1 = "Delete From " + Pre + "sys_styleclass Where SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql1, null);
tran.Commit();
Conn.Close();
}
catch (SqlException e)
{
tran.Rollback();
Conn.Close();
throw e;
}
}
public void DallStList()
{
string str_Sql = "Delete From " + Pre + "sys_LabelStyle Where SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void DallPSFList()
{
string str_Sql = "Delete From " + Pre + "sys_PSF Where isRecyle=1 And SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
//---------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------
public void PRNCList(string idstr)
{
string[] arr_id = idstr.Split(',');
for (int i = 0; i < arr_id.Length; i++)
{
string classid = arr_id[i].ToString().Replace("'", "");
string str_Sql = "";
if (checkParIsDel(classid, "news_Class") == true)
str_Sql = "Update " + Pre + "news_Class Set isRecyle=0,ParentID='0' Where SiteID='" + SiteID + "' and ClassID='" + classid + "'";
else
str_Sql = "Update " + Pre + "news_Class Set isRecyle=0 Where SiteID='" + SiteID + "' and ClassID='" + classid + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
}
public void PRNList(string classid, string idstr)
{
DataTable dt = getNewsTable();
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string tbname = dt.Rows[i][0].ToString();
string[] arr_id = idstr.Split(',');
for (int j = 0; j < arr_id.Length; j++)
{
string tempNewsID = arr_id[j].ToString().Replace("'", "");
string str_Sql = "Select NewsID,ClassID From " + tbname + " Where isRecyle=1 And " +
"SiteID='" + SiteID + "' And NewsID='" + tempNewsID + "'";
DataTable dv = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
if (dv != null)
{
if (dv.Rows.Count > 0)
{
string str_Sql1 = "";
string newsclassid = dv.Rows[0][1].ToString();
string newsid = dv.Rows[0][0].ToString();
if (checkParIsDel(newsclassid, "news_Class") == true)
str_Sql1 = "Update " + tbname + " Set isRecyle=0,ClassID='" + classid + "' Where SiteID='" + SiteID + "' and NewsID='" + newsid + "'";
else
str_Sql1 = "Update " + tbname + " Set isRecyle=0 Where SiteID='" + SiteID + "' and NewsID='" + newsid + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
}
dv.Clear(); dv.Dispose();
}
}
}
dt.Clear(); dt.Dispose();
}
}
public void PRCList(string idstr)
{
string str_Sql = "Update " + Pre + "news_site Set isRecyle=0 Where SiteID='" + SiteID + "' And ChannelID in(" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void PRSList(string idstr)
{
string[] arr_id = idstr.Split(',');
string str_Sql = "";
for (int i = 0; i < arr_id.Length; i++)
{
string Id = arr_id[i].Replace("'", "");
if (getParentlockTf(Id, "news_special", "SpecialID") == false)
str_Sql = "Update " + Pre + "news_special Set isRecyle=0 Where SiteID='" + SiteID + "' And SpecialID='" + Id + "'";
else
str_Sql = "Update " + Pre + "news_special Set isRecyle=0,ParentID='0' Where SiteID='" + SiteID + "' And SpecialID='" + Id + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
}
public void PRStCList(string idstr)
{
string str_Sql = "Update " + Pre + "sys_styleclass Set isRecyle=0 Where SiteID='" + SiteID + "' And ClassID In (" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void PRStList(string classid, string idstr)
{
string str_Sql = "Select ClassID From " + Pre + "sys_styleclass Where isRecyle=1 And " +
"SiteID='" + SiteID + "' And ClassID In (" + idstr + ")";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
if (dt != null)
{
string str_Sql1 = "";
for (int i = 0; i < dt.Rows.Count; i++)
{
string styleclassid = dt.Rows[i]["ClassID"].ToString();
string styleid = dt.Rows[i]["styleID"].ToString();
if (checkParIsDel(styleclassid, "sys_styleclass") == true)
str_Sql1 = "Update " + Pre + "sys_LabelStyle Set isRecyle=0,ClassID='" + styleclassid + "' Where SiteID='" + SiteID + "' And styleID='" + styleid + "'";
else
str_Sql1 = "Update " + Pre + "sys_LabelStyle Set isRecyle=0 Where SiteID='" + SiteID + "' And styleID='" + styleid + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
}
dt.Clear(); dt.Dispose();
}
}
public void PRLCList(string idstr)
{
string str_Sql = "Update " + Pre + "sys_LabelClass Set isRecyle=0 Where SiteID='" + SiteID + "' And ClassID In (" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void PRLList(string classid, string idstr)
{
string str_Sql = "Select LabelID,ClassID From " + Pre + "sys_Label Where isRecyle=1 " +
"And SiteID='" + SiteID + "' And LabelID In (" + idstr + ")";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
if (dt != null)
{
string str_Sql1 = "";
for (int i = 0; i < dt.Rows.Count; i++)
{
string strclassid = dt.Rows[i]["ClassID"].ToString();
string strlabelid = dt.Rows[i]["LabelID"].ToString();
if (checkParIsDel(strclassid, "sys_LabelClass") == true)
str_Sql1 = "Update " + Pre + "sys_Label Set isRecyle=0,ClassID='" + classid + "' Where SiteID='" + SiteID + "' And LabelID='" + strlabelid + "'";
else
str_Sql1 = "Update " + Pre + "sys_Label Set isRecyle=0 Where SiteID='" + SiteID + "' And LabelID='" + strlabelid + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
}
dt.Clear(); dt.Dispose();
}
}
public void PRPSFList(string idstr)
{
string str_Sql = "Update " + Pre + "sys_PSF Set isRecyle=0 Where SiteID='" + SiteID + "' And psfID In (" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
//---------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------
public void PDNCList(string idstr)
{
idstr = getIDStr(idstr, "ClassID,ParentID", "news_Class");
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
SqlTransaction tran = Conn.BeginTransaction();
try
{
DataTable dt = getNewsTable();
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string tbname = dt.Rows[i][0].ToString();
string str_Sql = "Delete From " + tbname + " Where ClassID In (Select ClassID From " + Pre + "news_Class" +
" Where SiteID='" + SiteID + "' And isRecyle=1 And ClassID In(" + idstr + "))";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql, null);
string str_Sql1 = "Delete From " + Pre + "news_Class Where SiteID='" + SiteID + "' And isRecyle=1 And ClassID In(" + idstr + ")";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql1, null);
}
tran.Commit();
dt.Clear(); dt.Dispose();
}
Conn.Close();
}
catch (SqlException e)
{
tran.Rollback();
Conn.Close();
throw e;
}
}
public void PDNList(string idstr)
{
DataTable dt = getNewsTable();
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string tbname = dt.Rows[i][0].ToString();
string Sql = "Delete From " + tbname + " Where SiteID='" + SiteID + "' And isRecyle=1 And NewsID In(" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
dt.Clear(); dt.Dispose();
}
}
public void PDCList(string idstr)
{
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
SqlTransaction tran = Conn.BeginTransaction();
try
{
DataTable dt = getNewsTable();
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string tbname = dt.Rows[i][0].ToString();
string str_Sql = "Delete From " + Pre + "API_commentary Where InfoID In(" +
"Select NewsID From " + tbname + " Where SiteID In(" +
"Select ChannelID From " + Pre + " news_site Where isRecyle=1 And ChannelID In(" + idstr + ")))";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql, null);
string str_Sql1 = "Delete From " + tbname + " Where SiteID In(" +
"Select ChannelID From " + Pre + " news_site Where isRecyle=1 And ChannelID In(" + idstr + "))";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql1, null);
string str_Sql2 = "Delete From " + Pre + "news_Class Where SiteID In(" +
"Select ChannelID From " + Pre + " news_site Where isRecyle=1 And ChannelID In(" + idstr + "))";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql2, null);
string str_Sql5 = "Delete From " + Pre + "special_news Where SpecialID In (Select SpecialID From "+
"" + Pre + "news_special Where SiteID In(Select ChannelID From " + Pre + " news_site "+
"Where isRecyle=1 And ChannelID In(" + idstr + ")))";
DbHelper.ExecuteNonQuery(tran,CommandType.Text, str_Sql5, null);
string str_Sql3 = "Delete From " + Pre + "news_special Where SiteID In(" +
"Select ChannelID From " + Pre + " news_site Where isRecyle=1 And ChannelID In(" + idstr + "))";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql3, null);
string str_Sql4 = "Delete From " + Pre + "news_site Where isRecyle=1 And ChannelID In(" + idstr + ")";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql4, null);
}
tran.Commit();
}
Conn.Close();
}
catch (SqlException e)
{
tran.Rollback();
Conn.Close();
throw e;
}
}
public void PDSList(string idstr)
{
idstr = getIDStr(idstr, "SpecialID,ParentID", "news_special");
string Sql = "Delete From " + Pre + "special_news Where SpecialID In (" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
Sql = "Delete From " + Pre + "news_special where SpecialID in(" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public void PDStCList(string idstr)
{
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
SqlTransaction tran = Conn.BeginTransaction();
try
{
string str_Sql = "Delete From " + Pre + "sys_LabelStyle Where ClassID In (" + idstr + ") And SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql, null);
string str_Sql1 = "Delete From " + Pre + "sys_styleclass Where SiteID='" + SiteID + "' And isRecyle=1 And ClassID In(" + idstr + ")";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql1, null);
tran.Commit();
Conn.Close();
}
catch (SqlException e)
{
tran.Rollback();
Conn.Close();
throw e;
}
}
public void PDStList(string idstr)
{
string str_Sql = "Delete From " + Pre + "sys_LabelStyle Where SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void PDLCList(string idstr)
{
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
SqlTransaction tran = Conn.BeginTransaction();
try
{
string str_Sql = "Delete From " + Pre + "sys_Label Where ClassID In (" + idstr + ") And SiteID='" + SiteID + "' And isRecyle=1";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql, null);
string str_Sql1 = "Delete From " + Pre + "sys_LabelClass Where SiteID='" + SiteID + "' And isRecyle=1 And ClassID In(" + idstr + ")";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql1, null);
tran.Commit();
Conn.Close();
}
catch (SqlException e)
{
tran.Rollback();
Conn.Close();
throw e;
}
}
public void PDLList(string idstr)
{
string str_Sql = "Delete From " + Pre + "sys_Label Where isRecyle=1 And SiteID='" + SiteID + "' And LabelID In(" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void PDPSFList(string idstr)
{
string str_Sql = "Delete From " + Pre + "sys_PSF Where isRecyle=1 And SiteID='" + SiteID + "' And psfID In(" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
//---------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------
public DataTable getNewsTable()
{
string str_Sql = "Select TableName From " + Pre + "sys_NewsIndex";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getNewsClass(string idstr)
{
string str_Sql = "";
if (idstr != null && idstr != "" && idstr != string.Empty)
str_Sql = "Select ClassID,SavePath,SaveClassframe From " + Pre + "news_Class Where SiteID='" + SiteID + "' And isRecyle=1 And ClassID In(" + getIDStr(idstr, "ClassID,ParentID", "news_Class") + ")";
else
str_Sql = "Select ClassID,SavePath,SaveClassframe From " + Pre + "news_Class Where SiteID='" + SiteID + "' And isRecyle=1";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getNews(string classid, string tbname)
{
string str_Sql = "";
if (classid != null && classid != "" && classid != string.Empty)
str_Sql = "Select NewsID,ClassID,SavePath,FileName,FileEXName From " + tbname + " Where isRecyle=1 And" +
" SiteID='" + SiteID + "' And ClassID='" + classid + "'";
else
str_Sql = "Select NewsID,ClassID,SavePath,FileName,FileEXName From " + tbname + " Where isRecyle=1 And SiteID='" + SiteID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getSpeaciList(string idstr)
{
string str_Sql = "";
if (idstr != "" && idstr != null & idstr != string.Empty)
str_Sql = "Select SpecialID,SavePath,specialEName,saveDirPath,FileName,FileEXName From " + Pre + "news_special Where " +
"isRecyle=1 And SiteID='" + SiteID + "' And SpecialID In(" + getIDStr(idstr, "SpecialID,ParentID", "news_special") + ")";
else
str_Sql = "Select SpecialID,SavePath,specialEName,saveDirPath,FileName,FileEXName From " +
"" + Pre + "news_special Where isRecyle=1 And SiteID='" + SiteID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getSite(string idstr)
{
string str_Sql = "";
if (idstr != "" && idstr != null & idstr != string.Empty)
str_Sql = "Select ChannelID,EName From " + Pre + "news_site Where isRecyle=1 And ParentID='0' And ChannelID In(" + idstr + ") And SiteID='" + SiteID + "'";
else
str_Sql = "Select ChannelID,EName From " + Pre + "news_site Where isRecyle=1 And ParentID='0' And SiteID='" + SiteID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
protected string getChildId(string id, string col, string tbname)
{
string str_Sql = "Select " + col + " From " + Pre + tbname + " Where SiteID='" + SiteID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
string idstr = "'" + id + "'," + getRecursion(dt, id);
return idstr;
}
protected string getRecursion(DataTable dt, string PID)
{
DataRow[] row = null;
string idstr = "";
row = dt.Select("ParentID='" + PID + "'");
if (row.Length < 1)
return idstr;
else
{
foreach (DataRow r in row)
{
idstr += "'" + r[0].ToString() + "',";
idstr += getRecursion(dt, r[0].ToString());
}
}
return idstr;
}
public string getIDStr(string id, string col, string tbname)
{
string[] arr_id = id.Split(',');
string temp_id = "";
string temp_id1 = "";
for (int i = 0; i < arr_id.Length; i++)
{
temp_id = arr_id[i].Replace("'", "");
temp_id1 += getChildId(temp_id, col, tbname);
}
temp_id1 = NetCMS.Common.Input.CutComma(temp_id1);
return temp_id1;
}
public void raDComment(string NewsID, bool isDel)
{
string str_Sql = "";
if (isDel == true)
str_Sql = "Delete From " + Pre + "API_commentary Where InfoID='" + NewsID + "'";
else
str_Sql = "Update " + Pre + "API_commentary Set isRecyle=0 Where InfoID='" + NewsID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
protected bool checkParIsDel(string classid, string tbname)
{
bool rtf = true;
string str_Sql = "Select isRecyle From " + Pre + tbname + " Where ClassID='" + classid + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
if (dt.Rows[0][0].ToString() != "1")
rtf = false;
}
dt.Clear(); dt.Dispose();
}
return rtf;
}
protected bool getParentlockTf(string ID, string tbname, string classid)
{
bool LockTf = false;
ID = getParentID(ID, tbname, classid);
string Str_Sql = "Select ParentID,isRecyle From " + Pre + tbname + " where " + classid + "='" + ID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Str_Sql, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
if (dt.Rows[0]["isRecyle"].ToString() == "1")
LockTf = true;
else
LockTf = getParentlockTf(dt.Rows[0]["ParentID"].ToString(), tbname, classid);
}
dt.Clear(); dt.Dispose();
}
return LockTf;
}
protected string getParentID(string ID, string tbname, string classid)
{
string strparentid = ID;
string str_Sql = "Select ParentID,isRecyle From " + Pre + tbname + " where " + classid + "='" + ID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
strparentid = dt.Rows[0]["ParentID"].ToString();
dt.Clear(); dt.Dispose();
}
return strparentid;
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Recyle.cs | C# | asf20 | 44,020 |
//======================================================
//== (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 Ads : DbBase, IAds
{
private string SiteID;
public Ads()
{
SiteID = NetCMS.Global.Current.SiteID;
}
/// <summary>
/// 获得广告列表/分类列表
/// </summary>
/// <param name="ali"></param>
/// <returns></returns>
public DataTable list(NetCMS.Model.AdsListInfo ali)
{
string tempselect = "";
string str_Sql = "";
switch (ali.type)
{
case "Ads":
switch (ali.showAdsType)
{
case "showadstype":
if (ali.adsType != null && ali.adsType != "" && ali.adsType != string.Empty && ali.adsType != "-1")
tempselect = "And adType=" + ali.adsType + "";
else
tempselect = "";
if (ali.showSiteID != null && ali.showSiteID != "" && ali.showSiteID != string.Empty)
tempselect += " And SiteID='" + ali.showSiteID + "'";
else
tempselect += " And SiteID='" + SiteID + "'";
str_Sql = "Select AdID,adName,adType,creatTime,CusID,isLock From " + Pre + "ads Where" +
" 1=1 " + tempselect + " Order By Id Desc";
break;
case "search":
if (SiteID == "0")
tempselect = "";
else
tempselect = " And SiteID='" + SiteID + "'";
switch (ali.searchType)
{
case "adsname":
str_Sql = "Select AdID,adName,adType,creatTime,CusID,isLock From " + Pre + "ads" +
" Where adName Like '%" + ali.SearchKey + "%' " + tempselect + " Order By Id Desc";
break;
case "user":
str_Sql = "Select AdID,adName,adType,creatTime,CusID,isLock From " + Pre + "ads" +
" Where CusID In(Select UserNum From " + Pre + "sys_User Where UserName" +
" Like '%" + ali.SearchKey + "%') " + tempselect + " Order By Id Desc";
break;
default:
str_Sql = "Select AdID,adName,adType,creatTime,CusID,isLock From " + Pre + "ads Where" +
" 1=1 " + tempselect + " Order By Id Desc";
break;
}
break;
case "site":
if (ali.adsType != null && ali.adsType != "" && ali.adsType != string.Empty && ali.adsType != "-1")
tempselect = "And adType=" + ali.adsType + "";
else
tempselect = "";
if (ali.showSiteID != null && ali.showSiteID != "" && ali.showSiteID != string.Empty)
tempselect += " And SiteID='" + ali.showSiteID + "'";
else
tempselect += " And SiteID='" + SiteID + "'";
str_Sql = "Select AdID,adName,adType,creatTime,CusID,isLock From " + Pre + "ads Where" +
" 1=1 " + tempselect + " Order By Id Desc";
break;
default:
str_Sql = "Select AdID,adName,adType,creatTime,CusID,isLock From " + Pre + "ads Where" +
" SiteID='" + SiteID + "' Order By Id Desc";
break;
}
break;
case "Class":
if (ali.showSiteID != null && ali.showSiteID != "" && ali.showSiteID != string.Empty)
tempselect = " And SiteID='" + ali.showSiteID + "'";
else
tempselect = " And SiteID='" + SiteID + "'";
str_Sql = "Select AcID,Cname,Adprice,creatTime From " + Pre + "ads_class Where ParentID='0' " +
"" + tempselect + " Order By Id Desc";
break;
case "Stat":
if (ali.showSiteID != null && ali.showSiteID != "" && ali.showSiteID != string.Empty)
tempselect = " And SiteID='" + ali.showSiteID + "'";
else
tempselect = " And SiteID='" + SiteID + "'";
str_Sql = "Select AdID,adName,clickNum,showNum From " + Pre + "ads Where 1=1 " + tempselect + " Order By Id Desc";
break;
}
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
/// <summary>
/// 得到广告的子分类
/// </summary>
/// <param name="classid">父分类ID</param>
/// <returns></returns>
public DataTable childlist(string classid)
{
string str_Sql = "Select AcID,Cname,Adprice,creatTime From " + Pre + "ads_class Where" +
" SiteID='" + SiteID + "' And ParentID='" + classid + "'";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
/// <summary>
/// 锁定广告
/// </summary>
/// <param name="id"></param>
public void Lock(string id)
{
string str_Sql = "Update " + Pre + "ads Set isLock=1 Where AdID='" + id + "' And SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
/// <summary>
/// 解锁广告
/// </summary>
/// <param name="id"></param>
public void UnLock(string id)
{
string str_Sql = "Update " + Pre + "ads Set isLock=0 Where AdID='" + id + "' And SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
/// <summary>
/// 删除所有的广告
/// </summary>
public void DelAllAds()
{
string str_Sql = "Delete From " + Pre + "adstxt Where AdID In (Select AdID From " + Pre + "ads Where SiteID='" + SiteID + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
string str_Sql1 = "Delete From " + Pre + "ads_stat Where AdID In (Select AdID From " + Pre + "ads Where SiteID='" + SiteID + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
string str_Sql2 = "Delete From " + Pre + "ads Where SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql2, null);
}
/// <summary>
/// 得到广告
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataTable AdsDt(string id)
{
string str_Sql = "";
if (id != null && id != "" && id != string.Empty)
str_Sql = "Select AdID,ClassID From " + Pre + "ads Where SiteID='" + SiteID + "' And AdID In (" + id + ")";
else
str_Sql = "Select AdID,ClassID From " + Pre + "ads Where SiteID='" + SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
/// <summary>
/// 批量删除广告
/// </summary>
/// <param name="id"></param>
public void DelPAds(string id)
{
SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
Conn.Open();
SqlTransaction tran = Conn.BeginTransaction();
try
{
string str_Sql = "Delete From " + Pre + "adstxt Where AdID In (" + id + ")";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql, null);
string str_Sql1 = "Delete From " + Pre + "ads_stat Where AdID In (" + id + ")";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql1, null);
string str_Sql2 = "Delete From " + Pre + "ads Where SiteID='" + SiteID + "' And AdID In(" + id + ")";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql2, null);
tran.Commit();
Conn.Close();
}
catch (SqlException e)
{
tran.Rollback();
Conn.Close();
throw e;
}
}
/// <summary>
/// 删除所有广告分类
/// </summary>
public void DelAllAdsClass()
{
string str_Sql = "Delete From " + Pre + "adstxt Where AdID In (Select AdID From " + Pre + "ads Where ClassID In(Select " +
"AcID From " + Pre + "ads_class Where SiteID='" + SiteID + "'))";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
string str_Sql1 = "Delete From " + Pre + "ads_stat Where AdID In (Select AdID From " + Pre + "ads Where ClassID In(Select " +
"AcID From " + Pre + "ads_class Where SiteID='" + SiteID + "'))";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
string str_Sql2 = "Delete From " + Pre + "ads Where And ClassID In(Select " +
"AcID From " + Pre + "ads_class Where SiteID='" + SiteID + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql2, null);
string str_Sql3 = "Delete From " + Pre + "ads_class Where SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql3, null);
}
public DataTable adsClassDt(string classid)
{
string str_Sql = "";
if (classid != null && classid != "" && classid != string.Empty)
{
Recyle rc = new Recyle();
string idstr = rc.getIDStr(classid, "AcID,ParentID", "ads_class");
str_Sql = "Select AcID From " + Pre + "ads_class Where SiteID='" + SiteID + "' And AcID in (" + idstr + ")";
}
else
str_Sql = "Select AcID From " + Pre + "ads_class Where SiteID='" + SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
/// <summary>
/// 删除广告分类
/// </summary>
/// <param name="classid"></param>
public void DelPAdsClass(string classid)
{
Recyle rc = new Recyle();
string idstr = rc.getIDStr(classid, "AcID,ParentID", "ads_class");
string str_Sql = "Delete From " + Pre + "adstxt Where AdID In (Select AdID From " + Pre + "ads Where ClassID In(" + idstr + "))";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
string str_Sql1 = "Delete From " + Pre + "ads_stat Where AdID In (Select AdID From " + Pre + "ads Where ClassID In(" + idstr + "))";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
string str_Sql2 = "Delete From " + Pre + "ads Where ClassID In(" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql2, null);
string str_Sql3 = "Delete From " + Pre + "ads_class Where SiteID='" + SiteID + "' And AcID In(" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql3, null);
}
/// <summary>
/// 增加广告分类
/// </summary>
/// <param name="aci"></param>
/// <returns></returns>
public int AddClass(NetCMS.Model.AdsClassInfo aci)
{
string checkSql = "";
int recordCount = 0;
string AcID = NetCMS.Common.Rand.Number(12);
while (true)
{
checkSql = "select count(*) from " + Pre + "ads_class where AcID='" + AcID + "'";
recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
if (recordCount < 1)
break;
else
AcID = NetCMS.Common.Rand.Number(12, true);
}
checkSql = "select count(*) from " + Pre + "ads_class where Cname='" + aci.Cname + "'";
recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
if (recordCount > 0)
{
throw new Exception("分类名称重复,请重新添加!");
}
string Sql = "insert into " + Pre + "ads_class (AcID,Cname,ParentID,creatTime,SiteID,Adprice";
Sql += ") values ('" + AcID + "',";
Sql += "@Cname,@ParentID,@creatTime,@SiteID,@Adprice)";
SqlParameter[] param = GetClassParameters(aci);
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
/// <summary>
/// 编辑分类
/// </summary>
/// <param name="aci"></param>
/// <returns></returns>
public int EditClass(NetCMS.Model.AdsClassInfo aci)
{
string checkSql = "select count(*) from " + Pre + "ads_class Where AcID!='" + aci.AcID + "' And Cname='" + aci.Cname + "'";
int recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
if (recordCount > 0)
{
throw new Exception("分类名称重复,请重新修改!");
}
string Sql = "Update " + Pre + "ads_class Set Cname=@Cname,Adprice=@Adprice Where AcID=@AcID";
SqlParameter[] param = GetClassParameters(aci);
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public DataTable getAdsClassInfo(string classid)
{
SqlParameter param = new SqlParameter("@ClassId",classid);
string str_Sql = "Select Cname,ParentID,Adprice From " + Pre + "ads_class Where AcID=@ClassId";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, param);
}
public void statDelAll()
{
string str_Sql = "Delete From " + Pre + "ads_stat Where AdID In(Select AdID From " + Pre + "ads Where SiteID='" + SiteID + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
string str_Sql1 = "Update " + Pre + "ads Set ClickNum=0,ShowNum=0 Where SiteID='" + SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
}
public void statDel(string idstr)
{
string str_Sql = "Delete From " + Pre + "ads_stat Where AdID In(" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
string str_Sql1 = "Update " + Pre + "ads Set ClickNum=0,ShowNum=0 Where SiteID='" + SiteID + "' And AdID In(" + idstr + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
}
public DataTable getAdsClassList()
{
string str_Sql = "Select AcID,Cname,ParentID,Adprice From " + Pre + "ads_class Where SiteID='" + SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public DataTable getAdsList(string id)
{
string str_Sql = "";
if (id != null && id != "" && id != string.Empty)
str_Sql = "Select AdID,adName From " + Pre + "ads Where SiteID='" + SiteID + "' And isLock=0 And adType!=11 And AdID!='" + id + "'";
else
str_Sql = "Select AdID,adName From " + Pre + "ads Where SiteID='" + SiteID + "' And isLock=0 And adType!=11";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public string adsAdd(NetCMS.Model.AdsInfo ai)
{
string AdID = "";
string checkSql = "";
int recordCount = 0;
AdID = NetCMS.Common.Rand.Number(15);
while (true)
{
checkSql = "select count(*) from " + Pre + "ads where AdID='" + AdID + "'";
recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
if (recordCount < 1)
break;
else
AdID = NetCMS.Common.Rand.Number(15, true);
}
checkSql = "select count(*) from " + Pre + "ads where adName='" + ai.adName + "'";
recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
if (recordCount > 0)
{
throw new Exception("广告名称重复,请重新添加!");
}
string Sql = "Insert Into " + Pre + "ads(AdID,adName,ClassID,CusID,adType,leftPic,rightPic,leftSize,rightSize," +
"LinkURL,CycTF,CycAdID,CycSpeed,CycDic,ClickNum,ShowNum,CondiTF,maxShowClick,TimeOutDay,maxClick," +
"creatTime,AdTxtNum,isLock,SiteID) Values('" + AdID + "',@adName,@ClassID,@CusID,@adType,@leftPic," +
"@rightPic,@leftSize,@rightSize,@LinkURL,@CycTF,@CycAdID,@CycSpeed,@CycDic,@ClickNum,@ShowNum," +
"@CondiTF,@maxShowClick,@TimeOutDay,@maxClick,@creatTime,@AdTxtNum,@isLock,@SiteID)";
if (ai.adType == 11)
{
string[] arr_Content = ai.AdTxtContent.Split(',');
string[] arr_Css = ai.AdTxtCss.Split(',');
string[] arr_Link = ai.AdTxtLink.Split(',');
string str_txtSql = "";
for (int i = 0; i < arr_Content.Length; i++)
{
str_txtSql = "Insert Into " + Pre + "adstxt(AdID,AdTxt,AdCss,AdLink) Values('" + AdID + "','" + arr_Content[i].ToString() + "','" + arr_Css[i].ToString() + "','" + arr_Link[i].ToString() + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, str_txtSql, null);
}
}
SqlParameter[] param = GetAdsParameters(ai);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
return AdID;
}
public int adsEdit(NetCMS.Model.AdsInfo ai)
{
string checkSql = "";
int recordCount = 0;
checkSql = "select count(*) from " + Pre + "ads Where AdID!='" + ai.AdID + "' And adName='" + ai.adName + "'";
recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
if (recordCount > 0)
{
throw new Exception("广告名称重复,请重新修改!");
}
string Sql = "";
if (ai.adType == 11)
{
Sql = "Update " + Pre + "ads Set adName=@adName,ClassID=@ClassID,adType=@adType,leftPic='',rightPic=''," +
"leftSize='',rightSize='',LinkURL='',CondiTF=@CondiTF,maxShowClick=@maxShowClick,TimeOutDay=@TimeOutDay," +
"maxClick=@maxClick,AdTxtNum=@AdTxtNum,isLock=@isLock Where AdID=@AdID";
string str_DeltxtSql = "Delete From " + Pre + "adstxt Where AdID='" + ai.AdID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_DeltxtSql, null);
string[] arr_Content = ai.AdTxtContent.Split(',');
string[] arr_Css = ai.AdTxtCss.Split(',');
string[] arr_Link = ai.AdTxtLink.Split(',');
string str_txtSql = "";
for (int i = 0; i < arr_Content.Length; i++)
{
str_txtSql = "Insert Into " + Pre + "adstxt(AdID,AdTxt,AdCss,AdLink) Values('" + ai.AdID + "','" + arr_Content[i].ToString() + "','" + arr_Css[i].ToString() + "','" + arr_Link[i].ToString() + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, str_txtSql, null);
}
}
else
{
Sql = "Update " + Pre + "ads Set adName=@adName,ClassID=@ClassID,adType=@adType,leftPic=@leftPic," +
"rightPic=@rightPic,leftSize=@leftSize,rightSize=@rightSize,LinkURL=@LinkURL,CondiTF=@CondiTF," +
"maxShowClick=@maxShowClick,TimeOutDay=@TimeOutDay,maxClick=@maxClick,AdTxtNum=0,isLock=@isLock," +
"CycTF=@CycTF,CycAdID=@CycAdID,CycSpeed=@CycSpeed,CycDic=@CycDic Where AdID=@AdID";
}
SqlParameter[] param = GetAdsParameters(ai);
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public DataTable getAdsDomain()
{
string str_Sql = "";
if (SiteID == "0")
str_Sql = "Select SiteDomain From " + Pre + "sys_Param";
else
str_Sql = "Select [Domain] From " + Pre + "news_site Where ChannelID='" + SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public DataTable getAdsPicInfo(string col, string tbname, string id)
{
SqlParameter param = new SqlParameter("@AdID", id);
string str_Sql = "Select " + col + " From " + Pre + tbname + " Where AdID=@AdID";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, param);
}
public DataTable getAdsInfo(string id)
{
string str_Sql = "Select AdID,adName,ClassID,CusID,adType,leftPic,rightPic,leftSize,rightSize,LinkURL,CycTF,CycAdID,CycSpeed,CycDic" +
",CondiTF,maxShowClick,TimeOutDay,maxClick,creatTime,AdTxtNum,isLock From " + Pre +
"ads Where AdID='" + id + "'";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public DataTable get24HourStat(string type, string id)
{
string str_Sql = "";
if (type == "1")
{
str_Sql = "Select creatTime From " + Pre + "ads_stat Where AdID='" + id + "' And datediff(hour,creatTime,getDate())" +
" < 24 And datediff(hour,creatTime,getDate()) >=0";
}
else
{
str_Sql = "Select creatTime From " + Pre + "ads_stat Where AdID='" + id + "'";
}
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public DataTable getDayStat(string type, string id, string mday)
{
string str_Sql = "";
if (type == "1")
{
str_Sql = "Select creatTime From " + Pre + "ads_stat Where AdID='" + id + "' And datediff(day,creatTime,getDate()) " +
"<= " + mday + " And datediff(hour,creatTime,getDate()) >=0";
}
else
{
str_Sql = "Select creatTime From " + Pre + "ads_stat Where AdID='" + id + "'";
}
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public DataTable getMonthStat(string type, string id)
{
string str_Sql = "";
if (type == "1")
{
str_Sql = "Select creatTime From " + Pre + "ads_stat Where AdID='" + id + "' And " +
"datediff(month,creatTime,getDate()) < 13 And datediff(hour,creatTime,getDate()) >=0";
}
else
{
str_Sql = "Select creatTime From " + Pre + "ads_stat Where AdID='" + id + "'";
}
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public DataTable getYearStat(string id)
{
string str_Sql = "Select creatTime From " + Pre + "ads_stat Where AdID='" + id + "' And datediff(year,creatTime,getDate())=datediff(year,getDate(),getDate())"; ;
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public DataTable getWeekStat(string type, string id)
{
string str_Sql = "";
if (type == "1")
{
str_Sql = "Select creatTime From " + Pre + "ads_stat Where AdID='" + id + "' And datediff(w,creatTime,getDate()) < 8 And datediff(w,creatTime,getDate()) >=0";
}
else
{
str_Sql = "Select creatTime From " + Pre + "ads_stat Where AdID='" + id + "'";
}
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public DataTable getSourceStat(string id)
{
string str_Sql = "Select AdID,Address,Count(IP) as Ipnum from " + Pre + "ads_stat group by AdID,Address having AdID=" + id + " order by Count(IP) desc";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public DataTable getDbNull()
{
string str_Sql = "Select ID,IP From " + Pre + "ads_stat Where Address is Null or Address=''";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public void upStat(string adress, string id)
{
string str_Sql = "Update " + Pre + "ads_stat Set Address='" + adress + "' where ID='" + id + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public void upShowNum(string id)
{
SqlParameter param = new SqlParameter("@AdID", id);
string str_Sql = "Update " + Pre + "ads Set ShowNum=ShowNum+1 Where AdID=@AdID";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, param);
}
public void upClickNum(string id, string type)
{
SqlParameter param = new SqlParameter("@AdID", id);
string str_Sql = "Update " + Pre + "ads Set ClickNum=ClickNum+1 Where AdID=@AdID";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, param);
}
public void addStat(string id, string ip)
{
SqlParameter param = new SqlParameter("@ID", id);
string str_Sql = "Insert Into " + Pre + "ads_stat(AdID,IP,creatTime) Values(@ID,'" + ip + "','" + DateTime.Now.ToString() + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, param);
}
public DataTable getClassAdprice(string classid)
{
string str_Sql = "Select Adprice From " + Pre + "ads_class Where AcID='" + classid + "'";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public DataTable getuserG()
{
string str_Sql = "Select gPoint From " + Pre + "sys_User Where UserNum='" + NetCMS.Global.Current.UserNum + "'";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public void DelUserG(int Gnum)
{
string str_Sql = "Update " + Pre + "sys_User Set gPoint=gPoint-" + Gnum + " Where UserNum='" + NetCMS.Global.Current.UserNum + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
private SqlParameter[] GetAdsParameters(NetCMS.Model.AdsInfo ai)
{
SqlParameter[] param = new SqlParameter[24];
param[0] = new SqlParameter("@AdID", SqlDbType.NVarChar, 15);
param[0].Value = ai.AdID;
param[1] = new SqlParameter("@adName", SqlDbType.NVarChar, 50);
param[1].Value = ai.adName;
param[2] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 12);
param[2].Value = ai.ClassID;
param[3] = new SqlParameter("@CusID", SqlDbType.NVarChar, 12);
param[3].Value = ai.CusID;
param[4] = new SqlParameter("@adType", SqlDbType.TinyInt, 1);
param[4].Value = ai.adType;
param[5] = new SqlParameter("@leftPic", SqlDbType.NVarChar, 200);
param[5].Value = ai.leftPic;
param[6] = new SqlParameter("@rightPic", SqlDbType.NVarChar, 200);
param[6].Value = ai.rightPic;
param[7] = new SqlParameter("@leftSize", SqlDbType.NVarChar, 12);
param[7].Value = ai.leftSize;
param[8] = new SqlParameter("@rightSize", SqlDbType.NVarChar, 12);
param[8].Value = ai.rightSize;
param[9] = new SqlParameter("@CycTF", SqlDbType.TinyInt, 1);
param[9].Value = ai.CycTF;
param[10] = new SqlParameter("@CycAdID", SqlDbType.NVarChar, 15);
param[10].Value = ai.CycAdID;
param[11] = new SqlParameter("@CycSpeed", SqlDbType.Int, 4);
param[11].Value = ai.CycSpeed;
param[12] = new SqlParameter("@CycDic", SqlDbType.TinyInt, 1);
param[12].Value = ai.CycDic;
param[13] = new SqlParameter("@ClickNum", SqlDbType.Int, 4);
param[13].Value = ai.ClickNum;
param[14] = new SqlParameter("@ShowNum", SqlDbType.Int, 4);
param[14].Value = ai.ShowNum;
param[15] = new SqlParameter("@CondiTF", SqlDbType.TinyInt, 1);
param[15].Value = ai.CondiTF;
param[16] = new SqlParameter("@maxShowClick", SqlDbType.Int, 4);
param[16].Value = ai.maxShowClick;
param[17] = new SqlParameter("@TimeOutDay", SqlDbType.DateTime, 8);
param[17].Value = ai.TimeOutDay;
param[18] = new SqlParameter("@maxClick", SqlDbType.Int, 4);
param[18].Value = ai.maxClick;
param[19] = new SqlParameter("@creatTime", SqlDbType.DateTime, 8);
param[19].Value = ai.creatTime;
param[20] = new SqlParameter("@AdTxtNum", SqlDbType.Int, 4);
param[20].Value = ai.AdTxtNum;
param[21] = new SqlParameter("@isLock", SqlDbType.TinyInt, 1);
param[21].Value = ai.isLock;
param[22] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[22].Value = ai.SiteID;
param[23] = new SqlParameter("@LinkURL", SqlDbType.NVarChar, 200);
param[23].Value = ai.LinkURL;
return param;
}
private SqlParameter[] GetClassParameters(NetCMS.Model.AdsClassInfo aci)
{
SqlParameter[] param = new SqlParameter[6];
param[0] = new SqlParameter("@AcID", SqlDbType.NVarChar, 12);
param[0].Value = aci.AcID;
param[1] = new SqlParameter("@Cname", SqlDbType.NVarChar, 50);
param[1].Value = aci.Cname;
param[2] = new SqlParameter("@ParentID", SqlDbType.NVarChar, 12);
param[2].Value = aci.ParentID;
param[3] = new SqlParameter("@creatTime", SqlDbType.DateTime, 8);
param[3].Value = aci.creatTime;
param[4] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[4].Value = aci.SiteID;
param[5] = new SqlParameter("@Adprice", SqlDbType.Int, 4);
param[5].Value = aci.Adprice;
return param;
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Ads.cs | C# | asf20 | 32,369 |
//======================================================
//== (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 NetCMS.Common;
using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Photo : DbBase, IPhoto
{
#region photo.aspx
public DataTable sel_getUserInfo(string PhotoalbumID)
{
SqlParameter param = new SqlParameter("@PhotoalbumID", PhotoalbumID);
string Sql = "select pwd,UserName,PhotoalbumName,PhotoalbumJurisdiction,ClassID,PhotoalbumUrl from " + Pre + "User_Photoalbum where PhotoalbumID=@PhotoalbumID";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
#endregion
#region photo_add.aspx
public DataTable sel_getPhotoInfo(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "Select PhotoalbumName,PhotoalbumID From " + Pre + "User_Photoalbum where isDisPhotoalbum=0 and UserName=@UserNum";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
public DataTable sel_getPhotoId()
{
string Sql = "select PhotoID from " + Pre + "User_Photo";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public int Add(PhotoInfo Pho, string UserNum, string PhotoalbumID, string PhotoUrl, string PhotoID)
{
string Sql = "insert into " + Pre + "User_Photo(PhotoID,PhotoName,PhotoTime,UserNum,PhotoalbumID,PhotoContent,PhotoUrl) values(@PhotoID,@PhotoName,@PhotoTime,@UserNum,@PhotoalbumID,@PhotoContent,@PhotoUrl)";
SqlParameter[] parm = GetPhoto(Pho);
int i_length = parm.Length;
Array.Resize<SqlParameter>(ref parm, i_length + 4);
parm[i_length] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 18);
parm[i_length].Value = UserNum;
parm[i_length + 1] = new SqlParameter("@PhotoalbumID", SqlDbType.NVarChar, 18);
parm[i_length + 1].Value = PhotoalbumID;
parm[i_length + 2] = new SqlParameter("@PhotoUrl", SqlDbType.NVarChar, 200);
parm[i_length + 2].Value = PhotoUrl;
parm[i_length + 3] = new SqlParameter("@PhotoID", SqlDbType.NVarChar, 18);
parm[i_length + 3].Value = PhotoID;
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
private SqlParameter[] GetPhoto(PhotoInfo Pho)
{
SqlParameter[] parm = new SqlParameter[3];
parm[0] = new SqlParameter("@PhotoName", SqlDbType.NVarChar, 18);
parm[0].Value = Pho.PhotoName;
parm[1] = new SqlParameter("@PhotoContent", SqlDbType.NVarChar, 200);
parm[1].Value = Pho.PhotoContent;
parm[2] = new SqlParameter("@PhotoTime", SqlDbType.DateTime);
parm[2].Value = DateTime.Now;
return parm;
}
#endregion
#region photo_del.aspx
public int Delete(string PhotoID)
{
SqlParameter param = new SqlParameter("@PhotoID", PhotoID);
string Sql = "delete " + Pre + "User_Photo where PhotoID=@PhotoID";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion
#region photo_up.aspx
public DataTable sel_getUserPhoto(string PhotoID)
{
SqlParameter param = new SqlParameter("@PhotoID", PhotoID);
string Sql = "select PhotoName,PhotoalbumID,PhotoContent,PhotoUrl from " + Pre + "User_Photo where PhotoID=@PhotoID";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
public int Update(string PhotoName, DateTime PhotoTime, string PhotoalbumID, string PhotoContent, string PhotoUrl1, string PhotoIDs)
{
SqlParameter[] param = new SqlParameter[6];
param[0] = new SqlParameter("@PhotoName", SqlDbType.NVarChar, 18);
param[0].Value = PhotoName;
param[1] = new SqlParameter("@PhotoTime", SqlDbType.DateTime, 8);
param[1].Value = PhotoTime;
param[2] = new SqlParameter("@PhotoalbumID", SqlDbType.NVarChar, 18);
param[2].Value = PhotoalbumID;
param[3] = new SqlParameter("@PhotoContent", SqlDbType.NVarChar, 200);
param[3].Value = PhotoContent;
param[4] = new SqlParameter("@PhotoUrl", SqlDbType.NVarChar, 200);
param[4].Value = PhotoUrl1;
param[5] = new SqlParameter("@PhotoID", SqlDbType.NVarChar, 200);
param[5].Value = PhotoIDs;
string Sql = "update " + Pre + "User_Photo set PhotoName=@PhotoName,PhotoTime=@PhotoTime,PhotoalbumID=@PhotoalbumID,PhotoContent=@PhotoContent,PhotoUrl=@PhotoUrl where PhotoID=@PhotoID";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion
#region Photoalbum.aspx
public DataTable sel_getPhotoClass(string UserNum)
{
string Sql = "Select ClassName,ClassID From " + Pre + "user_PhotoalbumClass where UserName='" + UserNum + "' and isDisclass=0";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public int add_photoalBum(PhotoAlbumInfo Pb, string UserNum)
{
string Sql = "insert into " + Pre + "user_Photoalbum(PhotoalbumName,PhotoalbumID,Creatime,UserName,PhotoalbumJurisdiction,isDisPhotoalbum,pwd,PhotoalbumUrl,DisID,ClassID) values(@PhotoalbumName,@PhotoalbumID,@Creatime,@UserNum,@PhotoalbumJurisdiction,@isDisPhotoalbum,@pwd,@PhotoalbumUrl,@DisID,@ClassID)";
SqlParameter[] parm = GetPhotoalbum(Pb);
int i_length = parm.Length;
Array.Resize<SqlParameter>(ref parm, i_length + 1);
parm[i_length] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 18);
parm[i_length].Value = UserNum;
return (int)DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
private SqlParameter[] GetPhotoalbum(PhotoAlbumInfo Pb)
{
SqlParameter[] parm = new SqlParameter[9];
parm[0] = new SqlParameter("@PhotoalbumName", SqlDbType.NVarChar, 18);
parm[0].Value = Pb.PhotoalbumName;
parm[1] = new SqlParameter("@PhotoalbumID", SqlDbType.NVarChar, 200);
parm[1].Value = Rand.Number(12);
parm[2] = new SqlParameter("@Creatime", SqlDbType.DateTime);
parm[2].Value = DateTime.Now;
parm[3] = new SqlParameter("@PhotoalbumJurisdiction", SqlDbType.NVarChar, 200);
parm[3].Value = Pb.PhotoalbumJurisdiction;
parm[4] = new SqlParameter("@isDisPhotoalbum", SqlDbType.NVarChar, 200);
parm[4].Value = Pb.isDisPhotoalbum;
parm[5] = new SqlParameter("@pwd", SqlDbType.NVarChar, 200);
parm[5].Value = Pb.pwd;
parm[6] = new SqlParameter("@PhotoalbumUrl", SqlDbType.NVarChar, 200);
parm[6].Value = Pb.PhotoalbumUrl;
parm[7] = new SqlParameter("@DisID", SqlDbType.NVarChar, 200);
parm[7].Value = Pb.DisID;
parm[8] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 200);
parm[8].Value = Pb.ClassID;
return parm;
}
#endregion
#region Photoalbum_up.aspx
public int update_photoalBum(string PhotoalbumName, string PhotoalbumJurisdiction, string ClassID, DateTime Creatime, string PhotoalbumIDs)
{
SqlParameter[] param = new SqlParameter[5];
param[0] = new SqlParameter("@PhotoalbumName", SqlDbType.NVarChar, 200);
param[0].Value = PhotoalbumName;
param[1] = new SqlParameter("@PhotoalbumJurisdiction", SqlDbType.NVarChar, 50);
param[1].Value = PhotoalbumJurisdiction;
param[2] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 18);
param[2].Value = ClassID;
param[3] = new SqlParameter("@Creatime", SqlDbType.NVarChar, 200);
param[3].Value = Creatime;
param[4] = new SqlParameter("@PhotoalbumIDs", SqlDbType.NVarChar, 18);
param[4].Value = PhotoalbumIDs;
string Sql = "update " + Pre + "user_Photoalbum set PhotoalbumName=@PhotoalbumName,Creatime=@Creatime,PhotoalbumJurisdiction=@PhotoalbumJurisdiction,ClassID=@ClassID where PhotoalbumID=@PhotoalbumIDs";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public string sel_getPhotoalBum()
{
string Sql = "select pwd from " + Pre + "user_Photoalbum";
return DbHelper.ExecuteScalar(CommandType.Text, Sql, null).ToString();
}
public int update_photoalBumPwd(string newpwds, string PhotoalbumIDs)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@newpwds", SqlDbType.NVarChar, 18);
param[0].Value = newpwds;
param[1] = new SqlParameter("@PhotoalbumIDs", SqlDbType.NVarChar, 18);
param[1].Value = PhotoalbumIDs;
string Sql = "update " + Pre + "user_Photoalbum set pwd=@newpwds where PhotoalbumID=@PhotoalbumIDs";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion
#region Photoalbumlist.aspx
public int del_photoalBumById(string ID)
{
SqlParameter param = new SqlParameter("@PhotoalbumID", ID);
string Sql = "delete " + Pre + "User_Photoalbum where PhotoalbumID=@PhotoalbumID";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public int del_photoById(string ID)
{
SqlParameter param = new SqlParameter("@PhotoalbumID", ID);
string Sql = "delete " + Pre + "User_Photo where PhotoalbumID=@PhotoalbumID";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public string sel_sysUser(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "select UserName from " + Pre + "sys_user where UserNum=@UserNum";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
public int sel_userPhoCount(string ID)
{
SqlParameter param = new SqlParameter("@PhotoalbumID", ID);
string Sql = "select count(*) from " + Pre + "User_Photo where PhotoalbumID=@PhotoalbumID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
public DataTable GetPage(string UserNum, string ClassID, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
string Sql = "";
if (UserNum != null && UserNum != "")
{
Sql = " and UserName='" + UserNum + "'";
}
if (ClassID != "" && ClassID != null)
{
Sql += "and ClassID='" + ClassID + "'";
}
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@UserName", UserNum), new SqlParameter("@ClassID", ClassID) };
string AllFields = "PhotoalbumName,PhotoalbumID,UserName,Creatime,pwd";
string Condition = "" + Pre + "User_Photoalbum where isDisPhotoalbum=0 " + Sql + "";
string IndexField = "id";
string OrderFields = "order by ID desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, param);
}
#endregion
#region photoclass.aspx
public int del_phoBumById(string ID)
{
SqlParameter param = new SqlParameter("@ClassID", ID);
string Sql = "delete " + Pre + "user_PhotoalbumClass where ClassID=@ClassID";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public int del_photoalBum(string ID)
{
SqlParameter param = new SqlParameter("@ClassID", ID);
string Sql = "delete " + Pre + "User_Photoalbum where ClassID=@ClassID";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public DataTable sel_getPhotoById(string ID)
{
SqlParameter param = new SqlParameter("@ClassID", ID);
string Sql = "select PhotoalbumName,PhotoalbumUrl from " + Pre + "User_Photoalbum where ClassID=@ClassID";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
public DataTable sel_disActive()
{
string Sql = "select AId,UserNum from " + Pre + "user_DiscussActiveMember";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
#endregion
#region photoclass_add.aspx
public int add_photoalBumClass(string ClassName, string ClassID, DateTime Creatime, string UserNum, int isDisclass, string DisID)
{
SqlParameter[] param = new SqlParameter[6];
param[0] = new SqlParameter("@ClassName", SqlDbType.NVarChar, 50);
param[0].Value = ClassName;
param[1] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 18);
param[1].Value = ClassID;
param[2] = new SqlParameter("@Creatime", SqlDbType.DateTime, 8);
param[2].Value = Creatime;
param[3] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 18);
param[3].Value = UserNum;
param[4] = new SqlParameter("@isDisclass", SqlDbType.Int, 4);
param[4].Value = isDisclass;
param[5] = new SqlParameter("@DisID", SqlDbType.NVarChar, 18);
param[5].Value = DisID;
string Sql = "insert into " + Pre + "user_PhotoalbumClass(ClassName,ClassID,Creatime,UserName,isDisclass,DisID) values(@ClassName,@ClassID,@Creatime,@UserNum,@isDisclass,@DisID)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion
#region photoclass_up.aspx
public string sel_phoClassName(string ClassID)
{
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string Sql = "select ClassName from " + Pre + "user_PhotoalbumClass where ClassID=@ClassID";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
public int update_phoBumClass(string ClassName, DateTime Creatime, string ClassIDs)
{
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@ClassName", SqlDbType.NVarChar, 50);
param[0].Value = ClassName;
param[1] = new SqlParameter("@Creatime", SqlDbType.DateTime, 8);
param[1].Value = Creatime;
param[2] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 18);
param[2].Value = ClassIDs;
string Sql = "update " + Pre + "user_PhotoalbumClass set ClassName=@ClassName,Creatime=@Creatime where ClassID=@ClassID";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion
public DataTable sel_photoUrl(string PhotoalbumID)
{
SqlParameter param = new SqlParameter("@PhotoalbumID", PhotoalbumID);
string Sql = "Select PhotoUrl From " + Pre + "user_photo where PhotoalbumID=@PhotoalbumID";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
}
} | 0575kaoshicj | trunk/NetCMS.DALSQLServer/Photo.cs | C# | asf20 | 16,273 |
//======================================================
//== (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.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Rss : DbBase, IRss
{
public int sel(string ClassID)
{
string Sql = "select count(*) from " + Pre + "news_Class where ParentID='" + ClassID + "' and isLock=0 and isRecyle=0 and IsURL=0";
return (int)DbHelper.ExecuteScalar(CommandType.Text, Sql, null);
}
public DataTable getxmllist(string ClassID)
{
string _datalib = Pre + "_news";
string getclassSQL = "Select DataLib from " + Pre + "news_class where ClassID='" + ClassID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, getclassSQL, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
_datalib = dt.Rows[0]["DataLib"].ToString();
}
dt.Clear(); dt.Dispose();
}
string Sql = "select top 5 NewsTitle,CreatTime from " + _datalib + " where ClassID='" + ClassID + "' and isLock=0 and isRecyle=0 order by orderID asc,id desc";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return rdr;
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Rss.cs | C# | asf20 | 1,763 |
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using NetCMS.DALFactory;
using NetCMS.Global;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class JSTemplet : DbBase, IJSTemplet
{
public DataTable List()
{
string Sql = "select TempletID,CName,JSTType from " + Pre + "news_JSTemplet where SiteID='" + Current.SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public DataTable ClassList()
{
string Sql = "select id,ClassID,CName,ParentID from " + Pre + "News_JST_Class where SiteID='" + Current.SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public DataTable GetCustom()
{
string Sql = "select defineCname,defineValue From " + Pre + "define_data Where SiteID='" + Global.Current.SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public DataTable reviewTempletContent(string tid)
{
string Sql = "select JSTContent From " + Pre + "news_JSTemplet Where TempletID='" + tid + "' and SiteID='" + Global.Current.SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public DataTable GetPage(int PageIndex, int PageSize, out int RecordCount, out int PageCount, string ParentID)
{
RecordCount = 0;
PageCount = 0;
if (ParentID.IndexOf("'") >= 0) ParentID = ParentID.Replace("'", "");
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
try
{
string Sql = "select count(*) from " + Pre + "news_JST_Class where SiteID='" + Current.SiteID + "' and ParentID='" + ParentID + "'";
int m = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null));
Sql = "select count(*) from " + Pre + "news_JSTemplet where SiteID='" + Current.SiteID + "' and JSClassid='" + ParentID + "'";
int n = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null));
RecordCount = m + n;
if (RecordCount % PageSize == 0)
PageCount = RecordCount / PageSize;
else
PageCount = RecordCount / PageSize + 1;
if (PageIndex > PageCount)
PageIndex = PageCount;
if (PageIndex < 1)
PageIndex = 1;
Sql = "(SELECT a.id, 255 AS JSTType, a.ClassID AS TmpID, a.CName, a.CreatTime, COUNT(b.id) AS NumCLS,(SELECT COUNT(*) FROM " + Pre + "news_JSTemplet WHERE JSClassid = a.ClassID) AS NumTMP FROM " + Pre + "news_JST_Class a LEFT OUTER JOIN " + Pre + "news_JST_Class b ON a.ClassID = b.ParentID where a.ParentID='" + ParentID + "' and a.SiteID='" + Current.SiteID + "' GROUP BY a.id, a.CName, a.CreatTime, a.ClassID) union ";
Sql += "(select id,JSTType,TempletID as TmpID,CName,CreatTime,NumCLS=0,NumTMP=0 from " + Pre + "news_JSTemplet where JSClassid='" + ParentID + "' and SiteID='" + Current.SiteID + "')";
SqlDataAdapter ap = new SqlDataAdapter(Sql, cn);
DataSet st = new DataSet();
ap.Fill(st, (PageIndex - 1) * PageSize, PageSize, "RESULT");
return st.Tables[0];
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
public void Add(string CName, string JSClassid, int JSTType, string JSTContent)
{
Edit(0, CName, JSClassid, JSTType, JSTContent);
}
public void Update(int id, string CName, string JSClassid, string JSTContent)
{
Edit(id, CName, JSClassid, -1, JSTContent);
}
private void Edit(int id, string CName, string JSClassid, int JSTType, string JSTContent)
{
string Sql = "select count(*) from " + Pre + "news_JSTemplet where SiteID='" + Current.SiteID + "' and CName=@CName";
if (id > 0)
Sql += " and id<>" + id;
SqlParameter parm = new SqlParameter("@CName", SqlDbType.NVarChar, 50);
parm.Value = CName;
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
try
{
cn.Open();
int n = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, parm));
if (n > 0)
throw new Exception("JS模型名称不能重复,该JS模型名称已存在!");
if (id > 0)
{
Sql = "update " + Pre + "news_JSTemplet set CName=@CName,JSClassid=@JSClassid,JSTContent=@JSTContent where SiteID=@SiteID and id=" + id;
}
else
{
string JsTID = NetCMS.Common.Rand.Str(12);
if (Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, "select count(*) from " + Pre + "news_JSTemplet where TempletID='" + JsTID + "'")) > 0)
{
JsTID = NetCMS.Common.Rand.Str(12, true);
}
Sql = "insert into " + Pre + "news_JSTemplet (TempletID,CName,JSClassid,JSTType,JSTContent,CreatTime,SiteID) values ";
Sql += "('" + JsTID + "',@CName,@JSClassid," + JSTType + ",@JSTContent,'" + DateTime.Now + "',@SiteID)";
}
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@CName", SqlDbType.NVarChar, 50);
param[0].Value = CName;
param[1] = new SqlParameter("@JSClassid", SqlDbType.NVarChar, 12);
param[1].Value = JSClassid;
param[2] = new SqlParameter("@JSTContent", SqlDbType.NText);
param[2].Value = JSTContent;
param[3] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[3].Value = Current.SiteID;
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, param);
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
public DataTable GetSingle(int id)
{
string Sql = "select * from " + Pre + "news_JSTemplet where Siteid='" + Current.SiteID + "' and id=" + id;
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public DataTable GetClass(int id)
{
string Sql = "SELECT * FROM " + Pre + "news_JST_Class where SiteID='" + Current.SiteID + "' and id=" + id;
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public void ClassAdd(string CName, string ParentID, string Description)
{
ClassEdit(0, CName, ParentID, Description);
}
public void ClassUpdate(int id, string CName, string ParentID, string Description)
{
ClassEdit(id, CName, ParentID, Description);
}
private void ClassEdit(int id, string CName, string ParentID, string Description)
{
string Sql = "select count(*) from " + Pre + "news_JST_Class where SiteID='" + Current.SiteID + "' and CName=@CName";
if (id > 0)
Sql += " and id<>" + id;
SqlParameter parm = new SqlParameter("@CName", SqlDbType.NVarChar, 50);
parm.Value = CName;
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
try
{
cn.Open();
int n = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, parm));
if (n > 0)
throw new Exception("JS模型分类名称不能重复,该分类名称已存在!");
if (id > 0)
{
Sql = "update " + Pre + "news_JST_Class set CName=@CName,ParentID=@ParentID,Description=@Description where SiteID=@SiteID and id=" + id;
}
else
{
string CLID = NetCMS.Common.Rand.Str(12);
if (Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, "select count(*) from " + Pre + "news_JST_Class where ClassID='" + CLID + "'")) > 0)
{
CLID = NetCMS.Common.Rand.Str(12, true);
}
Sql = "insert into " + Pre + "news_JST_Class (ClassID,CName,ParentID,Description,CreatTime,SiteID) values ";
Sql += "('" + CLID + "',@CName,@ParentID,@Description,'" + DateTime.Now + "',@SiteID)";
}
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@CName", SqlDbType.NVarChar, 50);
param[0].Value = CName;
param[1] = new SqlParameter("@ParentID", SqlDbType.NVarChar, 12);
param[1].Value = ParentID;
param[2] = new SqlParameter("@Description", SqlDbType.NVarChar, 500);
param[2].Value = Description.Equals("") ? DBNull.Value : (object)Description;
param[3] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[3].Value = Current.SiteID;
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, param);
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
public void Delete(int id)
{
string Sql = "delete from " + Pre + "news_JSTemplet where SiteID='" + Current.SiteID + "' and id=" + id;
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public void ClassDelete(string id)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
try
{
if (id.IndexOf("'") >= 0) id = id.Replace("'", "''");
IList<string> lstid = new List<string>();
cn.Open();
DataTable tb = DbHelper.ExecuteTable(cn, CommandType.Text, "select ClassID,ParentID from " + Pre + "news_JST_Class where SiteID='" + Current.SiteID + "'", null);
FindChildren(tb, id, ref lstid);
string ids = "'" + id + "'";
foreach (string x in lstid)
{
ids += ",'" + x + "'";
}
SqlTransaction tran = cn.BeginTransaction();
try
{
string Sql = "delete from " + Pre + "news_JSTemplet where SiteID='" + Current.SiteID + "' and JSClassid in (" + ids + ")";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, null);
Sql = "delete from " + Pre + "news_JST_Class where SiteID='" + Current.SiteID + "' and ClassID in (" + ids + ")";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, null);
tran.Commit();
}
catch
{
tran.Rollback();
throw;
}
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
private void FindChildren(DataTable tb, string PID, ref IList<string> list)
{
DataRow[] row = tb.Select("ParentID='" + PID + "'");
if (row.Length < 1)
return;
else
{
foreach (DataRow r in row)
{
list.Add(r["ClassID"].ToString());
FindChildren(tb, r["ClassID"].ToString(), ref list);
}
}
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/JSTemplet.cs | C# | asf20 | 12,546 |
//======================================================
//== (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 NetCMS.Common;
using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Message : DbBase, IMessage
{
#region Message_box.aspx
public int sel_msgInfo(string ID,int flag)
{
#region
SqlParameter param = new SqlParameter("@Mid", ID);
string Sql = null;
if (flag == 0)
{
Sql = "select count(Id) from " + Pre + "user_Message where Mid=@Mid and isRecyle = 0";
}
else if (flag == 1)
{
Sql = "select count(Mid) from " + Pre + "User_Message where Mid=@Mid";
}
else if (flag == 2)
{
Sql = "select FileTF from " + Pre + "User_Message where Mid=@Mid";
}
else if (flag == 3)
{
Sql = "select count(UserNum) from " + Pre + "User_Message where UserNum=@Mid and issDel=0";
}
else if (flag == 4)
{
Sql = "select count(Id) from " + Pre + "user_Message where Mid=@Mid and issRecyle = 0";
}
return (int)DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
#endregion
}
public int update_msgInfo(string ID,int flag)
{
#region
SqlParameter param = new SqlParameter("@Mid", ID);
string Sql = null;
if (flag == 0)
{
Sql = "update " + Pre + "user_Message set isRecyle='1' where Mid=@Mid";
}
else if (flag == 1)
{
Sql = "update " + Pre + "User_Message set isRead='1' where Mid=@Mid";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public DataTable sel_userMessage(string ID,int flag)
{
#region
SqlParameter param = new SqlParameter("@Mid", ID);
string Sql = null;
if (flag == 0)
{
Sql = "select isRdel,issDel,Title,Content,Rec_UserNum,FileTF,LevelFlag from " + Pre + "User_Message where Mid=@Mid";
}
else if (flag == 1)
{
Sql = "select FriendUserNum,UserName from " + Pre + "User_Friend where UserNum=@Mid";
}
else if (flag == 2)
{
Sql = "select MessageNum,MessageGroupNum From " + Pre + "User_Group where GroupNumber=@Mid";
}
else if (flag == 3)
{
Sql = "select UserNum from " + Pre + "sys_User where UserName=@Mid";
}
else if (flag == 4)
{
Sql = "select FileName,FileUrl from " + Pre + "User_MessFiles where mID=@Mid";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
#endregion
}
public string sel_userInfo(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "Select UserGroupNumber,UserName From " + Pre + "sys_User where UserNum=@UserNum";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
public void del_userMsg(string ID)
{
#region
SqlParameter param = new SqlParameter("@Mid", ID);
string Sql = "update " + Pre + "user_Message set issDel=1 where Mid=@Mid and UserNum='" + NetCMS.Global.Current.UserNum + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
string Sql1 = "update " + Pre + "user_Message set isRdel=1 where Mid=@Mid and Rec_UserNum='" + NetCMS.Global.Current.UserNum + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql1, param);
string Sql2 = "update " + Pre + "user_Message set isRdel=1,issDel=1 where SortType=0 and Mid=@Mid and Rec_UserNum='" + NetCMS.Global.Current.UserNum + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql2, param);
#endregion
}
#endregion
#region message_write.aspx
public void Add(NetCMS.Model.message uc)
{
string Sql = "insert into " + Pre + "User_Message(Mid,UserNum,Title,Content,CreatTime,Send_DateTime,SortType,Rec_UserNum,FileTF,LevelFlag,isRead,issDel,isRdel,isRecyle,issRecyle) values(@Mid,@UserNum,@Title,@Content,@CreatTime,@Send_DateTime,@SortType,@Rec_UserNum,@FileTF,@LevelFlag,'0','0','0','0','0')";
SqlParameter[] param = addParam(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
private SqlParameter[] addParam(NetCMS.Model.message uc)
{
#region
SqlParameter[] param = new SqlParameter[10];
param[0] = new SqlParameter("@Mid", SqlDbType.NVarChar, 12);
param[0].Value = uc.Mid;
param[1] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
param[1].Value = uc.UserNum;
param[2] = new SqlParameter("@Title", SqlDbType.NVarChar, 50);
param[2].Value = uc.Title;
param[3] = new SqlParameter("@Content", SqlDbType.NText);
param[3].Value = uc.Content;
param[4] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[4].Value = uc.CreatTime;
param[5] = new SqlParameter("@Send_DateTime", SqlDbType.DateTime, 8);
param[5].Value = uc.Send_DateTime;
param[6] = new SqlParameter("@SortType", SqlDbType.TinyInt, 1);
param[6].Value = uc.SortType;
param[7] = new SqlParameter("@Rec_UserNum", SqlDbType.NVarChar, 15);
param[7].Value = uc.Rec_UserNum;
param[8] = new SqlParameter("@FileTF", SqlDbType.TinyInt, 1);
param[8].Value = uc.FileTF;
param[9] = new SqlParameter("@LevelFlag", SqlDbType.TinyInt, 1);
param[9].Value = uc.LevelFlag;
return param;
#endregion
}
public int add_userMsg(string MfID, string Mid, string UserNum, string fileName, string FileUrl, DateTime CreatTime)
{
#region
SqlParameter[] param = new SqlParameter[6];
param[0] = new SqlParameter("@MfID",SqlDbType.NVarChar,18 );
param[0].Value = MfID;
param[1] = new SqlParameter("@Mid",SqlDbType.NVarChar,18 );
param[1].Value = Mid;
param[2] = new SqlParameter("@UserNum",SqlDbType.NVarChar,16 );
param[2].Value = UserNum;
param[3] = new SqlParameter("@fileName",SqlDbType.NVarChar,50 );
param[3].Value = fileName;
param[4] = new SqlParameter("@FileUrl",SqlDbType.NVarChar,100 );
param[4].Value = FileUrl;
param[5] = new SqlParameter("@CreatTime",SqlDbType.DateTime,8 );
param[5].Value = CreatTime;
string Sql = "insert into " + Pre + "User_MessFiles(MfID,mID,UserNum,FileName,FileUrl,CreatTime) values(@MfID,@Mid,@UserNum,@fileName,@FileUrl,@CreatTime)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region Message_red.aspx
/// <summary>
/// 清除无用的消息
/// </summary>
/// <returns></returns>
public int clearmessage()
{
#region
int j = 0;
string Sql = "select ID,Mid from " + Pre + "User_Message where issDel=1 and isRdel=1 order by id desc";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (dt != null && dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string Sql1 = "delete from " + Pre + "User_Message where id=" + int.Parse(dt.Rows[i]["id"].ToString()) + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql1, null);
string Sql2 = "delete from " + Pre + "user_MessFiles where mID='" + dt.Rows[i]["Mid"].ToString() + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql2, null);
j++;
}
}
return j;
#endregion
}
public void clearmessagerecyle()
{
string Sql1 = "delete from " + Pre + "User_Message where issRecyle=1 and isRecyle=1";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql1, null);
}
#endregion
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Message.cs | C# | asf20 | 9,275 |
//======================================================
//== (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 Database : DbBase, IDatabase
{
public DataTable ExecuteSql(string sqlText)
{
DataTable dt = null;
SqlConnection conn = new SqlConnection(DBConfig.CmsConString);
conn.Open();
try
{
dt = DbHelper.ExecuteTable(CommandType.Text, sqlText, null);
}
catch (SqlException e)
{
throw e;
}
if (conn != null && conn.State == ConnectionState.Open)
{
conn.Close();
conn.Dispose();
}
return dt;
}
public int backSqlData(int type, string backpath)
{
string s_dbCstring = "";
if (type == 1)
s_dbCstring = NetCMS.Config.DBConfig.CmsConString;
else if (type == 2)
s_dbCstring = NetCMS.Config.DBConfig.HelpConString;
else
s_dbCstring = NetCMS.Config.DBConfig.CollectConString;
string[] a_dbNamestring = s_dbCstring.Split(';');
string[] a_dbNameS = a_dbNamestring[3].ToString().Split('=');
string Sql = "backup DATABASE [" + a_dbNameS[1].ToString() + "] to disk='" + backpath + "' with format";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
return 1;
}
public void Replace(string oldTxt, string newTxt, string Table, string FieldName)
{
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@oldTxt", oldTxt), new SqlParameter("@newTxt", newTxt) };
string Sql = "update [" + Table + "] set [" + FieldName + "]=replace([" + FieldName + "] ,@oldTxt,@newTxt)";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Database.cs | C# | asf20 | 2,421 |
//======================================================
//== (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 AdminGroup : DbBase, IAdminGroup
{
private string SiteID;
public AdminGroup()
{
SiteID = NetCMS.Global.Current.SiteID;
}
/// <summary>
/// 增加管理员组
/// </summary>
/// <param name="agci">构造参数</param>
/// <returns></returns>
public int add(NetCMS.Model.AdminGroupInfo agci)
{
string checkSql = "";
int recordCount = 0;
string AdminGruopNum = NetCMS.Common.Rand.Number(8);
while (true)
{
checkSql = "select count(*) from " + Pre + "sys_AdminGroup where adminGroupNumber='" + AdminGruopNum + "'";
recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
if (recordCount < 1)
break;
else
AdminGruopNum = NetCMS.Common.Rand.Number(12, true);
}
checkSql = "select count(*) from " + Pre + "sys_AdminGroup where GroupName='" + agci.GroupName + "'";
recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
if (recordCount > 0)
{
throw new Exception("管理员组名称重复,请重新添加!");
}
string Sql = "insert into " + Pre + "sys_AdminGroup (";
Sql += "adminGroupNumber,GroupName,ClassList,channelList,SpecialList,CreatTime,SiteID";
Sql += ") values ('" + AdminGruopNum + "',";
Sql += "@GroupName,@ClassList,@channelList,@SpecialList,@CreatTime,@SiteID)";
SqlParameter[] param = GetAdminGroupParameters(agci);
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public int Edit(NetCMS.Model.AdminGroupInfo agci)
{
string str_Sql = "Update " + Pre + "sys_AdminGroup Set ClassList=@ClassList,SpecialList=@SpecialList,";
str_Sql += "channelList=@channelList Where adminGroupNumber='" + agci.adminGroupNumber + "'";
SqlParameter[] param = GetAdminGroupParameters(agci);
return DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, param);
}
public void Del(string id)
{
string str_Sql = "Delete From " + Pre + "sys_AdminGroup where adminGroupNumber='" + id + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
}
public DataTable getInfo(string id)
{
string str_Sql = "Select adminGroupNumber,GroupName,ClassList,SpecialList,channelList From " + Pre + "sys_AdminGroup Where SiteID='" + SiteID + "' and adminGroupNumber='" + id + "'";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public DataTable getClassList(string col, string TbName, string sqlselect)
{
string str_Sql = "Select " + col + " From " + Pre + TbName + " " + sqlselect + " Order By ID Asc";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
public DataTable getColCname(string colname, string TbName, string classid, string id)
{
string str_Sql = "Select " + colname + " From " + Pre + TbName + " Where " + classid + "='" + id + "'";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
private SqlParameter[] GetAdminGroupParameters(NetCMS.Model.AdminGroupInfo agci)
{
SqlParameter[] param = new SqlParameter[7];
param[0] = new SqlParameter("@adminGroupNumber", SqlDbType.NVarChar, 8);
param[0].Value = agci.adminGroupNumber;
param[1] = new SqlParameter("@GroupName", SqlDbType.NVarChar, 20);
param[1].Value = agci.GroupName;
param[2] = new SqlParameter("@ClassList", SqlDbType.NText);
param[2].Value = agci.ClassList;
param[3] = new SqlParameter("@SpecialList", SqlDbType.NText);
param[3].Value = agci.SpecialList;
param[4] = new SqlParameter("@channelList", SqlDbType.NText);
param[4].Value = agci.channelList;
param[5] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[5].Value = agci.CreatTime;
param[6] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[6].Value = agci.SiteID;
return param;
}
/// <summary>
/// 根据管理员编号读取所属会员组编号
/// </summary>
/// <param name="userNum">会员编号</param>
/// <returns></returns>
public string getAdminGroup(string userNum)
{
SqlParameter param = new SqlParameter("@UserNum", userNum);
string sql = "select AdminGroupNumber from NT_sys_admin where UserNum=@UserNum";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql,param));
}
/// <summary>
/// 获取管理员组信息
/// </summary>
/// <param name="UserGroupNumber">管理员组编号</param>
/// <returns></returns>
public IDataReader getAdminGroups(string UserGroupNumber)
{
SqlParameter param = new SqlParameter("@adminGroupNumber", UserGroupNumber);
string sql = "select ClassList,SpecialList,channelList from " + Pre + "sys_AdminGroup where adminGroupNumber=@adminGroupNumber";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
/// <summary>
/// 判断管理员是不是超级管理员
/// </summary>
/// <param name="usernum"></param>
/// <returns></returns>
public string GetAdminIsSuper(string usernum)
{
SqlParameter param = new SqlParameter("@UserNum", usernum);
string Sql = "select isSuper from " + Pre + "sys_Admin where UserNum=@UserNum";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/AdminGroup.cs | C# | asf20 | 6,714 |
//======================================================
//== (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 Install : DbBase, IInstall
{
public int InserAdmin(string UserName, string Password)
{
string sql = "select count(id) from " + Pre + "sys_User where UserName='" + UserName + "'";
int countTF = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, null));
string gsql = "select count(id) from " + Pre + "sys_User where isAdmin=1";
countTF = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, gsql, null));
if (countTF == 0)
{
string s_adminpwd = NetCMS.Common.Input.MD5(Password, true);
string s_usernum = "000000000000";
string s_Addadmin = "insert into [" + Pre + "sys_User] ([UserNum],[UserName],[UserPassword],[NickName]," +
"[RealName],[isAdmin],[UserGroupNumber],[PassQuestion],[PassKey],[CertType],[CertNumber]," +
"[Email],[mobile],[Sex],[birthday],[Userinfo],[UserFace],[userFacesize],[marriage],[iPoint]," +
"[gPoint],[cPoint],[ePoint],[aPoint],[isLock],[RegTime],[LastLoginTime],[OnlineTime],[OnlineTF]," +
"[LoginNumber],[FriendClass],[LoginLimtNumber],[LastIP],[SiteID],[Addfriend],[isOpen]," +
"[ParmConstrNum],[isIDcard],[IDcardFiles],[Addfriendbs],[EmailATF],[EmailCode],[isMobile]," +
"[BindTF],[MobileCode]) " +
"values " +
"('" + s_usernum + "','" + UserName + "','" + s_adminpwd + "','admin'," +
"'admin',1,'00000000001','','','','','','12345678901',0,'1986-12-6 00:00:00',''," +
"'/sysImages/user/noHeadpic.gif','50|50',0,15,10,2,0,2,0,'" + DateTime.Now + "'," +
"'" + DateTime.Now + "',0,0,1,'',0,'127.0.0.1','0',2,0,0,1,'',2,1,'',1,0,'');" +
" insert into [" + Pre + "sys_admin] ([UserNum],[isSuper],[adminGroupNumber],[PopList]," +
"[OnlyLogin],[isChannel],[isLock],[SiteID],[isChSupper],[Iplimited],[verCode]) " +
"values " +
"('" + s_usernum + "',1,'00000001','',0,0,0,'0',0,'','')";
return DbHelper.ExecuteNonQuery(CommandType.Text, s_Addadmin, null);
}
else
{
return 0;
}
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Install.cs | C# | asf20 | 3,171 |
//======================================================
//== (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.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class DefineTable : DbBase, IDefineTable
{
#region DefineTable.aspx
public DataTable Sel_DefineInfoId()
{
string Sql = "Select DefineInfoId,DefineName,ParentInfoId From " + Pre + "define_class where SiteID='" + NetCMS.Global.Current.SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public DataTable Sel_ParentInfo(string PID, int flag)
{
#region
SqlParameter param = new SqlParameter("@ParentInfoId", PID);
string Sql = null;
if (flag == 0)
{
Sql = "Select DefineInfoId,DefineName,ParentInfoId From " + Pre + "define_class where ParentInfoId=@ParentInfoId and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "Select DefineID,DefineInfoId,DefineName,ParentInfoID From " + Pre + "define_class where ParentInfoID=@ParentInfoID";
}
else if (flag == 2)
{
Sql = "Select DefineInfoId,DefineName,ParentInfoId From " + Pre + "define_class where DefineInfoId=@ParentInfoID";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
#endregion
}
public int sel_defCname(string defCname)
{
SqlParameter param = new SqlParameter("@DefineCname", defCname);
string Sql = "Select count(id) From " + Pre + "Define_Data Where DefineCname=@DefineCname";
return (int)DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
}
public int sel_defEname(string defEname)
{
SqlParameter param = new SqlParameter("@defineColumns", defEname);
string Sql = "Select count(id) From " + Pre + "Define_Data Where defineColumns=@defineColumns";
return (int)DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
}
public int Add(string Str_ColumnsType, string defCname, string defEname, int definSelected, int Isnull, string defColumns, string defExp, string definedvalue,int DtType)
{
#region
SqlParameter[] param = new SqlParameter[9];
param[0] = new SqlParameter("@ColumnsType", SqlDbType.NVarChar, 12);
param[0].Value = Str_ColumnsType;
param[1] = new SqlParameter("@defCname", SqlDbType.NVarChar, 50);
param[1].Value = defCname;
if (defEname == null)
defEname = "";
param[2] = new SqlParameter("@defEname", SqlDbType.NVarChar, 50);
param[2].Value = defEname;
param[3] = new SqlParameter("@defineType", SqlDbType.Int, 4);
param[3].Value = definSelected;
param[4] = new SqlParameter("@Is_null", SqlDbType.Int, 4);
param[4].Value = Isnull;
if (defColumns == null)
defColumns = "";
param[5] = new SqlParameter("@defColumns", SqlDbType.NText);
param[5].Value = defColumns;
if (defExp == null)
defExp = "";
param[6] = new SqlParameter("@defExp", SqlDbType.NVarChar, 200);
param[6].Value = defExp;
if (definedvalue == null)
definedvalue = "";
param[7] = new SqlParameter("@definedvalue", SqlDbType.NVarChar, 200);
param[7].Value = definedvalue;
param[8] = new SqlParameter("@DtType", SqlDbType.NVarChar, 200);
param[8].Value = DtType;
string Sql = "Insert Into " + Pre + "Define_Data(defineInfoId,DefineCname,DefineColumns,defineType,IsNull,defineValue," +
"defineExpr,SiteID,definedvalue,Type) Values(@ColumnsType,@defCname,@defEname,@defineType,@Is_null,@defColumns," +
"@defExp,'" + NetCMS.Global.Current.SiteID + "',@definedvalue,@DtType)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region DefineTable_Edit_List.aspx
public DataTable Str_Start_Sql(int ID)
{
SqlParameter param = new SqlParameter("@ID", ID);
string Sql = "Select id,defineInfoId,defineCname,defineColumns,defineType,IsNull,defineValue,defineExpr,definedvalue,Type From " + Pre + "define_data where Id=@ID";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
public int Update(string Str_ColumnsType, string Str_DefName, string Str_DefEname, string Str_DefType, int Str_DefIsNull, string Str_DefColumns, string Str_DefExpr, int DefID, string definedvalue,int type)
{
#region
SqlParameter[] param = new SqlParameter[10];
param[0] = new SqlParameter("@ColumnsType", SqlDbType.NVarChar, 12);
param[0].Value = Str_ColumnsType;
param[1] = new SqlParameter("@defCname", SqlDbType.NVarChar, 50);
param[1].Value = Str_DefName;
if (Str_DefEname == null)
Str_DefEname = "";
param[2] = new SqlParameter("@defEname", SqlDbType.NVarChar, 50);
param[2].Value = Str_DefEname;
param[3] = new SqlParameter("@defineType", SqlDbType.Int, 4);
param[3].Value = Convert.ToInt32(Str_DefType);
param[4] = new SqlParameter("@Is_null", SqlDbType.Int, 4);
param[4].Value = Convert.ToInt32(Str_DefIsNull);
param[5] = new SqlParameter("@defColumns", SqlDbType.NText);
if (Str_DefColumns == null)
Str_DefColumns = "";
param[5].Value = Str_DefColumns;
param[6] = new SqlParameter("@defExp", SqlDbType.NVarChar, 200);
if (Str_DefExpr == null)
Str_DefExpr = "";
param[6].Value = Str_DefExpr;
param[7] = new SqlParameter("@definedvalue", SqlDbType.NVarChar, 200);
if (definedvalue == null)
definedvalue = "";
param[7].Value = definedvalue;
param[8] = new SqlParameter("@DefID", SqlDbType.Int, 4);
param[8].Value = DefID;
param[9] = new SqlParameter("@type", SqlDbType.Int, 4);
param[9].Value = type;
string Sql = "Update " + Pre + "define_data Set defineInfoId=@ColumnsType,defineCname=@defCname," +
"defineColumns=@defEname,defineType=@defineType,IsNull=@Is_null,defineValue=@defColumns," +
"defineExpr=@defExp,definedvalue=@definedvalue,Type=@type where id=@DefID";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region DefineTable_Edit_Manage.aspx
public int update_defineClass(string Str_NewText, string DefID)
{
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@DefineName", Str_NewText), new SqlParameter("@DefineInfoId", DefID) };
string Sql = "Update " + Pre + "define_class Set DefineName=@DefineName where DefineInfoId=@DefineInfoId";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion
#region DefineTable_List.aspx
public DataTable GetPage(string defid, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
#region
string where = "";
if (defid == null && defid == string.Empty)
{
where = "";
}
else
{
where = " where defineInfoId=@defineInfoId";
}
SqlParameter param = new SqlParameter("@defineInfoId", defid);
string AllFields = "id,defineInfoId,defineCname,defineType,[IsNull]";
string Condition = "" + Pre + "Define_Data " + where + "";
string IndexField = "id";
string OrderFields = "order by id Desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, param);
#endregion
}
public int del_defineStr(string pr)
{
SqlParameter param = new SqlParameter("@defineInfoId", pr);
string Sql= "Delete From " + Pre + "define_data where defineInfoId=@defineInfoId";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public int del_deData(int DefID)
{
string Sql = "Delete From " + Pre + "define_data where Id=" + DefID + "";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
#endregion
public int sel_defineClass(string _NewText,int flag)
{
#region
SqlParameter param = new SqlParameter("@DefineName", _NewText);
string Sql = null;
if (flag == 0)
{
Sql = "Select count(DefineId) From " + Pre + "Define_Class Where DefineName=@DefineName";
}
else if (flag == 1)
{
Sql = "Select count(DefineId) From " + Pre + "Define_Class Where DefineInfoId=@DefineName";
}
return (int)DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
#endregion
}
public int add_defineClass(string rand, string _NewText, string _PraText)
{
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@DefineInfoId", rand), new SqlParameter("@DefineName", _NewText), new SqlParameter("@ParentInfoId", _PraText) };
string Sql = "Insert Into " + Pre + "Define_Class(DefineInfoId,DefineName,ParentInfoId,SiteID) values(@DefineInfoId,@DefineName,@ParentInfoId,'" + NetCMS.Global.Current.SiteID + "')";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public void del_defineClass(string DefID, int flag)
{
#region
SqlParameter param = null;
if (flag < 3)
{
param = new SqlParameter("@DefineInfoId", DefID);
}
string Sql = null;
if (flag == 0)
{
Sql = "Delete From " + Pre + "define_class where DefineInfoId=@DefineInfoId";
}
else if (flag == 1)
{
Sql = "Delete From " + Pre + "define_class where ParentInfoId=@DefineInfoId";
}
else if (flag == 2)
{
Sql = "Delete From " + Pre + "define_data where defineInfoId=@DefineInfoId";
}
else if (flag == 3)
{
Sql = "Delete From " + Pre + "define_class where DefineInfoId in(" + DefID + ")";
}
else if (flag == 4)
{
Sql = "Delete From " + Pre + "define_class where ParentInfoId in(" + DefID + ")";
}
else if (flag == 5)
{
Sql = "Delete From " + Pre + "define_data where Id in(" + DefID + ")";
}
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public int del_defClassInfo(int flag)
{
#region
string Sql = "";
if (flag == 0)
{
if (NetCMS.Global.Current.SiteID == "0")
{
Sql = "Delete From " + Pre + "define_class";
}
else
{
Sql = "Delete From " + Pre + "define_class where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
}
else if (flag == 1)
{
if (NetCMS.Global.Current.SiteID == "0")
{
Sql = "Delete From " + Pre + "define_data";
}
else
{
Sql = "Delete From " + Pre + "define_data where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
//读取属于自定义字段
public DataTable getDefineUser(int type)
{
string sql = "select id,defineInfoId,defineCname,defineColumns,defineType,IsNull,defineValue,defineExpr,definedvalue,SiteID,Type from " + Pre + "define_data where type=" + type;
return DbHelper.ExecuteTable(CommandType.Text,sql,null);
}
//根据会员编号和自定义字段类型读取自定义字段
public DataTable setDefineByNum(string userNum)
{
string sql = "select a.*,deID=b.Id,b.DsnewsId,b.DsEName,b.DsnewsTable,b.DsType,b.DsContent,b.DsApiId,b.SiteID from " + Pre + "define_data a inner join " + Pre + "define_save b on a.defineColumns=b.DsEname where b.DsnewsId='" + userNum + "'";
return DbHelper.ExecuteTable(CommandType.Text, sql, null);
}
//添加修改会员自定义字段
/// <summary>
/// </summary>
/// <param name="DsnewsId">ID编号</param>
/// <param name="DsEName">英文名称</param>
/// <param name="DsnewsTable">保存会员信息表名字</param>
/// <param name="DsType">自定义类型 系统默认后台数据为:0,前台为1 </param>
/// <param name="DsContent">内容</param>
/// <param name="DsApiId">API唯一编号</param>
/// <param name="SiteID"></param>
/// <returns></returns>
public int AddUpdateDefine(int Id,string DsnewsId, string DsEName, string DsnewsTable, int DsType, string DsContent, string DsApiId, string SiteID,int flag)
{
string sql=null;
SqlParameter[] param = new SqlParameter[8];
param[0] = new SqlParameter("@Id", SqlDbType.Int,4);
param[0].Value = Id;
param[1] = new SqlParameter("@DsnewsId", SqlDbType.NVarChar, 12);
param[1].Value = DsnewsId;
param[2] = new SqlParameter("@DsEName", SqlDbType.NVarChar, 50);
param[2].Value = DsEName;
param[3] = new SqlParameter("@DsnewsTable", SqlDbType.NVarChar, 50);
param[3].Value = DsnewsTable;
param[4] = new SqlParameter("@DsType", SqlDbType.TinyInt, 1);
param[4].Value = DsType;
param[5] = new SqlParameter("@DsContent", SqlDbType.NText, 16);
param[5].Value = DsContent;
param[6] = new SqlParameter("@DsApiId", SqlDbType.NVarChar, 30);
param[6].Value = DsApiId;
param[7] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[7].Value = SiteID;
if(flag==0)//添加
{
sql = "insert into " + Pre + "define_save(DsnewsId,DsEName,DsnewsTable,DsType,DsContent,DsApiId,SiteID) values(@DsnewsId,@DsEName,@DsnewsTable,@DsType,@DsContent,@DsApiId,@SiteID)";
}
else if (flag == 1)
{
sql = "update " + Pre + "define_save set DsContent=@DsContent where Id=@Id";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
}
} | 0575kaoshicj | trunk/NetCMS.DALSQLServer/DefineTable.cs | C# | asf20 | 16,223 |
//======================================================
//== (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);
}
public DataTable getRuleID()
{
string str_Sql = "Select DISTINCT UnID,(Select top 1 UnName from [" + Pre + "News_unNews] where unid=a.unid order by [rows],id desc) as UnName From " + Pre + "News_unNews a Where 1=1 " + NetCMS.Common.Public.getSessionStr() + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getTodayPicID()
{
string str_Sql = "Select NewsID,NewsTitle From " + Pre + "News Where isRecyle=0 And isLock=0 And substring(NewsProperty,9,1)='1' and newspictopline=1 " + NetCMS.Common.Public.getSessionStr() + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getfreeJSInfo()
{
string str_Sql = "Select JsID,JSName From " + Pre + "News_JS Where jsType=1 " + NetCMS.Common.Public.getSessionStr() + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getsysJSInfo()
{
string str_Sql = "Select JsID,JSName From " + Pre + "News_JS Where jsType=0 " + NetCMS.Common.Public.getSessionStr() + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getadsJsInfo()
{
string str_Sql = "Select AdID,adName From " + Pre + "ads Where isLock=0 " + NetCMS.Common.Public.getSessionStr() + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getsurveyJSInfo()
{
string str_Sql = "Select TID,Title From " + Pre + "vote_Topic Where 1=1 " + NetCMS.Common.Public.getSessionStr() + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getstatJSInfo()
{
string str_Sql = "Select Statid,classname From " + Pre + "stat_class Where 1=1 " + NetCMS.Common.Public.getSessionStr() + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getDiscussInfo()
{
string str_Sql = "Select DisID,Cname From " + Pre + "user_Discuss Where 1=1 " + NetCMS.Common.Public.getSessionStr() + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getLableList(string SiteID, int intsys)
{
string siteWhere = "";
string topstr = "";
string stringintsys = "";
if (intsys != 1)
{
siteWhere = " and SiteID='" + SiteID + "'";
stringintsys = " and isSys=" + intsys + "";
if (intsys == 2)
{
topstr = "top 20";
stringintsys = " and isSys=0";
}
}
else
{
stringintsys = " and isSys=1";
}
string str_Sql = "Select " + topstr + " Label_Name,Label_Content,Description From " + Pre + "sys_Label Where 1=1 " + siteWhere + " " +
"And isBack=0 And isRecyle=0 " + stringintsys + " Order By CreatTime Desc,id desc";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getfreeLableList()
{
string str_Sql = "Select LabelName,StyleContent From " + Pre + "sys_LabelFree Where SiteID='0' Order By CreatTime Desc,id desc";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
public DataTable getFreeLabelInfo()
{
string str_Sql = "Select LabelName From " + Pre + "sys_LabelFree Where 1=1 " + NetCMS.Common.Public.getSessionStr() + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
private SqlParameter[] GetLabelClassParameters(NetCMS.Model.LabelClassInfo lbcc)
{
SqlParameter[] param = new SqlParameter[5];
param[0] = new SqlParameter("@ClassName", SqlDbType.NVarChar, 30);
param[0].Value = lbcc.ClassName;
param[1] = new SqlParameter("@Content", SqlDbType.NVarChar, 200);
param[1].Value = lbcc.Content;
param[2] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[2].Value = lbcc.CreatTime;
param[3] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[3].Value = lbcc.SiteID;
param[4] = new SqlParameter("@isRecyle", SqlDbType.TinyInt, 1);
param[4].Value = lbcc.isRecyle;
return param;
}
private SqlParameter[] GetLabelParameters(NetCMS.Model.LabelInfo lbc)
{
SqlParameter[] param = new SqlParameter[9];
param[0] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 12);
param[0].Value = lbc.ClassID;
param[1] = new SqlParameter("@Label_Name", SqlDbType.NVarChar, 30);
param[1].Value = lbc.Label_Name;
param[2] = new SqlParameter("@Label_Content", SqlDbType.NText);
param[2].Value = lbc.Label_Content;
param[3] = new SqlParameter("@Description", SqlDbType.NVarChar, 200);
param[3].Value = lbc.Description;
param[4] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[4].Value = lbc.CreatTime;
param[5] = new SqlParameter("@isBack", SqlDbType.TinyInt, 1);
param[5].Value = lbc.isBack;
param[6] = new SqlParameter("@isRecyle", SqlDbType.TinyInt, 1);
param[6].Value = lbc.isRecyle;
param[7] = new SqlParameter("@isSys", SqlDbType.TinyInt, 1);
param[7].Value = lbc.isSys;
param[8] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[8].Value = lbc.SiteID;
return param;
}
/// <summary>
/// 导出标签获得所有
/// </summary>
/// <returns></returns>
public DataTable outLabelALL(int Num)
{
string sysTF = "";
if (Num != 2) { sysTF = " and isSys=" + Num + ""; }
// else { sysTF = " and isSys=0"; }
string str_Sql = "Select LabelID,ClassID,Label_Name,Label_Content,Description,CreatTime,isSys,SiteID From " + Pre + "sys_Label Where 1=1 " + NetCMS.Common.Public.getSessionStr() + sysTF + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
/// <summary>
/// 批量获得导出标签
/// </summary>
/// <param name="LabelID"></param>
/// <returns></returns>
public DataTable outLabelmutile(string LabelID)
{
string _LabelID = LabelID;
if (LabelID.IndexOf(",") > 0) { _LabelID = LabelID.Replace(",", ""); }
string str_Sql = "Select LabelID,ClassID,Label_Name,Label_Content,Description,CreatTime,isSys,SiteID From " + Pre + "sys_Label Where LabelID in ('" + _LabelID + "') " + NetCMS.Common.Public.getSessionStr() + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
return dt;
}
/// <summary>
/// 导入标签
/// </summary>
/// <param name="Classid"></param>
/// <param name="Label_Name"></param>
/// <param name="Label_Content"></param>
/// <param name="Description"></param>
/// <param name="isSys"></param>
public void inserLabelLocal(string LabelID, string Classid, string Label_Name, string Label_Content, string Description, string isSystem)
{
string _Label_Name = Label_Name;
string SQLTF = "select ID from " + Pre + "sys_Label where Label_Name ='" + Label_Name.Trim() + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, SQLTF, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
_Label_Name = Label_Name.Replace("}", "_导入的重名标签}");
}
dt.Clear(); dt.Dispose();
}
string _LabelID = LabelID;
string SQLTF1 = "select ID from " + Pre + "sys_Label where LabelID ='" + LabelID + "'";
DataTable dt1 = DbHelper.ExecuteTable(CommandType.Text, SQLTF1, null);
if (dt1 != null&&dt1.Rows.Count > 0)
{
_LabelID = NetCMS.Common.Rand.Number(12, true);
dt1.Clear(); dt1.Dispose();
}
if (isSystem == "1") { Classid = "99999999"; }
string Sql = "insert into " + Pre + "sys_Label (";
Sql += "LabelID,ClassID,Label_Name,Label_Content,Description,CreatTime,isBack,isRecyle,isSys,SiteID";
Sql += ") values (";
Sql += "'" + _LabelID + "','" + Classid + "','" + _Label_Name + "','" + Label_Content + "','" + Description + "','" + DateTime.Now + "',0,0," + int.Parse(isSystem) + ",'" + NetCMS.Global.Current.SiteID + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public DataTable getLableListM(int Num, string ParentID)
{
string Sql = "";
if (Num == 0)
{
Sql = "select ClassID,ClassCName,ClassEName from " + Pre + "news_class where ParentID='" + ParentID + "' and isLock=0 and isRecyle=0 and isURL=0 and isPage=0 order by OrderID desc,id desc";
}
else
{
Sql = "select SpecialID,specialEName,SpecialCName from " + Pre + "news_special where ParentID='" + ParentID + "' and isLock=0 and isRecyle=0";
}
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return dt;
}
public int getClassLabelCount(string ClassID,int num)
{
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string Sql = "";
if (num == 0)
{
Sql = "Select count(id) From " + Pre + "sys_Label Where ClassID=@ClassID and isBack=0 and isRecyle=0 and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else
{
Sql = "Select count(id) From " + Pre + "sys_LabelStyle Where ClassID=@ClassID and isRecyle=0 and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
public IDataReader GetStyleList(string SiteID)
{
SqlParameter param = new SqlParameter("@SiteID", SiteID);
string sql = "select ClassID,Sname from " + Pre + "sys_styleclass where SiteID=@SiteID and isRecyle=0";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Label.cs | C# | asf20 | 23,066 |
//======================================================
//== (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, 100);
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
}
public int add_conStrClass(STConstrClass Con, string Ccid, string UserNum)
{
#region
string Sql = "insert into " + Pre + "user_ConstrClass(Ccid,UserNum,cName,Content,creatTime) values(@Ccid,@UserNum,@cName,@Content,@creatTime)";
SqlParameter[] parm = GetConstrClass(Con);
int i_length = parm.Length;
Array.Resize<SqlParameter>(ref parm, i_length + 3);
parm[i_length + 1] = new SqlParameter("@Ccid", Ccid);
parm[i_length + 2] = new SqlParameter("@UserNum", UserNum);
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
#endregion
}
public string ConstrTF()
{
string Sql = "select ConstrTF from " + Pre + "sys_PramUser where SiteID = '" + NetCMS.Global.Current.SiteID + "'";
try
{
return DbHelper.ExecuteScalar(CommandType.Text, Sql, null).ToString();
}
catch { return "1"; }
}
#region ConstrClass_up.aspx
public int update_conStrClass(STConstrClass Con, string Ccid)
{
#region
string Sql = "update " + Pre + "user_ConstrClass set cName=@cName,Content=@Content where Ccid=@Ccid";
SqlParameter[] parm = GetConstrClass(Con);
int i_length = parm.Length;
Array.Resize<SqlParameter>(ref parm, i_length + 2);
parm[i_length + 1] = new SqlParameter("@Ccid", Ccid);
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
#endregion
}
#endregion
private SqlParameter[] GetConstrClass(STConstrClass Con)
{
#region
SqlParameter[] parm = new SqlParameter[3];
parm[0] = new SqlParameter("@cName", SqlDbType.NVarChar, 100);
parm[0].Value = Con.cName;
parm[1] = new SqlParameter("@Content", SqlDbType.NVarChar, 20);
parm[1].Value = Con.Content;
parm[2] = new SqlParameter("@creatTime", SqlDbType.DateTime);
parm[2].Value = DateTime.Now;
return parm;
#endregion
}
#region Constrlist.aspx
public int update_UserInfos(string tagsd, string ID, int flag)
{
#region
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ID", SqlDbType.NVarChar, 12);
param[0].Value = ID;
string Sql = null;
if (flag == 0)
{
param[1] = new SqlParameter("@tagsd", SqlDbType.NVarChar, 10);
param[1].Value = tagsd;
Sql = "Update " + Pre + "user_Constr Set Contrflg=@tagsd where ConID=@ID";
}
else if (flag == 1)//Constr_Return.aspx
{
param[1] = new SqlParameter("@passcontent", SqlDbType.NText);
param[1].Value = tagsd;
Sql = "update " + Pre + "User_Constr set ispass='1',passcontent=@passcontent where ConID=@ID ";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public DataTable GetPage(string UserNum, string ClassID, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
#region
string Sql = "";
if (UserNum != null && UserNum != "")
{
Sql += " where UserNum=@UserNum";
}
if (ClassID != null && !ClassID.Equals(""))
{
Sql += " and ClassID=@ClassID";
}
string AllFields = "ConID,Title,creatTime,ClassID,isCheck,Contrflg,ispass,UserNum";
string Condition = "" + Pre + "user_Constr " + Sql + "";
string IndexField = "id";
string OrderFields = "order by Id desc";
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@UserNum", UserNum), new SqlParameter("@ClassID", ClassID) };
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, param);
#endregion
}
public DataTable sel_getUserConStr(int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
string AllFields = "UserNum";
string Condition = "(select DISTINCT UserNum from " + Pre + "user_Constr where substring(Contrflg,3,1) = '1' and SiteID='" + NetCMS.Global.Current.SiteID + "') UserNum1";
string IndexField = "UserNum";
string OrderFields = "order by UserNum desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, null);
}
#endregion
#endregion
#region 后台
#region Constr_chicklist.aspx
public int update_conStrInfo(string ID, int flag)
{
#region
SqlParameter param = new SqlParameter("@ConID", ID);
string Sql = null;
if (flag == 0)
{
Sql = "update " + Pre + "user_Constr set isadmidel=1 where ConID=@ConID";
}
else if (flag == 1)
{
Sql = "update " + Pre + "User_Constr set isCheck=1 where ConID=@ConID";
}
else if (flag == 2)
{
Sql = "update " + Pre + "sys_user set ParmConstrNum=0 where UserNum=@ConID";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region Constr_Edit.aspx
public int add_conStrEdit(string NewsID, string Title, string PicURL, string ClassID, string Author, string UserNum, string Source, string Contents, string creatTime, string SiteID, string Tags, string DataLib, string NewsTemplet, string strSavePath, string strfileName, string strfileexName, string strCheckInt)
{
#region
SqlParameter[] param = new SqlParameter[17];
param[0] = new SqlParameter("@NewsID", SqlDbType.NVarChar, 12);
param[0].Value = NewsID;
param[1] = new SqlParameter("@Title", SqlDbType.NVarChar, 100);
param[1].Value = Title;
param[2] = new SqlParameter("@PicURL", SqlDbType.NVarChar, 200);
param[2].Value = PicURL;
param[3] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 12);
param[3].Value = ClassID;
param[4] = new SqlParameter("@Author", SqlDbType.NVarChar, 100);
param[4].Value = Author;
param[5] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 18);
param[5].Value = UserNum;
param[6] = new SqlParameter("@Source", SqlDbType.NVarChar, 100);
param[6].Value = Source;
param[7] = new SqlParameter("@Contents", SqlDbType.NText);
param[7].Value = Contents;
param[8] = new SqlParameter("@creatTime", SqlDbType.DateTime, 8);
param[8].Value = DateTime.Now;
param[9] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[9].Value = SiteID;
param[10] = new SqlParameter("@Tags", SqlDbType.NVarChar, 100);
param[10].Value = Tags;
param[11] = new SqlParameter("@DataLib", SqlDbType.NVarChar, 20);
param[11].Value = DataLib;
param[12] = new SqlParameter("@NewsTemplet", SqlDbType.NVarChar, 200);
param[12].Value = NewsTemplet;
param[13] = new SqlParameter("@strSavePath", SqlDbType.NVarChar, 200);
param[13].Value = strSavePath;
param[14] = new SqlParameter("@strfileName", SqlDbType.NVarChar, 100);
param[14].Value = strfileName;
param[15] = new SqlParameter("@strfileexName", SqlDbType.NVarChar, 6);
param[15].Value = strfileexName;
param[16] = new SqlParameter("@strCheckInt", SqlDbType.NVarChar, 10);
param[16].Value = strCheckInt;
string Sql = "insert into " + DataLib + "(NewsID,NewsType,NewsTitle,TitleITF,PicURL,ClassID,Author,Editor,Souce," +
"Content,CreatTime,SiteID,Tags,OrderID,CommlinkTF,SubNewsTF,NewsProperty,newspictopline,templet,click," +
"savepath,fileName,fileEXName,isDelPoint,gPoint,ipoint,groupNumber,ContentPicTF,CommTF,DiscussTF,topnum," +
"voteTF,checkstat,islock,isRecyle,isVoteTF,isHTML,DataLib,isConstr,DefineID) values(@NewsID,0,@Title,0,@PicURL," +
"@ClassID,@Author,@UserNum,@Source,@Contents,@creatTime,@SiteID,@Tags,0,0,0,'0,0,0,0,0,0,0,0'," +
"0,@NewsTemplet,0,@strSavePath,@strfileName,@strfileexName,0,0,0,'',0,1,1,0,0,@strCheckInt,0,0,0,0,@DataLib,1,0)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public void updateConstrStrat(string ConID)
{
SqlParameter param = new SqlParameter("@ConID", ConID);
string Sql = "update " + Pre + "User_Constr set isCheck=1 where ConID=@ConID";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public int add_userGhistory(string NewsID, int gPoint, int iPoint, int Money1, DateTime CreatTime1, string UserNum, string content4)
{
#region
SqlParameter[] param = new SqlParameter[7];
param[0] = new SqlParameter("@NewsID", SqlDbType.NVarChar, 12);
param[0].Value = NewsID;
param[1] = new SqlParameter("@gPoint", SqlDbType.Int, 4);
param[1].Value = gPoint;
param[2] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
param[2].Value = iPoint;
param[3] = new SqlParameter("@Money1", SqlDbType.Int, 4);
param[3].Value = Money1;
param[4] = new SqlParameter("@CreatTime1", SqlDbType.DateTime, 8);
param[4].Value = CreatTime1;
param[5] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 12);
param[5].Value = UserNum;
param[6] = new SqlParameter("@content4", SqlDbType.NText);
param[6].Value = content4;
string Sql = "insert into " + Pre + "User_Ghistory(GhID,ghtype,Gpoint,iPoint,Money,CreatTime,UserNUM,gtype,content,siteID) values(@NewsID,1,@gPoint,@iPoint,@Money1,@CreatTime1,@UserNum,4,@content4,'" + NetCMS.Global.Current.SiteID + "')";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public int update_sysUser(int iPoint2, int gPoint2, Decimal Money3, int cPoint2, int aPoint2, string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "update " + Pre + "sys_User set iPoint='" + iPoint2 + "',gPoint='" + gPoint2 + "',ParmConstrNum=" + Money3 + ",cPoint='" + cPoint2 + "',aPoint='" + aPoint2 + "' where UserNum=@UserNum";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public string sel_newsClass(string ClassID)
{
#region
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string _tb = Pre + "news";
string Sql = "select DataLib from " + Pre + "news_Class where ClassID=@ClassID";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (dt != null)
{
if (dt.Rows.Count > 0) { _tb = dt.Rows[0]["DataLib"].ToString(); }
dt.Clear(); dt.Dispose();
}
return _tb;
#endregion
}
#endregion
#region Constr_Pay.aspx
public int add_userConstrPay(string UserNum1, int ParmConstrNums, DateTime payTime, string constrPayID)
{
#region
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@userNum", SqlDbType.NVarChar, 12);
param[0].Value = UserNum1;
param[1] = new SqlParameter("@ParmConstrNums", SqlDbType.Int, 4);
param[1].Value = ParmConstrNums;
param[2] = new SqlParameter("@payTime", SqlDbType.DateTime, 8);
param[2].Value = payTime;
param[3] = new SqlParameter("@constrPayID", SqlDbType.NVarChar, 12);
param[3].Value = constrPayID;
string Sql = "insert into " + Pre + "user_constrPay(userNum,Money,payTime,constrPayID,SiteID,PayAdmin) values(@userNum,@ParmConstrNums,@payTime,@constrPayID,'" + NetCMS.Global.Current.SiteID + "','" + NetCMS.Global.Current.UserName + "')";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region Constr_SetParam.aspx
public int add_sysParmConstr(string PCId, string ConstrPayName, string gpoint, string ipoint, int moneys1, string Gunit)
{
#region
string CSql = "select count(id) from " + Pre + "sys_ParmConstr where ConstrPayName='" + ConstrPayName + "'";
int CCount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, CSql, null));
if (CCount > 0)
{
return 0;
}
SqlParameter[] param = new SqlParameter[6];
param[0] = new SqlParameter("@PCId", SqlDbType.NVarChar, 18);
param[0].Value = PCId;
param[1] = new SqlParameter("@ConstrPayName", SqlDbType.NVarChar, 20);
param[1].Value = ConstrPayName;
param[2] = new SqlParameter("@gpoint", SqlDbType.Int, 4);
param[2].Value = gpoint;
param[3] = new SqlParameter("@ipoint", SqlDbType.Int, 4);
param[3].Value = ipoint;
param[4] = new SqlParameter("@moneys1", SqlDbType.Int, 4);
param[4].Value = moneys1;
param[5] = new SqlParameter("@Gunit", SqlDbType.NVarChar, 10);
param[5].Value = Gunit;
string Sql = "insert into " + Pre + "sys_ParmConstr(PCId,ConstrPayName,gPoint,iPoint,money,Gunit,SiteID) values(@PCId,@ConstrPayName,@gpoint,@ipoint,@moneys1,@Gunit,'" + NetCMS.Global.Current.SiteID + "')";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region Constr_SetParamup.aspx
public int update_sysParmConstr(string ConstrPayName, string gpoint, string ipoint, int moneys1, string Gunit, string PCIdup)
{
#region
SqlParameter[] param = new SqlParameter[6];
param[0] = new SqlParameter("@PCId", SqlDbType.NVarChar, 18);
param[0].Value = PCIdup;
param[1] = new SqlParameter("@ConstrPayName", SqlDbType.NVarChar, 20);
param[1].Value = ConstrPayName;
param[2] = new SqlParameter("@gpoint", SqlDbType.Int, 4);
param[2].Value = gpoint;
param[3] = new SqlParameter("@ipoint", SqlDbType.Int, 4);
param[3].Value = ipoint;
param[4] = new SqlParameter("@moneys1", SqlDbType.Int, 4);
param[4].Value = moneys1;
param[5] = new SqlParameter("@Gunit", SqlDbType.NVarChar, 10);
param[5].Value = Gunit;
string Sql = "update " + Pre + "sys_ParmConstr set ConstrPayName=@ConstrPayName,gPoint=@gPoint,iPoint=@iPoint,money=@moneys1,Gunit=@Gunit where PCId=@PCId";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#endregion
#region Constr_Stat.aspx
public int sel_userConstrCount(string UserNum, int m1)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "select count(Id) from " + Pre + "User_Constr where UserNum=@UserNum and Month(creatTime)= '" + m1 + "' and substring(Contrflg,3,1) = '1' and isadmidel=0 and ispass=0";
return (int)DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
}
#endregion
#endregion
}
} | 0575kaoshicj | trunk/NetCMS.DALSQLServer/Constr.cs | C# | asf20 | 30,730 |
//======================================================
//== (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.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Help : DbBase, IHelp
{
private string cnstr;
public Help()
{
cnstr = DBConfig.HelpConString;
}
public int Str_CheckSql(string Str_HelpID)
{
SqlParameter param = new SqlParameter("@HelpID",Str_HelpID);
string Sql = "Select count(HelpID) From " + Pre + "Sys_Help Where HelpID=@HelpID";
return (int)DbHelper.ExecuteScalar(cnstr, CommandType.Text, Sql, param);
}
public int Str_InsSql(string Str_HelpID, string Str_CnHelpTitle, string Str_CnHelpContent)
{
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@HelpID",SqlDbType.NVarChar,30);
param[0].Value = Str_HelpID;
param[1] = new SqlParameter("@TitleCN", SqlDbType.NVarChar, 80);
param[1].Value = Str_CnHelpTitle;
param[2] = new SqlParameter("@ContentCN", SqlDbType.NText);
param[2].Value = Str_CnHelpContent;
string Sql = "Insert Into " + Pre + "Sys_Help(HelpID,TitleCN,ContentCN) Values(@HelpID,@TitleCN,@ContentCN)";
return DbHelper.ExecuteNonQuery(cnstr, CommandType.Text, Sql, param);
}
public int updatehelp(int Str_HelpID, string Str_CnHelpTitle, string Str_CnHelpContent)
{
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@HelpID", SqlDbType.NVarChar, 30);
param[0].Value = Str_HelpID;
param[1] = new SqlParameter("@TitleCN", SqlDbType.NVarChar, 80);
param[1].Value = Str_CnHelpTitle;
param[2] = new SqlParameter("@ContentCN", SqlDbType.NText);
param[2].Value = Str_CnHelpContent;
string Sql = "update " + Pre + "Sys_Help set TitleCN=@TitleCN,ContentCN=@ContentCN where id=@HelpID";
return DbHelper.ExecuteNonQuery(cnstr, CommandType.Text, Sql, param);
}
public int Str_DelSql(int ID)
{
string Sql = "Delete From " + Pre + "Sys_Help Where id=" + ID;
return DbHelper.ExecuteNonQuery(cnstr, CommandType.Text, Sql, null);
}
public DataTable GetPage(string _helpID, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
string QSQL = "";
SqlParameter param = null;
if (_helpID != "" && _helpID != null)
{
param = new SqlParameter("@HelpID", _helpID);
QSQL = " and HelpID=@HelpID";
}
string AllFields = "id,HelpID,TitleCN";
string Condition = "" + Pre + "Sys_Help where 1=1 " + QSQL + "";
string IndexField = "id";
string OrderFields = "order by id desc";
return DbHelper.ExecutePage(cnstr, AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, param);
}
public DataTable getHelpID(int ID)
{
string Sql = "select ID,HelpID,TitleCN,ContentCN from " + Pre + "Sys_Help where ID=" + ID + "";
return DbHelper.ExecuteTable(cnstr, CommandType.Text, Sql, null);
}
public DataTable getHelpID1(string HelpID)
{
SqlParameter param = new SqlParameter("@HelpID", HelpID);
string Sql = "select ID,HelpID,TitleCN,ContentCN from " + Pre + "Sys_Help where HelpID=@HelpID";
return DbHelper.ExecuteTable(cnstr, CommandType.Text, Sql, param);
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Help.cs | C# | asf20 | 4,216 |
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using NetCMS.Model;
using NetCMS.DALFactory;
using NetCMS.Global;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class NewsJS : DbBase, INewsJS
{
public IList<NewsJSInfo> GetPage(int PageIndex, int PageSize, out int RecordCount, out int PageCount, int JsType)
{
IList<NewsJSInfo> njs = new List<NewsJSInfo>();
string SqlWhere = Pre + "news_JS a left join " + Pre + "News_JSFile b on a.jsid=b.jsid where a.SiteID='" + Current.SiteID + "'";
if (JsType >= 0)
SqlWhere += " and jsType=" + JsType;
IDataReader rd = DbHelper.ExecuteReaderPage(DBConfig.CmsConString, "a.id,a.JSName,a.jsType,a.CreatTime,a.jsNum,count(b.id)", SqlWhere, "a.id", "group by a.id,a.jsType,a.JSName,a.jsNum,a.CreatTime", "order by a.id desc", PageIndex, PageSize, out RecordCount, out PageCount, null);
while (rd.Read())
{
NewsJSInfo info = new NewsJSInfo();
info.Id = rd.GetInt32(0);
info.JSName = rd.GetString(1);
info.jsType = (int)rd.GetByte(2);
info.CreatTime = rd.GetDateTime(3);
info.jsNum = rd.GetInt32(4);
info.ActualNum = rd.GetInt32(5);
njs.Add(info);
}
rd.Close();
return njs;
}
public void Delete(string id)
{
if (id.IndexOf("'") >= 0)
throw new Exception("编号中有非法字符'");
string Sql = "delete from " + Pre + "news_JS where SiteID='" + Current.SiteID + "' and id in (" + id + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public DataTable GetJSFilePage(int PageIndex, int PageSize, out int RecordCount, out int PageCount, int id)
{
return DbHelper.ExecutePage("a.ID,a.Njf_title", Pre + "News_JSFile a inner join " + Pre + "News_JS b on a.JsID=b.JsID where a.SiteID='" + Current.SiteID + "' and b.id=" + id, "a.id", "order by a.id", PageIndex, PageSize, out RecordCount, out PageCount, null);
}
public void RemoveNews(int id)
{
string Sql = "delete from " + Pre + "News_JSFile where SiteID='" + Current.SiteID + "' and ID=" + id;
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public NewsJSInfo GetSingle(int id)
{
string Sql = "select JsID,jsType,JSName,JsTempletID,jsNum,jsLenTitle,jsLenNavi,jsLenContent,jsContent,SiteID,jsColsNum,jsfilename,jssavepath from " + Pre + "News_JS where SiteID='" + Current.SiteID + "' and id=" + id;
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, null);
if (rd.Read())
{
NewsJSInfo js = new NewsJSInfo();
js.Id = id;
js.JsID = rd.GetString(0);
js.jsType = (int)rd.GetByte(1);
js.JSName = rd.GetString(2);
js.JsTempletID = rd.GetString(3);
if (rd.IsDBNull(4)) { js.jsNum = 0; } else { js.jsNum = rd.GetInt32(4); }
if (rd.IsDBNull(5)) { js.jsLenTitle = 0; } else { js.jsLenTitle = rd.GetInt32(5); }
if (rd.IsDBNull(6)) { js.jsLenNavi = 0; } else { js.jsLenNavi = rd.GetInt32(6); }
if (rd.IsDBNull(7)) { js.jsLenContent = 0; } else { js.jsLenContent = rd.GetInt32(7); }
if (rd.IsDBNull(8)) { js.jsContent = ""; } else { js.jsContent = rd.GetString(8); }
js.SiteID = rd.GetString(9);
if (rd.IsDBNull(10)) { js.jsColsNum = 0; } else { js.jsColsNum = rd.GetInt32(10); }
js.jsfilename = rd.GetString(11);
js.jssavepath = rd.GetString(12);
rd.Close();
return js;
}
else
{
if (!rd.IsClosed)
rd.Close();
throw new Exception("未找到相关的JS记录!");
}
}
public void Update(NewsJSInfo info)
{
Edit(info);
}
public string Add(NewsJSInfo info)
{
return Edit(info);
}
private string Edit(NewsJSInfo info)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
try
{
string RetVal = info.JsID;
string Sql = "select JSName,jsfilename,jssavepath from " + Pre + "News_JS where SiteID='" + Current.SiteID + "' and (JSName=@JSName or (jsfilename=@jsfilename and jssavepath=@jssavepath))";
if (info.Id > 0)
Sql += " and Id<>" + info.Id;
SqlParameter[] parm = new SqlParameter[3];
parm[0] = new SqlParameter("@JSName", SqlDbType.NVarChar, 50);
parm[0].Value = info.JSName;
parm[1] = new SqlParameter("@jsfilename", SqlDbType.NVarChar, 50);
parm[1].Value = info.jsfilename;
parm[2] = new SqlParameter("@jssavepath", SqlDbType.NVarChar, 200);
parm[2].Value = info.jssavepath;
IDataReader rd = DbHelper.ExecuteReader(cn, CommandType.Text, Sql, parm);
if (rd.Read())
{
string nm = rd.GetString(0);
rd.Close();
if (nm.Equals(info.JSName))
{
rd.Close();
throw new Exception("JS名称不能重复,该名称已经存在!");
}
else
{
rd.Close();
throw new Exception("已存在相同的路径和文件名的JS!");
}
}
if (!rd.IsClosed)
rd.Close();
if (info.Id > 0)
{
Sql = "update " + Pre + "News_JS set JSName=@JSName,JsTempletID=@JsTempletID,jsNum=@jsNum,jsLenTitle=@jsLenTitle,jsLenNavi=@jsLenNavi,";
Sql += "jsLenContent=@jsLenContent,jsContent=@jsContent,jsColsNum=@jsColsNum,jsfilename=@jsfilename,jssavepath=@jssavepath where SiteID=@SiteID and Id=" + info.Id;
}
else
{
string jsid = NetCMS.Common.Rand.Number(12);
while (Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, "select count(*) from " + Pre + "News_JS where JsID='" + jsid + "'", null)) > 0)
{
jsid = NetCMS.Common.Rand.Number(12, true);
}
RetVal = jsid;
Sql = "insert into " + Pre + "News_JS (JsID,jsType,JSName,JsTempletID,jsNum,jsLenTitle,jsLenNavi,jsLenContent,jsContent,SiteID,jsColsNum,CreatTime,jsfilename,jssavepath) ";
Sql += "values ('" + jsid + "'," + info.jsType + ",@JSName,@JsTempletID,@jsNum,@jsLenTitle,@jsLenNavi,@jsLenContent,@jsContent,@SiteID,@jsColsNum,'" + DateTime.Now + "',@jsfilename,@jssavepath)";
}
SqlParameter[] param = new SqlParameter[11];
param[0] = new SqlParameter("@JSName", SqlDbType.NVarChar, 50);
param[0].Value = info.JSName;
param[1] = new SqlParameter("@JsTempletID", SqlDbType.NVarChar, 12);
param[1].Value = info.JsTempletID;
param[2] = new SqlParameter("@jsNum", SqlDbType.Int);
param[2].Value = info.jsNum;
param[3] = new SqlParameter("@jsLenTitle", SqlDbType.Int);
param[3].Value = info.jsLenTitle < 0 ? DBNull.Value : (object)info.jsLenTitle;
param[4] = new SqlParameter("@jsLenNavi", SqlDbType.Int);
param[4].Value = info.jsLenNavi < 0 ? DBNull.Value : (object)info.jsLenNavi;
param[5] = new SqlParameter("@jsLenContent", SqlDbType.Int);
param[5].Value = info.jsLenContent < 0 ? DBNull.Value : (object)info.jsLenContent;
param[6] = new SqlParameter("@jsContent", SqlDbType.NText);
param[6].Value = info.jsContent.Equals("") ? DBNull.Value : (object)info.jsContent;
param[7] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[7].Value = Current.SiteID;
param[8] = new SqlParameter("@jsColsNum", SqlDbType.Int);
param[8].Value = info.jsColsNum < 0 ? DBNull.Value : (object)info.jsColsNum;
param[9] = new SqlParameter("@jsfilename", SqlDbType.NVarChar, 50);
param[9].Value = info.jsfilename;
param[10] = new SqlParameter("@jssavepath", SqlDbType.NVarChar, 200);
param[10].Value = info.jssavepath;
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, param);
return RetVal;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
string INewsJS.GetJsTmpContent(string jstmpid)
{
string Sql = "select JSTContent from "+ Pre +"news_JSTemplet where TempletID=@TempletID";
SqlParameter param = new SqlParameter("@TempletID", jstmpid);
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
DataTable INewsJS.GetJSFiles(string jsid)
{
string Sql = "select NewsId from " + Pre + "news_JSFile where JsID=@JsID";
SqlParameter param = new SqlParameter("@JsID", jsid);
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/NewsJS.cs | C# | asf20 | 10,346 |
//======================================================
//== (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.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class NTLog : DbBase, INTLog
{
public int Add(int IsManager, string Title, string Content, string IP, string UserNum, string SiteID)
{
string SQL = "Insert Into " + Pre + "sys_logs(title,content,creatTime,IP,usernum,SiteID,ismanage) Values(@title,@content,@creatTime,@IP,@usernum,@SiteID,@ismanage)";
SqlParameter[] parm = new SqlParameter[7];
parm[0] = new SqlParameter("@title", SqlDbType.NVarChar, 50);
parm[0].Value = Title;
parm[1] = new SqlParameter("@content", SqlDbType.NText);
parm[1].Value = Content;
parm[2] = new SqlParameter("@creatTime", SqlDbType.DateTime);
parm[2].Value = DateTime.Now;
parm[3] = new SqlParameter("@IP", SqlDbType.NVarChar, 16);
parm[3].Value = IP;
parm[4] = new SqlParameter("@usernum", SqlDbType.NVarChar, 15);
parm[4].Value = UserNum;
parm[5] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
parm[5].Value = SiteID;
parm[6] = new SqlParameter("@ismanage", SqlDbType.NVarChar, 50);
parm[6].Value = IsManager;
return DbHelper.ExecuteNonQuery(CommandType.Text, SQL, parm);
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/NTLog.cs | C# | asf20 | 1,762 |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过下列属性集
// 控制。更改这些属性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("NetCMS.DALSQLServer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("NetCMS Inc.")]
[assembly: AssemblyProduct("NetCMS.DALSQLServer")]
[assembly: AssemblyCopyright("版权所有 (C) NetCMS Inc. 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 属性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("b1680fd0-5559-4ebd-bfa5-2f484cbf3b51")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 内部版本号
// 修订号
//
// 可以指定所有这些值,也可以使用“修订号”和“内部版本号”的默认值,
// 方法是按如下所示使用“*”:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Properties/AssemblyInfo.cs | C# | asf20 | 1,355 |
//======================================================
//== (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 NetCMS.Common;
using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Stat : DbBase, IStat
{
string isDataBase = NetCMS.Config.UIConfig.indeData;
public DataTable sel()
{
string Sql = "select * from " + Pre + "stat_Param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return rdr;
}
public string sel_statInfoById(string id)
{
SqlParameter param = new SqlParameter("@id", id);
string Sql = "Select classname From " + Pre + "stat_class where statid=@id and SiteID='" + NetCMS.Global.Current.SiteID + "'";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
public bool del_statSql(string ID,int flag)
{
#region
SqlParameter param = new SqlParameter("@ID", ID);
string Sql = null;
if (flag == 0)
{
Sql = "Delete From " + Pre + "stat_class where statid=@ID and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "Delete From " + Pre + "stat_Info where classid = @ID and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "Delete From " + Pre + "stat_Content where classid = @ID and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
int i = DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
if (i == 0)
{
return false;
}
return true;
#endregion
}
public void Str_InSql(NetCMS.Model.StatParamInfo sp)
{
string Sql = "Update " + Pre + "stat_Param Set SystemName=@Str_SystemName,SystemNameE=@Str_SystemNameE,ipCheck=@Str_ipCheck,ipTime=@Str_ipTime,isOnlinestat=@Str_isOnlinestat,pageNum=@Str_pageNum,cookies=@Str_cookies,pointNum=@Str_pointNum,SiteID=@SiteID";
SqlParameter[] parm = GetStatParamInfo(sp);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
private SqlParameter[] GetStatParamInfo(NetCMS.Model.StatParamInfo sp)
{
SqlParameter[] parm = new SqlParameter[9];
parm[0] = new SqlParameter("@Str_SystemName", SqlDbType.NVarChar, 100);
parm[0].Value = sp.SystemName;
parm[1] = new SqlParameter("@Str_SystemNameE", SqlDbType.NVarChar, 150);
parm[1].Value = sp.SystemNameE;
parm[2] = new SqlParameter("@Str_ipCheck", SqlDbType.TinyInt, 1);
parm[2].Value = sp.ipCheck;
parm[3] = new SqlParameter("@Str_ipTime", SqlDbType.Int, 4);
parm[3].Value = sp.ipTime;
parm[4] = new SqlParameter("@Str_isOnlinestat", SqlDbType.TinyInt, 1);
parm[4].Value = sp.isOnlinestat;
parm[5] = new SqlParameter("@Str_pageNum", SqlDbType.Int, 4);
parm[5].Value = sp.pageNum;
parm[6] = new SqlParameter("@Str_cookies", SqlDbType.NVarChar, 30);
parm[6].Value = sp.cookies;
parm[7] = new SqlParameter("@Str_pointNum", SqlDbType.Int, 4);
parm[7].Value = sp.pointNum;
parm[8] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
parm[8].Value = sp.SiteID;
return parm;
}
public int Stat_Sql()
{
int intnum = 20;
string Sql = "Select pageNum From " + Pre + "stat_Param where SiteID='" + NetCMS.Global.Current.SiteID + "'";//取得参数设置中的每页显示数
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
intnum = int.Parse(dt.Rows[0]["pageNum"].ToString());
}
dt.Clear(); dt.Dispose();
}
return intnum;
}
public void del_statInfoStr(string CheckboxArray,int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "Delete From " + Pre + "stat_class where statid in ('" + CheckboxArray + "') and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "Delete From " + Pre + "stat_Info where classid in ('" + CheckboxArray + "') and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "Delete From " + Pre + "stat_Content where classid in ('" + CheckboxArray + "') and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
public bool del_statInfo(int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "Delete From " + Pre + "stat_class where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "Delete From " + Pre + "stat_Info where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "Delete From " + Pre + "stat_Content where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
int i = DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
if (i == 0)
{
return false;
}
return true;
#endregion
}
public int sel_statInfo(string Str_statid,int flag)
{
#region
SqlParameter param = new SqlParameter("@statid", Str_statid);
string Sql = null;
if (flag == 0)
{
Sql = "Select count(statid) From " + Pre + "stat_class where statid = @statid and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "Select count(classname) From " + Pre + "stat_class Where classname=@statid and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
return (int)DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
#endregion
}
public int insert_statInfo(string Str_statid, string Str_Classname, string SiteID)
{
string Sql = "Insert into " + Pre + "stat_class (statid,classname,SiteID) Values('" + Str_statid + "','" + Str_Classname + "','" + SiteID + "')";
return DbHelper.ExecuteNonQuery( CommandType.Text, Sql, null);
}
public int Str_UpdateSql(string Str_ClassnameE, string id)
{
SqlParameter[] parm = new SqlParameter[2];
parm[0] = new SqlParameter("@Str_ClassnameE", SqlDbType.NVarChar,20);
parm[0].Value = Str_ClassnameE;
parm[1] = new SqlParameter("@statid", SqlDbType.NVarChar, 12);
parm[1].Value = id;
string Sql = "Update " + Pre + "stat_class set classname=@Str_ClassnameE where statid=@statid and SiteID='" + NetCMS.Global.Current.SiteID + "'";
return DbHelper.ExecuteNonQuery( CommandType.Text, Sql, parm);
}
public int del_Stat(int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "Delete From " + Pre + "stat_Info where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
Sql = "Delete From " + Pre + "stat_content where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
public DataTable sel_Stat(string viewid, string SiteID,int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "select vtop,starttime,vhigh,vhightime,today,yesterday from " + Pre + "stat_Content where classid='" + viewid + "' and SiteID='" + SiteID + "'";
}
else if (flag == 1)
{
Sql = "select vhour,count(id) as allhour from " + Pre + "stat_Info where classid='" + viewid + "' and SiteID='" + SiteID + "' group by vhour";
}
else if (flag == 2)
{
Sql = "Select top 1 vtime from " + Pre + "stat_Info where classid='" + viewid + "' and SiteID='" + SiteID + "' order by id";
}
else if (flag == 3)
{
Sql = "select vday,count(id) as allday from " + Pre + "stat_Info where classid='" + viewid + "' and SiteID='" + SiteID + "' group by vday";
}
else if (flag == 4)
{
Sql = "Select top 1 vtime as vfirst from " + Pre + "stat_Info where classid='" + viewid + "' and SiteID='" + SiteID + "' order by vtime";
}
else if (flag == 5)
{
Sql = "select vweek,count(id) as allweek from " + Pre + "stat_Info where classid='" + viewid + "' and SiteID='" + SiteID + "' group by vweek";
}
else if (flag == 6)
{
Sql = "select vmonth,count(id) as allmonth from " + Pre + "stat_Info where classid='" + viewid + "' and SiteID='" + SiteID + "' group by vmonth";
}
else if (flag == 7)
{
Sql = "select vyear,count(id) as allyear from " + Pre + "stat_Info where classid='" + viewid + "' and SiteID='" + SiteID + "' group by vyear order by vyear DESC";
}
else if (flag == 8)
{
Sql = "select vpage,count(id) as allpage from " + Pre + "stat_Info where classid='" + viewid + "' and SiteID='" + SiteID + "' group by vpage order by count(id) DESC";
}
else if (flag == 9)
{
Sql = "select vip,count(id) as allip from " + Pre + "stat_Info where classid='" + viewid + "' and SiteID='" + SiteID + "' group by vip order by count(id) DESC";
}
else if (flag == 10)
{
Sql = "select vwidth,count(id) as allwidth from " + Pre + "stat_Info where vwidth<>0 and classid='" + viewid + "' and SiteID='" + SiteID + "' group by vwidth order by vwidth DESC";
}
else if (flag == 11)
{
Sql = "select vwhere,count(id) as allwhere from " + Pre + "stat_Info where classid='" + viewid + "' and SiteID='" + SiteID + "' group by vwhere order by count(id) DESC";
}
else if (flag == 12)
{
Sql = "select vcome,count(id) as allcome from " + Pre + "stat_Info where classid='" + viewid + "' and SiteID='" + SiteID + "' group by vcome order by count(id) DESC";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
#endregion
}
public DataTable sel_statVip(DateTime newtime, string viewid, string SiteID)
{
string Sql ="select vip from " + Pre + "stat_Info where vtime >='" + newtime + "' and classid='" + viewid + "' and SiteID='" + SiteID + "' group by vip";
return DbHelper.ExecuteTable( CommandType.Text, Sql, null);
}
public DataTable sel_yearMonth(int vyear, string viewid, string SiteID,int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "Select vyear from " + Pre + "stat_Info where vyear=" + vyear + " and classid='" + viewid + "' and SiteID='" + SiteID + "'";
}
else if (flag == 1)
{
Sql = "Select vmonth from " + Pre + "stat_Info where vmonth=" + vyear + " and classid='" + viewid + "' and SiteID='" + SiteID + "'";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
#endregion
}
public DataTable sel_vhourcon(int vhour, int vday, int vmonth, int vyear, string viewid, string SiteID)
{
string Sql = "Select count(id) as vhourcon from " + Pre + "stat_Info where vhour='" + vhour + "' and vday='" + vday + "' and vmonth='" + vmonth + "' and vyear='" + vyear + "' and classid='" + viewid + "' and SiteID='" + SiteID + "'";
return DbHelper.ExecuteTable( CommandType.Text, Sql, null);
}
public DataTable sel_statCount(int thehour, string vtime, string viewid, string SiteID)
{
string Sql = "Select count(id) as vhourcon from " + Pre + "stat_Info where vhour='" + thehour + "' and vtime>'" + vtime + "' and classid='" + viewid + "' and SiteID='" + SiteID + "'";
return DbHelper.ExecuteTable( CommandType.Text, Sql, null);
}
public DataTable sel_vdaycon(string strtheday, string strthetday, string viewid, string SiteID)
{
string Sql = "Select count(id) as vdaycon from " + Pre + "stat_Info where vtime>='" + strtheday + "' and vtime<='" + strthetday + "' and classid='" + viewid + "' and SiteID='" + SiteID + "'";
return DbHelper.ExecuteTable( CommandType.Text, Sql, null);
}
public DataTable sel_statById(string strdatetwelve, string viewid, string SiteID,int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "select vmonth,count(id) as allmonth from " + Pre + "stat_Info where vtime>='" + strdatetwelve + "' and classid='" + viewid + "' and SiteID='" + SiteID + "' group by vmonth";
}
else if (flag == 1)
{
Sql = "Select count(id) as howsoft from " + Pre + "stat_Info where vsoft='" + strdatetwelve + "' and classid='" + viewid + "' and SiteID='" + SiteID + "'";
}
else if (flag ==2)
{
Sql = "Select count(id) as howOS from " + Pre + "stat_Info where vOS='" + strdatetwelve + "' and classid='" + viewid + "' and SiteID='" + SiteID + "'";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
#endregion
}
#region 前台调用
public DataTable sel_StatParamInfo()
{
string Sql = "select * from " + Pre + "stat_Param";
return DbHelper.ExecuteTable( CommandType.Text, Sql, null);
}
public DataTable sel_Vip(DateTime newtime)
{
SqlParameter param = new SqlParameter("@newtime", newtime);
string Sql = "select vip from " + Pre + "stat_Info where vtime >=@newtime group by vip";
return DbHelper.ExecuteTable( CommandType.Text, Sql, param);
}
public void Add(StatInfo info)
{
string Sql = "insert into " + Pre + "stat_Info(vyear,vmonth,vday,vhour,vtime,vweek,vip,vwhere,vwheref,vcome,vpage,vsoft,vOS,vwidth,classid,SiteID) values(@year,@month,@day,@hour,@time,@week,@ip,@country,@city,@come,@page,@soft,@Os,@width,@statid,@SiteID)";
SqlParameter[] parm = Getstat_Info(info);
DbHelper.ExecuteNonQuery( CommandType.Text, Sql, parm);
}
private SqlParameter[] Getstat_Info(StatInfo info)
{
#region
SqlParameter[] parm = new SqlParameter[16];
parm[0] = new SqlParameter("@year", SqlDbType.Int, 4);
parm[0].Value = info.vyear;
parm[1] = new SqlParameter("@month", SqlDbType.Int, 4);
parm[1].Value = info.vmonth;
parm[2] = new SqlParameter("@day", SqlDbType.Int, 4);
parm[2].Value = info.vday;
parm[3] = new SqlParameter("@hour", SqlDbType.Int, 4);
parm[3].Value = info.vhour;
parm[4] = new SqlParameter("@time", SqlDbType.NVarChar, 4);
parm[4].Value = info.vtime;
parm[5] = new SqlParameter("@week", SqlDbType.Int, 4);
parm[5].Value = info.vweek;
parm[6] = new SqlParameter("@ip", SqlDbType.NVarChar, 50);
parm[6].Value = info.vip;
parm[7] = new SqlParameter("@country", SqlDbType.NVarChar, 250);
parm[7].Value = info.vwhere;
parm[8] = new SqlParameter("@city", SqlDbType.NVarChar, 50);
parm[8].Value = info.vwheref;
parm[9] = new SqlParameter("@come", SqlDbType.NVarChar, 250);
parm[9].Value = info.vcome;
parm[10] = new SqlParameter("@page", SqlDbType.NVarChar, 250);
parm[10].Value = info.vpage;
parm[11] = new SqlParameter("@soft", SqlDbType.NVarChar, 50);
parm[11].Value = info.vsoft;
parm[12] = new SqlParameter("@Os", SqlDbType.NVarChar, 50);
parm[12].Value = info.vOS;
parm[13] = new SqlParameter("@width", SqlDbType.Int, 4);
parm[13].Value = info.vwidth;
parm[14] = new SqlParameter("@statid", SqlDbType.NVarChar, 12);
parm[14].Value = info.classid;
parm[15] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
parm[15].Value = info.SiteID;
return parm;
#endregion
}
public DataTable sel_stat_content(string statidz)
{
SqlParameter param = new SqlParameter("@statidz", statidz);
string Sql = "select * from " + Pre + "stat_Content where classid=@statidz";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
public void add_statContent(string vdatee, string starttimee, string highttimee, string statidz, string SiteID)
{
string Sql = "Insert into " + Pre + "stat_Content(today,yesterday,vdate,vtop,starttime,vhigh,vhightime,classid,SiteID) Values(1,0,'" + vdatee + "',1,'" + starttimee + "',1,'" + highttimee + "','" + statidz + "','" + SiteID + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public void Update(int today, int yesterday, string content_data, int all, int heigh, string heightime, string strclassid, string siteID, string strclassids)
{
string Sql = "Update " + Pre + "stat_Content set today=" + today + ",yesterday=" + yesterday + ",vdate='" + content_data + "',vtop=" + all + ",vhigh=" + heigh + ",vhightime='" + heightime + "',classid='" + strclassid + "',SiteID='" + siteID + "' where classid='" + strclassid + "'";
}
#endregion
}
} | 0575kaoshicj | trunk/NetCMS.DALSQLServer/Stat.cs | C# | asf20 | 19,529 |
using System;
using System.Data;
using System.Data.SqlClient;
using NetCMS.DALFactory;
using NetCMS.Model;
using System.Text.RegularExpressions;
using System.Text;
using System.Collections.Generic;
using System.Reflection;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Publish : DbBase, IPublish
{
public IDataReader GetSysParam()
{
string Sql = "select top 1 LinkType,SiteDomain,SaveIndexPage,SiteName,CopyRight,ReadType from " + Pre + "sys_param order by id desc";
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
public IList<PubClassInfo> GetClassList()
{
IList<PubClassInfo> list = new List<PubClassInfo>();
string Sql = "select Id,ClassID,ClassCName,ClassEName,ParentID,IsURL,URLaddress,ClassTemplet,SavePath,SaveClassframe,ClassSaveRule";
Sql += ",ClassIndexRule,SiteID,NaviPIC,NaviContent,MetaKeywords,MetaDescript,isDelPoint,Gpoint,iPoint,GroupNumber,NaviShowtf,NaviPosition,NewsPosition,isPage,pageContent";
Sql += " from " + Pre + "news_Class where isRecyle=0 and isLock=0";
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, null);
while (rd.Read())
{
PubClassInfo info = new PubClassInfo();
info.Id = (int)rd["Id"];
info.ClassID = rd["ClassID"].ToString();
if (rd["ClassCName"] != DBNull.Value) info.ClassCName = rd["ClassCName"].ToString();
if (rd["ClassEName"] != DBNull.Value) info.ClassEName = rd["ClassEName"].ToString();
if (rd["ParentID"] != DBNull.Value) info.ParentID = rd["ParentID"].ToString();
if (rd["IsURL"] != DBNull.Value) info.IsURL = Convert.ToInt32(rd["IsURL"].ToString());
if (rd["URLaddress"] != DBNull.Value) info.URLaddress = rd["URLaddress"].ToString();
if (rd["ClassTemplet"] != DBNull.Value) info.ClassTemplet = rd["ClassTemplet"].ToString();
if (rd["SavePath"] != DBNull.Value) info.SavePath = rd["SavePath"].ToString();
if (rd["SaveClassframe"] != DBNull.Value) info.SaveClassframe = rd["SaveClassframe"].ToString();
if (rd["ClassSaveRule"] != DBNull.Value) info.ClassSaveRule = rd["ClassSaveRule"].ToString();
if (rd["ClassIndexRule"] != DBNull.Value) info.ClassIndexRule = rd["ClassIndexRule"].ToString();
if (rd["SiteID"] != DBNull.Value) info.SiteID = rd["SiteID"].ToString();
if (rd["NaviPIC"] != DBNull.Value) info.NaviPIC = rd["NaviPIC"].ToString();
if (rd["NaviContent"] != DBNull.Value) info.NaviContent = rd["NaviContent"].ToString();
if (rd["MetaKeywords"] != DBNull.Value) info.MetaKeywords = rd["MetaKeywords"].ToString();
if (rd["MetaDescript"] != DBNull.Value) info.MetaDescript = rd["MetaDescript"].ToString();
if (rd["isDelPoint"] != DBNull.Value) info.isDelPoint = Convert.ToInt32(rd["isDelPoint"].ToString());
if (rd["Gpoint"] != DBNull.Value) info.Gpoint = Convert.ToInt32(rd["Gpoint"].ToString());
if (rd["iPoint"] != DBNull.Value) info.iPoint = Convert.ToInt32(rd["iPoint"].ToString());
if (rd["GroupNumber"] != DBNull.Value) info.GroupNumber = rd["GroupNumber"].ToString();
if (rd["NaviPosition"] != DBNull.Value) info.NaviPosition = rd["NaviPosition"].ToString();
if (rd["NewsPosition"] != DBNull.Value) info.NewsPosition = rd["NewsPosition"].ToString();
if (rd["isPage"] != DBNull.Value) info.isPage = Convert.ToInt32(rd["isPage"].ToString());
if (rd["NaviShowtf"] != DBNull.Value) info.NaviShowtf = Convert.ToInt32(rd["NaviShowtf"].ToString());
if (rd["pageContent"] != DBNull.Value) info.PageContent = rd["PageContent"].ToString();
list.Add(info);
}
rd.Close();
return list;
}
public IList<PubCHClassInfo> GetCHClassList()
{
IList<PubCHClassInfo> list = new List<PubCHClassInfo>();
string Sql = "select Id,ClassCName,ClassEName,ParentID,Templet,SavePath,FileName";
Sql += ",ChID,PicURL,NaviContent,KeyMeta,DescMeta,isDelPoint,Gpoint,iPoint,GroupNumber,ClassNavi,ContentNavi,isPage";
Sql += " from " + Pre + "sys_channelclass where isLock=0";
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, null);
while (rd.Read())
{
PubCHClassInfo info = new PubCHClassInfo();
info.Id = (int)rd["Id"];
if (rd["classCName"] != DBNull.Value) info.classCName = rd["classCName"].ToString();
if (rd["classEName"] != DBNull.Value) info.classEName = rd["classEName"].ToString();
if (rd["ParentID"] != DBNull.Value) info.ParentID = Convert.ToInt32(rd["ParentID"].ToString());
if (rd["Templet"] != DBNull.Value) info.Templet = rd["Templet"].ToString();
if (rd["SavePath"] != DBNull.Value) info.SavePath = rd["SavePath"].ToString();
if (rd["FileName"] != DBNull.Value) info.FileName = rd["FileName"].ToString();
if (rd["ChID"] != DBNull.Value) info.ChID = Convert.ToInt32(rd["ChID"].ToString());
if (rd["PicURL"] != DBNull.Value) info.PicURL = rd["PicURL"].ToString();
if (rd["NaviContent"] != DBNull.Value) info.NaviContent = rd["NaviContent"].ToString();
if (rd["KeyMeta"] != DBNull.Value) info.MetaKeywords = rd["KeyMeta"].ToString();
if (rd["DescMeta"] != DBNull.Value) info.MetaDescript = rd["DescMeta"].ToString();
if (rd["isDelPoint"] != DBNull.Value) info.isDelPoint = Convert.ToInt32(rd["isDelPoint"].ToString());
if (rd["Gpoint"] != DBNull.Value) info.Gpoint = Convert.ToInt32(rd["Gpoint"].ToString());
if (rd["iPoint"] != DBNull.Value) info.iPoint = Convert.ToInt32(rd["iPoint"].ToString());
if (rd["GroupNumber"] != DBNull.Value) info.GroupNumber = rd["GroupNumber"].ToString();
if (rd["ClassNavi"] != DBNull.Value) info.ClassNavi = rd["ClassNavi"].ToString();
if (rd["ContentNavi"] != DBNull.Value) info.ContentNavi = rd["ContentNavi"].ToString();
if (rd["isPage"] != DBNull.Value) info.isPage = Convert.ToInt32(rd["isPage"].ToString());
list.Add(info);
}
rd.Close();
return list;
}
public IList<PubSpecialInfo> GetSpecialList()
{
IList<PubSpecialInfo> list = new List<PubSpecialInfo>();
string Sql = "select Id,SpecialID,SpecialCName,specialEName,ParentID,isDelPoint,saveDirPath,SavePath,FileName,FileEXName,NaviPicURL,";
Sql += "NaviContent,SiteID,Templet,NaviPosition,Gpoint,iPoint,GroupNumber";
Sql += " from " + Pre + "news_special where isRecyle=0 and isLock=0";
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, null);
while (rd.Read())
{
PubSpecialInfo info = new PubSpecialInfo();
info.Id = (int)rd["Id"];
info.SpecialID = rd["SpecialID"].ToString();
if (rd["SpecialCName"] != DBNull.Value) info.SpecialCName = rd["SpecialCName"].ToString();
if (rd["specialEName"] != DBNull.Value) info.specialEName = rd["specialEName"].ToString();
if (rd["ParentID"] != DBNull.Value) info.ParentID = rd["ParentID"].ToString();
if (rd["isDelPoint"] != DBNull.Value) info.isDelPoint = Convert.ToInt32(rd["isDelPoint"].ToString());
if (rd["Gpoint"] != DBNull.Value) info.Gpoint = Convert.ToInt32(rd["Gpoint"].ToString());
if (rd["iPoint"] != DBNull.Value) info.iPoint = Convert.ToInt32(rd["iPoint"].ToString());
if (rd["GroupNumber"] != DBNull.Value) info.GroupNumber = rd["GroupNumber"].ToString();
if (rd["saveDirPath"] != DBNull.Value) info.saveDirPath = rd["saveDirPath"].ToString();
if (rd["SavePath"] != DBNull.Value) info.SavePath = rd["SavePath"].ToString();
if (rd["FileName"] != DBNull.Value) info.FileName = rd["FileName"].ToString();
if (rd["FileEXName"] != DBNull.Value) info.FileEXName = rd["FileEXName"].ToString();
if (rd["NaviPicURL"] != DBNull.Value) info.NaviPicURL = rd["NaviPicURL"].ToString();
if (rd["NaviContent"] != DBNull.Value) info.NaviContent = rd["NaviContent"].ToString();
if (rd["SiteID"] != DBNull.Value) info.SiteID = rd["SiteID"].ToString();
if (rd["Templet"] != DBNull.Value) info.Templet = rd["Templet"].ToString();
if (rd["NaviPosition"] != DBNull.Value) info.NaviPosition = rd["NaviPosition"].ToString();
list.Add(info);
}
rd.Close();
return list;
}
public IList<PubCHSpecialInfo> GetCHSpecialList()
{
IList<PubCHSpecialInfo> list = new List<PubCHSpecialInfo>();
string Sql = "select Id,ChID,specialCName,specialEName,ParentID,binddomain,navicontent,savePath,filename,templet,";
Sql += "islock,isRec,PicURL,OrderID,SiteID";
Sql += " from " + Pre + "sys_channelspecial where isLock=0";
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, null);
while (rd.Read())
{
PubCHSpecialInfo info = new PubCHSpecialInfo();
info.Id = (int)rd["Id"];
info.ChID = Convert.ToInt32(rd["ChID"].ToString());
if (rd["specialCName"] != DBNull.Value) info.specialCName = rd["specialCName"].ToString();
if (rd["specialEName"] != DBNull.Value) info.specialEName = rd["specialEName"].ToString();
if (rd["ParentID"] != DBNull.Value) info.ParentID = Convert.ToInt32(rd["ParentID"].ToString());
if (rd["binddomain"] != DBNull.Value) info.binddomain = rd["binddomain"].ToString();
if (rd["navicontent"] != DBNull.Value) info.navicontent = rd["navicontent"].ToString();
if (rd["savePath"] != DBNull.Value) info.savePath = rd["savePath"].ToString();
if (rd["filename"] != DBNull.Value) info.filename = rd["filename"].ToString();
if (rd["templet"] != DBNull.Value) info.templet = rd["templet"].ToString();
if (rd["islock"] != DBNull.Value) info.islock = Convert.ToInt32(rd["islock"].ToString());
if (rd["isRec"] != DBNull.Value) info.isRec = Convert.ToInt32(rd["isRec"].ToString());
if (rd["PicURL"] != DBNull.Value) info.PicURL = rd["PicURL"].ToString();
if (rd["OrderID"] != DBNull.Value) info.OrderID = Convert.ToInt32(rd["OrderID"].ToString());
if (rd["SiteID"] != DBNull.Value) info.SiteID = rd["SiteID"].ToString();
list.Add(info);
}
rd.Close();
return list;
}
public DataTable GetLastNews(int topnum, string classid)
{
SqlParameter Param = null;
string Sql = "select top " + topnum + " a.NewsTitle,a.sNewsTitle,a.URLaddress,a.Content,a.CreatTime,a.SavePath,a.FileName,a.FileEXName,";
Sql += "b.savepath as savepath1,b.SaveClassframe,b.ClassEName,b.ClassCName,b.ClassSaveRule from " + Pre + "news a," + Pre + "news_class b";
Sql += " where a.islock=0 and a.ClassID=b.ClassID and a.isRecyle=0 and b.isPage!=1 and b.islock=0";
if (classid != "0")
{
Sql += " and b.ClassID=@ClassID";
Param = new SqlParameter("@ClassID", classid);
}
Sql += " order by a.id desc";
return DbHelper.ExecuteTable(CommandType.Text, Sql, Param);
}
public DataTable GetTodayNews(string siteid, string classid)
{
string Sql = "select NewsType,NewsTitle,URLaddress,SavePath,FileName,FileEXName from " + Pre + "news where ClassID=@ClassID";
Sql += " And DateDiff(Day,[creatTime] ,Getdate()) = 0 and islock=0 and isRecyle=0 and SiteID=@SiteID order by id desc";
SqlParameter[] Param = new SqlParameter[]{
new SqlParameter("@ClassID",classid),
new SqlParameter("@SiteID",siteid)};
return DbHelper.ExecuteTable(CommandType.Text, Sql, Param);
}
public IDataReader GetSinglePageClass(string classid)
{
string Sql = "select ClassTemplet,ClassCName,SavePath,PageContent,MetaKeywords,MetaDescript from " + Pre + "news_class";
Sql += " where ClassID=@ClassID and isLock=0 and isRecyle=0 and isPage=1";
SqlParameter Param = new SqlParameter("@ClassID", classid);
return DbHelper.ExecuteReader(CommandType.Text, Sql, Param);
}
public IDataReader GetNewsSavePath(string newsid)
{
string Sql = "select a.templet,a.classid,a.datalib,a.SavePath,a.FileName,a.FileEXName,b.SavePath as SavePath1,b.SaveClassframe,a.NewsID,a.isDelPoint,a.Tags,a.NewsTitle from " + Pre + "news a, ";
Sql += Pre + "news_class b where a.classid=b.classid and a.newsid=@newsid";
SqlParameter Param = new SqlParameter("@newsid", newsid);
return DbHelper.ExecuteReader(CommandType.Text, Sql, Param);
}
public string GetSysLabelContent(string labelname)
{
string Sql = "select Label_Content from " + Pre + "sys_Label where Label_Name=@Label_Name and isBack=0 and isRecyle=0";
SqlParameter Param = new SqlParameter("@Label_Name", labelname);
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, Param));
}
/// <summary>
///从频道标签库中获取数据
/// </summary>
/// <param name="labelname"></param>
/// <returns></returns>
public string GetChannelSysLabelContent(string labelname)
{
string Sql = "select LabelContent from " + Pre + "sys_channellabel where LabelName=@LabelName and isLock=0";
SqlParameter Param = new SqlParameter("@LabelName", labelname);
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, Param));
}
public IDataReader GetFreeLabelContent(string labelname)
{
string Sql = "select LabelSQL,StyleContent from " + Pre + "sys_LabelFree where LabelName=@LabelName";
SqlParameter Param = new SqlParameter("@LabelName", labelname);
return DbHelper.ExecuteReader(CommandType.Text, Sql, Param);
}
public DataTable ExecuteSql(string sql)
{
return DbHelper.ExecuteTable(CommandType.Text, sql, null);
}
public IDataReader GetTemplatePath()
{
string Sql = "select IndexTemplet,IndexFileName,ReadNewsTemplet,ClassListTemplet,SpecialTemplet from " + Pre + "sys_param";
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
#region 选择发布选项部分
public IDataReader GetPublishSpecial(string spid, out int ncount)
{
string SqlCondition = " where isLock=0 and isRecyle=0";
if (spid != null && spid.Trim() != "")
{
SqlCondition = " where specialID in (" + spid + ")";
}
string SqlCount = "select count(id) from " + Pre + "news_special" + SqlCondition;
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
string Sql = "select specialID,Templet,SavePath,saveDirPath,FileName,FileEXName from " + Pre + "news_special" + SqlCondition;
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
public IDataReader GetPublishClass(string siteid, string classid, bool isflag, out int ncount)
{
string SqlCondition = "";
if (classid.Trim() == "")
{
if (isflag)
{
SqlCondition = " where isunHTML !=1 and isPage!=1 and isLock=0 and isRecyle=0 and IsURL=0 and SiteID='" + siteid + "'";
}
else
{
SqlCondition = " where isLock=0 and isRecyle=0 and IsURL=0 and isPage!=1 and isLock=0 and SiteID='" + siteid + "'";
}
}
else
{
SqlCondition = " where classID in (" + classid + ")";
}
string SqlCount = "select count(id) from " + Pre + "news_class" + SqlCondition;
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
string Sql = "select Datalib,classtemplet,classid,SavePath,SaveClassframe,ClassSaveRule from " + Pre + "news_class" + SqlCondition;
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
#region 发布新闻
/// <summary>
/// 选择发布所有新闻时,取得所有新闻
/// </summary>
/// <param name="strParams">页面信息字符串</param>
/// <returns>取得符合条件的所有新闻的查询结果</returns>
public IDataReader GetPublishNewsAll(out int ncount)
{
string TopParam = "";
int refreshNum = int.Parse(NetCMS.Common.Public.readparamConfig("infoNumber", "refresh"));
if (refreshNum != 0)
{
TopParam = "top " + NetCMS.Common.Public.readparamConfig("infoNumber", "refresh") + "";
}
string Sql = "select " + TopParam + " NewsID,templet,datalib,classID,SavePath,FileName,FileEXName from " + Pre + "news where isRecyle=0 and isLock=0 and isDelPoint=0 and NewsType!=2";
string SqlCount = "select count(ID) from " + Pre + "news where isRecyle=0 and isLock=0 and isDelPoint=0 and NewsType!=2";
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
if (refreshNum != 0)
{
if (refreshNum < ncount)
{
ncount = refreshNum;
}
}
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
/// <summary>
/// 选择发布最新时,取得所有新闻
/// </summary>
/// <param name="strParams">页面信息字符串</param>
/// <returns>取得符合条件的所有新闻的查询结果</returns>
public IDataReader GetPublishNewsLast(int topnum, bool unpublish, out int ncount)
{
string Sql = "select top " + topnum + " NewsID,templet,datalib,classID,SavePath,FileName,FileEXName from " + Pre + "news where isRecyle=0 and isLock=0 and isDelPoint=0 and NewsType!=2";
string SqlCount = "select count(ID) from " + Pre + "news where isRecyle=0 and isLock=0 and isDelPoint=0 and NewsType!=2";
if (unpublish)
{
Sql += " and isHtml=0";
SqlCount += " and isHtml=0";
}
Sql += " order by id desc";
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
#region 根据栏目选择发布的新闻
/// <summary>
/// 根据栏目发布新闻
/// </summary>
/// <param name="classid"></param>
/// <param name="unpublish"></param>
/// <param name="isdesc"></param>
/// <param name="condition"></param>
/// <param name="ncount"></param>
/// <returns></returns>
public IDataReader GetPublishNewsByClass(string classid, bool unpublish, bool isdesc, string condition, out int ncount)
{
string SqlCondition = " where isRecyle=0 and isLock=0 and isDelPoint=0 and NewsType!=2 and ClassID in (" + classid + ")";
string SqlOrder = "";
if (unpublish)
{
//只发布未发布的
SqlCondition += " and isHtml=0 ";
}
switch (condition)
{
#region 条件判断
case "0":
SqlOrder = " order by newsID ";
break;
case "1":
SqlOrder = " order by Click ";
break;
case "2":
SqlOrder = " order by OrderID ";
break;
case "3":
SqlOrder = " order by CreatTime ";
break;
case "4":
SqlCondition += " and substring(NewsProperty,1,1)='1'";
SqlOrder = " order by newsID ";
break;
case "5":
SqlCondition += " and substring(NewsProperty,3,1)='1'";
SqlOrder = " order by newsID ";
break;
case "6":
SqlCondition += " and substring(NewsProperty,5,1)='1'";
SqlOrder = " order by newsID ";
break;
case "7":
SqlCondition += " and substring(NewsProperty,7,1)='1'";
SqlOrder = " order by newsID ";
break;
case "8":
SqlCondition += " and substring(NewsProperty,9,1)='1'";
SqlOrder = " order by newsID ";
break;
case "9":
SqlCondition += " and substring(NewsProperty,11,1)='1'";
SqlOrder = " order by newsID ";
break;
case "10":
SqlCondition += " and substring(NewsProperty,15,1)='1'";
SqlOrder = " order by newsID ";
break;
case "11":
SqlCondition += " and author!=''";
SqlOrder = " order by newsID ";
break;
case "12":
SqlCondition += " and Souce!=''";
SqlOrder = " order by newsID ";
break;
case "13":
SqlCondition += " and tags!=''";
SqlOrder = " order by newsID ";
break;
case "14":
SqlCondition += " and newstype=1";
SqlOrder = " order by newsID ";
break;
case "15":
SqlCondition += " and isFiles=1";
SqlOrder = " order by newsID ";
break;
case "16":
SqlCondition += " and vURL!=''";
SqlOrder = " order by newsID ";
break;
case "17":
SqlCondition += " and ContentPicTF=1";
SqlOrder = " order by newsID ";
break;
case "18":
SqlCondition += " and VoteTF=1";
SqlOrder = " order by newsID ";
break;
case "19":
SqlCondition += " and (select count(b.id) from " + Pre + "api_commentary b where b.InfoID=a.newsid)>0";
SqlOrder = " order by newsID";
break;
default:
break;
#endregion 条件判断
}
if (isdesc)
{
//倒序
SqlOrder += " desc ";
}
string Sql = "select newsid,templet,datalib,classID,SavePath,FileName,FileEXName from " + Pre + "news a " + SqlCondition + SqlOrder;
string SqlCount = "select count(a.ID) from " + Pre + "news a " + SqlCondition;
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
#endregion 根据栏目选择发布的新闻
/// <summary>
/// 选择按照日期发布时,取得所有新闻
/// </summary>
/// <param name="starttime"></param>
/// <param name="endtime"></param>
/// <param name="ncount"></param>
/// <returns></returns>
public IDataReader GetPublishNewsByTime(DateTime starttime, DateTime endtime, out int ncount)
{
string Sql = "select newsID,templet,datalib,classID,SavePath,FileName,FileEXName from " + Pre + "news where creattime between '" + starttime + "' and '" + endtime + "' and isRecyle=0 and isLock=0 and isDelPoint=0 and NewsType!=2";
string SqlCount = "select count(ID) from " + Pre + "news where creattime between '" + starttime + "' and '" + endtime + "' and isRecyle=0 and isLock=0 and isDelPoint=0 and NewsType!=2";
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
/// <summary>
/// 选择按照ID发布时,取得所有新闻
/// </summary>
/// <param name="minid"></param>
/// <param name="maxid"></param>
/// <param name="ncount"></param>
/// <returns></returns>
public IDataReader GetPublishNewsByID(int minid, int maxid, out int ncount)
{
string Sql = "select newsid,templet,datalib,classID,SavePath,FileName,FileEXName from " + Pre + "news where isRecyle=0 and isLock=0 and isDelPoint=0 and NewsType!=2 and id between " + minid + " and " + maxid;
string SqlCount = "select count(id) from " + Pre + "news where isRecyle=0 and isLock=0 and isDelPoint=0 and NewsType!=2 and id between " + minid + " and " + maxid;
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
#endregion 发布新闻
#endregion 选择发布选项部分
public IDataReader GetJsPath(string jsid)
{
string Sql = "Select [jssavepath],[jsfilename] From [" + Pre + "news_js] Where [JsID]=@JsID";
SqlParameter Param = new SqlParameter("@JsID", jsid);
return DbHelper.ExecuteReader(CommandType.Text, Sql, Param);
}
public DataTable GetSysUser(int topnum)
{
string Sql = "Select Top " + topnum + " [UserName],[RegTime] From [" + Pre + "sys_User] Where [isLock]=0 Order By [RegTime] Desc";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public DataTable GetApiComm(int LoopNumber)
{
string Sql = "Select top " + LoopNumber + " [InfoID],[Commid],[Content],[creatTime],[DataLib] From [" + Pre + "API_commentary] Where [isRecyle]=0 And [islock]=0 And [isCheck]=0 Order By [creatTime] Desc";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public string GetNewsTag(string newsid)
{
string Sql = "Select [Tags] From [" + Pre + "News] Where [NewsID]=@NewsID";
SqlParameter Param = new SqlParameter("@NewsID", newsid);
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, Param));
}
public void UpdateNewsIsHtml(string tablename, string ishtml, string idfield, IList<string> succeedlist)
{
SqlParameter[] sqlParams = new SqlParameter[4];
sqlParams[0] = new SqlParameter("@tableName", SqlDbType.VarChar, 30);
sqlParams[0].Value = tablename;
sqlParams[1] = new SqlParameter("@filedname", SqlDbType.VarChar, 30);
sqlParams[1].Value = ishtml;
sqlParams[2] = new SqlParameter("@idtype", SqlDbType.VarChar, 30);
sqlParams[2].Value = idfield;
for (int i = 0; i < succeedlist.Count; i++)
{
sqlParams[3] = new SqlParameter("@newsID", SqlDbType.VarChar, 12);
sqlParams[3].Value = succeedlist[i];
DbHelper.ExecuteNonQuery(CommandType.StoredProcedure, Pre + "publish_updateishtml", sqlParams);
}
}
public void UpdateCHNewsIsHtml(string tablename, string ishtml, string idfield, IList<string> succeedlist)
{
SqlParameter[] sqlParams = new SqlParameter[4];
sqlParams[0] = new SqlParameter("@tableName", SqlDbType.VarChar, 30);
sqlParams[0].Value = tablename;
sqlParams[1] = new SqlParameter("@filedname", SqlDbType.VarChar, 30);
sqlParams[1].Value = ishtml;
sqlParams[2] = new SqlParameter("@idtype", SqlDbType.VarChar, 30);
sqlParams[2].Value = idfield;
for (int i = 0; i < succeedlist.Count; i++)
{
sqlParams[3] = new SqlParameter("@ID", SqlDbType.Int, 4);
sqlParams[3].Value = int.Parse(succeedlist[i]);
DbHelper.ExecuteNonQuery(CommandType.StoredProcedure, Pre + "publish_CHupdateishtml", sqlParams);
}
}
public IDataReader GetDiscussInfo(string grouptype, int TopNumber)
{
string Sql;
switch (grouptype)
{
case "hot":
Sql = "Select top " + TopNumber + " [DisID],[Cname],[Creatime],((Select Count([Id]) From [" + Pre + "User_DiscussMember] Where [" + Pre + "User_DiscussMember].[DisID]=[" + Pre + "User_Discuss].[DisID])+Browsenumber) As Cnt1 From [" + Pre + "User_Discuss] Order By Cnt1 Desc";
break;
case "click":
Sql = "Select top " + TopNumber + " [DisID],[Cname],[Creatime],[Browsenumber] From [" + Pre + "User_Discuss] Order By [Browsenumber] Desc";
break;
case "Mmore":
Sql = "Select top " + TopNumber + " [DisID],[Cname],[Creatime],(Select Count([Id]) From [" + Pre + "User_DiscussMember] Where [" + Pre + "User_DiscussMember].[DisID]=[" + Pre + "User_Discuss].[DisID]) As Cnt1 From [" + Pre + "User_Discuss] Order By Cnt1 Desc";
break;
case "Last":
Sql = "Select top " + TopNumber + " [DisID],[Cname],[Creatime] From [" + Pre + "User_Discuss] Order By [Creatime] Desc";
break;
default:
Sql = "Select top " + TopNumber + " [DisID],[Cname],[Creatime] From [" + Pre + "User_Discuss] Order By [Creatime] Desc";
break;
}
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
public string GetMetaContent(string id, string Str, int num)
{
string Sql = "";
switch (Str)
{
case "News":
if (num == 0)
Sql = "select top 1 Metakeywords from " + Pre + "news where NewsID=@ID";
else
Sql = "select top 1 Metadesc from " + Pre + "news where NewsID=@ID";
break;
case "Class":
if (num == 0)
Sql = "select top 1 MetaKeywords from " + Pre + "news_class where ClassID=@ID";
else
Sql = "select top 1 MetaDescript from " + Pre + "news_class where ClassID=@ID";
break;
case "Special":
Sql = "select top 1 SpecialCName from " + Pre + "news_special where SpecialID=@ID";
break;
}
if (Sql != "")
{
SqlParameter Param = new SqlParameter("@ID", id);
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, Param));
}
else
return "";
}
public string GetPageTitle(string id, string Str)
{
string Sql = "";
switch (Str)
{
case "News":
Sql = "select top 1 NewsTitle from " + Pre + "news where NewsID=@ID";
break;
case "Class":
Sql = "select top 1 ClassCName from " + Pre + "news_class where ClassID=@ID";
break;
case "Special":
Sql = "select top 1 SpecialCName from " + Pre + "news_special where SpecialID=@ID";
break;
}
if (Sql != "")
{
SqlParameter Param = new SqlParameter("@ID", id);
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, Param));
}
else
return "";
}
public IDataReader GetNewsFiles(string newsid)
{
string Sql = "select id,URLName,FileURL from " + Pre + "news_URL where [NewsID]=@NewsID order by orderid desc";
SqlParameter Param = new SqlParameter("@NewsID", newsid);
return DbHelper.ExecuteReader(CommandType.Text, Sql, Param);
}
public IDataReader GetPrePage(int id, string datalib, int num, string classid, int ChID)
{
if (ChID == 0)
{
string Sql = "select top 1 a.newsID,a.NewsTitle,a.SavePath,a.FileName,a.FileEXName,b.savepath as savepath1,b.SaveClassframe,a.isDelPoint from " + Pre + "news a," + Pre + "news_class b where a.id";
if (num == 0)
Sql += ">";
else
Sql += "<";
Sql += id + " and a.CLassID=@ClassID and a.ClassID=b.ClassID and a.NewsType<>2 and a.islock=0 and a.isRecyle=0 order by a.id desc";
SqlParameter Param = new SqlParameter("@ClassID", classid);
return DbHelper.ExecuteReader(CommandType.Text, Sql, Param);
}
else
{
string csql = "select top 1 a.id,a.Title,a.SavePath,a.FileName,b.SavePath as savepath1,a.isDelPoint from " + datalib + " a," + Pre + "sys_channelclass b where a.id";
if (num == 0)
csql += ">";
else
csql += "<";
csql += id + " and a.CLassID=@ID and a.ClassID=b.id and a.islock=0 order by a.id desc";
SqlParameter Param1 = new SqlParameter("@ID", int.Parse(classid));
return DbHelper.ExecuteReader(CommandType.Text, csql, Param1);
}
}
public IDataReader GetNewsInfoAndClassInfo(string NewsID, string DataLib)
{
string Sql = "select a.SavePath,a.FileName,a.FileEXName,a.NewsType,a.URLaddress,a.isDelPoint,b.SavePath as SavePath1,b.SaveClassframe from " + Pre + "news a," + Pre + "news_class b where a.NewsID=@NewsID and a.ClassID=b.ClassID and a.isLock=0 and a.isRecyle=0";
SqlParameter Param = new SqlParameter("@NewsID", NewsID);
return DbHelper.ExecuteReader(CommandType.Text, Sql, Param);
}
public int GetCommCount(string newsid, int td, int ChID)
{
string WhereStr = string.Empty;
if (ChID != 0)
{
WhereStr = " and ChID=" + ChID + "";
}
string Sql = "Select Count(ID) From [" + Pre + "api_commentary] Where [InfoID]=@NewsID and islock=0" + WhereStr;
if (td == 1)
{
Sql += " And DateDiff(Day,[creatTime] ,Getdate())=0";
}
SqlParameter Param = new SqlParameter("@NewsID", newsid);
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, Param));
}
public string GetStyleContent(string styleid)
{
string Sql = "select [Content] from " + Pre + "sys_LabelStyle where styleID=@styleID and isRecyle=0";
SqlParameter Param = new SqlParameter("@styleID", styleid);
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, Param));
}
public string GetCHStyleContent(int ID, int ChID)
{
string Sql = "select [styleContent] from " + Pre + "sys_channelstyle where id=@ID and isLock=0 and ChID=" + ChID + "";
SqlParameter Param = new SqlParameter("@ID", ID);
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, Param));
}
public IDataReader GetNaviShowClass(string parentid)
{
string Sql = "select [ClassID],[ClassCName],[ParentID],[ClassSaveRule],[SaveClassFrame],[SavePath],[isDelPoint] from " + Pre + "News_Class where ParentID=@ParentID and isLock=0 and isRecyle=0 and NaviShowtf=1 order by orderid desc,id desc";
SqlParameter Param = new SqlParameter("@ParentID", parentid);
return DbHelper.ExecuteReader(CommandType.Text, Sql, Param);
}
public DataTable Gethistory(int Numday)
{
string Sql = "select * from " + Pre + "old_news where DateDiff(Day,[creatTime] ,Getdate()) = " + Numday + " and isLock=0 and isRecyle=0 order by orderid desc,id desc";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public DataTable GetTopLine(string newsid)
{
SqlParameter Param = null;
string Sql = "select top 1 NewsID,tl_SavePath from " + DBConfig.TableNamePrefix + "news_topline ";
if (newsid != null && newsid != "")
{
Sql += " where NewsID=@NewsID";
Param = new SqlParameter("@NewsID", newsid);
}
else
{
Sql += " order by Id desc";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, Param);
}
public DataTable GetPosition(string ID, int Num)
{
SqlParameter param = new SqlParameter("@ID", ID);
string sql = string.Empty;
if (Num == 0)
{
sql = "select * from " + Pre + "news_class where ClassID=@ID";
}
else
{
sql = "select * from " + Pre + "news_special where SpecialID=@ID";
}
return DbHelper.ExecuteTable(CommandType.Text, sql, param);
}
public IDataReader GetNewsDetail(int id, string newsid)
{
SqlParameter Param = null;
string Sql = "Select [Id],[NewsID],[NewsType],[OrderID],[NewsTitle],[sNewsTitle],[TitleColor],[TitleITF],[TitleBTF],[CommLinkTF],";
Sql += "[SubNewsTF],[URLaddress],[PicURL],[SPicURL],[ClassID],[SpecialID],[Author],[Souce],[Tags],[NewsProperty],[NewsPicTopline],";
Sql += "[Templet],[Content],[Metakeywords],[Metadesc],[naviContent],[Click],[CreatTime],[EditTime],[SavePath],[FileName],";
Sql += "[FileEXName],[isDelPoint],[Gpoint],[iPoint],[GroupNumber],[ContentPicTF],[ContentPicURL],[ContentPicSize],[CommTF],";
Sql += "[DiscussTF],[TopNum],[VoteTF],[CheckStat],[isLock],[isRecyle],[SiteID],[DataLib],[DefineID],[isVoteTF],[Editor],[isHtml],";
Sql += "[isConstr],[isFiles],[vURL] From [" + Pre + "News]";
if (id > 0)
{
Sql += " Where ID=" + id;
}
else
{
Sql += " Where [NewsID]=@NewsID";
Param = new SqlParameter("@NewsID", newsid);
}
return DbHelper.ExecuteReader(CommandType.Text, Sql, Param);
}
public string GetClassIDByNewsID(string newsid)
{
string Sql = "Select [ClassID] From " + DBConfig.TableNamePrefix + "news Where [NewsID]=@NewsID";
SqlParameter Param = new SqlParameter("@NewsID", newsid);
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, Param));
}
public IDataReader GetTopUser(int topnum, string orderfld)
{
string Sql = "Select Top " + topnum + " [NickName],[UserName],[iPoint],[gPoint],[ePoint],[RegTime],(Select Count(*) From [" + Pre + "User_Constr] Where [" + Pre + "sys_User].UserNum=[" + Pre + "User_Constr].UserNum) Cnt From [" + Pre + "sys_User] Where [isLock]=0";
switch (orderfld)
{
case "iPoint":
Sql += " Order By [iPoint] Desc,[ID] Desc";
break;
case "gPoint":
Sql += " Order By [gPoint] Desc,[ID] Desc";
break;
case "ePoint":
Sql += " Order By [ePoint] Desc,[ID] Desc";
break;
case "Cnt":
Sql += "Order By [Cnt] Desc,[ID] Desc";
break;
default:
Sql += " Order By [RegTime] Desc,[ID] Desc";
break;
}
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
public DataTable GetUnRule(string UnID, string SiteID)
{
string Sql = string.Empty;
if (UnID != "0")
{
Sql = "Select [unName],[TitleCSS],[SubCSS],[ONewsID],[Rows],[unTitle],[NewsTable] From [" + Pre + "news_unNews] Where [UnID]=@UnID And [SiteID]=@SiteID Order By [Rows] Asc,[ID] asc";
}
else
{
Sql = "Select [unName],[TitleCSS],[SubCSS],[ONewsID],[Rows],[unTitle],[NewsTable] From [" + Pre + "news_unNews] Where [UnID] in (select top 1 UnID from [" + Pre + "news_unNews] order by id desc) [SiteID]=@SiteID Order By [Rows] Asc,[ID] asc";
}
SqlParameter[] Param = new SqlParameter[] { new SqlParameter("@UnID", UnID), new SqlParameter("@SiteID", SiteID) };
return DbHelper.ExecuteTable(CommandType.Text, Sql, Param);
}
public DataTable GetSubUnRule(string NewsID)
{
string Sql = "Select ID,getNewsID,NewsTitle,DataLib,TitleCSS,colsNum,SiteID,CreatTime From [" + Pre + "news_sub] Where [NewsID]=@NewsID Order By [colsNum] Asc,[ID] asc";
SqlParameter[] Param = new SqlParameter[] { new SqlParameter("@NewsID", NewsID) };
return DbHelper.ExecuteTable(CommandType.Text, Sql, Param);
}
public DataTable GetSubClass(string ClassID, int isParent, string OrderBy, string Desc)
{
SqlParameter Param = new SqlParameter("@ClassID", ClassID);
string Sql = string.Empty;
if (isParent == 1)
{
Sql = "Select ClassID From [" + Pre + "news_class] Where [ParentID]=@ClassID and isLock=0 and isRecyle=0 and isPage=0 order by " + OrderBy + " " + Desc + ",id " + Desc + "";
}
else
{
Sql = "Select ClassID,IsURL,URLaddress,SavePath,SaveClassframe,ClassSaveRule,ClassIndexRule From [" + Pre + "news_class] Where [ClassID]=@ClassID and isLock=0 and isRecyle=0 and isPage=0";
}
//SqlParameter[] Param = new SqlParameter[] { new SqlParameter("@NewsID", NewsID) };
return DbHelper.ExecuteTable(CommandType.Text, Sql, Param);
}
public string GetDefinedValue(string dfid, string dfcolumn)
{
//string Sql = "Select [definedvalue] From [" + Pre + "define_data] Where [defineInfoId]=@defineInfoId And [defineColumns]=@defineColumns";
//SqlParameter[] Param = new SqlParameter[]{
// new SqlParameter("@defineInfoId", dfid),
// new SqlParameter("@defineColumns", dfcolumn)
//};
string Sql = "Select [DsContent] From [" + Pre + "Define_Save] Where [DsNewsID]=@defineInfoId And [DsEname]=@defineColumns";
SqlParameter[] Param = new SqlParameter[]{
new SqlParameter("@defineInfoId", dfid),
new SqlParameter("@defineColumns", dfcolumn)
};
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, Param));
}
public string GetCHDefinedValue(int ID, string dfcolumn, string DTalbe)
{
string Sql = "Select " + dfcolumn + " From [" + DTalbe + "] Where ID=@ID";
SqlParameter[] Param = new SqlParameter[]
{
new SqlParameter("@ID", ID),
new SqlParameter("@defineColumns", dfcolumn)
};
string ReturnValue = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, Param));
return ReturnValue;
}
/// <summary>
/// 文字副新闻
/// </summary>
/// <param name="TopNum"></param>
/// <returns></returns>
public DataTable GetTextSubNews(int TopNum)
{
string Sql = "select top " + TopNum + " NewsTitle,TitleColor,TitleITF,TitleBTF,NewsID,ClassID,SavePath,FileName,FileEXName,isDelPoint from " + Pre + "news where substring(NewsProperty,9,1)='1' and substring(NewsProperty,1,1)='1' and islock=0 and isRecyle=0 and NewsPicTopline=0 order by EditTime desc,id desc";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
#region 频道开始
public string GetCHDatable(int ChID)
{
SqlParameter param = new SqlParameter("@ChID", ChID);
string sql = "select DataLib from " + Pre + "sys_channel Where ID=@ChID";
string ChTable = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
if (ChTable != string.Empty)
{
return ChTable;
}
else
{
return "#";
}
}
public IDataReader GetCHDetail(int id, string DTable)
{
string Sql = "Select [Id],[OrderID],[Title],[TitleColor],[TitleITF],[TitleBTF],";
Sql += "[PicURL],[ClassID],[SpecialID],[Author],[Souce],[Tags],[ContentProperty],";
Sql += "[Templet],[Content],[Metakeywords],[Metadesc],[naviContent],[Click],[CreatTime],[SavePath],[FileName],";
Sql += "[isDelPoint],[Gpoint],[iPoint],[GroupNumber],";
Sql += "[isLock],[ChID],[Editor],[isHtml],[isConstr] From [" + DTable + "]";
Sql += " Where [ID]=@ID";
SqlParameter Param = new SqlParameter("@ID", id);
return DbHelper.ExecuteReader(CommandType.Text, Sql, Param);
}
/// <summary>
/// 选择发布频道所有新闻时,取得所有新闻
/// </summary>
/// <param name="strParams">页面信息字符串</param>
/// <returns>取得符合条件的所有新闻的查询结果</returns>
public IDataReader GetPublishCHNewsAll(string DTable, out int ncount)
{
string Sql = "select ID,Templet,classID,SavePath,FileName from " + DTable + " where isLock=0 and isDelPoint=0";
string SqlCount = "select count(ID) from " + DTable + " where isLock=0 and isDelPoint=0";
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
/// <summary>
/// 选择发布频道最新时,取得所有新闻
/// </summary>
/// <param name="strParams">页面信息字符串</param>
/// <returns>取得符合条件的所有新闻的查询结果</returns>
public IDataReader GetPublishCHNewsLast(string DTable, int topnum, bool unpublish, out int ncount)
{
string Sql = "select top " + topnum + " ID,Templet,classID,SavePath,FileName from " + DTable + " where isLock=0 and isDelPoint=0";
string SqlCount = "select count(ID) from " + DTable + " where isLock=0 and isDelPoint=0";
if (unpublish)
{
Sql += " and isHtml=0";
SqlCount += " and isHtml=0";
}
Sql += " order by id desc";
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
/// <summary>
/// 根据栏目发布新闻
/// </summary>
/// <param name="classid"></param>
/// <param name="unpublish"></param>
/// <param name="isdesc"></param>
/// <param name="condition"></param>
/// <param name="ncount"></param>
/// <returns></returns>
public IDataReader GetPublishCHNewsByClass(string DTable, string classid, bool unpublish, bool isdesc, string condition, out int ncount)
{
string SqlCondition = " where isLock=0 and isDelPoint=0 and ClassID in (" + classid + ")";
string SqlOrder = "";
if (unpublish)
{
//只发布未发布的
SqlCondition += " and isHtml=0 ";
}
string Sql = "select ID,Templet,classID,SavePath,FileName from " + DTable + " a " + SqlCondition + SqlOrder;
string SqlCount = "select count(a.ID) from " + DTable + " a " + SqlCondition;
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
/// <summary>
/// 选择按照日期发布时,取得所有新闻
/// </summary>
/// <param name="starttime"></param>
/// <param name="endtime"></param>
/// <param name="ncount"></param>
/// <returns></returns>
public IDataReader GetPublishCHNewsByTime(string DTable, DateTime starttime, DateTime endtime, out int ncount)
{
string Sql = "select ID,Templet,classID,SavePath,FileName from " + DTable + " where creattime between '" + starttime + "' and '" + endtime + "' and isLock=0 and isDelPoint=0";
string SqlCount = "select count(ID) from " + DTable + " where creattime between '" + starttime + "' and '" + endtime + "' and isLock=0 and isDelPoint=0";
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
/// <summary>
/// 选择按照ID发布时,取得所有新闻
/// </summary>
/// <param name="minid"></param>
/// <param name="maxid"></param>
/// <param name="ncount"></param>
/// <returns></returns>
public IDataReader GetPublishCHNewsByID(string DTable, int minid, int maxid, out int ncount)
{
string Sql = "select ID,Templet,classID,SavePath,FileName from " + DTable + " where isLock=0 and isDelPoint=0 and id between " + minid + " and " + maxid;
string SqlCount = "select count(id) from " + DTable + " where isLock=0 and isDelPoint=0 and id between " + minid + " and " + maxid;
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
public IDataReader GetPublishCHClass(string classid, int ChID, out int ncount)
{
string SqlCondition = string.Empty;
if (classid.Trim() == "")
{
SqlCondition = " where isLock=0 and isPage!=1 and isDelPoint=0 and ChID=" + ChID + "";
}
else
{
SqlCondition = " where isLock=0 and isPage!=1 and isDelPoint=0 classID in (" + classid + ")";
}
string SqlCount = "select count(id) from " + Pre + "sys_channelclass" + SqlCondition;
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
string Sql = "select id,Templet,SavePath,FileName from " + Pre + "sys_channelclass" + SqlCondition;
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
public IDataReader GetPublishCHSpecial(int ChID, string spid, out int ncount)
{
string SqlCondition = " where isLock=0 and ChID=" + ChID + "";
if (spid != null && spid.Trim() != "")
{
SqlCondition = " where isLock=0 and id in (" + spid + ") and ChID=" + ChID + "";
}
string SqlCount = "select count(id) from " + Pre + "sys_channelspecial" + SqlCondition;
ncount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, SqlCount, null));
string Sql = "select id,templet,savePath,filename from " + Pre + "sys_channelspecial" + SqlCondition;
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
public string GetCHPageTitle(int id, string Str, int ChID)
{
string Sql = string.Empty;
switch (Str)
{
case "ChIndex":
Sql = "select channelName from " + Pre + "sys_channel where id=@ID";
break;
case "ChNews":
Sql = "select Title from " + GetCHDatable(ChID) + " where id=@ID";
break;
case "ChClass":
Sql = "select classCName from " + Pre + "sys_channelclass where id=@ID and ChID=" + ChID + "";
break;
case "ChSpecial":
Sql = "select specialCName from " + Pre + "sys_channelspecial where id=@ID and ChID=" + ChID + "";
break;
default:
return string.Empty;
}
SqlParameter Param = null;
if (Str == "ChIndex")
{
Param = new SqlParameter("@ID", ChID);
}
else
{
Param = new SqlParameter("@ID", id);
}
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, Param));
}
public IDataReader GetPositionNavi(int id, string Str, int ChID)
{
string Sql = "select id,channelName,htmldir,indexFileName,ParentID from " + Pre + "sys_channel where id=@ChID";
SqlParameter param = new SqlParameter("@ChID", ChID);
return DbHelper.ExecuteReader(CommandType.Text, Sql, param);
}
public IDataReader GetParentPositionNavi(int ChId)
{
string Sql = "select id,channelName,htmldir,indexFileName,ParentID from " + Pre + "sys_channel where ID=@ChID";
SqlParameter param = new SqlParameter("@ChID", ChId);
return DbHelper.ExecuteReader(CommandType.Text, Sql, param);
}
public IDataReader GetFieldName(int ChID)
{
string sql = "select CName,EName from " + Pre + "sys_channelvalue where ChID=@ChID and isLock=0 and isSearch=1";
SqlParameter param = new SqlParameter("@ChID", ChID);
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public string GetCHMeta(int id, int Num, int ChID, string Str)
{
string sql = string.Empty;
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[0].Value = id;
param[1] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[1].Value = ChID;
switch (Str)
{
case "ChIndex":
sql = "select channelName from " + Pre + "sys_channel where ID=" + ChID + "";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, null));
case "ChClass":
if (Num == 0)
{
sql = "select KeyMeta from " + Pre + "sys_channelclass where ID=@ID and ChID=@ChID";
}
else
{
sql = "select DescMeta from " + Pre + "sys_channelclass where ID=@ID and ChID=@ChID";
}
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
case "ChNews":
if (Num == 0)
{
sql = "select Metakeywords from " + GetCHDatable(ChID) + " where ID=@ID and ChID=@ChID";
}
else
{
sql = "select Metadesc from " + GetCHDatable(ChID) + " where ID=@ID and ChID=@ChID";
}
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
case "ChSpecial":
if (Num == 0)
{
sql = "select specialCName from " + Pre + "sys_channelspecial where ID=@ID and ChID=@ChID";
}
else
{
sql = "select navicontent from " + Pre + "sys_channelspecial where ID=@ID and ChID=@ChID";
}
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
default:
return string.Empty;
}
}
public IDataReader GetCHPosition(int ID, int Num, int ChID)
{
SqlParameter param = new SqlParameter("@ID", ID);
string sql = string.Empty;
switch (Num)
{
case 0:
sql = "select id,SavePath,FileName,isDelPoint,classCName,ParentID from " + Pre + "sys_channelclass where id=@ID and ChID=" + ChID + "";
break;
case 1:
sql = "select b.id,b.SavePath,b.FileName,b.isDelPoint,classCName,b.ParentID from " + GetCHDatable(ChID) + " a," + Pre + "sys_channelclass b where a.id=@ID and a.ClssID=b.ID";
break;
case 2:
sql = "select id,parentID,SavePath,filename,specialCName from " + Pre + "sys_channelspecial where id=@ID and ChID=" + ChID + "";
break;
}
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public IDataReader GetSingleCHPageClass(int classid)
{
string Sql = "select Templet,classCName,SavePath,PageContent,MetaKeywords,MetaDescript,FileName from " + Pre + "syschannelclass";
Sql += " where ID=@ClassID and isLock=0 and isPage=1";
SqlParameter Param = new SqlParameter("@ClassID", classid);
return DbHelper.ExecuteReader(CommandType.Text, Sql, Param);
}
public IDataReader GetCHNewsSavePath(int newsid, int ChID)
{
string Sql = "select a.templet,a.classid,a.SavePath,a.FileName,b.SavePath as SavePath1,b.FileName as FileName1,a.id,a.isDelPoint from " + GetCHDatable(ChID) + " a, ";
Sql += Pre + "sys_channelclass b where a.classid=b.id and a.id=@newsid";
SqlParameter Param = new SqlParameter("@newsid", newsid);
return DbHelper.ExecuteReader(CommandType.Text, Sql, Param);
}
public DataTable GetLastCHNews(int topnum, int classid, int ChID)
{
SqlParameter Param = null;
string Sql = "select top " + topnum + " a.Title,a.Content,a.CreatTime,a.SavePath,a.FileName,";
Sql += "b.savepath as savepath1,b.ClassEName,b.ClassCName,b.id as id1 from " + GetCHDatable(ChID) + " a," + Pre + "sys_channelclass b";
Sql += " where a.islock=0 and a.ClassID=b.id and b.isPage!=1 and b.islock=0";
if (classid != 0)
{
Sql += " and b.id=@ClassID";
Param = new SqlParameter("@ClassID", classid);
}
Sql += " order by a.id desc";
return DbHelper.ExecuteTable(CommandType.Text, Sql, Param);
}
public IDataReader GetFriend(int Type, int Number, int IsAdmin)
{
string sql = string.Empty;
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@Type", SqlDbType.Int, 4);
param[0].Value = Type;
param[1] = new SqlParameter("@Number", SqlDbType.Int, 4);
param[1].Value = Number;
param[2] = new SqlParameter("@IsAdmin", SqlDbType.Int, 4);
param[2].Value = IsAdmin;
if (IsAdmin == 3)
{
sql = "select top " + Number + " Name,Url,PicUrl,Content from " + Pre + "friend_link where Type=@Type and Lock=0 order by id desc";
}
else
{
sql = "select top " + Number + " Name,Url,PicUrl,Content from " + Pre + "friend_link where Type=@Type and isUser=@IsAdmin and Lock=0 order by id desc";
}
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
#endregion
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Publish.cs | C# | asf20 | 62,384 |
//======================================================
//== (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 Admin : DbBase, IAdmin
{
//private string SiteID;
/// <summary>
/// 锁定管理员
/// </summary>
/// <param name="id">管理员用户编号</param>
public void Lock(string id)
{
SqlParameter param = new SqlParameter("@UserNum", id);
string str_sql = "Update " + Pre + "sys_admin Set isLock=1 where UserNum=@UserNum";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, param);
}
/// <summary>
/// 解锁管理员
/// </summary>
/// <param name="id">管理员用户编号</param>
public void UnLock(string id)
{
SqlParameter param = new SqlParameter("@UserNum", id);
string str_sql = "Update " + Pre + "sys_admin Set isLock=0 where UserNum=@UserNum";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, param);
}
/// <summary>
/// 删除管理员
/// </summary>
/// <param name="id">管理员编号</param>
public void Del(string id)
{
SqlParameter param = new SqlParameter("@UserNum", id);
string str_Admin = "Delete From " + Pre + "sys_admin where UserNum=@UserNum";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Admin, param);
string str_User = "Update " + Pre + "sys_User Set isAdmin=0 where UserNum=@UserNum";
DbHelper.ExecuteNonQuery(CommandType.Text, str_User, param);
}
/// <summary>
/// 得到管理员组列表
/// </summary>
/// <returns>返回的Table</returns>
public DataTable GetAdminGroupList()
{
string str_Sql = "Select adminGroupNumber,GroupName From " + Pre + "sys_AdminGroup where SiteID='" + NetCMS.Global.Current.SiteID + "'";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
/// <summary>
/// 得到管理员的权限列表
/// </summary>
/// <param name="UserNum">用户编号</param>
/// <param name="Id">管理员ID</param>
/// <returns></returns>
public string GetAdminPopList(string UserNum, int Id)
{
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@UserNum", UserNum), new SqlParameter("@Id", Id) };
string str = "0|";
string str_Sql = "Select isSuper,PopList From " + Pre + "sys_Admin where ID=@Id and UserNum=@UserNum";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, param);
if (dt != null && dt.Rows.Count > 0)
{
str = dt.Rows[0]["isSuper"].ToString() + "|" + dt.Rows[0]["PopList"].ToString();
dt.Clear(); dt.Dispose();
}
return str;
}
/// <summary>
/// 得到站点列表
/// </summary>
/// <returns>返回DataTable</returns>
public DataTable GetSiteList()
{
string str_Sql = "";
if (NetCMS.Global.Current.SiteID == "0")
str_Sql = "Select ChannelID,CName From " + Pre + "news_site Where isRecyle=0 And IsURL=0 and islock=0";
else
str_Sql = "Select ChannelID,CName From " + Pre + "news_site Where isRecyle=0 and islock=0 and ParentID='" + NetCMS.Global.Current.SiteID + "' And IsURL=0";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null); ;
}
/// <summary>
/// 增加管理员,并插入User表
/// </summary>
/// <param name="ac">构造</param>
/// <returns></returns>
public int Add(NetCMS.Model.AdminInfo ac)
{
int result = 0;
string checkSql = "";
int recordCount = 0;
string UserNum = NetCMS.Common.Rand.Number(12);
while (true)
{
checkSql = "select count(*) from " + Pre + "sys_User where UserNum='" + UserNum + "'";
recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
if (recordCount < 1)
break;
else
UserNum = NetCMS.Common.Rand.Number(12, true);
}
checkSql = "select ID,UserNum from " + Pre + "sys_User where UserName='" + ac.UserName + "'";
DataTable dts = DbHelper.ExecuteTable(CommandType.Text, checkSql, null);
SqlParameter[] param = GetAdminParameters(ac);
if (dts != null)
{
if (dts.Rows.Count > 0)
{
string str_upUser = "update " + Pre + "sys_User set isAdmin=1,siteID='" + ac.SiteID + "' where UserNum='" + dts.Rows[0]["UserNum"].ToString() + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_upUser, null);
string str_Admin = "Insert Into " + Pre + "sys_admin(UserNum,isSuper,adminGroupNumber,";
str_Admin += "OnlyLogin,isChannel,isLock,SiteID,isChSupper,Iplimited) Values ";
str_Admin += "('" + dts.Rows[0]["UserNum"].ToString() + "',@isSuper,@adminGroupNumber,@OnlyLogin,@isChannel";
str_Admin += ",@isLock,@SiteID,@isChSupper,@Iplimited)";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Admin, param);
result = 1;
}
else
{
string str_User = "Insert Into " + Pre + "sys_User(UserNum,UserName,UserPassword";
str_User += ",RealName,isAdmin,Email,RegTime,SiteID,LoginNumber,OnlineTF,OnlineTime";
str_User += ",isLock,aPoint,ePoint,cPoint,gPoint,iPoint,UserGroupNumber,isIDcard) Values (";
str_User += "'" + UserNum + "',@UserName,@UserPassword,@RealName,@isAdmin,@Email,";
str_User += "@RegTime,@SiteID,@LoginNumber,@OnlineTF,@OnlineTime,@isLock,@aPoint,";
str_User += "@ePoint,@cPoint,@gPoint,@iPoint,@UserGroupNumber,0)";
DbHelper.ExecuteNonQuery(CommandType.Text, str_User, param);
string str_Admin = "Insert Into " + Pre + "sys_admin(UserNum,isSuper,adminGroupNumber,";
str_Admin += "OnlyLogin,isChannel,isLock,SiteID,isChSupper,Iplimited) Values ";
str_Admin += "('" + UserNum + "',@isSuper,@adminGroupNumber,@OnlyLogin,@isChannel";
str_Admin += ",@isLock,@SiteID,@isChSupper,@Iplimited)";
DbHelper.ExecuteNonQuery(CommandType.Text, str_Admin, param);
result = 1;
}
dts.Clear(); dts.Dispose();
}
else
{
throw new Exception("意外错误");
}
return result;
}
/// <summary>
/// 编辑管理员
/// </summary>
/// <param name="ac"></param>
/// <returns></returns>
public int Edit(NetCMS.Model.AdminInfo ac)
{
SqlParameter[] param = GetAdminParameters(ac);
string str_adminSql = "";
string str_userSql = "";
if (ac.UserPassword != null && ac.UserPassword != "" && ac.UserPassword != string.Empty)
{
str_adminSql = "Update " + Pre + "sys_User Set UserPassword=@UserPassword,RealName=@RealName";
str_adminSql += ",Email=@Email,SiteID=@SiteID Where UserNum='" + ac.UserNum + "'";
}
else
{
str_adminSql = "Update " + Pre + "sys_User Set RealName=@RealName,Email=@Email,";
str_adminSql += "SiteID=@SiteID Where UserNum='" + ac.UserNum + "'";
}
DbHelper.ExecuteNonQuery(CommandType.Text, str_adminSql, param);
if (ac.isChSupper == 0)
{
str_userSql = "Update " + Pre + "sys_admin Set adminGroupNumber=@adminGroupNumber,";
str_userSql += "OnlyLogin=@OnlyLogin,isChannel=@isChannel,isLock=@isLock,";
str_userSql += "isChSupper=@isChSupper,Iplimited=@Iplimited,";
str_userSql += "SiteID=@SiteID Where UserNum='" + ac.UserNum + "'";
}
else
{
str_userSql = "Update " + Pre + "sys_admin ";
str_userSql += "Set isChSupper=@isChSupper,Iplimited=@Iplimited Where UserNum='" + ac.UserNum + "'";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, str_userSql, param);
}
/// <summary>
/// 得到管理员相关信息
/// </summary>
/// <param name="id">传入的管理员编号</param>
/// <returns></returns>
public DataTable GetAdminInfo(string id)
{
SqlParameter param = new SqlParameter("@UserNum", id);
string str_Sql = "Select a.UserNum,a.isSuper,a.adminGroupNumber,a.PopList,a.OnlyLogin,a.isChannel,a.isLock,a.SiteID,a.isChSupper,a.Iplimited,b.RealName,b.Email,b.UserName From " + Pre + "sys_admin as a," + Pre + "sys_User as b Where a.UserNum=b.UserNum and b.isAdmin=1 and a.UserNum=@UserNum";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, param);
}
/// <summary>
/// 获得构造参数
/// </summary>
/// <param name="ac"></param>
/// <returns></returns>
private SqlParameter[] GetAdminParameters(NetCMS.Model.AdminInfo ac)
{
SqlParameter[] param = new SqlParameter[23];
param[0] = new SqlParameter("@UserName", SqlDbType.NVarChar, 18);
param[0].Value = ac.UserName;
param[1] = new SqlParameter("@UserPassword", SqlDbType.NVarChar, 32);
param[1].Value = ac.UserPassword;
param[2] = new SqlParameter("@RealName", SqlDbType.NVarChar, 20);
param[2].Value = ac.RealName;
param[3] = new SqlParameter("@isAdmin", SqlDbType.TinyInt, 1);
param[3].Value = ac.isAdmin;
param[4] = new SqlParameter("@Email", SqlDbType.NVarChar, 120);
param[4].Value = ac.Email;
param[5] = new SqlParameter("@RegTime", SqlDbType.DateTime, 8);
param[5].Value = ac.RegTime;
param[6] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[6].Value = ac.SiteID;
param[7] = new SqlParameter("@LoginNumber", SqlDbType.Int, 4);
param[7].Value = ac.LoginNumber;
param[8] = new SqlParameter("@OnlineTF", SqlDbType.Int, 4);
param[8].Value = ac.OnlineTF;
param[9] = new SqlParameter("@OnlineTime", SqlDbType.Int, 4);
param[9].Value = ac.OnlineTime;
param[10] = new SqlParameter("@isLock", SqlDbType.TinyInt, 1);
param[10].Value = ac.isLock;
param[11] = new SqlParameter("@aPoint", SqlDbType.Int, 4);
param[11].Value = ac.aPoint;
param[12] = new SqlParameter("@ePoint", SqlDbType.Int, 4);
param[12].Value = ac.ePoint;
param[13] = new SqlParameter("@cPoint", SqlDbType.Int, 4);
param[13].Value = ac.cPoint;
param[14] = new SqlParameter("@gPoint", SqlDbType.Int, 4);
param[14].Value = ac.gPoint;
param[15] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
param[15].Value = ac.iPoint;
param[16] = new SqlParameter("@UserGroupNumber", SqlDbType.NVarChar, 12);
param[16].Value = ac.UserGroupNumber;
param[17] = new SqlParameter("@isSuper", SqlDbType.TinyInt, 1);
param[17].Value = ac.isSuper;
param[18] = new SqlParameter("@adminGroupNumber", SqlDbType.NVarChar, 12);
param[18].Value = ac.adminGroupNumber;
param[19] = new SqlParameter("@OnlyLogin", SqlDbType.TinyInt, 1);
param[19].Value = ac.OnlyLogin;
param[20] = new SqlParameter("@isChannel", SqlDbType.TinyInt, 1);
param[20].Value = ac.isChannel;
param[21] = new SqlParameter("@isChSupper", SqlDbType.TinyInt, 1);
param[21].Value = ac.isChSupper;
param[22] = new SqlParameter("@Iplimited", SqlDbType.NText);
param[22].Value = ac.Iplimited;
return param;
}
/// <summary>
/// 更新会员权限
/// </summary>
/// <param name="UserNum"></param>
/// <param name="Id"></param>
/// <param name="PopLIST"></param>
public void UpdatePOPlist(string UserNum, int Id, string PopLIST)
{
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@UserNum", UserNum), new SqlParameter("@PopLIST", PopLIST) };
string str_User = "Update " + Pre + "sys_admin Set PopList=@PopLIST where UserNum=@UserNum and ID=" + Id + "";
DbHelper.ExecuteNonQuery(CommandType.Text, str_User, param);
}
/// <summary>
/// 得到管理员列表
/// </summary>
/// <returns></returns>
public DataTable getAdmininfoList()
{
string str_Sql = "Select a.ID,a.UserNum,a.isSuper,a.adminGroupNumber,b.UserName From " + Pre + "sys_admin a left join " + Pre + "sys_User b on a.UserNum=b.UserNum Where b.isAdmin=1 and a.SiteID='" + NetCMS.Global.Current.SiteID + "' order by a.id desc";
return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Admin.cs | C# | asf20 | 14,329 |
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
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.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Sys : DbBase, ISys
{
/// <summary>
/// 检查新闻表数量
/// </summary>
/// <returns></returns>
public DataTable GetTableRecord()
{
string Sql = "Select id From " + Pre + "sys_NewsIndex";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return rdr;
}
/// <summary>
/// 检查新闻表是否存在
/// </summary>
/// <param name="TableName"></param>
/// <returns></returns>
public DataTable GetTableExsit(string TableName)
{
string Sql = "Select tableName From " + Pre + "sys_NewsIndex Where tableName='" + TableName + "'";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return rdr;
}
/// <summary>
/// 插入表记录
/// </summary>
/// <param name="TableName"></param>
public void InsertTableLab(string TableName)
{
string Sql = "Insert Into " + Pre + "sys_NewsIndex(TableName,CreatTime)Values('" + TableName + "','" + System.DateTime.Now + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 创建新表数据结构
/// </summary>
/// <param name="TableName"></param>
public void CreatTableData(string TableName)
{
string Sql = " CREATE TABLE [dbo].[" + TableName + "](" +
"[Id] [int] IDENTITY (1, 1) NOT NULL ," +
"[NewsID] [nvarchar] (12) NOT NULL ," +
"[NewsType] [tinyint] NOT NULL ," +
"[OrderID] [tinyint] NOT NULL ," +
"[NewsTitle] [nvarchar] (100) NOT NULL ," +
"[sNewsTitle] [nvarchar] (100) NULL ," +
"[TitleColor] [nvarchar] (10) NULL ," +
"[TitleITF] [tinyint] NULL ," +
"[TitleBTF] [tinyint] NULL ," +
"[CommLinkTF] [tinyint] NULL ," +
"[SubNewsTF] [tinyint] NULL ," +
"[URLaddress] [nvarchar] (200) NULL ," +
"[PicURL] [nvarchar] (200) NULL ," +
"[SPicURL] [nvarchar] (200) NULL ," +
"[ClassID] [nvarchar] (12) NULL ," +
"[SpecialID] [nvarchar] (20) NULL ," +
"[Author] [nvarchar] (100) NULL ," +
"[Souce] [nvarchar] (100) NULL ," +
"[Tags] [nvarchar] (100) NULL ," +
"[NewsProperty] [nvarchar] (30) NULL ," +
"[NewsPicTopline] [tinyint] NULL ," +
"[Templet] [nvarchar] (200) NULL ," +
"[Content] [ntext] NULL ," +
"[Metakeywords] [nvarchar] (200) NULL ," +
"[Metadesc] [nvarchar] (200) NULL ," +
"[naviContent] [nvarchar](255) NULL ," +
"[Click] [int] NULL ," +
"[CreatTime] [datetime] NULL ," +
"[EditTime] [datetime] NULL ," +
"[SavePath] [nvarchar] (200) NULL ," +
"[FileName] [nvarchar] (100) NULL ," +
"[FileEXName] [nvarchar] (6) NULL ," +
"[isDelPoint] [tinyint] NULL ," +
"[Gpoint] [int] NULL ," +
"[iPoint] [int] NULL ," +
"[GroupNumber] [ntext] NULL ," +
"[ContentPicTF] [tinyint] NULL ," +
"[ContentPicURL] [nvarchar] (200) NULL ," +
"[ContentPicSize] [nvarchar] (10) NULL ," +
"[CommTF] [tinyint] NULL ," +
"[DiscussTF] [tinyint] NULL ," +
"[TopNum] [int] NULL ," +
"[VoteTF] [tinyint] NULL ," +
"[CheckStat] [nvarchar] (10) NULL ," +
"[isLock] [tinyint] NULL ," +
"[isRecyle] [tinyint] NULL ," +
"[SiteID] [nvarchar] (12) NULL ," +
"[DataLib] [nvarchar] (20) NULL ," +
"[DefineID] [tinyint] NULL ," +
"[isVoteTF] [tinyint] NULL ," +
"[Editor] [nvarchar] (18) NULL ," +
"[isConstr] [tinyint] NULL ," +
"[vURL] [nvarchar] (200) NULL ," +//视频地址
"[isFiles] [tinyint] NULL ," +
"[isHtml] [tinyint] NULL " +
") ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]";
Sql += "ALTER TABLE [dbo].[" + TableName + "] WITH NOCHECK ADD CONSTRAINT [PK_" + TableName + "] PRIMARY KEY CLUSTERED([Id]) ON [PRIMARY] ";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 检查新闻表是否存在
/// </summary>
/// <param name="TableName"></param>
/// <returns></returns>
public DataTable GetTableList()
{
string Sql = "select id,TableName,creattime From " + Pre + "sys_NewsIndex order by id desc";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return rdr;
}
#region 常规管
/// <summary>
/// 删除单个记录
/// </summary>
/// <param name="TableName"></param>
public void General_M_Del(int Gid)
{
string Sql = "Delete From " + Pre + "News_Gen where id=" + Gid + " " + NetCMS.Common.Public.getSessionStr() + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 锁定单个记录
/// </summary>
/// <param name="TableName"></param>
public void General_M_Suo(int Gid)
{
string Sql = "Update " + Pre + "News_Gen Set isLock=1 where id=" + Gid + " " + NetCMS.Common.Public.getSessionStr() + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 解锁单个记录
/// </summary>
/// <param name="TableName"></param>
public void General_M_UnSuo(int Gid)
{
string Sql = "Update " + Pre + "News_Gen Set isLock=0 where id=" + Gid + " " + NetCMS.Common.Public.getSessionStr() + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 删除单个记录
/// </summary>
/// <param name="TableName"></param>
public void General_DelAll()
{
string Sql = "Delete From " + Pre + "News_Gen where 1=1 " + NetCMS.Common.Public.getSessionStr() + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public DataTable GetGeneralRecord(string Cname)
{
SqlParameter param = new SqlParameter("@Cname",Cname);
string Sql = "Select Cname From " + Pre + "News_Gen Where Cname=@Cname " + NetCMS.Common.Public.getSessionStr() + "";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql,param);
return rdr;
}
/// <summary>
/// 插入表记录
/// </summary>
/// <param name="TableName"></param>
public void insertGeneral(string _Sel_Type, string _Name, string _LinkUrl, string _Email)
{
SqlParameter[] parm = new SqlParameter[5];
parm[0] = new SqlParameter("@_Sel_Type", SqlDbType.TinyInt,1);
parm[0].Value =_Sel_Type;
parm[1] = new SqlParameter("@_Name", SqlDbType.NVarChar,100);
parm[1].Value = _Name;
parm[2] = new SqlParameter("@_LinkUrl", SqlDbType.NVarChar,200);
parm[2].Value = _LinkUrl;
parm[3] = new SqlParameter("@_Email", SqlDbType.NVarChar,200);
parm[3].Value = _Email;
parm[4] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
parm[4].Value = NetCMS.Global.Current.SiteID;
string Sql = "Insert Into " + Pre + "news_Gen(gType,Cname,URL,EmailURL,SiteID) Values(@_Sel_Type,@_Name,@_LinkUrl,@_Email,@SiteID)";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
/// <summary>
/// 修改表记录
/// </summary>
/// <param name="TableName"></param>
public void UpdateGeneral(string _Sel_Type, string _Name, string _LinkUrl, string _Email, int GID)
{
SqlParameter[] parm = new SqlParameter[5];
parm[0] = new SqlParameter("@_Sel_Type", SqlDbType.TinyInt, 1);
parm[0].Value = _Sel_Type;
parm[1] = new SqlParameter("@_Name", SqlDbType.NVarChar, 100);
parm[1].Value = _Name;
parm[2] = new SqlParameter("@_LinkUrl", SqlDbType.NVarChar, 200);
parm[2].Value = _LinkUrl;
parm[3] = new SqlParameter("@_Email", SqlDbType.NVarChar, 200);
parm[3].Value = _Email;
parm[4] = new SqlParameter("@GID", SqlDbType.Int,4);
parm[4].Value = GID;
string Sql = "Update " + Pre + "news_Gen Set gType=@_Sel_Type,Cname=@_Name,EmailURL=@_Email,URL=@_LinkUrl where id=@GID and SiteID = " + NetCMS.Global.Current.SiteID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
/// <summary>
/// 获取某个常规管理的记录
/// </summary>
/// <param name="GID"></param>
/// <returns></returns>
public DataTable getGeneralIdInfo(int GID)
{
SqlParameter param = new SqlParameter("@GID",GID);
string Sql = "Select id,Cname,gType,URL,EmailURL From " + Pre + "news_Gen where id=@GID";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
return rdr;
}
#endregion 常规管理
#region 参数设置
#region 初始参数设置初始化
public DataTable UserGroup()//取会员组
{
string Sql = "Select GroupNumber,GroupName From " + Pre + "user_Group";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public DataTable UserReg()//会员注册
{
string Str_CheckSql = "Select regItem,returnemail,returnmobile From " + Pre + "sys_PramUser";
return DbHelper.ExecuteTable(CommandType.Text, Str_CheckSql, null);
}
public DataTable BasePramStart()//初始基本参数设置
{
string Str_StartSql = "Select * From " + Pre + "Sys_Param";
return DbHelper.ExecuteTable(CommandType.Text, Str_StartSql, null);
}
public DataTable FtpRss()//FTP,RSS初始化
{
string Str_StartSql = "Select * From " + Pre + "sys_Pramother";
return DbHelper.ExecuteTable(CommandType.Text, Str_StartSql, null);
}
public DataTable UserPram()//会员参数基本设置
{
string Str_StartSql = "Select * From " + Pre + "Sys_PramUser";
return DbHelper.ExecuteTable(CommandType.Text, Str_StartSql, null);
}
public DataTable UserLeavel()//会员等级设置
{
string Str_LeavlStartSql = "Select * From " + Pre + "Sys_UserLevel";
return DbHelper.ExecuteTable(CommandType.Text, Str_LeavlStartSql, null);
}
public DataTable WaterStart()//水印参数初始化
{
string Str_StartSql = "Select * From " + Pre + "Sys_ParmPrint";
return DbHelper.ExecuteTable(CommandType.Text, Str_StartSql, null);
}
#endregion
#region 更新参数表
public int Update_BaseInfo(SysParamInfo sys)//保存基本参数设置
{
string Str_InSql = "Update " + Pre + "Sys_Param Set SiteName=@Str_SiteName ,SiteDomain=@Str_SiteDomain,IndexTemplet=@Str_IndexTemplet,IndexFileName=@Str_Txt_IndexFileName,FileEXName=@Str_FileEXName,ReadNewsTemplet=@Str_ReadNewsTemplet,ClassListTemplet=@Str_ClassListTemplet,SpecialTemplet=@Str_SpecialTemplet,ReadType=@readtypef,LoginTimeOut=@Str_LoginTimeOut,Email=@Str_Email,LinkType=@linktypef,CopyRight=@Str_BaseCopyRight,CheckInt=@Str_CheckInt,UnLinkTF=@picc,LenSearch=@Str_LenSearch,CheckNewsTitle=@chetitle,CollectTF=@collect,SaveClassFilePath=@Str_SaveClassFilePath,SaveIndexPage=@Str_SaveIndexPage,SaveNewsFilePath=@Str_SaveNewsFilePath,SaveNewsDirPath=@Str_SaveNewsDirPath,Pram_Index=@Str_Pram_Index,InsertPicPosition=@InsertPicPosition,HistoryNum=@HistoryNum";
SqlParameter[] parm = GetBaseInfo(sys);
return DbHelper.ExecuteNonQuery(CommandType.Text, Str_InSql, parm);
}
private SqlParameter[] GetBaseInfo(SysParamInfo sys)
{
SqlParameter[] parm = new SqlParameter[25];
parm[0] = new SqlParameter("@Str_SiteName", SqlDbType.NVarChar, 50);
parm[0].Value = sys.Str_SiteName;
parm[1] = new SqlParameter("@Str_SiteDomain", SqlDbType.NVarChar, 100);
parm[1].Value = sys.Str_SiteDomain;
parm[2] = new SqlParameter("@Str_IndexTemplet", SqlDbType.NVarChar, 200);
parm[2].Value = sys.Str_IndexTemplet;
parm[3] = new SqlParameter("@Str_Txt_IndexFileName", SqlDbType.NVarChar, 20);
parm[3].Value = sys.Str_Txt_IndexFileName;
parm[4] = new SqlParameter("@Str_FileEXName", SqlDbType.NVarChar, 30);
parm[4].Value = sys.Str_FileEXName;
parm[5] = new SqlParameter("@Str_ReadNewsTemplet", SqlDbType.NVarChar, 200);
parm[5].Value = sys.Str_ReadNewsTemplet;
parm[6] = new SqlParameter("@Str_ClassListTemplet", SqlDbType.NVarChar, 200);
parm[6].Value = sys.Str_ClassListTemplet;
parm[7] = new SqlParameter("@Str_SpecialTemplet", SqlDbType.NVarChar, 200);
parm[7].Value = sys.Str_SpecialTemplet;
parm[8] = new SqlParameter("@readtypef", SqlDbType.TinyInt);
parm[8].Value = sys.readtypef;
parm[9] = new SqlParameter("@Str_LoginTimeOut", SqlDbType.Int, 4);
parm[9].Value = sys.Str_LoginTimeOut;
parm[10] = new SqlParameter("@Str_Email", SqlDbType.NVarChar, 150);
parm[10].Value = sys.Str_Email;
parm[11] = new SqlParameter("@linktypef", SqlDbType.TinyInt);
parm[11].Value = sys.linktypef;
parm[12] = new SqlParameter("@Str_BaseCopyRight", SqlDbType.NText);
parm[12].Value = sys.Str_BaseCopyRight;
parm[13] = new SqlParameter("@Str_CheckInt", SqlDbType.TinyInt);
parm[13].Value = sys.Str_CheckInt;
parm[14] = new SqlParameter("@picc", SqlDbType.TinyInt);
parm[14].Value = sys.picc;
parm[15] = new SqlParameter("@Str_LenSearch", SqlDbType.NVarChar, 8);
parm[15].Value = sys.Str_LenSearch;
parm[16] = new SqlParameter("@chetitle", SqlDbType.TinyInt);
parm[16].Value = sys.chetitle;
parm[17] = new SqlParameter("@collect", SqlDbType.TinyInt);
parm[17].Value = sys.collect;
parm[18] = new SqlParameter("@Str_SaveClassFilePath", SqlDbType.NVarChar, 200);
parm[18].Value = sys.Str_SaveClassFilePath;
parm[19] = new SqlParameter("@Str_SaveIndexPage", SqlDbType.NVarChar, 100);
parm[19].Value = sys.Str_SaveIndexPage;
parm[20] = new SqlParameter("@Str_SaveNewsFilePath", SqlDbType.NVarChar, 200);
parm[20].Value = sys.Str_SaveNewsFilePath;
parm[21] = new SqlParameter("@Str_SaveNewsDirPath", SqlDbType.NVarChar, 100);
parm[21].Value = sys.Str_SaveNewsDirPath;
parm[22] = new SqlParameter("@Str_Pram_Index", SqlDbType.Int, 4);
parm[22].Value = sys.Str_Pram_Index;
parm[23] = new SqlParameter("@InsertPicPosition", SqlDbType.NVarChar, 20);
parm[23].Value = sys.InsertPicPosition;
parm[24] = new SqlParameter("@HistoryNum", SqlDbType.Int, 4);
parm[24].Value = sys.HistoryNum;
return parm;
}
#endregion
#region 更新会员参数表
#region 会员注册参数SQL语句
public int Update_UserRegInfo(SysParamInfo sys)//保存基本参数设置
{
string SQL = "update " + Pre + "sys_PramUser set regItem=@strContent,returnemail=@returnemail,returnmobile=@returnmobile";
SqlParameter[] parm = GetUserRegInfo(sys);
return DbHelper.ExecuteNonQuery(CommandType.Text, SQL, parm);
}
private SqlParameter[] GetUserRegInfo(SysParamInfo sys)
{
SqlParameter[] parm = new SqlParameter[3];
parm[0] = new SqlParameter("@strContent", SqlDbType.NText);
parm[0].Value = sys.strContent;
parm[1] = new SqlParameter("@returnemail", SqlDbType.TinyInt);
parm[1].Value = sys.returnemail;
parm[2] = new SqlParameter("@returnmobile", SqlDbType.TinyInt);
parm[2].Value = sys.returnmobile;
return parm;
}
#endregion
#region 会员基本参数设置
public int Update_UserInfo(SysParamInfo sys)//保存基本参数设置
{
string Str_InSql = "Update " + Pre + "Sys_PramUser Set RegGroupNumber=@Str_RegGroupNumber,ConstrTF=@constrr,RegTF=@reg,UserLoginCodeTF=@code,CommCodeTF=@diss,SendMessageTF=@senemessage,UnRegCommTF=@n,CommHTMLLoad=@htmls,Commfiltrchar=@Str_Commfiltrchar,IPLimt=@Str_IPLimt,GpointName=@Str_GpointName,LoginLock=@Str_LoginLock,setPoint=@Str_setPoint,RegContent=@Str_RegContent,GhClass=@ghclass,cPointParam=@Str_cPointParam,aPointparam=@Str_aPointparam,CommCheck=@CommCheck";
SqlParameter[] parm = GetUserInfo(sys);
return DbHelper.ExecuteNonQuery(CommandType.Text, Str_InSql, parm);
}
private SqlParameter[] GetUserInfo(SysParamInfo sys)
{
SqlParameter[] parm = new SqlParameter[18];
parm[0] = new SqlParameter("@Str_RegGroupNumber", SqlDbType.NVarChar, 20);
parm[0].Value = sys.Str_RegGroupNumber;
parm[1] = new SqlParameter("@constrr", SqlDbType.TinyInt);
parm[1].Value = sys.constrr;
parm[2] = new SqlParameter("@reg", SqlDbType.TinyInt);
parm[2].Value = sys.reg;
parm[3] = new SqlParameter("@code", SqlDbType.TinyInt);
parm[3].Value = sys.code;
parm[4] = new SqlParameter("@diss", SqlDbType.TinyInt);
parm[4].Value = sys.diss;
parm[5] = new SqlParameter("@senemessage", SqlDbType.TinyInt);
parm[5].Value = sys.senemessage;
parm[6] = new SqlParameter("@n", SqlDbType.TinyInt);
parm[6].Value = sys.n;
parm[7] = new SqlParameter("@htmls", SqlDbType.TinyInt);
parm[7].Value = sys.htmls;
parm[8] = new SqlParameter("@Str_Commfiltrchar", SqlDbType.NText);
parm[8].Value = sys.Str_Commfiltrchar;
parm[9] = new SqlParameter("@Str_IPLimt", SqlDbType.NText);
parm[9].Value = sys.Str_IPLimt;
parm[10] = new SqlParameter("@Str_GpointName", SqlDbType.NVarChar, 10);
parm[10].Value = sys.Str_GpointName;
parm[11] = new SqlParameter("@Str_LoginLock", SqlDbType.NVarChar, 10);
parm[11].Value = sys.Str_LoginLock;
parm[12] = new SqlParameter("@Str_setPoint", SqlDbType.NVarChar, 20);
parm[12].Value = sys.Str_setPoint;
parm[13] = new SqlParameter("@Str_RegContent", SqlDbType.NText);
parm[13].Value = sys.Str_RegContent;
parm[14] = new SqlParameter("@ghclass", SqlDbType.TinyInt);
parm[14].Value = sys.ghclass;
parm[15] = new SqlParameter("@Str_cPointParam", SqlDbType.NVarChar, 30);
parm[15].Value = sys.Str_cPointParam;
parm[16] = new SqlParameter("@Str_aPointparam", SqlDbType.NVarChar, 30);
parm[16].Value = sys.Str_aPointparam;
parm[17] = new SqlParameter("@CommCheck", SqlDbType.TinyInt, 1);
parm[17].Value = sys.CommCheck;
return parm;
}
#endregion
#region 会员等级设置
public int Update_Leavel(SysParamInfo sys, int k)//保存等级设置
{
string Str_InSqlLeavel = "Update " + Pre + "Sys_UserLevel Set LTitle=@Str_LtitleArr,Lpicurl=@Str_LpicurlArr,iPoint=@Str_iPointArr where id=" + k + "";
SqlParameter[] parm = GetUserleavelInfo(sys, k);
return DbHelper.ExecuteNonQuery(CommandType.Text, Str_InSqlLeavel, parm);
}
private SqlParameter[] GetUserleavelInfo(SysParamInfo sys, int k)
{
SqlParameter[] parm = new SqlParameter[3];
parm[0] = new SqlParameter("@Str_LtitleArr", SqlDbType.NVarChar, 50);
parm[0].Value = sys.Str_LtitleArr[k];
parm[1] = new SqlParameter("@Str_LpicurlArr", SqlDbType.NVarChar, 200);
parm[1].Value = sys.Str_LpicurlArr[k];
parm[2] = new SqlParameter("@Str_iPointArr", SqlDbType.Int, 4);
parm[2].Value = sys.Str_iPointArr[k];
return parm;
}
#endregion
#endregion
#region 更新上传
public int Update_FtpInfo(SysParamInfo sys)//保存基本参数设置
{
string Str_InSql = "Update " + Pre + "Sys_Param Set PicServerTF=@picsa,PicServerDomain=@Str_PicServerDomain,PicUpLoad=@Str_PicUpLoad,UpfilesType=@Str_UpfilesType,UpFilesSize=@Str_UpFilesSize,ReMoteDomainTF=@domainnn,RemoteDomain=@Str_RemoteDomain,RemoteSavePath=@Str_RemoteSavePath,ClassListNum=@Str_ClassListNum,NewsNum=@Str_NewsNum,BatDelNum=@Str_BatDelNum,SpecialNum=@Str_SpecialNum";
SqlParameter[] parm = GetFtpInfo(sys);
return DbHelper.ExecuteNonQuery(CommandType.Text, Str_InSql, parm);
}
private SqlParameter[] GetFtpInfo(SysParamInfo sys)
{
SqlParameter[] parm = new SqlParameter[12];
parm[0] = new SqlParameter("@picsa", SqlDbType.TinyInt);
parm[0].Value = sys.picsa;
parm[1] = new SqlParameter("@Str_PicServerDomain", SqlDbType.NText);
parm[1].Value = sys.Str_PicServerDomain;
parm[2] = new SqlParameter("@Str_PicUpLoad", SqlDbType.NVarChar, 200);
parm[2].Value = sys.Str_PicUpLoad;
parm[3] = new SqlParameter("@Str_UpfilesType", SqlDbType.NVarChar, 150);
parm[3].Value = sys.Str_UpfilesType;
parm[4] = new SqlParameter("@Str_UpFilesSize", SqlDbType.Int, 4);
parm[4].Value = sys.Str_UpFilesSize;
parm[5] = new SqlParameter("@domainnn", SqlDbType.TinyInt);
parm[5].Value = sys.domainnn;
parm[6] = new SqlParameter("@Str_RemoteDomain", SqlDbType.NVarChar, 100);
parm[6].Value = sys.Str_RemoteDomain;
parm[7] = new SqlParameter("@Str_RemoteSavePath", SqlDbType.NVarChar, 200);
parm[7].Value = sys.Str_RemoteSavePath;
parm[8] = new SqlParameter("@Str_ClassListNum", SqlDbType.Int, 4);
parm[8].Value = sys.Str_ClassListNum;
parm[9] = new SqlParameter("@Str_NewsNum", SqlDbType.Int, 4);
parm[9].Value = sys.Str_NewsNum;
parm[10] = new SqlParameter("Str_BatDelNum", SqlDbType.Int, 4);
parm[10].Value = sys.Str_BatDelNum;
parm[11] = new SqlParameter("@Str_SpecialNum", SqlDbType.Int, 4);
parm[11].Value = sys.Str_SpecialNum;
return parm;
}
#endregion
#region JS
public int Update_JS(SysParamInfo sys)//更新JS
{
string Str_InSqljs = "Update " + Pre + "Sys_Param Set HotNewsJs=@Str_HotJS,LastNewsJs=@Str_LastJS,RecNewsJS=@Str_RecJS,HotCommJS=@Str_HoMJS,TNewsJS=@Str_TMJS";
SqlParameter[] parm = GetJSInfo(sys);
return DbHelper.ExecuteNonQuery(CommandType.Text, Str_InSqljs, parm);
}
private SqlParameter[] GetJSInfo(SysParamInfo sys)
{
SqlParameter[] parm = new SqlParameter[5];
parm[0] = new SqlParameter("@Str_HotJS", SqlDbType.NVarChar, 200);
parm[0].Value = sys.Str_HotJS;
parm[1] = new SqlParameter("@Str_LastJS", SqlDbType.NVarChar, 200);
parm[1].Value = sys.Str_LastJS;
parm[2] = new SqlParameter("@Str_RecJS", SqlDbType.NVarChar, 200);
parm[2].Value = sys.Str_RecJS;
parm[3] = new SqlParameter("@Str_HoMJS", SqlDbType.NVarChar, 200);
parm[3].Value = sys.Str_HoMJS;
parm[4] = new SqlParameter("@Str_TMJS", SqlDbType.NVarChar, 200);
parm[4].Value = sys.Str_TMJS;
return parm;
}
#endregion
#region ftp
public int Update_JFtP(SysParamInfo sys)//更新JS
{
string Str_InSqlftp = "Update " + Pre + "sys_Pramother Set FtpTF=@ftpp,FTPIP=@Str_FTPIP,Ftpport=@Str_Ftpport,FtpUserName=@Str_FtpUserName,FTPPASSword=@Str_FTPPASSword";
SqlParameter[] parm = GetftpInfo(sys);
return DbHelper.ExecuteNonQuery(CommandType.Text, Str_InSqlftp, parm);
}
private SqlParameter[] GetftpInfo(SysParamInfo sys)
{
SqlParameter[] parm = new SqlParameter[5];
parm[0] = new SqlParameter("@ftpp", SqlDbType.Int, 4);
parm[0].Value = sys.ftpp;
parm[1] = new SqlParameter("@Str_FTPIP", SqlDbType.NVarChar, 100);
parm[1].Value = sys.Str_FTPIP;
parm[2] = new SqlParameter("@Str_Ftpport", SqlDbType.NVarChar, 5);
parm[2].Value = sys.Str_Ftpport;
parm[3] = new SqlParameter("@Str_FtpUserName", SqlDbType.NVarChar, 20);
parm[3].Value = sys.Str_FtpUserName;
parm[4] = new SqlParameter("@Str_FTPPASSword", SqlDbType.NVarChar, 50);
parm[4].Value = sys.Str_FTPPASSword;
return parm;
}
#endregion
#region 水印
public int Update_Water(SysParamInfo sys)//更新JS
{
string Str_InSql = "Update " + Pre + "Sys_ParmPrint Set PrintTF=@water,PrintPicTF=@Str_PrintPicTF,PrintWord=@Str_PrintWord,Printfontsize=@Str_Printfontsize,Printfontfamily=@Str_Printfontfamily,Printfontcolor=@Str_Printfontcolor,PrintBTF=@Str_PrintBTF,PintPicURL=@Str_PintPicURL,PrintPicsize=@Str_PrintPicsize,PintPictrans=@Str_PintPictrans,PrintPosition=@Str_PrintPosition,PrintSmallTF=@Str_PrintSmallTF,PrintSmallSizeStyle=@Str_PrintSmallSizeStyle,PrintSmallSize=@Str_PrintSmallSize,PrintSmallinv=@Str_PrintSmallinv";
SqlParameter[] parm = GetwaterInfo(sys);
return DbHelper.ExecuteNonQuery(CommandType.Text, Str_InSql, parm);
}
private SqlParameter[] GetwaterInfo(SysParamInfo sys)
{
SqlParameter[] parm = new SqlParameter[15];
parm[0] = new SqlParameter("@water", SqlDbType.TinyInt);
parm[0].Value = sys.water;
parm[1] = new SqlParameter("@Str_PrintPicTF", SqlDbType.TinyInt);
parm[1].Value = sys.Str_PrintPicTF;
parm[2] = new SqlParameter("@Str_PrintWord", SqlDbType.NVarChar, 50);
parm[2].Value = sys.Str_PrintWord;
parm[3] = new SqlParameter("@Str_Printfontsize", SqlDbType.Int, 4);
parm[3].Value = sys.Str_Printfontsize;
parm[4] = new SqlParameter("@Str_Printfontfamily", SqlDbType.NVarChar, 30);
parm[4].Value = sys.Str_Printfontfamily;
parm[5] = new SqlParameter("@Str_Printfontcolor", SqlDbType.NVarChar, 10);
parm[5].Value = sys.Str_Printfontcolor;
parm[6] = new SqlParameter("@Str_PrintBTF", SqlDbType.TinyInt);
parm[6].Value = sys.Str_PrintBTF;
parm[7] = new SqlParameter("@Str_PintPicURL", SqlDbType.NVarChar, 150);
parm[7].Value = sys.Str_PintPicURL;
parm[8] = new SqlParameter("@Str_PrintPicsize", SqlDbType.NVarChar, 8);
parm[8].Value = sys.Str_PrintPicsize;
parm[9] = new SqlParameter("@Str_PintPictrans", SqlDbType.NVarChar, 20);
parm[9].Value = sys.Str_PintPictrans;
parm[10] = new SqlParameter("@Str_PrintPosition", SqlDbType.TinyInt);
parm[10].Value = sys.Str_PrintPosition;
parm[11] = new SqlParameter("@Str_PrintSmallTF", SqlDbType.TinyInt);
parm[11].Value = sys.Str_PrintSmallTF;
parm[12] = new SqlParameter("@Str_PrintSmallSizeStyle", SqlDbType.TinyInt);
parm[12].Value = sys.Str_PrintSmallSizeStyle;
parm[13] = new SqlParameter("@Str_PrintSmallSize", SqlDbType.NVarChar, 8);
parm[13].Value = sys.Str_PrintSmallSize;
parm[14] = new SqlParameter("@Str_PrintSmallinv", SqlDbType.NVarChar, 20);
parm[14].Value = sys.Str_PrintSmallinv;
return parm;
}
/// <summary>
/// 取得站点水印信息
/// </summary>
/// <returns></returns>
public DataTable ParmPrintInfo()
{
string Sql = "Select * From " + Pre + "Sys_ParmPrint";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
#endregion
#region rss wap
public int Update_RssWap(SysParamInfo sys)//更新JS
{
string Str_InSql = "Update " + Pre + "sys_Pramother Set RssNum=@Str_RssNum,RssContentNum=@Str_RssContentNum,RssTitle=@Str_RssTitle,RssPicURL=@Str_RssPicURL,WapTF=@wapp,WapPath=@Str_WapPath,WapDomain=@Str_WapDomain,WapLastNum=@Str_WapLastNum";
SqlParameter[] parm = GetrssrInfo(sys);
return DbHelper.ExecuteNonQuery(CommandType.Text, Str_InSql, parm);
}
private SqlParameter[] GetrssrInfo(SysParamInfo sys)
{
SqlParameter[] parm = new SqlParameter[8];
parm[0] = new SqlParameter("@Str_RssNum", SqlDbType.Int, 4);
parm[0].Value = sys.Str_RssNum;
parm[1] = new SqlParameter("@Str_RssContentNum", SqlDbType.Int, 4);
parm[1].Value = sys.Str_RssContentNum;
parm[2] = new SqlParameter("@Str_RssTitle", SqlDbType.NVarChar, 50);
parm[2].Value = sys.Str_RssTitle;
parm[3] = new SqlParameter("@Str_RssPicURL", SqlDbType.NVarChar, 200);
parm[3].Value = sys.Str_RssPicURL;
parm[4] = new SqlParameter("@wapp", SqlDbType.TinyInt);
parm[4].Value = sys.wapp;
parm[5] = new SqlParameter("@Str_WapPath", SqlDbType.NVarChar, 50);
parm[5].Value = sys.Str_WapPath;
parm[6] = new SqlParameter("@Str_WapDomain", SqlDbType.NVarChar, 50);
parm[6].Value = sys.Str_WapDomain;
parm[7] = new SqlParameter("@Str_WapLastNum", SqlDbType.Int, 4);
parm[7].Value = sys.Str_WapLastNum;
return parm;
}
#endregion
public DataTable ShowJS1()
{
string Str_StartSql = "Select PicServerTF,ReMoteDomainTF From " + Pre + "Sys_Param";//从参数设置表中读出数据并初始化赋值
return DbHelper.ExecuteTable(CommandType.Text, Str_StartSql, null);
}
public DataTable ShoeJs2()
{
string Str_StartSqlf = "Select FtpTF,WapTF From " + Pre + "Sys_Pramother";//从其他参数表中去数据
return DbHelper.ExecuteTable(CommandType.Text, Str_StartSqlf, null);
}
public DataTable showJs3()
{
string Str_StartSqlp = "Select PrintPicTF,PrintSmallTF,PrintSmallSizeStyle From " + Pre + "Sys_ParmPrint";//从水印参数表中去数据
return DbHelper.ExecuteTable(CommandType.Text, Str_StartSqlp, null);
}
public DataTable JsTemplet1()
{
string Str_SelectSql1 = "Select JsID,jsTName From " + Pre + "news_JSTemplet";
return DbHelper.ExecuteTable(CommandType.Text, Str_SelectSql1, null);
}
public DataTable JsTemplet2()
{
string Str_SelectSql2 = "Select JsID,jsTName From " + Pre + "news_JSTemplet";
return DbHelper.ExecuteTable(CommandType.Text, Str_SelectSql2, null);
}
public DataTable JsTemplet3()
{
string Str_SelectSql3 = "Select JsID,jsTName From " + Pre + "news_JSTemplet";
return DbHelper.ExecuteTable(CommandType.Text, Str_SelectSql3, null);
}
public DataTable JsTemplet4()
{
string Str_SelectSql4 = "Select JsID,jsTName From " + Pre + "news_JSTemplet";
return DbHelper.ExecuteTable(CommandType.Text, Str_SelectSql4, null);
}
public DataTable JsTemplet5()
{
string Str_SelectSql5 = "Select JsID,jsTName From " + Pre + "news_JSTemplet";
return DbHelper.ExecuteTable(CommandType.Text, Str_SelectSql5, null);
}
#endregion
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Sys.cs | C# | asf20 | 34,442 |
using System;
using System.Text;
using System.Text.RegularExpressions;
namespace Discuz.Common
{
public class TypeConverter
{
/// <summary>
/// string型转换为bool型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的bool类型结果</returns>
public static bool StrToBool(object expression, bool defValue)
{
if (expression != null)
return StrToBool(expression, defValue);
return defValue;
}
/// <summary>
/// string型转换为bool型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的bool类型结果</returns>
public static bool StrToBool(string expression, bool defValue)
{
if (expression != null)
{
if (string.Compare(expression, "true", true) == 0)
return true;
else if (string.Compare(expression, "false", true) == 0)
return false;
}
return defValue;
}
/// <summary>
/// 将对象转换为Int32类型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static int ObjectToInt(object expression)
{
return ObjectToInt(expression, 0);
}
/// <summary>
/// 将对象转换为Int32类型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static int ObjectToInt(object expression, int defValue)
{
if (expression != null)
return StrToInt(expression.ToString(), defValue);
return defValue;
}
/// <summary>
/// 将对象转换为Int32类型,转换失败返回0
/// </summary>
/// <param name="str">要转换的字符串</param>
/// <returns>转换后的int类型结果</returns>
public static int StrToInt(string str)
{
return StrToInt(str, 0);
}
/// <summary>
/// 将对象转换为Int32类型
/// </summary>
/// <param name="str">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static int StrToInt(string str, int defValue)
{
if (string.IsNullOrEmpty(str) || str.Trim().Length >= 11 || !Regex.IsMatch(str.Trim(), @"^([-]|[0-9])[0-9]*(\.\w*)?$"))
return defValue;
int rv;
if (Int32.TryParse(str, out rv))
return rv;
return Convert.ToInt32(StrToFloat(str, defValue));
}
/// <summary>
/// string型转换为float型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static float StrToFloat(object strValue, float defValue)
{
if ((strValue == null))
return defValue;
return StrToFloat(strValue.ToString(), defValue);
}
/// <summary>
/// string型转换为float型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static float ObjectToFloat(object strValue, float defValue)
{
if ((strValue == null))
return defValue;
return StrToFloat(strValue.ToString(), defValue);
}
/// <summary>
/// string型转换为float型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static float ObjectToFloat(object strValue)
{
return ObjectToFloat(strValue.ToString(), 0);
}
/// <summary>
/// string型转换为float型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <returns>转换后的int类型结果</returns>
public static float StrToFloat(string strValue)
{
if ((strValue == null))
return 0;
return StrToFloat(strValue.ToString(), 0);
}
/// <summary>
/// string型转换为float型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static float StrToFloat(string strValue, float defValue)
{
if ((strValue == null) || (strValue.Length > 10))
return defValue;
float intValue = defValue;
if (strValue != null)
{
bool IsFloat = Regex.IsMatch(strValue, @"^([-]|[0-9])[0-9]*(\.\w*)?$");
if (IsFloat)
float.TryParse(strValue, out intValue);
}
return intValue;
}
/// <summary>
/// 将对象转换为日期时间类型
/// </summary>
/// <param name="str">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static DateTime StrToDateTime(string str, DateTime defValue)
{
if (!string.IsNullOrEmpty(str))
{
DateTime dateTime;
if (DateTime.TryParse(str, out dateTime))
return dateTime;
}
return defValue;
}
/// <summary>
/// 将对象转换为日期时间类型
/// </summary>
/// <param name="str">要转换的字符串</param>
/// <returns>转换后的int类型结果</returns>
public static DateTime StrToDateTime(string str)
{
return StrToDateTime(str, DateTime.Now);
}
/// <summary>
/// 将对象转换为日期时间类型
/// </summary>
/// <param name="obj">要转换的对象</param>
/// <returns>转换后的int类型结果</returns>
public static DateTime ObjectToDateTime(object obj)
{
return StrToDateTime(obj.ToString());
}
/// <summary>
/// 将对象转换为日期时间类型
/// </summary>
/// <param name="obj">要转换的对象</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static DateTime ObjectToDateTime(object obj, DateTime defValue)
{
return StrToDateTime(obj.ToString(), defValue);
}
/// <summary>
/// 字符串转成整型数组
/// </summary>
/// <param name="idList">要转换的字符串</param>
/// <returns>转换后的int类型结果</returns>
public static int[] StringToIntArray(string idList)
{
return StringToIntArray(idList, -1);
}
/// <summary>
/// 字符串转成整型数组
/// </summary>
/// <param name="idList">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static int[] StringToIntArray(string idList, int defValue)
{
if (string.IsNullOrEmpty(idList))
return null;
string[] strArr = idList.Split(',');
int[] intArr = new int[strArr.Length];
for (int i = 0; i < strArr.Length; i++)
intArr[i] = StrToInt(strArr[i], defValue);
return intArr;
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/TypeConverter.cs | C# | asf20 | 8,629 |
//======================================================
//== (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.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class UserList : DbBase, IUserList
{
public string getGroupName(string strGroupNumber)
{
SqlParameter param = new SqlParameter("@GroupNumber", strGroupNumber);
string Sql = "select GroupName from " + Pre + "user_Group where GroupNumber=@GroupNumber";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
public int singdel(int id)
{
//删除投稿
rootPublic pd = new rootPublic();
string _user = pd.getUidUserNum(id);
pd.delUserAllInfo(_user);
string Sql = "delete " + Pre + "sys_user where id = " + id + NetCMS.Common.Public.getSessionStr() + "";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public int dels(string id)
{
rootPublic pd = new rootPublic();
string _user = "";
if (id.IndexOf(",") == -1)
{
_user = pd.getUidUserNum(int.Parse(id));
pd.delUserAllInfo(_user);
}
else
{
for (int m = 0; m < id.Split(',').Length; m++)
{
_user = pd.getUidUserNum(int.Parse(id.Split(',')[m]));
pd.delUserAllInfo(_user);
}
}
string Sql = "delete " + Pre + "sys_user where id in (" + id + ") " + NetCMS.Common.Public.getSessionStr() + "";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public int isLock(string id)
{
string Sql = "update " + Pre + "sys_user set islock=1 where id in (" + id.Trim() + ") " + NetCMS.Common.Public.getSessionStr() + "";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public int unLock(string id)
{
string Sql = "update " + Pre + "sys_user set islock=0 where id in (" + id.Trim() + ") " + NetCMS.Common.Public.getSessionStr() + "";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public DataTable GroupList()
{
string Sql = "select ID,GroupNumber,GroupName from " + Pre + "user_group where SiteID='" + NetCMS.Global.Current.SiteID + "' order by id desc";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
public int bIpoint(string uid, int sPoint)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@uid", SqlDbType.Int,4);
param[0].Value =uid;
param[1] = new SqlParameter("@sPoint", SqlDbType.Int,4);
param[1].Value =sPoint;
string Sql = "update " + Pre + "sys_user set iPoint=iPoint+@sPoint where id in (@uid) " + NetCMS.Common.Public.getSessionStr() + "";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public int sIpoint(string uid, int sPoint)
{
string Sql = "update " + Pre + "sys_user set iPoint=iPoint-" + sPoint + " where id in (" + uid + ") " + NetCMS.Common.Public.getSessionStr() + "";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public int bGpoint(string uid, int sPoint)
{
string Sql = "update " + Pre + "sys_user set gPoint=gPoint+" + sPoint + " where id in (" + uid + ") " + NetCMS.Common.Public.getSessionStr() + "";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public int sGpoint(string uid, int sPoint)
{
string Sql = "update " + Pre + "sys_user set gPoint=gPoint-" + sPoint + " where id in (" + uid + ") " + NetCMS.Common.Public.getSessionStr() + "";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public DataTable GetPage(string UserName, string RealName, string UserNum, string Sex, string siPoint, string biPoint, string sgPoint, string bgPoint, string _userlock, string _group, string _iscerts, string _SiteID, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
string QSQL = "";
if (UserName != "" && UserName != null) { QSQL = " and UserName like '%" + UserName + "%'"; }
if (RealName != "" && RealName != null) { QSQL = " and RealName like '%" + RealName + "%'"; }
if (UserNum != "" && UserNum != null) { QSQL = " and UserNum = '" + UserNum + "'"; }
if (Sex != "" && Sex != null)
{
int _Sex = int.Parse(Sex.ToString());
QSQL += " and Sex = " + _Sex + "";
}
if (siPoint != "" && siPoint != null)
{
int _siPoint = int.Parse(siPoint.ToString());
QSQL += " and iPoint >= " + _siPoint + "";
}
if (biPoint != "" && biPoint != null)
{
int _biPoint = int.Parse(biPoint.ToString());
QSQL += " and iPoint <= " + _biPoint + "";
}
if (sgPoint != "" && sgPoint != null)
{
int _sgPoint = int.Parse(sgPoint.ToString());
QSQL += " and gPoint >= " + _sgPoint + "";
}
if (bgPoint != "" && bgPoint != null)
{
int _bgPoint = int.Parse(bgPoint.ToString());
QSQL += " and gPoint <= " + _bgPoint + "";
}
if (_userlock != null && _userlock != "")
{
QSQL += " and islock=" + int.Parse(_userlock) + "";
}
if (_group != "" && _group != null)
{
QSQL += " and UserGroupNumber='" + _group + "'";
}
if (_iscerts != "" && _iscerts != null)
{
QSQL += " and isIDcard='" + int.Parse(_iscerts) + "'";
}
if (_SiteID != "" && _SiteID != null) { QSQL += " and SiteID='" + _SiteID + "'"; }
else { QSQL += " and SiteID='" + NetCMS.Global.Current.SiteID + "'"; }
string AllFields = "id,userNum,username,RealName,UserGroupNumber,islock,RegTime,ipoint,gPoint,LastLoginTime,LastIP,isIDcard,isAdmin";
string Condition = "" + Pre + "sys_user where 1=1 " + QSQL + "";
string IndexField = "ID";
string OrderFields = "order by Id Desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, null);
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/UserList.cs | C# | asf20 | 7,372 |
//======================================================
//== (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 System.Text;
using NetCMS.Model;
using NetCMS.Config;
using NetCMS.DALProfile;
using NetCMS.DALFactory;
namespace NetCMS.DALSQLServer
{
public class CustomForm : DbBase, ICustomForm
{
void ICustomForm.Edit(CustomFormInfo info)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
SqlTransaction tran = cn.BeginTransaction();
try
{
if (info.id > 0)
{
#region 修改
string Sql = "update " + Pre + "customform set formname=@formname,accessorypath=@accessorypath,accessorysize=@accessorysize,";
Sql += "memo=@memo,islock=@islock,timelimited=@timelimited,starttime=@starttime,endtime=@endtime,";
Sql += "showvalidatecode=@showvalidatecode,submitonce=@submitonce,isdelpoint=@isdelpoint,gpoint=@gpoint,ipoint=@ipoint,";
Sql += "groupnumber=@groupnumber where id=" + info.id;
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, GetEditParams(info));
#endregion
}
else
{
#region 新增
string tab = info.formtablename;
if (tab.IndexOf("'") >= 0)
tab.Replace("'", "''");
string Sql = "IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[" + tab + "]') AND ";
Sql += "OBJECTPROPERTY(id, N'IsUserTable') = 1) SELECT 1 ELSE SELECT 0";
object obj = DbHelper.ExecuteScalar(tran, CommandType.Text, Sql, null);
if (obj != null && obj != DBNull.Value)
{
if (obj.ToString() == "1")
{
throw new Exception("该用户表名已经存在!");
}
}
else
{
throw new Exception("该用户表名已经存在(null)!");
}
Sql = "insert into " + Pre + "customform (formname,formtablename,accessorypath,accessorysize,memo,islock,timelimited,";
Sql += "starttime,endtime,showvalidatecode,submitonce,isdelpoint,gpoint,ipoint,groupnumber,addtime) values (";
Sql += "@formname,@formtablename,@accessorypath,@accessorysize,@memo,@islock,@timelimited,";
Sql += "@starttime,@endtime,@showvalidatecode,@submitonce,@isdelpoint,@gpoint,@ipoint,@groupnumber,'" + DateTime.Now + "')";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, GetEditParams(info));
Sql = "CREATE TABLE [" + tab + "] ([id] [int] IDENTITY (1, 1) NOT NULL ,";
Sql += " [usernum] [nvarchar] (50) NULL ,";
Sql += " [username] [nvarchar] (50) NULL ,";
Sql += " [submit_ip] [nvarchar] (15) NULL ,";
Sql += " [submit_time] [datetime] NULL ,";
Sql += ")ON [PRIMARY]";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, null);
#endregion
}
tran.Commit();
}
catch
{
try
{
tran.Rollback();
}
catch
{ }
throw;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
protected SqlParameter[] GetEditParams(CustomFormInfo info)
{
SqlParameter[] Param = new SqlParameter[15];
Param[0] = new SqlParameter("@formname", SqlDbType.NVarChar, 50);
Param[0].Value = info.formname;
Param[1] = new SqlParameter("@formtablename", SqlDbType.NVarChar, 50);
Param[1].Value = info.formtablename;
Param[2] = new SqlParameter("@accessorypath", SqlDbType.NVarChar, 100);
Param[3] = new SqlParameter("@accessorysize", SqlDbType.Int);
if (info.accessorypath == string.Empty && info.accessorysize > 0)
{
Param[2].Value = DBNull.Value;
Param[3].Value = DBNull.Value;
}
else
{
Param[2].Value = info.accessorypath;
Param[3].Value = info.accessorysize;
}
Param[4] = new SqlParameter("@memo", SqlDbType.NVarChar, 255);
if (info.memo == string.Empty)
Param[4].Value = DBNull.Value;
else
Param[4].Value = info.memo;
Param[5] = new SqlParameter("@islock", SqlDbType.Bit);
Param[5].Value = info.islock;
Param[6] = new SqlParameter("@timelimited", SqlDbType.Bit);
Param[6].Value = info.timelimited;
Param[7] = new SqlParameter("@starttime", SqlDbType.DateTime);
Param[8] = new SqlParameter("@endtime", SqlDbType.DateTime);
if (info.timelimited)
{
Param[7].Value = info.starttime;
Param[8].Value = info.endtime;
}
else
{
Param[7].Value = DBNull.Value;
Param[8].Value = DBNull.Value;
}
Param[9] = new SqlParameter("@showvalidatecode", SqlDbType.Bit);
Param[9].Value = info.showvalidatecode;
Param[10] = new SqlParameter("@submitonce", SqlDbType.Bit);
Param[10].Value = info.submitonce;
Param[11] = new SqlParameter("@isdelpoint", SqlDbType.TinyInt);
Param[11].Value = info.isdelpoint;
Param[12] = new SqlParameter("@gpoint", SqlDbType.Int);
Param[12].Value = info.gpoint;
Param[13] = new SqlParameter("@ipoint", SqlDbType.Int);
Param[13].Value = info.ipoint;
Param[14] = new SqlParameter("@groupnumber", SqlDbType.NText);
if (info.groupnumber == string.Empty)
Param[14].Value = DBNull.Value;
else
Param[14].Value = info.groupnumber;
return Param;
}
CustomFormInfo ICustomForm.GetInfo(int id)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
return GetInfo(cn, id);
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
protected CustomFormInfo GetInfo(SqlConnection cn, int id)
{
CustomFormInfo info = new CustomFormInfo();
string Sql = "select * from " + Pre + "customform where id=" + id;
bool flag = false;
IDataReader rd = DbHelper.ExecuteReader(cn, CommandType.Text, Sql, null);
if (rd.Read())
{
info.id = id;
info.formname = rd["formname"].ToString();
info.formtablename = rd["formtablename"].ToString();
if (rd["accessorypath"] != DBNull.Value) info.accessorypath = rd["accessorypath"].ToString();
if (rd["accessorysize"] != DBNull.Value) info.accessorysize = Convert.ToInt32(rd["accessorysize"]);
if (rd["memo"] != DBNull.Value) info.memo = rd["memo"].ToString();
if (rd["islock"] != DBNull.Value) info.islock = Convert.ToBoolean(rd["islock"]);
info.timelimited = Convert.ToBoolean(rd["timelimited"]);
if (rd["starttime"] != DBNull.Value) info.starttime = Convert.ToDateTime(rd["starttime"]);
if (rd["endtime"] != DBNull.Value) info.endtime = Convert.ToDateTime(rd["endtime"]);
info.showvalidatecode = Convert.ToBoolean(rd["showvalidatecode"]);
info.submitonce = Convert.ToBoolean(rd["submitonce"]);
info.isdelpoint = Convert.ToByte(rd["isdelpoint"]);
info.gpoint = Convert.ToInt32(rd["gpoint"]);
info.ipoint = Convert.ToInt32(rd["ipoint"]);
if (rd["groupnumber"] != DBNull.Value) info.groupnumber = rd["groupnumber"].ToString();
flag = true;
}
rd.Close();
if (!flag)
{
throw new Exception("没有找到相关的自定义表单记录!");
}
return info;
}
void ICustomForm.DeleteForm(int id)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
SqlTransaction tran = cn.BeginTransaction();
try
{
string Sql = "select formtablename from " + Pre + "customform where id=" + id;
object obj = DbHelper.ExecuteScalar(tran, CommandType.Text, Sql, null);
if (obj != null && obj != DBNull.Value)
{
Sql = "delete from " + Pre + "customform where id=" + id;
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, null);
Sql = "delete from " + Pre + "customform_item where formid=" + id;
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, null);
Sql = "drop table [" + obj + "]";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, null);
tran.Commit();
}
else
{
throw new Exception("没有找到相关的自定义表单记录");
}
}
catch
{
try
{
tran.Rollback();
}
catch
{ }
throw;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
string ICustomForm.GetFormName(int id)
{
string Sql = "select formname from " + Pre + "customform where id=" + id;
object obj = DbHelper.ExecuteScalar(CommandType.Text, Sql, null);
if (obj == null)
{
throw new Exception("没有找到相关的表单记录");
}
else
{
if (obj == DBNull.Value)
return string.Empty;
else
return obj.ToString();
}
}
CustomFormItemInfo ICustomForm.GetFormItemInfo(int itemid)
{
CustomFormItemInfo info = new CustomFormItemInfo();
string Sql = "select a.*,b.formname from " + Pre + "customform_item a inner join " + Pre + "customform b on a.formid=b.id where a.id=" + itemid;
bool flag = false;
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, null);
if (rd.Read())
{
info.id = Convert.ToInt32(rd["id"]);
info.formid = Convert.ToInt32(rd["formid"]);
info.formname = rd["formname"].ToString();
info.seriesnumber = Convert.ToInt32(rd["seriesnumber"]);
info.fieldname = rd["fieldname"].ToString();
info.itemname = rd["itemname"].ToString();
info.itemtype = (EnumCstmFrmItemType)Enum.Parse(typeof(EnumCstmFrmItemType), rd["itemtype"].ToString());
if (rd["defaultvalue"] != DBNull.Value) info.defaultvalue = rd["defaultvalue"].ToString();
info.isnotnull = Convert.ToBoolean(rd["isnotnull"].ToString());
if (rd["itemsize"] != DBNull.Value) info.itemsize = Convert.ToInt32(rd["itemsize"].ToString());
info.islock = Convert.ToBoolean(rd["islock"].ToString());
if (rd["prompt"] != DBNull.Value) info.prompt = rd["prompt"].ToString();
if (rd["selectitem"] != DBNull.Value) info.selectitem = rd["selectitem"].ToString();
flag = true;
}
rd.Close();
if (!flag)
throw new Exception("未找到相关的自定义表单项");
return info;
}
int ICustomForm.GetItemCount(int formid)
{
string Sql = "select count(id) from " + Pre + "customform_item where formid=" + formid;
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, null));
}
void ICustomForm.EditFormItem(CustomFormItemInfo info)
{
if (info.id > 0)
UpdateItem(info);
else
AddItem(info);
}
/// <summary>
/// 修改表单项
/// </summary>
/// <param name="info"></param>
protected void UpdateItem(CustomFormItemInfo info)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
string Sql = "select count(id) from " + Pre + "customform_item where formid=" + info.formid + " and itemname=@itemname and id<>" + info.id;
SqlParameter Param1 = new SqlParameter("@itemname", info.itemname);
if (Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, Param1)) > 0)
throw new Exception("该自定义表单已存在相同的表单项名称");
#region 检查序号
string UpOldSql = string.Empty;
Sql = "select id from " + Pre + "customform_item where formid=" + info.formid + " and seriesnumber=" + info.seriesnumber;
object obj = DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null);
if (obj != null && obj != DBNull.Value)
{
int oldsnid = Convert.ToInt32(obj);
Sql = "select seriesnumber from " + Pre + "customform_item where id=" + info.id;
object oldsn = DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null);
if (oldsn != null && oldsn != DBNull.Value)
{
int nold = Convert.ToInt32(oldsn);
UpOldSql = "update " + Pre + "customform_item set seriesnumber=" + nold + " where id=" + oldsnid;
}
}
#endregion
SqlTransaction tran = cn.BeginTransaction();
try
{
Sql = "update " + Pre + "customform_item set seriesnumber=@seriesnumber,itemname=@itemname,";
Sql += "defaultvalue=@defaultvalue,isnotnull=@isnotnull,itemsize=@itemsize,islock=@islock,prompt=@prompt,";
Sql += "selectitem=@selectitem where id=" + info.id;
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, GetItemEditParams(info));
if (UpOldSql != string.Empty)
DbHelper.ExecuteNonQuery(tran, CommandType.Text, UpOldSql, null);
tran.Commit();
}
catch
{
try
{
tran.Rollback();
}
catch
{ }
throw;
}
}
catch
{
throw;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
/// <summary>
/// 新增表单项
/// </summary>
/// <param name="info"></param>
protected void AddItem(CustomFormItemInfo info)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
#region 检查字段名是否重复
string Sql = "select count(id) from " + Pre + "customform_item where formid=" + info.formid + " and itemname=@itemname";
SqlParameter Param1 = new SqlParameter("@itemname", info.itemname);
if (Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, Param1)) > 0)
throw new Exception("该自定义表单已存在相同的表单项名称");
Sql = "select count(id) from " + Pre + "customform_item where formid=" + info.formid + " and fieldname=@fieldname";
SqlParameter Param2 = new SqlParameter("@fieldname", info.fieldname);
if (Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, Param2)) > 0)
throw new Exception("该自定义表单中已存在相同的字段名称");
#endregion
#region 检查字段名是否重复
#endregion
#region 获取数据表名
Sql = "select formtablename from " + Pre + "customform where id=" + info.formid;
object obj = DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null);
if (obj == null)
throw new Exception("没有找到相关的表单记录");
else if (obj == DBNull.Value)
throw new Exception("相关的数据表名为空");
string tbnm = obj.ToString();
#endregion
#region 检查实际表中是否存在相同名称
bool flag = false;
Sql = "select * from " + tbnm + " where 1=0";
IDataReader rd = DbHelper.ExecuteReader(cn, CommandType.Text, Sql, null);
DataTable dt = rd.GetSchemaTable();
foreach (DataColumn col in dt.Columns)
{
if (col.ColumnName.ToLower().Trim() == info.fieldname.ToLower().Trim())
{
flag = true;
break;
}
}
rd.Close();
dt.Dispose();
if (flag)
throw new Exception("该自定义表单的数据表中已存在相同的字段名称,或者您使用了系统默认的字段名");
#endregion
#region 检查数据表是否存在
Sql = "IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[" + tbnm + "]') AND ";
Sql += "OBJECTPROPERTY(id, N'IsUserTable') = 1) SELECT 1 ELSE SELECT 0";
obj = DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null);
if (obj != null && obj != DBNull.Value)
{
if (obj.ToString() == "0")
{
throw new Exception("该自定义表单数据表不存在!");
}
}
else
{
throw new Exception("该自定义表单数据表不存在(null)!");
}
#endregion
#region 查看序列号是否已被占用
string UpOldSql = string.Empty;
Sql = "select id from " + Pre + "customform_item where formid=" + info.formid + " and seriesnumber=" + info.seriesnumber;
obj = DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null);
if (obj != null && obj != DBNull.Value)
{
int oldsnid = Convert.ToInt32(obj);
Sql = "select max(seriesnumber) from " + Pre + "customform_item where formid=" + info.formid;
object maxid = DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null);
if (maxid != null && maxid != DBNull.Value)
{
int nmax = Convert.ToInt32(maxid);
nmax++;
UpOldSql = "update " + Pre + "customform_item set seriesnumber=" + nmax + " where id=" + oldsnid;
}
}
#endregion
SqlTransaction tran = cn.BeginTransaction();
try
{
Sql = "insert into " + Pre + "customform_item (seriesnumber,formid,fieldname,itemname,itemtype,defaultvalue,isnotnull,";
Sql += "itemsize,islock,prompt,selectitem,addtime) values (";
Sql += "@seriesnumber,@formid,@fieldname,@itemname,@itemtype,@defaultvalue,@isnotnull,";
Sql += "@itemsize,@islock,@prompt,@selectitem,'" + DateTime.Now + "')";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, GetItemEditParams(info));
if (UpOldSql != string.Empty)
DbHelper.ExecuteNonQuery(tran, CommandType.Text, UpOldSql, null);
string fldtype = "nvarchar(100)";
switch (info.itemtype)
{
case EnumCstmFrmItemType.Numberic:
fldtype = "numeric(10,4)";
break;
case EnumCstmFrmItemType.DateTime:
fldtype = "datetime";
break;
case EnumCstmFrmItemType.MultiLineText:
fldtype = "ntext";
break;
}
Sql = "ALTER TABLE [" + tbnm + "] ADD " + info.fieldname + " " + fldtype + " NULL";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, null);
tran.Commit();
}
catch
{
try
{
tran.Rollback();
}
catch
{ }
throw;
}
}
catch
{
throw;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
protected SqlParameter[] GetItemEditParams(CustomFormItemInfo info)
{
SqlParameter[] Param = new SqlParameter[11];
Param[0] = new SqlParameter("@seriesnumber", SqlDbType.Int);
Param[0].Value = info.seriesnumber;
Param[1] = new SqlParameter("@formid", SqlDbType.Int);
Param[1].Value = info.formid;
Param[2] = new SqlParameter("@fieldname", SqlDbType.NVarChar, 50);
Param[2].Value = info.fieldname;
Param[3] = new SqlParameter("@itemname", SqlDbType.NVarChar, 50);
Param[3].Value = info.itemname;
Param[4] = new SqlParameter("@itemtype", SqlDbType.NVarChar, 50);
Param[4].Value = info.itemtype.ToString();
Param[5] = new SqlParameter("@defaultvalue", SqlDbType.NVarChar, 50);
if (info.defaultvalue.Trim() == string.Empty)
Param[5].Value = DBNull.Value;
else
Param[5].Value = info.defaultvalue;
Param[6] = new SqlParameter("@isnotnull", SqlDbType.Bit);
Param[6].Value = info.isnotnull;
Param[7] = new SqlParameter("@itemsize", SqlDbType.Int);
Param[7].Value = info.itemsize;
Param[8] = new SqlParameter("@islock", SqlDbType.Bit);
Param[8].Value = info.islock;
Param[9] = new SqlParameter("@prompt", SqlDbType.NVarChar, 255);
if (info.prompt.Trim() == string.Empty)
Param[9].Value = DBNull.Value;
else
Param[9].Value = info.prompt;
Param[10] = new SqlParameter("@selectitem", SqlDbType.NText);
if (info.selectitem.Trim() == string.Empty)
Param[10].Value = DBNull.Value;
else
Param[10].Value = info.selectitem;
return Param;
}
void ICustomForm.DeleteFormItem(int itemid)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
string tabnm = string.Empty;
string fldnm = string.Empty;
int fm = 0;
int sn = 0;
string Sql = "select a.formtablename,b.fieldname,b.formid,b.seriesnumber from " + Pre + "customform a ";
Sql += "inner join " + Pre + "customform_item b on a.id=b.formid where b.id=" + itemid;
IDataReader rd = DbHelper.ExecuteReader(cn, CommandType.Text, Sql, null);
if (rd.Read())
{
tabnm = rd.GetString(0);
fldnm = rd.GetString(1);
fm = rd.GetInt32(2);
sn = rd.GetInt32(3);
}
rd.Close();
if (tabnm == string.Empty || fldnm == string.Empty)
throw new Exception("没有找到相关的数据表或字段");
SqlTransaction tran = cn.BeginTransaction();
try
{
Sql = "ALTER TABLE [" + tabnm + "] DROP COLUMN " + fldnm + "";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, null);
Sql = "delete from " + Pre + "customform_item where id=" + itemid;
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, null);
Sql = "update " + Pre + "customform_item set seriesnumber=seriesnumber-1 where formid=" + fm + " and seriesnumber>" + sn;
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, null);
tran.Commit();
}
catch
{
try
{
tran.Rollback();
}
catch
{ }
throw;
}
}
catch
{
throw;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
IList<CustomFormItemInfo> ICustomForm.GetAllInfo(int formid, out CustomFormInfo FormInfo)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
FormInfo = GetInfo(cn, formid);
IList<CustomFormItemInfo> list = new List<CustomFormItemInfo>();
string Sql = "select * from " + Pre + "customform_item where islock=0 and formid=" + formid + " order by seriesnumber asc";
IDataReader rd = DbHelper.ExecuteReader(cn, CommandType.Text, Sql, null);
while (rd.Read())
{
CustomFormItemInfo info = new CustomFormItemInfo();
info.id = Convert.ToInt32(rd["id"]);
info.formid = Convert.ToInt32(rd["formid"]);
info.seriesnumber = Convert.ToInt32(rd["seriesnumber"]);
info.fieldname = rd["fieldname"].ToString();
info.itemname = rd["itemname"].ToString();
info.itemtype = (EnumCstmFrmItemType)Enum.Parse(typeof(EnumCstmFrmItemType), rd["itemtype"].ToString());
if (rd["defaultvalue"] != DBNull.Value) info.defaultvalue = rd["defaultvalue"].ToString();
info.isnotnull = Convert.ToBoolean(rd["isnotnull"].ToString());
if (rd["itemsize"] != DBNull.Value) info.itemsize = Convert.ToInt32(rd["itemsize"].ToString());
info.islock = Convert.ToBoolean(rd["islock"].ToString());
if (rd["prompt"] != DBNull.Value) info.prompt = rd["prompt"].ToString();
if (rd["selectitem"] != DBNull.Value) info.selectitem = rd["selectitem"].ToString();
list.Add(info);
}
rd.Close();
return list;
}
catch
{
throw;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
void ICustomForm.AddRecord(int formid, SQLConditionInfo[] data)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
string SqlF = string.Empty;
string SqlV = string.Empty;
SqlParameter[] Param = new SqlParameter[data.Length + 4];
#region 用户相关信息
Param[0] = new SqlParameter("@usernum", SqlDbType.NVarChar, 50);
Param[0].Value = DBNull.Value;
Param[1] = new SqlParameter("@username", SqlDbType.NVarChar, 50);
Param[1].Value = DBNull.Value;
Param[2] = new SqlParameter("@submit_ip", SqlDbType.NVarChar, 15);
Param[2].Value = NetCMS.Common.Public.getUserIP();
Param[3] = new SqlParameter("@submit_time", SqlDbType.DateTime);
Param[3].Value = DateTime.Now;
#endregion
CustomFormInfo FormInfo = GetInfo(cn, formid);
if (FormInfo.isdelpoint != 0)
{
if (Global.Current.IsTimeout())
throw new Exception("您还未登录,请先登录才能提交表单");
if (FormInfo.submitonce)
{
string SqlTimes = "select count(id) from " + FormInfo.formtablename + " where usernum='" + Global.Current.UserNum + "'";
int times = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, SqlTimes, null));
if (times > 1)
throw new Exception("该表单只允许每个会员提交一次,您已经提交过了。");
}
Param[0].Value = Global.Current.UserNum;
Param[1].Value = Global.Current.UserName;
if (FormInfo.ipoint > 0 || FormInfo.gpoint > 0)
{
bool bread = false;
int ipnt = 0;
int gpnt = 0;
string grp = string.Empty;
string SqlUser = "select iPoint,gPoint,UserGroupNumber from " + Pre + "sys_User where UserNum='" + Global.Current.UserNum + "'";
IDataReader rd = DbHelper.ExecuteReader(cn, CommandType.Text, SqlUser, null);
if (rd.Read())
{
ipnt = rd.GetInt32(0);
gpnt = rd.GetInt32(1);
grp = rd.GetString(2);
bread = true;
}
rd.Close();
if (!bread)
{
throw new Exception("该用户的相关信息未找到");
}
switch (FormInfo.isdelpoint)
{
case 1:
if (gpnt < FormInfo.gpoint)
throw new Exception("提交需要扣除" + FormInfo.gpoint + "金币,您的金币不足");
break;
case 2:
if (ipnt < FormInfo.ipoint)
throw new Exception("提交需要扣除" + FormInfo.ipoint + "点数,您的点数不足");
break;
case 3:
if (gpnt < FormInfo.gpoint || ipnt < FormInfo.ipoint)
throw new Exception("提交需要扣除金币和点数,您的金币或点数不足");
break;
case 4:
if (gpnt < FormInfo.gpoint)
throw new Exception("提交需要达到" + FormInfo.gpoint + "金币,您的金币不足");
break;
case 5:
if (ipnt < FormInfo.ipoint)
throw new Exception("提交需要达到" + FormInfo.ipoint + "点数,您的点数不足");
break;
case 6:
if (gpnt < FormInfo.gpoint || ipnt < FormInfo.ipoint)
throw new Exception("提交需要达到一定的金币和点数,您的金币或点数不足");
break;
}
if (FormInfo.groupnumber != string.Empty && FormInfo.groupnumber.IndexOf(grp + ",") < 0)
{
throw new Exception("只有指定的会员组才能提交,您不属于该会员组");
}
}
}
for (int i = 0; i < data.Length; i++)
{
SQLConditionInfo info = data[i];
if (i > 0)
{
SqlF += ",";
SqlV += ",";
}
SqlF += info.name;
SqlV += "@" + info.name;
Param[i + 4] = new SqlParameter("@" + info.name, info.value);
}
SqlTransaction tran = cn.BeginTransaction();
try
{
string Sql = "insert into [" + FormInfo.formtablename + "] (usernum,username,submit_ip,submit_time," + SqlF + ")";
Sql += " values (@usernum,@username,@submit_ip,@submit_time," + SqlV + ")";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, Param);
if ((FormInfo.isdelpoint == 1 || FormInfo.isdelpoint == 2 || FormInfo.isdelpoint == 3)
&& (FormInfo.ipoint > 0 || FormInfo.gpoint > 0))
{
if (FormInfo.isdelpoint == 1)
Sql = "update " + Pre + "sys_User set gPoint=gPoint-" + FormInfo.gpoint + " where UserNum='" + Global.Current.UserNum + "'";
else if (FormInfo.isdelpoint == 2)
Sql = "update " + Pre + "sys_User set iPoint=iPoint-" + FormInfo.ipoint + " where UserNum='" + Global.Current.UserNum + "'";
else if (FormInfo.isdelpoint == 3)
Sql = "update " + Pre + "sys_User set gPoint=gPoint-" + FormInfo.gpoint + ",iPoint=iPoint-" + FormInfo.ipoint + " where UserNum='" + Global.Current.UserNum + "'";
DbHelper.ExecuteNonQuery(tran, CommandType.Text, Sql, null);
}
tran.Commit();
}
catch
{
tran.Rollback();
throw;
}
}
catch
{
throw;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
DataTable ICustomForm.GetSubmitData(int formid, out string formname, out string tablename)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
CustomFormInfo FormInfo = GetInfo(cn, formid);
string GSql = "select itemname from " + Pre + "Customform_item where fieldname='" + FormInfo.formname + "'";
string gCName = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, GSql, null));
formname = FormInfo.formname;
tablename = FormInfo.formtablename;
return DbHelper.ExecuteTable(cn, CommandType.Text, "select * from " + tablename, null);
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
void ICustomForm.TruncateTable(int formid)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
CustomFormInfo FormInfo = GetInfo(cn, formid);
string tablename = FormInfo.formtablename;
DbHelper.ExecuteTable(cn, CommandType.Text, "TRUNCATE TABLE " + tablename, null);
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/CustomForm.cs | C# | asf20 | 38,283 |
//======================================================
//== (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 DynamicTrans : DbBase, IDynamicTrans
{
/// <summary>
/// 得到新闻内容
/// </summary>
/// <param name="NewsID"></param>
/// <returns></returns>
public IDataReader GetNewsInfo(string ID, int Num, int ChID, string DTable)
{
SqlParameter[] param = new SqlParameter[2];
if (ChID != 0)
{
param[0] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[0].Value = int.Parse(ID);
}
else
{
param[0] = new SqlParameter("@ID", SqlDbType.NVarChar, 12);
param[0].Value = ID;
}
param[1] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[1].Value = ChID;
string sql = string.Empty;
if (ChID != 0)
{
if (Num == 0)
{
sql = "select id,isDelPoint,Templet,Gpoint,iPoint,GroupNumber from " + DTable + " where ID=@ID and isLock=0";
}
else
{
sql = "select id,isDelPoint,Gpoint,iPoint,GroupNumber from " + Pre + "sys_channelclass where ClassID=@ID and isLock=0";
}
}
else
{
if (Num == 0)
{
sql = "select NewsID,isDelPoint,Templet,Gpoint,iPoint,GroupNumber from " + Pre + "news where NewsID=@ID and isLock=0 and isRecyle=0 and NewsType!=2";
}
else
{
sql = "select ClassID,isDelPoint,Gpoint,iPoint,GroupNumber from " + Pre + "news_Class where ClassID=@ID and isLock=0 and isRecyle=0 and isURL!=1";
}
}
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public IDataReader getUserInfo(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string sql = "select isAdmin,UserGroupNumber,iPoint,gPoint from " + Pre + "sys_user where UserNum=@UserNum";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public int UpdateHistory(int infoType, string infoID, int iPoint, int Gpoint, string UserNum,string IP)
{
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@UserNum", UserNum), new SqlParameter("@infoID", infoID), new SqlParameter("@IP", IP), new SqlParameter("@infoType", infoType) };
string uSql = "insert into " + Pre + "user_note(infoType,infoID,logTime,IP,UserNum) values(@infoType,@infoID,'" + DateTime.Now + "',@IP,@UserNum)";
DbHelper.ExecuteNonQuery(CommandType.Text, uSql, param);
string Sql = "update " + Pre + "sys_User set iPoint=iPoint-" + iPoint + ",Gpoint=Gpoint-" + Gpoint + " where UserNum=@UserNum";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public bool getUserNote(string UserNum, string infoID,int Num)
{
bool bltf = false;
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@UserNum", UserNum), new SqlParameter("@infoID", infoID), new SqlParameter("@infoType", Num) };
string sql = "select count(id) from " + Pre + "user_note where UserNum=@UserNum and infoID=@infoID and infoType=@infoType";
int i = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
if (i > 0)
{
bltf = true;
}
return bltf;
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/DynamicTrans.cs | C# | asf20 | 4,232 |
//======================================================
//== (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.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class ContentManage : DbBase, IContentManage
{
/// <summary>
/// 得到站点栏目列表结果
/// </summary>
/// <returns></returns>
public IDataReader GetClassSitenewsstr(string ParentID, string SiteID)
{
string Sql = "Select ClassID,[Domain],DataLib,SiteID,ClassCName,(Select Count(id) from " + Pre + "news_Class where ParentID=a.ClassID and isRecyle=0 and isUrl=0 and islock=0 and isPage=0) as HasSub from " + Pre + "news_Class a where ParentID='" + ParentID + "' and isRecyle=0 and isUrl=0 and islock=0 and SiteID='" + SiteID + "' and isPage=0 order by OrderID desc,id desc";
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
#region 内容管理开始
#region 新闻
public void updateClassStat(int Num, string ID, int flag)
{
#region
string str_sql = null;
if (flag == 0)// 更新栏目状态:1为已生成,0表示未生成
{
str_sql = "update " + Pre + "news_Class set isunHTML=" + Num + " where ClassId='" + ID + "' " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 1)// 更新新闻状态:1为已生成,0表示未生成
{
str_sql = "update " + Pre + "news set isHtml=" + Num + " where NewsID='" + ID + "' " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 2)
{
str_sql = "Update " + Pre + "news_Class Set OrderID=" + Num + " Where ClassID='" + ID + "' and SiteID = '" + NetCMS.Global.Current.SiteID + "'";
}
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
#endregion
}
/// <summary>
/// 新闻内容管理.得到站点表
/// </summary>
/// <returns></returns>
public DataTable sel_newsInfo(int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "select top 15 CName from " + Pre + "news_Gen where gType=0 and islock=0 order by id desc";
}
else if (flag == 1)
{
Sql = "select * from " + Pre + "sys_param";
}
else if (flag == 2)//// 得到内部连接地址
{
Sql = "select Cname,URL from " + Pre + "news_Gen where gType=3";
}
else if (flag == 3)// 得到自定义类型
{
Sql = "Select id,defineInfoId,defineCname From " + Pre + "Define_Data where 1=1 " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 4)//得到栏目源
{
Sql = "Select ClassID,ClassCName,ParentID From " + Pre + "news_Class where SiteID='" + NetCMS.Global.Current.SiteID + "' and IsURL=0";
}
else if (flag == 5)//得到栏目
{
Sql = "Select ClassID,ClassCname,ParentID From " + Pre + "News_Class where SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 6)//得到站点列表
{
Sql = "select ID,ChannelID,CName from " + Pre + "news_site where IsURL=0 and isRecyle=0 and isLock=0 order by id";
}
else if (flag == 7)//得到归档新闻
{
Sql = "select top 1 * from " + Pre + "old_News order by id desc";
}
else if (flag == 8)
{
Sql = "select JsID,JSName from " + Pre + "News_JS where SiteID='" + NetCMS.Global.Current.SiteID + "' and jsType=1";
}
else if (flag == 9)
{
Sql = "select ClassID,ClassCName,ParentID from " + Pre + "News_Class where isURL=0 and isLock=0 and isRecyle=0 and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 10)
{
Sql = "select top 1 * from " + Pre + "old_News";
}
else if (flag == 11)//从临时表中获取记录
{
Sql = "select id,NewsID,DataLib,NewsType from " + Pre + "news where islock=0 and isRecyle=0 and siteID='" + NetCMS.Global.Current.SiteID + "' order by CreatTime desc,id desc";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
#endregion
}
/// <summary>
/// 新闻内容管理.得到索引表
/// </summary>
/// <returns></returns>
public IDataReader GetNewsIndex()
{
string Sql = "select TableName,id from " + Pre + "sys_NewsIndex order by Id asc";
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
public void updateNewsPro(string str, string ID, int num)
{
#region
string Sql = "";
if (num == 0)
{
Sql = "Update " + Pre + "news Set NewsProperty='" + str + "' Where Id In (" + ID + ")";
}
else if (num == 1)
{
Sql = "Update " + Pre + "news Set NewsProperty='" + str + "' Where ClassID In (" + ID + ")";
}
else if (num == 2)
{
Sql = "Update " + Pre + "news Set Templet='" + str + "' Where Id In (" + ID + ")";
}
else if (num == 3)
{
Sql = "Update " + Pre + "news Set Templet='" + str + "' Where ClassID In (" + ID + ")";
}
else if (num == 4)
{
Sql = "Update " + Pre + "news Set OrderID=" + int.Parse(str) + " Where Id In (" + ID + ")";
}
else if (num == 5)
{
Sql = "Update " + Pre + "news Set OrderID=" + int.Parse(str) + " Where ClassID In (" + ID + ")";
}
else if (num == 6)
{
Sql = "Update " + Pre + "news Set CommLinkTF=" + int.Parse(str) + " Where Id In (" + ID + ")";
}
else if (num == 7)
{
Sql = "Update " + Pre + "news Set CommLinkTF=" + int.Parse(str) + " Where ClassID In (" + ID + ")";
}
else if (num == 8)
{
Sql = "Update " + Pre + "news Set Tags='" + str + "' Where Id In (" + ID + ")";
}
else if (num == 9)
{
Sql = "Update " + Pre + "news Set Tags='" + str + "' Where ClassID In (" + ID + ")";
}
else if (num == 10)
{
Sql = "Update " + Pre + "news Set Click=" + int.Parse(str) + " Where Id In (" + ID + ")";
}
else if (num == 11)
{
Sql = "Update " + Pre + "news Set Click=" + int.Parse(str) + " Where ClassID In (" + ID + ")";
}
else if (num == 12)
{
Sql = "Update " + Pre + "news Set Souce='" + str + "' Where Id In (" + ID + ")";
}
else if (num == 13)
{
Sql = "Update " + Pre + "news Set Souce='" + str + "' Where ClassID In (" + ID + ")";
}
else if (num == 14)
{
Sql = "Update " + Pre + "news Set FileEXName='" + str + "' Where Id In (" + ID + ")";
}
else if (num == 15)
{
Sql = "Update " + Pre + "news Set FileEXName='" + str + "' Where ClassID In (" + ID + ")";
}
else if (num == 16)//更新目标栏目
{
string usql = "update " + Pre + "news_class set ParentID='" + ID + "' where ParentID='" + str + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, usql, null);
Sql = "Update " + Pre + "News Set ClassID='" + ID + "' Where ClassID='" + str + "' and SiteID = '" + NetCMS.Global.Current.SiteID + "'";
}
else if (num == 17)// 更新目标下新闻
{
Sql = "Update " + Pre + "News Set ClassID='" + ID + "' Where ClassID='" + str + "' and SiteID = '" + NetCMS.Global.Current.SiteID + "'";
}
else if (num == 18)//更新栏目
{
Sql = "update " + Pre + "News_Class Set " + str + " where ClassID in (" + ID + ") " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (num == 19)//更新目标下栏目
{
string gSQL = "select ID,ParentID from " + Pre + "News_Class where ClassID='" + str + "'";
IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, gSQL, null);
if (dr.Read())
{
string uSQL = "update " + Pre + "News_Class set ParentID='" + dr["ParentID"].ToString() + "' where ParentID='" + dr["ID"].ToString() + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, uSQL, null);
}
dr.Close();
Sql = "Update " + Pre + "News_Class Set ParentID='" + ID + "' Where ClassID='" + str + "' and SiteID = '" + NetCMS.Global.Current.SiteID + "'";
}
else if (num == 20)//更新所有表
{
Sql = "update " + Pre + "news Set Templet = '" + str + "' where ClassID in (" + ID + ") " + NetCMS.Common.Public.getSessionStr() + "";
}
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
// by Simplt.Xie
/// <summary>
/// 得到指定新闻的DataTable
/// </summary>
/// <param name="NewsID"></param>
/// <param name="DataLib"></param>
/// <returns></returns>
public IDataReader sel_NameID(string NewsID, int flag)
{
SqlParameter param = new SqlParameter("@ID", NewsID);
string Sql = null;
if (flag == 0)
{
Sql = "select a.*,b.ClassCName from " + Pre + "News a left join " + Pre + "news_Class b ";
Sql += " on a.ClassID=b.ClassID where a.NewsID=@ID";
}
else if (flag == 1)
{
Sql = "select ClassCName,ClassEName,ParentID,ClassID,DataLib,SavePath,SaveClassframe,ClassSaveRule from " + Pre + "news_class where ClassID=@ID " + NetCMS.Common.Public.getSessionStr() + "";
}
return DbHelper.ExecuteReader(CommandType.Text, Sql, param);
}
/// <summary>
/// 检查新闻标题
/// </summary>
/// <param name="NewsTitle"></param>
/// <param name="tb"></param>
/// <returns></returns>
public int newsTitletf(string NewsTitle, string dtable, string EditAction, string NewsID)
{
#region
int intflg = 0;
SqlParameter param = new SqlParameter("@NewsTitle", NewsTitle);
string Sql = "";
if (EditAction == "Edit")
{
Sql = "select ID from " + dtable + " where NewsTitle=@NewsTitle and NewsID!='" + NewsID + "'";
}
else
{
Sql = "select ID from " + dtable + " where NewsTitle=@NewsTitle";
}
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (rdr != null)
{
if (rdr.Rows.Count > 0) { intflg = 1; }
rdr.Clear(); rdr.Dispose();
}
return intflg;
#endregion
}
/// <summary>
/// 插入常规
/// </summary>
/// <param name="_TempStr"></param>
/// <param name="_URL"></param>
/// <param name="_EmailURL"></param>
/// <param name="_num"></param>
public void iGen(string _TempStr, string _URL, string _EmailURL, int _num)
{
#region
string SQLTF = "select id from " + Pre + "News_Gen where Cname='" + _TempStr.Trim() + "' and gType=" + _num + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, SQLTF, null);
if (rdr != null)
{
if (rdr.Rows.Count == 0)
{
string Sql = "insert into " + Pre + "News_Gen(";
Sql += "Cname,gType,URL,EmailURL,isLock,SiteID";
Sql += ") values (";
Sql += "'" + _TempStr + "'," + _num + ",'" + _URL + "','" + _EmailURL + "',0,'" + NetCMS.Global.Current.SiteID + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
rdr.Clear(); rdr.Dispose();
}
#endregion
}
/// <summary>
/// 插入栏目新记录
/// </summary>
/// <param name="uc2"></param>
public void addUpdate_newsContent(NetCMS.Model.NewsContent uc, int flag)
{
#region
string Sql = null;
SqlParameter[] parm = insertNewsContentParameters(uc);
if (flag == 0)
{
Sql = "insert into " + uc.DataLib + "(";
Sql += "NewsID,NewsType,OrderID,NewsTitle,sNewsTitle,TitleColor,TitleITF,TitleBTF,CommLinkTF,SubNewsTF,URLaddress,PicURL,SPicURL,ClassID,Author,Souce,Tags,NewsProperty,NewsPicTopline,Templet,Content,vURL,naviContent,Click,CreatTime,EditTime,SavePath,FileName,FileEXName,ContentPicTF,ContentPicURL,ContentPicSize,CommTF,DiscussTF,TopNum,VoteTF,CheckStat,isLock,isRecyle,SiteID,DataLib,DefineID,isVoteTF,Editor,isHtml,isDelPoint,Gpoint,iPoint,GroupNumber,Metakeywords,Metadesc,isConstr,isFiles";
Sql += ") values (";
Sql += "@NewsID,@NewsType,@OrderID,@NewsTitle,@sNewsTitle,@TitleColor,@TitleITF,@TitleBTF,@CommLinkTF,@SubNewsTF,@URLaddress,@PicURL,@SPicURL,@ClassID,@Author,@Souce,@Tags,@NewsProperty,@NewsPicTopline,@Templet,@Content,@vURL,@naviContent,@Click,@CreatTime,'" + DateTime.Now + "',@SavePath,@FileName,@FileEXName,@ContentPicTF,@ContentPicURL,@ContentPicSize,@CommTF,@DiscussTF,@TopNum,@VoteTF,@CheckStat,@isLock,@isRecyle,@SiteID,@DataLib,@DefineID,@isVoteTF,@Editor,@isHtml,@isDelPoint,@Gpoint,@iPoint,@GroupNumber,@Metakeywords,@Metadesc,0,@isFiles)";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
else if (flag == 1)
{
Sql = "Update " + uc.DataLib + " set NewsType=@NewsType,OrderID=@OrderID,NewsTitle=@NewsTitle,sNewsTitle=@sNewsTitle,TitleColor=@TitleColor,TitleITF=@TitleITF,TitleBTF=@TitleBTF,CommLinkTF=@CommLinkTF,SubNewsTF=@SubNewsTF,URLaddress=@URLaddress,PicURL=@PicURL,SPicURL=@SPicURL,ClassID=@ClassID,Author=@Author,Souce=@Souce,Tags=@Tags,NewsProperty=@NewsProperty,NewsPicTopline=@NewsPicTopline,Templet=@Templet,Content=@Content,vURL=@vURL,naviContent=@naviContent,Click=@Click,EditTime='" + DateTime.Now + "',ContentPicTF=@ContentPicTF,ContentPicURL=@ContentPicURL,ContentPicSize=@ContentPicSize,CommTF=@CommTF,DiscussTF=@DiscussTF,TopNum=@TopNum,VoteTF=@VoteTF,CheckStat=@CheckStat,DefineID=@DefineID,isVoteTF=@isVoteTF,Editor=@Editor,isHtml=@isHtml,isDelPoint=@isDelPoint,Gpoint=@Gpoint,iPoint=@iPoint,GroupNumber=@GroupNumber,Metakeywords=@Metakeywords,Metadesc=@Metadesc,isFiles=@isFiles,FileEXName=@FileEXName,FileName=@FileName where NewsId='" + uc.NewsID + "' " + NetCMS.Common.Public.getSessionStr() + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
string usql = "update " + uc.DataLib + " set islock=1 where NewsID='" + uc.NewsID + "' and substring(CheckStat,3,5)!='0|0|0'";
DbHelper.ExecuteNonQuery(CommandType.Text, usql, parm);
//删除新闻所属专题
DbHelper.ExecuteNonQuery(CommandType.Text, "Delete From " + Pre + "special_news Where NewsID='" + uc.NewsID + "'", null);
}
//添加专题
if (uc.SpecialID != null && uc.SpecialID != "")
{
string[] arr_specialID = uc.SpecialID.Split(',');
for (int i = 0; i < arr_specialID.Length; i++)
{
SqlParameter[] param1 = new SqlParameter[2];
param1[0] = new SqlParameter("@SpecialID", SqlDbType.NVarChar, 20);
param1[0].Value = arr_specialID[i].ToString();
param1[1] = new SqlParameter("@NewsID", SqlDbType.NVarChar, 12);
param1[1].Value = uc.NewsID;
Sql = "Insert Into " + Pre + "special_news(SpecialID,NewsID) Values(@SpecialID,@NewsID)";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param1);
}
}
#endregion
}
/// <summary>
/// 获取NewsContent构造(修改)
/// </summary>
/// <param name="uc"></param>
/// <returns></returns>
private SqlParameter[] UpdateNewsContentParameters(NetCMS.Model.NewsContent uc)
{
#region
SqlParameter[] param = new SqlParameter[45];
param[0] = new SqlParameter("@NewsType", SqlDbType.TinyInt, 1);
param[0].Value = uc.NewsType;
param[1] = new SqlParameter("@OrderID", SqlDbType.TinyInt, 1);
param[1].Value = uc.OrderID;
param[2] = new SqlParameter("@NewsTitle", SqlDbType.NVarChar, 100);
param[2].Value = uc.NewsTitle;
param[3] = new SqlParameter("@sNewsTitle", SqlDbType.NVarChar, 100);
param[3].Value = uc.sNewsTitle;
param[4] = new SqlParameter("@TitleColor", SqlDbType.NVarChar, 10);
param[4].Value = uc.TitleColor;
param[5] = new SqlParameter("@TitleITF", SqlDbType.TinyInt, 1);
param[5].Value = uc.TitleITF;
param[6] = new SqlParameter("@TitleBTF", SqlDbType.TinyInt, 1);
param[6].Value = uc.TitleBTF;
param[7] = new SqlParameter("@CommLinkTF", SqlDbType.TinyInt, 1);
param[7].Value = uc.CommLinkTF;
param[8] = new SqlParameter("@SubNewsTF", SqlDbType.TinyInt, 1);
param[8].Value = uc.SubNewsTF;
param[9] = new SqlParameter("@URLaddress", SqlDbType.NVarChar, 200);
param[9].Value = uc.URLaddress;
param[10] = new SqlParameter("@PicURL", SqlDbType.NVarChar, 200);
param[10].Value = uc.PicURL;
param[11] = new SqlParameter("@SPicURL", SqlDbType.NVarChar, 200);
param[11].Value = uc.SPicURL;
param[12] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 12);
param[12].Value = uc.ClassID;
param[13] = new SqlParameter("@SpecialID", SqlDbType.NVarChar, 200);
param[13].Value = "";
param[14] = new SqlParameter("@Author", SqlDbType.NVarChar, 100);
param[14].Value = uc.Author;
param[15] = new SqlParameter("@Souce", SqlDbType.NVarChar, 100);
param[15].Value = uc.Souce;
param[16] = new SqlParameter("@Tags", SqlDbType.NVarChar, 100);
param[16].Value = uc.Tags;
param[17] = new SqlParameter("@NewsProperty", SqlDbType.NVarChar, 30);
param[17].Value = uc.NewsProperty;
param[18] = new SqlParameter("@Templet", SqlDbType.NVarChar, 200);
param[18].Value = uc.Templet;
param[19] = new SqlParameter("@Content", SqlDbType.NText);
param[19].Value = uc.Content;
param[20] = new SqlParameter("@naviContent", SqlDbType.NVarChar, 255);
param[20].Value = uc.naviContent;
param[21] = new SqlParameter("@ContentPicTF", SqlDbType.TinyInt, 1);
param[21].Value = uc.ContentPicTF;
param[22] = new SqlParameter("@ContentPicURL", SqlDbType.NVarChar, 200);
param[22].Value = uc.ContentPicURL;
param[23] = new SqlParameter("@ContentPicSize", SqlDbType.NVarChar, 10);
param[23].Value = uc.ContentPicSize;
param[24] = new SqlParameter("@CommTF", SqlDbType.TinyInt, 1);
param[24].Value = uc.CommTF;
param[25] = new SqlParameter("@DiscussTF", SqlDbType.TinyInt, 1);
param[25].Value = uc.DiscussTF;
param[26] = new SqlParameter("@TopNum", SqlDbType.Int, 4);
param[26].Value = uc.TopNum;
param[27] = new SqlParameter("@VoteTF", SqlDbType.TinyInt, 1);
param[27].Value = uc.VoteTF;
param[28] = new SqlParameter("@NewsPicTopline", SqlDbType.TinyInt, 1);
param[28].Value = uc.NewsPicTopline;
param[29] = new SqlParameter("@CheckStat", SqlDbType.NVarChar, 10);
param[29].Value = uc.CheckStat;
param[30] = new SqlParameter("@isLock", SqlDbType.TinyInt, 1);
param[30].Value = uc.isLock;
param[31] = new SqlParameter("@DefineID", SqlDbType.TinyInt, 1);
param[31].Value = uc.DefineID;
param[32] = new SqlParameter("@isVoteTF", SqlDbType.TinyInt, 1);
param[32].Value = uc.isVoteTF;
param[33] = new SqlParameter("@Editor", SqlDbType.NVarChar, 18);
param[33].Value = uc.Editor;
param[34] = new SqlParameter("@isHtml", SqlDbType.TinyInt, 1);
param[34].Value = uc.isHtml;
param[35] = new SqlParameter("@Click", SqlDbType.Int, 4);
param[35].Value = uc.Click;
param[36] = new SqlParameter("@isDelPoint", SqlDbType.TinyInt, 1);
param[36].Value = uc.isDelPoint;
param[37] = new SqlParameter("@Gpoint", SqlDbType.Int, 4);
param[37].Value = uc.Gpoint;
param[38] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
param[38].Value = uc.iPoint;
param[39] = new SqlParameter("@GroupNumber", SqlDbType.NText);
param[39].Value = uc.GroupNumber;
param[40] = new SqlParameter("@NewsID", SqlDbType.NVarChar, 12);
param[40].Value = uc.NewsID;
param[41] = new SqlParameter("@DataLib", SqlDbType.NVarChar, 20);
param[41].Value = uc.DataLib;
param[42] = new SqlParameter("@Metakeywords", SqlDbType.NVarChar, 200);
param[42].Value = uc.Metakeywords;
param[43] = new SqlParameter("@Metadesc", SqlDbType.NVarChar, 200);
param[43].Value = uc.Metadesc;
param[44] = new SqlParameter("@isFiles", SqlDbType.TinyInt, 1);
param[44].Value = uc.isFiles;
return param;
#endregion
}
/// <summary>
/// 获取NewsContent构造(插入)
/// </summary>
/// <param name="uc"></param>
/// <returns></returns>
private SqlParameter[] insertNewsContentParameters(NetCMS.Model.NewsContent uc)
{
#region
SqlParameter[] param = new SqlParameter[52];
param[0] = new SqlParameter("@NewsID", SqlDbType.NVarChar, 12);
param[0].Value = uc.NewsID;
param[1] = new SqlParameter("@NewsType", SqlDbType.TinyInt, 1);
param[1].Value = uc.NewsType;
param[2] = new SqlParameter("@OrderID", SqlDbType.TinyInt, 1);
param[2].Value = uc.OrderID;
param[3] = new SqlParameter("@NewsTitle", SqlDbType.NVarChar, 100);
param[3].Value = uc.NewsTitle;
param[4] = new SqlParameter("@sNewsTitle", SqlDbType.NVarChar, 100);
param[4].Value = uc.sNewsTitle;
param[5] = new SqlParameter("@TitleColor", SqlDbType.NVarChar, 10);
param[5].Value = uc.TitleColor;
param[6] = new SqlParameter("@TitleITF", SqlDbType.TinyInt, 1);
param[6].Value = uc.TitleITF;
param[7] = new SqlParameter("@TitleBTF", SqlDbType.TinyInt, 1);
param[7].Value = uc.TitleBTF;
param[8] = new SqlParameter("@CommLinkTF", SqlDbType.TinyInt, 1);
param[8].Value = uc.CommLinkTF;
param[9] = new SqlParameter("@SubNewsTF", SqlDbType.TinyInt, 1);
param[9].Value = uc.SubNewsTF;
param[10] = new SqlParameter("@URLaddress", SqlDbType.NVarChar, 200);
param[10].Value = uc.URLaddress;
param[11] = new SqlParameter("@PicURL", SqlDbType.NVarChar, 200);
param[11].Value = uc.PicURL;
param[12] = new SqlParameter("@SPicURL", SqlDbType.NVarChar, 200);
param[12].Value = uc.SPicURL;
param[13] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 12);
param[13].Value = uc.ClassID;
param[14] = new SqlParameter("@SpecialID", SqlDbType.NVarChar, 200);
param[14].Value = "";
param[15] = new SqlParameter("@Author", SqlDbType.NVarChar, 100);
param[15].Value = uc.Author;
param[16] = new SqlParameter("@Souce", SqlDbType.NVarChar, 100);
param[16].Value = uc.Souce;
param[17] = new SqlParameter("@Tags", SqlDbType.NVarChar, 100);
param[17].Value = uc.Tags;
param[18] = new SqlParameter("@NewsProperty", SqlDbType.NVarChar, 30);
param[18].Value = uc.NewsProperty;
param[19] = new SqlParameter("@Templet", SqlDbType.NVarChar, 200);
param[19].Value = uc.Templet;
param[20] = new SqlParameter("@Content", SqlDbType.NText);
param[20].Value = uc.Content;
param[21] = new SqlParameter("@naviContent", SqlDbType.NVarChar, 255);
param[21].Value = uc.naviContent;
param[22] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[22].Value = uc.CreatTime;
param[23] = new SqlParameter("@SavePath", SqlDbType.NVarChar, 200);
param[23].Value = uc.SavePath;
param[24] = new SqlParameter("@FileName", SqlDbType.NVarChar, 100);
param[24].Value = uc.FileName;
param[25] = new SqlParameter("@FileEXName", SqlDbType.NVarChar, 6);
param[25].Value = uc.FileEXName;
param[26] = new SqlParameter("@ContentPicTF", SqlDbType.TinyInt, 1);
param[26].Value = uc.ContentPicTF;
param[27] = new SqlParameter("@ContentPicURL", SqlDbType.NVarChar, 200);
param[27].Value = uc.ContentPicURL;
param[28] = new SqlParameter("@ContentPicSize", SqlDbType.NVarChar, 10);
param[28].Value = uc.ContentPicSize;
param[29] = new SqlParameter("@CommTF", SqlDbType.TinyInt, 1);
param[29].Value = uc.CommTF;
param[30] = new SqlParameter("@DiscussTF", SqlDbType.TinyInt, 1);
param[30].Value = uc.DiscussTF;
param[31] = new SqlParameter("@TopNum", SqlDbType.Int, 4);
param[31].Value = uc.TopNum;
param[32] = new SqlParameter("@VoteTF", SqlDbType.TinyInt, 1);
param[32].Value = uc.VoteTF;
param[33] = new SqlParameter("@NewsPicTopline", SqlDbType.TinyInt, 1);
param[33].Value = uc.NewsPicTopline;
param[34] = new SqlParameter("@CheckStat", SqlDbType.NVarChar, 10);
param[34].Value = uc.CheckStat;
param[35] = new SqlParameter("@isLock", SqlDbType.TinyInt, 1);
param[35].Value = uc.isLock;
param[36] = new SqlParameter("@isRecyle", SqlDbType.TinyInt, 1);
param[36].Value = uc.isRecyle;
param[37] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[37].Value = uc.SiteID;
param[38] = new SqlParameter("@DataLib", SqlDbType.NVarChar, 20);
param[38].Value = uc.DataLib;
param[39] = new SqlParameter("@DefineID", SqlDbType.TinyInt, 1);
param[39].Value = uc.DefineID;
param[40] = new SqlParameter("@isVoteTF", SqlDbType.TinyInt, 1);
param[40].Value = uc.isVoteTF;
param[41] = new SqlParameter("@Editor", SqlDbType.NVarChar, 18);
param[41].Value = uc.Editor;
param[42] = new SqlParameter("@isHtml", SqlDbType.TinyInt, 1);
param[42].Value = uc.isHtml;
param[43] = new SqlParameter("@Click", SqlDbType.Int, 4);
param[43].Value = uc.Click;
param[44] = new SqlParameter("@isDelPoint", SqlDbType.TinyInt, 1);
param[44].Value = uc.isDelPoint;
param[45] = new SqlParameter("@Gpoint", SqlDbType.Int, 4);
param[45].Value = uc.Gpoint;
param[46] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
param[46].Value = uc.iPoint;
param[47] = new SqlParameter("@GroupNumber", SqlDbType.NText);
param[47].Value = uc.GroupNumber;
param[48] = new SqlParameter("@Metakeywords", SqlDbType.NVarChar, 200);
param[48].Value = uc.Metakeywords;
param[49] = new SqlParameter("@Metadesc", SqlDbType.NVarChar, 200);
param[49].Value = uc.Metadesc;
param[50] = new SqlParameter("@isFiles", SqlDbType.TinyInt, 1);
param[50].Value = uc.isFiles;
param[51] = new SqlParameter("@vURL", SqlDbType.NVarChar, 200);
param[51].Value = uc.vURL;
return param;
#endregion
}
public DataTable sel_infoByStr(string NewsID, string Datatb, int flag)
{
#region
string Sql = null;
SqlParameter param = null;
if (flag == 0)
{
Sql = "select NewsID from " + Datatb + " where NewsID='" + NewsID + "' order by id desc";
}
else if (flag == 1)
{
param = new SqlParameter("@NewsID", NewsID);
Sql = "select URLName,id,FileURL,OrderID from " + Pre + "news_URL where NewsID=@NewsID and DataLib='" + Datatb + "'";
}
else if (flag == 2)
{
Sql = "select voteNum,NewsID,voteContent,ismTF,isMember,SiteID,isTimeOutTime from " + Pre + "news_vote where NewsID='" + NewsID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "' and DataLib='" + Datatb + "'";
}
else if (flag == 3)
{
Sql = "select Id,NewsID,NewsTitle from " + NewsID + " where Id in ('" + Datatb + "')";
}
else if (flag == 4)
{
Sql = "select id from " + NewsID + " where ClassID='" + Datatb + "'";
}
else if (flag == 5)
{
Sql = "select PicURL,SPicUrl from " + Datatb + " where Id='" + NewsID + "'";
}
else if (flag == 6)
{
Sql = "Select NewsTitle From " + Pre + "News where NewsID='" + Datatb + "'";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
#endregion
}
/// <summary>
/// 插入子新闻
/// </summary>
/// <param name="uc2"></param>
public void insertSubNewsContent(string NewsID, string getNewsID, string NewsTitle, string DataLib, string TitleColor, int TitleBTF, int TitleITF, int colsNum)
{
string Sql = "insert into " + Pre + "news_sub(";
Sql += "NewsID,getNewsID,NewsTitle,DataLib,TitleColor,TitleBTF,TitleITF,colsNum,SiteID";
Sql += ") values (";
Sql += "'" + NewsID + "','" + getNewsID + "','" + NewsTitle + "','" + DataLib + "','" + TitleColor + "'," + TitleBTF + "," + TitleITF + "," + colsNum + ",'" + NetCMS.Global.Current.SiteID + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 插入头条
/// </summary>
/// <param name="uc2"></param>
public void addUpdate_TT(NetCMS.Model.NewsContentTT uc, int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "insert into " + Pre + "news_topline(";
Sql += "NewsTF,NewsID,DataLib,tl_font,tl_style,tl_size,tl_color,tl_space,tl_PicColor,tl_SavePath,Creattime,tl_Title,tl_Width,SiteID";
Sql += ") values (";
Sql += "@NewsTF,@NewsID,@DataLib,@tl_font,@tl_style,@tl_size,@tl_color,@tl_space,@tl_PicColor,@tl_SavePath,@Creattime,@tl_Title,@tl_Width,@SiteID)";
}
else if (flag == 1)
{
Sql = "update " + Pre + "news_topline set NewsTF=@NewsTF,NewsID=@NewsID,DataLib=@DataLib,tl_font=@tl_font,tl_style=@tl_style,tl_size=@tl_size,tl_color=@tl_color,tl_space=@tl_space,tl_PicColor=@tl_PicColor,tl_SavePath=@tl_SavePath,Creattime=@Creattime,tl_Title=@tl_Title,tl_Width=@tl_Width,SiteID=@SiteID where NewsID='" + uc.NewsID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
SqlParameter[] parm = intsertTTParameters(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
#endregion
}
/// <summary>
/// 获取NewsContentTT构造
/// </summary>
/// <param name="uc"></param>
/// <returns></returns>
private SqlParameter[] intsertTTParameters(NetCMS.Model.NewsContentTT uc)
{
#region
SqlParameter[] param = new SqlParameter[14];
param[0] = new SqlParameter("@NewsTF", SqlDbType.TinyInt, 1);
param[0].Value = uc.NewsTF;
param[1] = new SqlParameter("@NewsID", SqlDbType.NVarChar, 12);
param[1].Value = uc.NewsID;
param[2] = new SqlParameter("@DataLib", SqlDbType.NVarChar, 50);
param[2].Value = uc.DataLib;
param[3] = new SqlParameter("@tl_font", SqlDbType.NVarChar, 20);
param[3].Value = uc.tl_font;
param[4] = new SqlParameter("@tl_style", SqlDbType.TinyInt, 1);
param[4].Value = uc.tl_style;
param[5] = new SqlParameter("@tl_size", SqlDbType.TinyInt, 1);
param[5].Value = uc.tl_size;
param[6] = new SqlParameter("@tl_color", SqlDbType.NVarChar, 8);
param[6].Value = uc.tl_color;
param[7] = new SqlParameter("@tl_space", SqlDbType.TinyInt, 1);
param[7].Value = uc.tl_space;
param[8] = new SqlParameter("@tl_PicColor", SqlDbType.NVarChar, 8);
param[8].Value = uc.tl_PicColor;
param[9] = new SqlParameter("@tl_SavePath", SqlDbType.NVarChar, 220);
param[9].Value = uc.tl_SavePath;
param[10] = new SqlParameter("@Creattime", SqlDbType.DateTime, 8);
param[10].Value = uc.Creattime;
param[11] = new SqlParameter("@tl_Title", SqlDbType.NVarChar, 150);
param[11].Value = uc.tl_Title;
param[12] = new SqlParameter("@tl_Width", SqlDbType.Int, 4);
param[12].Value = uc.tl_Width;
param[13] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[13].Value = uc.SiteID;
return param;
#endregion
}
/// <summary>
/// 插入附件
/// </summary>
/// <param name="NewsID"></param>
/// <param name="DataLib"></param>
/// <param name="FileURL"></param>
/// <param name="OrderID"></param>
public void insertFileURL(string URLName, string NewsID, string DataLib, string FileURL, int OrderID)
{
string Sql = "insert into " + Pre + "news_URL(";
Sql += "URLName,NewsID,DataLib,FileURL,CreatTime,OrderID";
Sql += ") values (";
Sql += "'" + URLName + "','" + NewsID + "','" + DataLib + "','" + FileURL + "','" + DateTime.Now + "'," + OrderID + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 更新附件文件地址
/// </summary>
/// <param name="URLName"></param>
/// <param name="DataLib"></param>
/// <param name="FileURL"></param>
/// <param name="OrderID"></param>
/// <param name="ID"></param>
public void updateFileURL(string URLName, string DataLib, string FileURL, int OrderID, int ID)
{
string Sql = "update " + Pre + "news_URL set ";
Sql += "URLName='" + URLName + "',DataLib='" + DataLib + "',FileURL='" + FileURL + "',OrderID=" + OrderID + " where id=" + ID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 更新附件
/// </summary>
/// <param name="NewsID"></param>
/// <param name="DataLib"></param>
/// <param name="FileURL"></param>
/// <param name="OrderID"></param>
public void deleteFilesurl(int flgTF, string NewsID)
{
#region
string Sql = null;
string SQL1 = null;
if (flgTF == 1)
{
SQL1 = "select id,NewsID,DataLib from " + Pre + "news_URL order by id desc";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, SQL1, null);
if (dt != null && dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string SQLN = "select id from " + dt.Rows[i]["DataLib"].ToString() + " where NewsID='" + dt.Rows[i]["NewsID"].ToString() + "' order by id desc";
DataTable dts = DbHelper.ExecuteTable(CommandType.Text, SQLN, null);
if (dts != null && dts.Rows.Count == 0)
{
Sql = "delete from " + Pre + "news_URL where NewsId='" + dt.Rows[i]["NewsID"].ToString() + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
dts.Clear(); dts.Dispose();
}
}
dt.Clear(); dt.Dispose();
}
}
else
{
string getSQL = "select NewsID,DataLib from " + Pre + "News where ID=" + int.Parse(NewsID) + "";
DataTable dtss = DbHelper.ExecuteTable(CommandType.Text, getSQL, null);
if (dtss != null && dtss.Rows.Count > 0)
{
Sql = "delete from " + Pre + "news_URL where NewsId='" + dtss.Rows[0]["NewsID"].ToString() + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
string sSql = "update " + dtss.Rows[0]["DataLib"].ToString() + " set isFiles=0 where NewsId='" + dtss.Rows[0]["NewsID"].ToString() + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, sSql, null);
dtss.Clear(); dtss.Dispose();
}
}
#endregion
}
/// <summary>
/// 得到新闻是否有附件
/// </summary>
/// <param name="ID"></param>
/// <returns></returns>
public int getFileIDTF(int ID)
{
int intflg = 0;
string Sql = "select id from " + Pre + "news_URL where ID='" + ID + "'";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
intflg = 1;
}
rdr.Clear(); rdr.Dispose();
}
return intflg;
}
/// <summary>
/// 得到新闻附件地址
/// </summary>
/// <param name="ID"></param>
/// <returns></returns>
public string getNewsAccessory(int ID)
{
SqlParameter param = new SqlParameter("@ID", ID);
string Sql = "select FileURL from " + Pre + "news_URL where ID=@ID";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
/// <summary>
/// 插入投票
/// </summary>
/// <param name="uc2"></param>
public void addUpdate_Vote(NetCMS.Model.VoteContent uc, int flag)
{
string Sql = null;
if (flag == 0)
{
Sql = "insert into " + Pre + "news_vote(";
Sql += "voteNum,voteTitle,voteContent,creattime,ismTF,isMember,NewsID,DataLib,SiteID,isTimeOutTime";
Sql += ") values (";
Sql += "@voteNum,@voteTitle,@voteContent,@creattime,@ismTF,@isMember,@NewsID,@DataLib,@SiteID,@isTimeOutTime)";
}
else if (flag == 1)
{
Sql = "Update " + Pre + "news_vote set voteTitle=@voteTitle,voteContent=@voteContent,creattime=@creattime,ismTF=@ismTF,isMember=@isMember,isTimeOutTime=@isTimeOutTime where NewsId='" + uc.NewsID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
SqlParameter[] parm = intsertVoteParameters(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
/// <summary>
/// 获取VoteContent构造(插入)
/// </summary>
/// <param name="uc"></param>
/// <returns></returns>
private SqlParameter[] intsertVoteParameters(NetCMS.Model.VoteContent ucv)
{
#region
SqlParameter[] param = new SqlParameter[10];
param[0] = new SqlParameter("@voteNum", SqlDbType.NVarChar, 20);
param[0].Value = ucv.voteNum;
param[1] = new SqlParameter("@voteTitle", SqlDbType.NVarChar, 100);
param[1].Value = ucv.voteTitle;
param[2] = new SqlParameter("@voteContent", SqlDbType.NText);
param[2].Value = ucv.voteContent;
param[3] = new SqlParameter("@creattime", SqlDbType.DateTime, 8);
param[3].Value = ucv.creattime;
param[4] = new SqlParameter("@ismTF", SqlDbType.TinyInt, 1);
param[4].Value = ucv.ismTF;
param[5] = new SqlParameter("@isMember", SqlDbType.TinyInt, 1);
param[5].Value = ucv.isMember;
param[6] = new SqlParameter("@NewsID", SqlDbType.NVarChar, 12);
param[6].Value = ucv.NewsID;
param[7] = new SqlParameter("@DataLib", SqlDbType.NVarChar, 20);
param[7].Value = ucv.DataLib;
param[8] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[8].Value = ucv.SiteID;
param[9] = new SqlParameter("@isTimeOutTime", SqlDbType.DateTime, 8);
param[9].Value = ucv.isTimeOutTime;
return param;
#endregion
}
/// <summary>
/// 获取VoteContent构造(更新)
/// </summary>
/// <param name="uc"></param>
/// <returns></returns>
private SqlParameter[] updateVoteParameters(NetCMS.Model.VoteContent ucv)
{
#region
SqlParameter[] param = new SqlParameter[7];
param[0] = new SqlParameter("@voteTitle", SqlDbType.NVarChar, 100);
param[0].Value = ucv.voteTitle;
param[1] = new SqlParameter("@voteContent", SqlDbType.NText);
param[1].Value = ucv.voteContent;
param[2] = new SqlParameter("@creattime", SqlDbType.DateTime, 8);
param[2].Value = ucv.creattime;
param[3] = new SqlParameter("@ismTF", SqlDbType.TinyInt, 1);
param[3].Value = ucv.ismTF;
param[4] = new SqlParameter("@isMember", SqlDbType.TinyInt, 1);
param[4].Value = ucv.isMember;
param[5] = new SqlParameter("@isTimeOutTime", SqlDbType.DateTime, 8);
param[5].Value = ucv.isTimeOutTime;
param[6] = new SqlParameter("@NewsID", SqlDbType.NVarChar, 12);
param[6].Value = ucv.NewsID;
return param;
#endregion
}
/// <summary>
/// 得到头条(NewsID)
/// </summary>
/// <param name="NewsID"></param>
/// <param name="DataLib"></param>
/// <returns></returns>
public DataTable getTopline(string NewsID, string DataLib, int NewsTFNum)
{
string Sql = "select NewsTF,NewsID,DataLib,tl_style,tl_font,tl_size,tl_color,tl_space,tl_PicColor,tl_Title,tl_Width,SiteID,tl_SavePath from " + Pre + "news_topline where NewsID='" + NewsID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "' and DataLib='" + DataLib + "' and NewsTF=" + NewsTFNum + "";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return rdr;
}
/// <summary>
/// ajax保存新闻
/// </summary>
/// <param name="Content"></param>
/// <returns></returns>
public string saveAjaxContent(string Content)
{
//删除今天前的新闻
//string SqlTemp = "delete from " + Pre + "news_temp where CreatTime<>" + DateTime.Now.ToShortDateString() + "";
//DbHelper.ExecuteNonQuery(CommandType.Text, SqlTemp, null);
string _RandStr = NetCMS.Common.Rand.Number(12);
//string Sql = "insert into " + Pre + "news_temp(";
//Sql += "randNum,Content,CreatTime";
//Sql += ") values (";
//Sql += "'" + _RandStr + "','" + Content + "','" + DateTime.Now.ToShortDateString() + "')";
//DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
return _RandStr;
}
/// <summary>
/// 得到栏目中文名称
/// </summary>
/// <param name="ClassID"></param>
/// <returns></returns>
public string sel_cName(string ClassID, int flag)
{
#region
string strflg = null;
string Sql = null;
if (flag == 0)
{
strflg = "没选择栏目";
SqlParameter param = new SqlParameter("@ClassID", ClassID);
Sql = "Select ClassCName From " + Pre + "news_class where ClassID=@ClassID";
object obj = DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
if (obj != null)
{
if (obj != DBNull.Value)
strflg = obj.ToString();
else
strflg = string.Empty;
}
}
else if (flag == 1)
{
strflg = "没选择专题";
Sql = "Select SpecialCName From " + Pre + "news_special where SpecialID='" + ClassID + "'";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
strflg = rdr.Rows[0]["SpecialCName"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
}
return strflg;
#endregion
}
#endregion 新闻
#region 栏目开始
public DataTable getClassContent(string ClassID, int flag)
{
#region
SqlParameter Param = null;
string Sql = null;
if (flag == 0)// 得到栏目信息
{
Sql = "Select ClassID,ClassCName,ClassEName,ParentID,IsURL,Checkint,OrderID,Urladdress,Domain,ClassTemplet,ReadNewsTemplet,SavePath,SaveClassframe,ClassSaveRule,ClassIndexRule,NewsSavePath,NewsFileRule,PicDirPath,ContentPicTF,ContentPICurl,ContentPicSize,InHitoryDay,DataLib,SiteID,NaviShowtf,NaviPIC,NaviContent,MetaKeywords,MetaDescript,isDelPoint,Gpoint,iPoint,GroupNumber,FileName,isComm,NaviPosition,NewsPosition,Defineworkey From " + Pre + "news_class where ClassID='" + ClassID + "' " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 1)// 得到父类型是否合法
{
Sql = "Select ClassID From " + Pre + "News_Class Where ClassID='" + ClassID + "' " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 2)// 判断 栏目重复
{
Sql = "Select ClassEName From " + Pre + "news_class where ClassEName='" + ClassID + "'";
}
else if (flag == 3)// 得到自定义字段类型(修改)
{
Sql = "Select * From " + Pre + "News_Class where ClassID='" + ClassID + "'";
}
else if (flag == 4)// 得到某个自定义字段的值
{
Sql = "Select id,defineInfoId,defineCname,defineColumns,defineType,IsNull,defineValue,defineExpr,definedvalue,Type From " + Pre + "Define_Data where id=" + int.Parse(ClassID) + "";
}
else if (flag == 5)// 得到栏目列表的子类
{
Sql = "Select id,ClassID,ClassCName,ClassEname,ParentID,OrderID,IsURL,IsLock,[Domain],NaviShowtf,isPage From " + Pre + "News_Class Where isRecyle!=1 and ParentID='" + ClassID + "' order by OrderId desc,id desc";
}
else if (flag == 6)//得到栏目列表的子类
{
Sql = "Select isLock From " + Pre + "news_Class Where ClassID='" + ClassID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 7)//得到最新新闻ID
{
Sql = "select Id from " + ClassID + " order by id desc";
}
else if (flag == 8)// 得到站点参数
{
Param = new SqlParameter("@ChannelID", ClassID);
Sql = "select ClassTemplet,ReadNewsTemplet,SaveFileRule,SaveDirPath,SaveDirRule,PicSavePath,DataLib from " + Pre + "news_site where IsURL=0 and isRecyle=0 and isLock=0 and ChannelID=@ChannelID";
}
else if (flag == 9)//得到归档数字,并归档
{
Sql = "select id,CreatTime from " + Pre + "News Where ClassID='" + ClassID + "'";
}
else if (flag == 10)
{
Sql = "select NewsID,NewsTitle,PicURL,ClassID,CreatTime from " + Pre + "News where SiteID='" + NetCMS.Global.Current.SiteID + "' and Id='" + ClassID + "'";
}
else if (flag == 11)//得到不规则新闻
{
Sql = "Select unName,titleCSS,SubCSS,UnID,ONewsID,[Rows],unTitle,NewsTable From [" + Pre + "news_unNews] where UnID='" + ClassID + "'" + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 12)
{
Sql = "Select NewsID,NewsTitle,getNewsID,colsNum,DataLib,titleCSS From [" + Pre + "news_Sub] where NewsID='" + ClassID + "'" + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 13)
{
Param = new SqlParameter("@uID", ClassID);
Sql = "Select [unName],[TitleCSS],[SubCSS],[ONewsID],[Rows],[unTitle],[NewsTable] From [" + Pre + "news_unNews] Where [UnID]=@uID Order By [Rows] Asc,[ID] Asc";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, Param);
#endregion
}
/// <summary>
/// 插入栏目新记录
/// </summary>
/// <param name="uc2"></param>
public void addUpdate_ClassContent(NetCMS.Model.ClassContent uc, int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "insert into " + Pre + "News_Class(";
Sql += "ClassID,ClassCName,ClassEName,URLaddress,ParentID,IsURL,OrderID,NaviShowtf,NaviContent,NaviPIC,MetaKeywords,MetaDescript,SiteID,isLock,isRecyle,NaviPosition,Domain,ClassTemplet,ReadNewsTemplet,SavePath,SaveClassframe,Checkint,ClassSaveRule,ClassIndexRule,NewsSavePath,NewsFileRule,PicDirPath,ContentPicTF,ContentPICurl,ContentPicSize,InHitoryDay,isDelPoint,Gpoint,iPoint,GroupNumber,FileName,isComm,NewsPosition,Defineworkey,CreatTime,isPage,ModelID,isunHTML,DataLib";
Sql += ") values (";
Sql += "@ClassID,@ClassCName,@ClassEName,@URLaddress,@ParentID,@IsURL,@OrderID,@NaviShowtf,@NaviContent,@NaviPIC,@MetaKeywords,@MetaDescript,@SiteID,@isLock,@isRecyle,@NaviPosition,@Domain,@ClassTemplet,@ReadNewsTemplet,@SavePath,@SaveClassframe,@Checkint,@ClassSaveRule,@ClassIndexRule,@NewsSavePath,@NewsFileRule,@PicDirPath,@ContentPicTF,@ContentPICurl,@ContentPicSize,@InHitoryDay,@isDelPoint,@Gpoint,@iPoint,@GroupNumber,@FileName,@isComm,@NewsPosition,@Defineworkey,@CreatTime,0,'0',0,'" + Pre + "News')";
}
else if (flag == 1)
{
Sql = "Update " + Pre + "News_Class set ClassCName=@ClassCName,ClassEName=@ClassEName,URLaddress=@URLaddress,ParentID=@ParentID,IsURL=@IsURL,OrderID=@OrderID,NaviShowtf=@NaviShowtf,NaviContent=@NaviContent,NaviPIC=@NaviPIC,MetaKeywords=@MetaKeywords,MetaDescript=@MetaDescript,isLock=@isLock,isRecyle=@isRecyle,NaviPosition=@NaviPosition,Domain=@Domain,ClassTemplet=@ClassTemplet,ReadNewsTemplet=@ReadNewsTemplet,SavePath=@SavePath,SaveClassframe=@SaveClassframe,Checkint=@Checkint,ClassSaveRule=@ClassSaveRule,ClassIndexRule=@ClassIndexRule,NewsSavePath=@NewsSavePath,NewsFileRule=@NewsFileRule,PicDirPath=@PicDirPath,ContentPicTF=@ContentPicTF,ContentPICurl=@ContentPICurl,ContentPicSize=@ContentPicSize,InHitoryDay=@InHitoryDay,isDelPoint=@isDelPoint,Gpoint=@Gpoint,iPoint=@iPoint,GroupNumber=@GroupNumber,FileName=@FileName,isComm=@isComm,NewsPosition=@NewsPosition,Defineworkey=@Defineworkey,isPage=0,ModelID='0' where ClassID='" + uc.ClassID.ToString() + "' " + NetCMS.Common.Public.getSessionStr() + "";
}
SqlParameter[] parm = insertClassContentParameters(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
#endregion
}
/// <summary>
/// 获取ClassContent构造
/// </summary>
/// <param name="uc"></param>
/// <returns></returns>
private SqlParameter[] insertClassContentParameters(NetCMS.Model.ClassContent uc)
{
#region
SqlParameter[] param = new SqlParameter[41];
param[0] = new SqlParameter("@Defineworkey", SqlDbType.NVarChar, 255);
param[0].Value = uc.Defineworkey;
param[1] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 12);
param[1].Value = uc.ClassID;
param[2] = new SqlParameter("@ClassCName", SqlDbType.NVarChar, 50);
param[2].Value = uc.ClassCName;
param[3] = new SqlParameter("@ClassEName", SqlDbType.NVarChar, 50);
param[3].Value = uc.ClassEName;
param[4] = new SqlParameter("@ParentID", SqlDbType.NVarChar, 12);
param[4].Value = uc.ParentID;
param[5] = new SqlParameter("@IsURL", SqlDbType.TinyInt, 1);
param[5].Value = uc.IsURL;
param[6] = new SqlParameter("@OrderID", SqlDbType.Int, 4);
param[6].Value = uc.OrderID;
param[7] = new SqlParameter("@URLaddress", SqlDbType.NVarChar, 200);
param[7].Value = uc.URLaddress;
param[8] = new SqlParameter("@Domain", SqlDbType.NVarChar, 150);
param[8].Value = uc.Domain;
param[9] = new SqlParameter("@ClassTemplet", SqlDbType.NVarChar, 200);
param[9].Value = uc.ClassTemplet;
param[10] = new SqlParameter("@ReadNewsTemplet", SqlDbType.NVarChar, 200);
param[10].Value = uc.ReadNewsTemplet;
param[11] = new SqlParameter("@SavePath", SqlDbType.NVarChar, 50);
param[11].Value = uc.SavePath;
param[12] = new SqlParameter("@SaveClassframe", SqlDbType.NVarChar, 200);
param[12].Value = uc.SaveClassframe;
param[13] = new SqlParameter("@Checkint", SqlDbType.TinyInt, 1);
param[13].Value = uc.Checkint;
param[14] = new SqlParameter("@ClassSaveRule", SqlDbType.NVarChar, 200);
param[14].Value = uc.ClassSaveRule;
param[15] = new SqlParameter("@ClassIndexRule", SqlDbType.NVarChar, 50);
param[15].Value = uc.ClassIndexRule;
param[16] = new SqlParameter("@NewsSavePath", SqlDbType.NVarChar, 50);
param[16].Value = uc.NewsSavePath;
param[17] = new SqlParameter("@NewsFileRule", SqlDbType.NVarChar, 200);
param[17].Value = uc.NewsFileRule;
param[18] = new SqlParameter("@PicDirPath", SqlDbType.NVarChar, 50);
param[18].Value = uc.PicDirPath;
param[19] = new SqlParameter("@ContentPicTF", SqlDbType.TinyInt, 1);
param[19].Value = uc.ContentPicTF;
param[20] = new SqlParameter("@ContentPICurl", SqlDbType.NVarChar, 200);
param[20].Value = uc.ContentPICurl;
param[21] = new SqlParameter("@ContentPicSize", SqlDbType.NVarChar, 15);
param[21].Value = uc.ContentPicSize;
param[22] = new SqlParameter("@InHitoryDay", SqlDbType.Int, 4);
param[22].Value = uc.InHitoryDay;
param[24] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[24].Value = uc.SiteID;
param[25] = new SqlParameter("@NaviShowtf", SqlDbType.TinyInt, 1);
param[25].Value = uc.NaviShowtf;
param[26] = new SqlParameter("@NaviPIC", SqlDbType.NVarChar, 200);
param[26].Value = uc.NaviPIC;
param[27] = new SqlParameter("@NaviContent", SqlDbType.NVarChar, 255);
param[27].Value = uc.NaviContent;
param[28] = new SqlParameter("@MetaKeywords", SqlDbType.NVarChar, 200);
param[28].Value = uc.MetaKeywords;
param[29] = new SqlParameter("@MetaDescript", SqlDbType.NVarChar, 200);
param[29].Value = uc.MetaDescript;
param[30] = new SqlParameter("@isDelPoint", SqlDbType.TinyInt, 1);
param[30].Value = uc.isDelPoint;
param[31] = new SqlParameter("@Gpoint", SqlDbType.Int, 4);
param[31].Value = uc.Gpoint;
param[32] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
param[32].Value = uc.iPoint;
param[33] = new SqlParameter("@GroupNumber", SqlDbType.NVarChar, 255);
param[33].Value = uc.GroupNumber;
param[34] = new SqlParameter("@FileName", SqlDbType.NVarChar, 6);
param[34].Value = uc.FileName;
param[35] = new SqlParameter("@isLock", SqlDbType.TinyInt, 1);
param[35].Value = uc.isLock;
param[36] = new SqlParameter("@isRecyle", SqlDbType.TinyInt, 1);
param[36].Value = uc.isRecyle;
param[37] = new SqlParameter("@NaviPosition", SqlDbType.NVarChar, 255);
param[37].Value = uc.NaviPosition;
param[38] = new SqlParameter("@NewsPosition", SqlDbType.NVarChar, 255);
param[38].Value = uc.NewsPosition;
param[39] = new SqlParameter("@isComm", SqlDbType.TinyInt, 1);
param[39].Value = uc.isComm;
param[40] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[40].Value = uc.CreatTime;
return param;
#endregion
}
/// <summary>
/// 删除栏目到回收站
/// </summary>
/// <param name="ClassID"></param>
public void del_newsInfos(string ClassID, int flag)
{
string str_sql = null;
if (flag == 0)
{
str_sql = "Update " + Pre + "news_Class Set isRecyle=1 Where ClassID ='" + ClassID.ToString() + "' " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 1)
{
str_sql = "Delete From " + Pre + "news_Class Where ClassID ='" + ClassID.ToString() + "' " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 2)
{
str_sql = "delete from " + Pre + "News_unNews where UnID='" + ClassID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
if (flag == 0)
{
del_News(ClassID, 1);
}
else if (flag == 1)
{
del_News(ClassID, 0);
}
}
/// <summary>
/// 得到栏目下的子类并彻底删除
/// </summary>
/// <param name="ParentID"></param>
/// <returns></returns>
public void GetChildClassdel(string ParentID, int flag)
{
#region
string Sql = "select ClassID from " + Pre + "news_Class where ParentID=@ParentID";
SqlParameter Param = new SqlParameter("@ParentID", ParentID);
object obj = DbHelper.ExecuteScalar(CommandType.Text, Sql, Param);
if (obj != null && obj != DBNull.Value)
{
if (flag == 0)
{
del_newsInfos(obj.ToString(), 1);
}
else if (flag == 1)
{
del_newsInfos(obj.ToString(), 0);
}
GetChildClassdel(obj.ToString(), flag);
}
#endregion
}
/// <summary>
/// 删除栏目同时删除新闻
/// </summary>
/// <param name="ClassID"></param>
public void del_News(string ClassID, int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "Delete From " + Pre + "news Where ClassID ='" + ClassID.ToString() + "' and SiteID = '" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)// 删除栏目同时更新新闻到回收站
{
Sql = "Update " + Pre + "news set isRecyle=1 Where ClassID ='" + ClassID.ToString() + "' and SiteID = '" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 2)
{
Sql = "Delete From " + Pre + "news_Class Where ClassID='" + ClassID + "' and SiteID = '" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 3)
{
Sql = "delete From " + Pre + "News where ClassID='" + ClassID.ToString() + "'" + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 4)
{
Sql = "Update " + Pre + "news_Class Set ParentID=0 Where isLock=0 and isRecyle=0";
if (ClassID != null)
Sql += " and ClassID In(" + ClassID + ")";
}
else if (flag == 5)
{
string dSql = "select NewsID from " + Pre + "News where id=" + ClassID;
object obj = DbHelper.ExecuteScalar(CommandType.Text, dSql, null);
if (obj != null && obj != DBNull.Value)
{
del_News(obj.ToString(), 6);
}
Sql = "delete from " + Pre + "News where Id=" + ClassID + " " + NetCMS.Common.Public.getSessionStr();
}
else if (flag == 6)
{
Sql = "delete from " + Pre + "News_Sub where NewsID='" + ClassID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
/// <summary>
/// 得到栏目列表的子类
/// </summary>
/// <returns></returns>
public void ChangeLock(string ClassID, int NUM)
{
string str_sql = "Update " + Pre + "news_Class Set isLock=" + NUM + " Where ClassID='" + ClassID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
}
/// <summary>
/// 复位所有栏目
/// </summary>
/// <param name="ClassID"></param>
public void delUpdate_newsClass(int flag)
{
#region
string str_sql = null;
if (flag == 0)
{
str_sql = "Update " + Pre + "news_Class Set ParentID=0 Where isLock=0 and isRecyle=0 and SiteID = '" + NetCMS.Global.Current.SiteID + "'";
}
else if (flag == 1)
{
string str_sql1 = "delete From " + Pre + "News_Class Where SiteID = '" + NetCMS.Global.Current.SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql1, null);
str_sql = "delete From " + Pre + "news Where SiteID = '" + NetCMS.Global.Current.SiteID + "'";
}
DbHelper.ExecuteNonQuery(CommandType.Text, str_sql, null);
#endregion
}
/// <summary>
/// 更新权重
/// </summary>
/// <param name="ClassID"></param>
/// <param name="OrderID"></param>
public void updateOrderP(string ClassID, int OrderID)
{
string Sql = "update " + Pre + "News_Class Set OrderID=" + OrderID + " where ClassID ='" + ClassID + "' " + NetCMS.Common.Public.getSessionStr() + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 添加单页面
/// </summary>
/// <param name="uc"></param>
public void addUpdate_Page(NetCMS.Model.PageContent uc, int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "insert into " + Pre + "News_Class(";
Sql += "ClassID,ClassCName,ClassEName,ParentID,IsURL,OrderID,NaviShowtf,MetaKeywords,MetaDescript,SiteID,isLock,isRecyle,ClassTemplet,SavePath,isDelPoint,Gpoint,iPoint,GroupNumber,CreatTime,isPage,PageContent,InHitoryDay,ContentPicTF,Checkint,ModelID,isunHTML,DataLib";
Sql += ") values (";
Sql += "@ClassID,@ClassCName,@ClassEName,@ParentID,@IsURL,@OrderID,@NaviShowtf,@MetaKeywords,@MetaDescript,@SiteID,0,0,@ClassTemplet,@SavePath,@isDelPoint,@Gpoint,@iPoint,@GroupNumber,@CreatTime,@isPage,@Content,0,0,0,'0',0,'" + Pre + "news')";
}
else if (flag == 1)
{
Sql = "Update " + Pre + "News_Class set ClassCName=@ClassCName,ParentID=@ParentID,IsURL=@IsURL,OrderID=@OrderID,NaviShowtf=@NaviShowtf,MetaKeywords=@MetaKeywords,MetaDescript=@MetaDescript,ClassTemplet=@ClassTemplet,SavePath=@SavePath,isDelPoint=@isDelPoint,Gpoint=@Gpoint,iPoint=@iPoint,GroupNumber=@GroupNumber,isPage=@isPage,PageContent=@Content,InHitoryDay=0,ContentPicTF=0,Checkint=0,ModelID='0' where ClassID='" + uc.ClassID + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
SqlParameter[] parm = insertPageContentParameters(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
#endregion
}
/// <summary>
/// 获取PageContent构造
/// </summary>
/// <param name="uc"></param>
/// <returns></returns>
private SqlParameter[] insertPageContentParameters(NetCMS.Model.PageContent uc)
{
#region
SqlParameter[] param = new SqlParameter[19];
param[0] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 12);
param[0].Value = uc.ClassID;
param[1] = new SqlParameter("@ClassCName", SqlDbType.NVarChar, 50);
param[1].Value = uc.ClassCName;
param[2] = new SqlParameter("@ClassEName", SqlDbType.NVarChar, 50);
param[2].Value = uc.ClassEName;
param[3] = new SqlParameter("@ParentID", SqlDbType.NVarChar, 12);
param[3].Value = uc.ParentID;
param[4] = new SqlParameter("@IsURL", SqlDbType.TinyInt, 1);
param[4].Value = uc.IsURL;
param[5] = new SqlParameter("@OrderID", SqlDbType.Int, 4);
param[5].Value = uc.OrderID;
param[6] = new SqlParameter("@Content", SqlDbType.NText);
param[6].Value = uc.Content;
param[7] = new SqlParameter("@ClassTemplet", SqlDbType.NVarChar, 200);
param[7].Value = uc.ClassTemplet;
param[8] = new SqlParameter("@SavePath", SqlDbType.NVarChar, 50);
param[8].Value = uc.SavePath;
param[9] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[9].Value = uc.SiteID;
param[10] = new SqlParameter("@NaviShowtf", SqlDbType.TinyInt, 1);
param[10].Value = uc.NaviShowtf;
param[11] = new SqlParameter("@MetaKeywords", SqlDbType.NVarChar, 200);
param[11].Value = uc.MetaKeywords;
param[12] = new SqlParameter("@MetaDescript", SqlDbType.NVarChar, 200);
param[12].Value = uc.MetaDescript;
param[13] = new SqlParameter("@isDelPoint", SqlDbType.TinyInt, 1);
param[13].Value = uc.isDelPoint;
param[14] = new SqlParameter("@Gpoint", SqlDbType.Int, 4);
param[14].Value = uc.Gpoint;
param[15] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
param[15].Value = uc.iPoint;
param[16] = new SqlParameter("@GroupNumber", SqlDbType.NVarChar, 250);
param[16].Value = uc.GroupNumber;
param[17] = new SqlParameter("@CreatTime", SqlDbType.DateTime, 8);
param[17].Value = uc.CreatTime;
param[18] = new SqlParameter("@isPage", SqlDbType.TinyInt, 1);
param[18].Value = uc.isPage;
return param;
#endregion
}
#endregion 栏目
#region 新闻列表
/// <summary>
/// 新闻列表
/// </summary>
/// <param name="SpecialID">专题编号</param>
/// <param name="Editor">作者</param>
/// <param name="NewsDbTbs">表名</param>
/// <param name="ClassID">栏目</param>
/// <param name="sKeywrd">关键字</param>
/// <param name="DdlKwdType">关键字类型</param>
/// <param name="sChooses">提交的类型</param>
/// <param name="SiteID">站点</param>
/// <param name="TablePrefix">表扩展名</param>
/// <param name="PageIndex">每页数量</param>
/// <param name="PageSize">每页数量</param>
/// <param name="RecordCount">总记录数</param>
/// <param name="PageCount"></param>
/// <param name="SqlCondition">SQL</param>
/// <returns>返回DataTable</returns>
public DataTable GetPage(string SpecialID, string Editor, string ClassID, string sKeywrd, string DdlKwdType, string sChooses, string SiteID, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
#region
string sFilter = " where a.isRecyle=0";
if (ClassID != null && ClassID != "")
sFilter += " and a.ClassID='" + ClassID + "'";
if (SpecialID != null && SpecialID != "")
sFilter += " and a.NewsID In (Select NewsID From " + Pre + "special_news Where SpecialID='" + SpecialID + "') ";
string sKeywrds = sKeywrd;
if (sKeywrds != "" && sKeywrds != null)
{
switch (DdlKwdType)
{
case "content":
sFilter += " and Content like '%" + sKeywrds + "%'";
break;
case "author":
sFilter += " and Author like '%" + sKeywrds + "%'";
break;
case "editor":
sFilter += " and NewsTitle like '%" + sKeywrds + "%'";
break;
default:
sFilter += " and NewsTitle like '%" + sKeywrds + "%'";
break;
}
}
string sChoose = sChooses;
switch (sChoose)
{
case "Auditing":
sFilter += " and (CheckStat is null or CheckStat='0|0|0|0' or CheckStat='1|0|0|0' or CheckStat='2|0|0|0' or CheckStat='3|0|0|0')";
break;
case "UnAuditing":
sFilter += " and (CheckStat<>'0|0|0|0' and CheckStat<>'1|0|0|0' and CheckStat<>'2|0|0|0' and CheckStat<>'3|0|0|0' and CheckStat is not null)";
break;
case "All":
break;
case "Contribute":
sFilter += " and a.isConstr=1";
break;
case "Commend":
sFilter += " and SUBSTRING(NewsProperty,1,1)='1'";
break;
case "Lock":
sFilter += " and a.isLock=1";
break;
case "UnLock":
sFilter += " and a.isLock=0";
break;
case "Top":
sFilter += " and a.OrderID=10";
break;
case "Hot":
sFilter += " and SUBSTRING(NewsProperty,5,1)='1'";
break;
case "Splendid":
sFilter += " and SUBSTRING(NewsProperty,15,1)='1'";
break;
case "Headline":
sFilter += " and SUBSTRING(NewsProperty,9,1)='1'";
break;
case "Slide":
sFilter += " and SUBSTRING(NewsProperty,7,1)='1'";
break;
case "my":
sFilter += " and Editor='" + NetCMS.Global.Current.UserName + "'";
break;
case "isHtml":
sFilter += " and a.isHtml=1";
break;
case "unisHtml":
sFilter += " and a.isHtml=0";
break;
case "discuzz":
sFilter += " and a.DiscussTF=1";
break;
case "commat":
sFilter += " and a.CommTF=1";
break;
case "voteTF":
sFilter += " and a.VoteTF=1";
break;
case "contentPicTF":
sFilter += " and a.ContentPicTF=1";
break;
case "POPTF":
sFilter += " and a.isDelPoint!=0";
break;
case "Pic":
sFilter += " and a.NewsType=1";
break;
case "FilesURL":
sFilter += " and a.isFiles=1";
break;
}
if (SiteID != "" && SiteID != null)
{
sFilter += " and a.SiteID='" + SiteID + "'";
}
else
{
sFilter += " and a.SiteID='" + NetCMS.Global.Current.SiteID + "'";
}
if (Editor != "")
{
sFilter += " and a.Editor='" + Editor + "'";
}
string AllFields = "a.Id,a.NewsID,a.NewsType,a.TitleColor,a.TitleITF,a.TitleBTF,a.Author,a.DataLib,a.OrderID,a.NewsTitle,a.ishtml,a.Editor,a.Click,a.isConstr,a.ClassID,a.isLock,a.NewsProperty,a.CheckStat,a.URLaddress,b.UserName,c.ClassCName";
string Condition = Pre + "News a left join " + Pre + "sys_User b on a.Editor=b.UserNum left join " + Pre + "News_Class c on a.ClassID=c.ClassID " + sFilter;
string IndexField = "a.Id";
string OrderFields = "order by a.OrderID desc,a.Id desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, null);
#endregion
}
/// <summary>
/// 更新新闻到回收站
/// </summary>
/// <param name="TableName"></param>
/// <param name="id"></param>
/// <returns></returns>
public int delUpdate_news(string id, int flag)
{
#region
string Sql = null;
SqlParameter Param = new SqlParameter("@ClassID", id);
if (flag == 0)
{
Sql = "update " + Pre + "News set isRecyle=1 where Id in (" + id + ") " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 1)
{
Sql = "update " + Pre + "News set OrderID=0 where Id in (" + id + ") " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 2)
{
Sql = "delete from " + Pre + "News where Id in (" + id + ") " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 3)
{
Sql = "update " + Pre + "News set OrderID=10 where Id=" + id + " " + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 4)
{
Sql = "update " + Pre + "News set OrderID=0 where Id=" + id + "" + NetCMS.Common.Public.getSessionStr() + "";
}
else if (flag == 5)
{
Sql = "select count(*) from " + Pre + "news_class where IsURL=1 and ClassID='" + id + "'";
}
else if (flag == 6)
{
Sql = "select count(ID) from " + Pre + "News where NewsID=@NewsID";
Param = new SqlParameter("@NewsID", id);
}
else if (flag == 7)
{
#region
int delCount = int.Parse(NetCMS.Common.Public.readparamConfig("delinfoNumber", "refresh"));
string whereStr = "";
if (delCount != 0)
{
string cSQL = "select count(id) from " + Pre + "News where ClassID='" + id + "' " + NetCMS.Common.Public.getSessionStr() + "";
int tCount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, cSQL, null));
if (delCount < tCount)
{
string gSQL = "select top " + delCount + " id from " + Pre + "News where ClassID='" + id + "' " + NetCMS.Common.Public.getSessionStr() + " order by id desc";
int gCount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, gSQL, null));
whereStr = " and id>=" + gCount + "";
}
}
Sql = "delete from " + Pre + "News where ClassID='" + id + "' " + whereStr + NetCMS.Common.Public.getSessionStr() + "";
#endregion
}
else if (flag == 8)
{
Sql = "delete from " + Pre + "News where Id in (" + id + ")";
}
else if (flag == 9)
{
Sql = "update " + Pre + "News set isLock=1 where Id in (" + id + ")";
}
else if (flag == 10)
{
Sql = "update " + Pre + "News set isRecyle=1 where Id in (" + id + ")";
}
else if (flag == 11)
{
Sql = "select isPage from " + Pre + "news_class where ClassID=@ClassID";
object obj = DbHelper.ExecuteScalar(CommandType.Text, Sql, Param);
if (obj != null && obj != DBNull.Value)
{
return int.Parse(obj.ToString());
}
return 1;
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, Param);
#endregion
}
public int GetClassNewsCount(string cid)
{
SqlParameter Param = new SqlParameter("@ClassID", cid);
string Sql = "Select count(id) From [" + Pre + "news] Where [ClassID]=@ClassID";
return (int)DbHelper.ExecuteScalar(CommandType.Text, Sql, Param);
}
/// <summary>
/// 得到新闻的路径
/// </summary>
/// <param name="TableName"></param>
/// <param name="id"></param>
/// <returns></returns>
public string sel_path(string id, int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "select SavePath from " + Pre + "News where id=" + id;
}
else if (flag == 1)
{
Sql = "select " + id + " from " + Pre + "sys_param";
}
return DbHelper.ExecuteScalar(CommandType.Text, Sql, null).ToString();
#endregion
}
/// <summary>
/// 更新新闻状态
/// </summary>
/// <param name="TableName"></param>
/// <param name="id"></param>
/// <param name="nums"></param>
/// <returns></returns>
public int Update_Lock(string id, int nums)
{
string Sql = "update " + Pre + "News set isLock=" + nums + " where Id in (" + id + ") " + NetCMS.Common.Public.getSessionStr() + "";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public int sel_old_classInHitoryDay(string ClassID)
{
int intflg = 180;
string SQL = "select InHitoryDay from " + Pre + "News_Class Where ClassID='" + ClassID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, SQL, null);
if (dt != null && dt.Rows.Count > 0)
{
intflg = int.Parse(dt.Rows[0]["InHitoryDay"].ToString());
dt.Clear(); dt.Dispose();
}
return intflg;
}
public int Add_old_News(string fieldnm, string id, DateTime oldtime)
{
string Sql = "insert into " + Pre + "old_News (" + fieldnm + ",oldtime,DataLib) select " + fieldnm + ",oldtime='" + oldtime + "',DataLib='" + Pre + "News' from " + Pre + "News where Id in (" + id + ")";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public int Add_JSFile(string JsID, string Njf_title, string NewsId, string PicPath, string ClassId, string SiteID, DateTime CreatTime, DateTime TojsTime)
{
string Sql = "insert into " + Pre + "News_JSFile(JsID,Njf_title,NewsId,NewsTable,PicPath,ClassId,SiteID,CreatTime,TojsTime) values('" + JsID + "','" + Njf_title + "','" + NewsId + "','" + Pre + "News','" + PicPath + "','" + ClassId + "','" + SiteID + "','" + CreatTime + "','" + TojsTime + "')";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public int del_moveInfo(string sTb, string sOrgNews)
{
string Sql = "delete " + sTb + " where ID = " + sOrgNews + "";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public string getFileNameInfo(string NewsID, string DataLib)
{
string flg = NetCMS.Common.Rand.Number(5);
string Sql = "select FileName from " + DataLib + " where ID=" + NewsID + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (dt != null && dt.Rows.Count > 0)
{
flg = dt.Rows[0]["FileName"].ToString() + "_1";
dt.Clear(); dt.Dispose();
}
return flg;
}
public void Copy_news(string ClassID, string DataLib, string sOrgNews, string sTb, string NewsID, string FileName)
{
#region
string Sql = "insert into " + DataLib + "(NewsID,NewsType,OrderID,NewsTitle,sNewsTitle,TitleColor,TitleITF,TitleBTF,CommLinkTF,SubNewsTF,URLaddress,PicURL,SPicURL,ClassID,SpecialID,Author,Souce,Tags,NewsProperty,NewsPicTopline,Templet,Content,naviContent,Click,CreatTime,EditTime,SavePath,FileName,FileEXName,ContentPicTF,ContentPicURL,ContentPicSize,CommTF,DiscussTF,TopNum,VoteTF,CheckStat,isLock,isRecyle,SiteID,DataLib,DefineID,isVoteTF,Editor,isHtml,isDelPoint,Gpoint,iPoint,GroupNumber,isConstr)select '" + NewsID + "',NewsType,OrderID,NewsTitle,sNewsTitle,TitleColor,TitleITF,TitleBTF,CommLinkTF,SubNewsTF,URLaddress,PicURL,SPicURL,'" + ClassID + "',SpecialID,Author,Souce,Tags,NewsProperty,NewsPicTopline,Templet,Content,naviContent,Click,CreatTime,EditTime,SavePath,FileName,FileEXName,ContentPicTF,ContentPicURL,ContentPicSize,CommTF,DiscussTF,TopNum,VoteTF,CheckStat,isLock,isRecyle,SiteID,'" + DataLib + "',DefineID,isVoteTF,Editor,isHtml,isDelPoint,Gpoint,iPoint,GroupNumber,isConstr from " + sTb + " where id =" + sOrgNews + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
if (FileName.Trim() != "")
{
string gSQL = "select id from " + DataLib + " where ClassID='" + ClassID + "' and FileName='" + FileName + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, gSQL, null);
if (dt != null)
{
if (dt.Rows.Count > 0) { FileName = FileName + "1"; }
dt.Clear(); dt.Dispose();
}
string tSQL = "update " + DataLib + " set FileName='" + FileName + "',isHtml=0 where NewsID='" + NewsID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, tSQL, null);
}
#endregion
}
public void Copy_ClassNews(string ClassID, string DataLib, string sOrgNews, string sTb, string NewsID, string FileName)
{
#region
string Sql = "insert into " + DataLib + "(NewsID,NewsType,OrderID,NewsTitle,sNewsTitle,TitleColor,TitleITF,TitleBTF,CommLinkTF,SubNewsTF,URLaddress,PicURL,SPicURL,ClassID,SpecialID,Author,Souce,Tags,NewsProperty,NewsPicTopline,Templet,Content,naviContent,Click,CreatTime,EditTime,SavePath,FileName,FileEXName,ContentPicTF,ContentPicURL,ContentPicSize,CommTF,DiscussTF,TopNum,VoteTF,CheckStat,isLock,isRecyle,SiteID,DataLib,DefineID,isVoteTF,Editor,isHtml,isDelPoint,Gpoint,iPoint,GroupNumber,isConstr)select '" + NewsID + "',NewsType,OrderID,NewsTitle,sNewsTitle,TitleColor,TitleITF,TitleBTF,CommLinkTF,SubNewsTF,URLaddress,PicURL,SPicURL,'" + ClassID + "',SpecialID,Author,Souce,Tags,NewsProperty,NewsPicTopline,Templet,Content,naviContent,Click,CreatTime,EditTime,SavePath,FileName,FileEXName,ContentPicTF,ContentPicURL,ContentPicSize,CommTF,DiscussTF,TopNum,VoteTF,CheckStat,isLock,isRecyle,SiteID,'" + DataLib + "',DefineID,isVoteTF,Editor,isHtml,isDelPoint,Gpoint,iPoint,GroupNumber,isConstr from " + sTb + " where id ='" + sOrgNews + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
if (FileName.Trim() != "")
{
string gSQL = "select id from " + DataLib + " where ClassID='" + ClassID + "' and FileName='" + FileName + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, gSQL, null);
if (dt != null)
{
if (dt.Rows.Count > 0) { FileName = FileName + "1"; }
dt.Clear(); dt.Dispose();
}
string tSQL = "update " + DataLib + " set FileName='" + FileName + "',isHTML=0 where NewsID='" + NewsID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, tSQL, null);
}
#endregion
}
public int update_Info(int CommTF, int DiscussTF, string NewsProperty, string Templet, int OrderID, int CommLinkTF, int Click, string FileEXName, string sTb, string sOrgNews)
{
string Sql = "Update " + sTb + " set NewsProperty='" + NewsProperty + "',Templet='" + Templet + "',OrderID=" + OrderID + ",CommLinkTF=" + CommLinkTF + ",Click=" + Click + ",FileEXName='" + FileEXName + "',CommTF=" + CommTF + ",DiscussTF=" + DiscussTF + " where ID in (" + sOrgNews + ")";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public int update_newsStrInfo(int CommTF, int DiscussTF, string NewsProperty, string Templet, int OrderID, int CommLinkTF, int Click, string FileEXName, string sTb, string sOrgNews)
{
#region
if (NewsProperty == "" && Templet == "" && OrderID == 0 && CommLinkTF == 0 && Click == 0 && FileEXName == "")
{
return 0;
}
else
{
string Sql = "Update " + sTb + " set ";
Sql += "CommTF=" + CommTF + ",";
Sql += "DiscussTF=" + DiscussTF + ",";
if (NewsProperty != "")
{
Sql += "NewsProperty='" + NewsProperty + "',";
}
if (Templet != "")
{
Sql += "Templet='" + Templet + "',";
}
if (OrderID != 0)
{
Sql += "OrderID=" + OrderID + ",";
}
if (CommLinkTF != 0)
{
Sql += "CommLinkTF=" + CommLinkTF + ",";
}
if (Click != 0)
{
Sql += "Click=" + Click + ",";
}
if (FileEXName != "")
{
Sql += "FileEXName='" + FileEXName + "'";
}
Sql = NetCMS.Common.Public.Lost(Sql) + " where ID in (" + sOrgNews + ")";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
#endregion
}
public void Up_Classnews(int CommTF, int DiscussTF, string NewsProperty, string Templet, int OrderID, int CommLinkTF, int Click, string FileEXName, string sTb, string ClassID, string Tags, string Souce)
{
#region
//if (NewsProperty == "" && Templet == "" && OrderID == 0 && CommLinkTF == 0 && Click == 0 && FileEXName == "")
string Sql = "Update " + sTb + " set ";
Sql += "CommTF=" + CommTF;
Sql += ",DiscussTF=" + DiscussTF;
if (NewsProperty != "")
{
Sql += ",NewsProperty='" + NewsProperty + "'";
}
if (Templet != "")
{
Sql += ",Templet='" + Templet + "'";
}
if (OrderID != 0)
{
Sql += ",OrderID=" + OrderID + "";
}
if (CommLinkTF != 0)
{
Sql += ",CommLinkTF=" + CommLinkTF + "";
}
if (Click != 0)
{
Sql += ",Click=" + Click + "";
}
if (FileEXName != "")
{
Sql += ",FileEXName='" + FileEXName + "'";
}
if (Tags.Trim() != "")
{
Sql += ",Tags='" + Tags + "'";
}
if (Souce.Trim() != "")
{
Sql += ",Souce='" + Souce + "'";
}
Sql += " where ClassID = '" + ClassID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
public int Up_PicURL(string PicURL, string SPicURL, string ID, string tb)
{
string Sql = "update " + tb + " set PicURL='" + SPicURL + "',SPicURL='" + PicURL + "' where Id='" + ID + "'";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public void allCheck(int[] id)
{
#region
string ids = string.Empty;
foreach (int i in id)
{
ids += i + ",";
}
string Sql = "update " + Pre + "news SET checkstat = CASE WHEN checkstat IS NULL THEN '0|0|0|0' ";
Sql += "when checkstat<>'0|0|0|0' then SUBSTRING(checkstat,1,1)+'|0|0|0' else '0|0|0|0' END,islock=0";
Sql += " where Id in (" + ids.TrimEnd(',') + ") " + NetCMS.Common.Public.getSessionStr();
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
#endregion
}
public void upCheckStat(string getID, int levelsID)
{
#region
string _CheckStat = "0|0|0|0";
string GSql = "select CheckStat from " + Pre + "News where Id = " + getID + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, GSql, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
_CheckStat = dt.Rows[0]["CheckStat"].ToString();
}
dt.Clear(); dt.Dispose();
}
string[] checkStatARR = _CheckStat.Split('|');
string cSTR1 = checkStatARR[0];
string cSTR2 = checkStatARR[1];
string cSTR3 = checkStatARR[2];
string cSTR4 = checkStatARR[3];
switch (levelsID)
{
case 1:
cSTR2 = "0";
break;
case 2:
cSTR3 = "0";
break;
case 3:
cSTR4 = "0";
break;
}
string RCheckStat = cSTR1 + "|" + cSTR2 + "|" + cSTR3 + "|" + cSTR4;
string Sql = "update " + Pre + "News set CheckStat='" + RCheckStat + "' where Id = " + getID + " " + NetCMS.Common.Public.getSessionStr() + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
string gSQL = "select NewsProperty,CheckStat,islock,NewsID,NewsType,CreatTime,DataLib,NewsType,isConstr,ClassID from " + Pre + "News where ID=" + getID + "";
DataTable dts = DbHelper.ExecuteTable(CommandType.Text, gSQL, null);
if (dts != null && dts.Rows.Count > 0)
{
string[] TCheckStat = dts.Rows[0]["CheckStat"].ToString().Split('|');
string Tmp1 = TCheckStat[1] + "|";
Tmp1 += TCheckStat[2] + "|";
Tmp1 += TCheckStat[3];
if (Tmp1 == "0|0|0")
{
//int intisConstr = 0;
//if (NetCMS.Common.Input.IsInteger(dts.Rows[0]["isConstr"].ToString())) { intisConstr = int.Parse(dts.Rows[0]["isConstr"].ToString()); }
//insertFormTB(dts.Rows[0]["NewsProperty"].ToString(), dts.Rows[0]["NewsID"].ToString(), DateTime.Parse(dts.Rows[0]["CreatTime"].ToString()), TableName, int.Parse(dts.Rows[0]["NewsType"].ToString()), intisConstr, 3000, 0, dts.Rows[0]["ClassID"].ToString());
//更新状态
string Sqls = "update " + Pre + "News set islock=0 where Id = " + getID + " " + NetCMS.Common.Public.getSessionStr() + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sqls, null);
}
dts.Clear(); dts.Dispose();
}
#endregion
}
public DataTable getLockNews(string UserName)
{
string Sql = "";
if (UserName == "0")
{//0|0|0|0
Sql = "select TOP 5 NewsId,NewsTitle,CheckStat,CreatTime,ClassID from " + Pre + "news where substring(CheckStat,3,5)!='0|0|0' and isRecyle=0 and SiteID='" + NetCMS.Global.Current.SiteID + "' order by Id desc";
}
else
{
Sql = "select TOP 5 NewsId,NewsTitle,CheckStat,CreatTime,ClassID from " + Pre + "news where isRecyle=0 and SiteID='" + NetCMS.Global.Current.SiteID + "' and Editor='" + UserName + "' order by Id desc";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
#endregion
#region 不规则新闻
/// <summary>
/// 不规则新闻分页
/// </summary>
/// <param name="PageIndex"></param>
/// <param name="PageSize"></param>
/// <param name="RecordCount"></param>
/// <param name="PageCount"></param>
/// <param name="SqlCondition"></param>
/// <returns></returns>
public DataTable GetPages(int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
string AllFields = "*";
string Condition = "(SELECT DISTINCT Unid,(Select top 1 UnName from [" + Pre + "News_unNews] where unid=a.unid order by [rows],id desc) as UnName from [" + Pre + "News_unNews] a where 1=1" + NetCMS.Common.Public.getSessionStr() + ") Unnews";
string IndexField = "Unid";
string OrderFields = "order by Unid Desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, null);
}
/// <summary>
/// 删除不规则新闻
/// </summary>
/// <param name="UnID"></param>
/// <returns></returns>
public int Str_DelSql(string UnID)
{
SqlParameter param = new SqlParameter("@UnID", UnID);
string Sql = "delete " + Pre + "news_unNews WHERE UnID=@UnID" + NetCMS.Common.Public.getSessionStr() + "";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public int add_newsNews(string unName, string titleCSS, string unNewsid, string NewsID, string NewsTitle, string NewsTable, string TTNewsCSS, string IsMakePic, string SiteID, int flag)
{
string Sql = null;
if (flag == 0)
{
Sql = "INSERT INTO " + Pre + "News_unNews(unName,titleCSS,UnID,ONewsID,[Rows],unTitle,NewsTable,CreatTime,SiteID) VALUES('" + unName + "','" + titleCSS + "','" + unNewsid + "','" + NewsID + "',0,'" + NewsTitle + "','" + NewsTable + "',GETDATE(),'" + SiteID + "')";
}
else if (flag == 1)
{
Sql = "INSERT INTO " + Pre + "News_unNews(unName,titleCSS,SubCSS,UnID,ONewsID,[Rows],unTitle,NewsTable,CreatTime,SiteID) VALUES('" + unName + "','" + titleCSS + "','" + unNewsid + "','" + NewsID + "','" + NewsTitle + "'," + NewsTable + ",'" + TTNewsCSS + "','" + IsMakePic + "',GETDATE(),'" + SiteID + "')";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
/// <summary>
/// 插入子类
/// </summary>
/// <param name="unNewsid">编号</param>
/// <param name="Arr_OldNewsId">新闻ID</param>
/// <param name="NewsRow">行</param>
/// <param name="NewsTitle">标题</param>
/// <param name="NewsTable">新闻表</param>
/// <param name="SiteID">站点ID</param>
/// <returns></returns>
public int Add_SubNews(string unNewsid, string Arr_OldNewsId, string NewsRow, string NewsTitle, string NewsTable, string SiteID, string titleCSS)
{
string Sql = "INSERT INTO " + Pre + "News_Sub(NewsID,getNewsID,colsNum,NewsTitle,DataLib,CreatTime,SiteID,titleCSS) VALUES('" + unNewsid + "','" + Arr_OldNewsId + "'," + NewsRow + ",'" + NewsTitle + "','" + NewsTable + "',GETDATE(),'" + SiteID + "','" + titleCSS + "')";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
public DataTable GetPageiframe(string DdlClass, string sKeywrds, string sChoose, string DdlKwdType, int pageindex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
#region
string sFilter = " where a.isRecyle=0";
if (DdlClass != "0")
{
sFilter += " and a.ClassID='" + DdlClass + "'";
}
string sKeywrdsd = sKeywrds;
if (sKeywrdsd != "")
{
switch (DdlKwdType)
{
case "content":
sFilter += " and Content like '%" + sKeywrds + "%'";
break;
case "author":
sFilter += " and Author like '%" + sKeywrds + "%'";
break;
case "editor":
sFilter += " and NewsTitle like '%" + sKeywrds + "%'";
break;
default:
sFilter += " and NewsTitle like '%" + sKeywrds + "%'";
break;
}
}
string sChooses = sChoose;
switch (sChooses)
{
case "All":
break;
case "Contribute":
sFilter += " and isAdmin=0";
break;
case "Commend":
sFilter += " and SUBSTRING(NewsProperty,1,1)='1'";
break;
case "Top":
sFilter += " and a.OrderID=0";
break;
case "Hot":
sFilter += " and SUBSTRING(NewsProperty,5,1)='1'";
break;
case "Splendid":
sFilter += " and SUBSTRING(NewsProperty,15,1)='1'";
break;
case "Headline":
sFilter += " and SUBSTRING(NewsProperty,9,1)='1'";
break;
case "Slide":
sFilter += " and SUBSTRING(NewsProperty,7,1)='1'";
break;
case "Pic":
sFilter += " and NewsType=1";
break;
}
sFilter += " and a.isLock=0";
string AllFields = "a.Id,a.NewsID,a.NewsType,a.OrderID,a.NewsTitle,a.Author,a.Click,a.CheckStat,b.UserName,c.ClassCName";
string Condition = Pre + "News a left join " + Pre + "sys_User b on a.Editor=b.UserNum left join " + Pre + "News_Class c on a.ClassID=c.ClassID " + sFilter;
string IndexField = "a.Id";
string OrderFields = "order by a.OrderID asc,a.Id desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, pageindex, PageSize, out RecordCount, out PageCount, null);
#endregion
}
public int Add_fieldnm(string fieldnm, string id, DateTime oldtime)
{
string Sql = "insert into " + Pre + "old_News (" + fieldnm + ",oldtime,DataLib) select " + fieldnm + ",oldtime='" + DateTime.Now + "',DataLib='" + Pre + "News' from " + Pre + "News where Id in (" + id + ")";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
}
#endregion
#endregion 内容管理结束
public int infoIDNum(string InfoID, string APIID, string dbtable)
{
string andSTR = "";
if (APIID != "0") { andSTR = " and DataLib='" + dbtable + "'"; }
string Sql = "select count(*) from " + Pre + "api_commentary where InfoID='" + InfoID + "' and APIID='" + APIID + "' " + andSTR + "";
return (int)DbHelper.ExecuteScalar(CommandType.Text, Sql, null);
}
#region 自定义字段
public string modifyNewsDefineValue(string defineColumns, string NewsID, string DataLib, string DsApiID)
{
#region
string _STR = " | ";
string Sql = "select DsEname,DsContent from " + Pre + "define_save where DsEname='" + defineColumns + "' and DsNewsID='" + NewsID + "' and DsNewsTable='" + DataLib + "' and DsApiID='" + DsApiID + "' " + NetCMS.Common.Public.getSessionStr() + "";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
_STR = dt.Rows[0]["DsEname"].ToString() + "|" + dt.Rows[0]["DsContent"].ToString();
}
dt.Clear(); dt.Dispose();
}
return _STR;
#endregion
}
public void addUpdate_DefineSign(string DsNewsID, string DsEName, string DsNewsTable, int DsType, string DsContent, string DsApiID, int flag)
{
#region
string TSql = null;
string Sql = "";
DataTable dt = null;
if (flag == 0)
{
TSql = "select ID from " + Pre + "define_save where DsNewsID='" + DsNewsID + "' and DsEName='" + DsEName + "' and DsNewsTable='" + DsNewsTable + "' and DsApiID='" + DsApiID + "'";
dt = DbHelper.ExecuteTable(CommandType.Text, TSql, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
string DSql = "delete from " + Pre + "define_save where DsNewsID='" + DsNewsID + "' and DsEName='" + DsEName + "' and DsNewsTable='" + DsNewsTable + "' and DsApiID='" + DsApiID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, DSql, null);
}
dt.Clear(); dt.Dispose();
}
Sql = "insert into " + Pre + "define_save (DsNewsID,DsEname,DsNewsTable,DsType,DsContent,DsApiID,SiteID) VALUES ('" + DsNewsID + "','" + DsEName + "','" + DsNewsTable + "'," + DsType + ",'" + DsContent + "','" + DsApiID + "','" + NetCMS.Global.Current.SiteID + "')";
}
else if (flag == 1)
{
TSql = "select ID from " + Pre + "define_save where DsNewsID='" + DsNewsID + "' and DsEName='" + DsEName + "' and DsNewsTable='" + DsNewsTable + "' and DsApiID='" + DsApiID + "'";
dt = DbHelper.ExecuteTable(CommandType.Text, TSql, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
Sql = "update " + Pre + "define_save set DsNewsTable='" + DsNewsTable + "',DsContent='" + DsContent + "' where DsNewsID='" + DsNewsID + "' and DsEName='" + DsEName + "' and DsApiID='" + DsApiID + "' " + NetCMS.Common.Public.getSessionStr() + "";
}
else
{
Sql = "insert into " + Pre + "define_save (DsNewsID,DsEname,DsNewsTable,DsType,DsContent,DsApiID,SiteID) VALUES ('" + DsNewsID + "','" + DsEName + "','" + DsNewsTable + "'," + DsType + ",'" + DsContent + "','" + DsApiID + "','" + NetCMS.Global.Current.SiteID + "')";
}
}
}
if (dt != null)
{
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
dt.Clear(); dt.Dispose();
}
#endregion
}
#endregion 自定义字段
#region 插入临时表
//public void insertFormTB(string Prot, string NewsID, DateTime CreatTime, string DataTable, int NewsType, int isConstr, int MaxNumber, int updateNum,string ClassID)
//{
// string[] getProt = Prot.Split(',');
// int isRec = int.Parse(getProt[0]);
// int isMarquee = int.Parse(getProt[1]);
// int isHOT = int.Parse(getProt[2]);
// int isFilt = int.Parse(getProt[3]);
// int isTT = int.Parse(getProt[4]);
// int isAnnouce = int.Parse(getProt[5]);
// int isWap = int.Parse(getProt[6]);
// int isJC = int.Parse(getProt[7]);
// string Sql = "";
// if (updateNum == 0)
// {
// string sTF = "select id from " + Pre + "news_temp where NewsID='" + NewsID + "' and DataLib='" + DataTable + "' order by id desc";
// DataTable dtTF = DbHelper.ExecuteTable(CommandType.Text, sTF, null);
// if (dtTF != null)
// {
// if (dtTF.Rows.Count == 0)
// {
// Sql = "insert into " + Pre + "news_temp (NewsID,DataLib,NewsType,CreatTime,IsRec,isHot,isTT,isAnnounce,isMarQuee,isConstr,isJC,isWap,isFilt,ClassID)";
// Sql += " VALUES ('" + NewsID + "','" + DataTable + "'," + NewsType + ",'" + CreatTime + "'," + isRec + "," + isHOT + "," + isTT + "," + isAnnouce + "," + isMarquee + "," + isConstr + "," + isJC + "," + isWap + "," + isFilt + ",'" + ClassID + "')";
// DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
// }
// dtTF.Clear(); dtTF.Dispose();
// }
// }
// else
// {
// Sql = "update " + Pre + "news_temp set DataLib='" + DataTable + "',NewsType=" + NewsType + ",IsRec=" + isRec + ",isHot=" + isHOT + ",isTT=" + isTT + ",isAnnounce=" + isAnnouce + ",isMarQuee=" + isMarquee + ",isConstr=" + isConstr + ",isJC=" + isJC + ",isWap=" + isWap + ",isFilt=" + isFilt + " where NewsID='" + NewsID + "'";
// DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
// }
// //删除多余的信息
// RandFirst:
// string SqlTf = "select ID from " + Pre + "news_temp order by id desc";
// DataTable rTF = DbHelper.ExecuteTable(CommandType.Text, SqlTf, null);
// if (rTF.Rows.Count > MaxNumber)
// {
// string SQL1 = "delete from " + Pre + "news_temp where id=(select top 1 id from " + Pre + "news_temp order by id asc)";
// DbHelper.ExecuteNonQuery(CommandType.Text, SQL1, null);
// rTF.Clear(); rTF.Dispose();
// goto RandFirst;
// }
//}
#endregion 插入临时表
public void delTBDateNumber(int dateNum)
{
//扩展使用
//string SQL = "delete from " + Pre + "news_temp where DateDiff(d,CreatTime,'" + DateTime.Now + "') > " + dateNum + "";
//DbHelper.ExecuteNonQuery(CommandType.Text, SQL, null);
}
public void delTBNewsID(string NewsID)
{
#region
//扩展使用
//string[] nID = NewsID.Split(',');
//for (int i = 0; i < nID.Length; i++)
//{
// if (nID[i].Trim() != "")
// {
// if (NetCMS.Common.Input.IsInteger(nID[i]) == false){continue;}
// else
// {
// string gSQL = "select NewsID from " + Pre + "News where ID='" + int.Parse(nID[i]) + "'";
// DataTable dt = DbHelper.ExecuteTable(CommandType.Text, gSQL, null);
// if (dt != null && dt.Rows.Count > 0)
// {
// string SQL = "delete from " + Pre + "news_temp where NewsID ='" + dt.Rows[0]["NewsID"].ToString() + "' and DataLib='" + DataTable + "'";
// DbHelper.ExecuteNonQuery(CommandType.Text, SQL, null);
// dt.Clear(); dt.Dispose();
// }
// }
// }
//}
#endregion
}
public void delTBTypeNumber(int getcondition)
{
#region
//扩展使用
////清除推荐
// RandFirst:
// string Sql = "select ID from " + Pre + "news_temp where isRec=1 order by id desc";
// DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
// if (dt.Rows.Count > getcondition)
// {
// string SQL = "delete from " + Pre + "news_temp where isRec=1 and id=(select top 1 id from " + Pre + "news_temp where isRec=1 order by id asc)";
// DbHelper.ExecuteNonQuery(CommandType.Text, SQL, null);
// dt.Clear(); dt.Dispose();
// goto RandFirst;
// }
// //清除滚动
// RandFirst1:
// string Sql1 = "select ID from " + Pre + "news_temp where isMarQuee=1 order by id desc";
// DataTable dt1 = DbHelper.ExecuteTable(CommandType.Text, Sql1, null);
// if (dt1.Rows.Count > getcondition)
// {
// string SQL_1 = "delete from " + Pre + "news_temp where isMarQuee=1 and id=(select top 1 id from " + Pre + "news_temp where isMarQuee=1 order by id asc)";
// DbHelper.ExecuteNonQuery(CommandType.Text, SQL_1, null);
// dt1.Clear(); dt1.Dispose();
// goto RandFirst1;
// }
// //清除热点
// RandFirst2:
// string Sql2 = "select ID from " + Pre + "news_temp where isHot=1 order by id desc";
// DataTable dt2 = DbHelper.ExecuteTable(CommandType.Text, Sql2, null);
// if (dt2.Rows.Count > getcondition)
// {
// string SQL_2 = "delete from " + Pre + "news_temp where isHot=1 and id=(select top 1 id from " + Pre + "news_temp where isHot=1 order by id asc)";
// DbHelper.ExecuteNonQuery(CommandType.Text, SQL_2, null);
// dt2.Clear(); dt2.Dispose();
// goto RandFirst2;
// }
// //清除幻灯
// RandFirst3:
// string Sql3 = "select ID from " + Pre + "news_temp where isFilt=1 order by id desc";
// DataTable dt3 = DbHelper.ExecuteTable(CommandType.Text, Sql3, null);
// if (dt3.Rows.Count > getcondition)
// {
// string SQL_3 = "delete from " + Pre + "news_temp where isFilt=1 and id=(select top 1 id from " + Pre + "news_temp where isFilt=1 order by id asc)";
// DbHelper.ExecuteNonQuery(CommandType.Text, SQL_3, null);
// dt3.Clear(); dt3.Dispose();
// goto RandFirst3;
// }
// //清除头条
// RandFirst4:
// string Sql4 = "select ID from " + Pre + "news_temp where isTT=1 order by id desc";
// DataTable dt4 = DbHelper.ExecuteTable(CommandType.Text, Sql4, null);
// if (dt4.Rows.Count > getcondition)
// {
// string SQL_4 = "delete from " + Pre + "news_temp where isTT=1 and id=(select top 1 id from " + Pre + "news_temp where isTT=1 order by id asc)";
// DbHelper.ExecuteNonQuery(CommandType.Text, SQL_4, null);
// dt4.Clear(); dt4.Dispose();
// goto RandFirst4;
// }
// //清除公告
// RandFirst5:
// string Sql5 = "select ID from " + Pre + "news_temp where isAnnounce=1 order by id desc";
// DataTable dt5 = DbHelper.ExecuteTable(CommandType.Text, Sql5, null);
// if (dt5.Rows.Count > getcondition)
// {
// string SQL_5 = "delete from " + Pre + "news_temp where isAnnounce=1 and id=(select top 1 id from " + Pre + "news_temp where isAnnounce=1 order by id asc)";
// DbHelper.ExecuteNonQuery(CommandType.Text, SQL_5, null);
// dt5.Clear(); dt5.Dispose();
// goto RandFirst5;
// }
// //清除WAP
// RandFirst6:
// string Sql6 = "select ID from " + Pre + "news_temp where isWap=1 order by id desc";
// DataTable dt6 = DbHelper.ExecuteTable(CommandType.Text, Sql6, null);
// if (dt6.Rows.Count > getcondition)
// {
// string SQL_6 = "delete from " + Pre + "news_temp where isWap=1 and id=(select top 1 id from " + Pre + "news_temp where isWap=1 order by id asc)";
// DbHelper.ExecuteNonQuery(CommandType.Text, SQL_6, null);
// dt6.Clear(); dt6.Dispose();
// goto RandFirst6;
// }
// //清除精彩
// RandFirst7:
// string Sql7 = "select ID from " + Pre + "news_temp where isJC=1 order by id desc";
// DataTable dt7 = DbHelper.ExecuteTable(CommandType.Text, Sql7, null);
// if (dt7.Rows.Count > getcondition)
// {
// string SQL_7 = "delete from " + Pre + "news_temp where isJC=1 and id=(select top 1 id from " + Pre + "news_temp where isJC=1 order by id asc)";
// DbHelper.ExecuteNonQuery(CommandType.Text, SQL_7, null);
// dt7.Clear(); dt7.Dispose();
// goto RandFirst7;
// }
#endregion
}
public int getNewsRecordEdior(string UserName)
{
int Rint = 0;
string nSql = "";
nSql = "select id from " + Pre + "news where Editor='" + UserName + "'";
DataTable dts = DbHelper.ExecuteTable(CommandType.Text, nSql, null);
if (dts != null && dts.Rows.Count > 0)
{
Rint = Rint + dts.Rows.Count;
dts.Clear(); dts.Dispose();
}
return Rint;
}
/// <summary>
/// 得到浏览新闻的参数
/// </summary>
/// <param name="NewsID"></param>
///
/// <returns></returns>
public string getnewsReview(string ID, string gType)
{
#region
string newspath = string.Empty;
string newspath1 = string.Empty;
string sql = string.Empty;
string dim = NetCMS.Config.UIConfig.dirDumm.Trim();
string ReadType = NetCMS.Common.Public.readparamConfig("ReviewType");
if (dim != string.Empty) { dim = "/" + dim; }
SqlParameter param = new SqlParameter("@ID", ID);
if (gType != "special")
{
if (gType == "class")
{
sql = "select IsURL,URLaddress,SavePath,SaveClassframe,ClassSaveRule,isDelPoint,ClassID,isPage from " + Pre + "news_class where ClassID=@ID";
IDataReader dt = DbHelper.ExecuteReader(CommandType.Text, sql, param);
while (dt.Read())
{
if (dt["isURL"].ToString() == "1")
{
if (dt["URLaddress"].ToString().IndexOf("http://") > -1)
{
newspath = dt["URLaddress"].ToString();
}
else
{
newspath = "http://" + dt["URLaddress"].ToString();
}
}
else
{
if (dt["isDelPoint"].ToString() != "0")
{
newspath1 = dim + "/list-" + dt["ClassID"].ToString() + ".aspx";
}
else
{
if (ReadType == "1")
{
if (dt["isPage"].ToString() == "1")
{
newspath1 = dim + "/page-" + dt["ClassID"].ToString() + ".aspx";
}
else
{
newspath1 = dim + "/list-" + dt["ClassID"].ToString() + ".aspx";
}
}
else
{
if (dt["isPage"].ToString() == "1")
{
newspath1 = dim + "/" + dt["SavePath"].ToString();
}
else
{
newspath1 = dim + "/" + dt["SavePath"].ToString() + "/" + dt["SaveClassframe"].ToString() + "/" + dt["ClassSaveRule"].ToString();
}
}
}
newspath = newspath1.Replace("//", "/").Replace(@"\\", @"\");
}
}
dt.Close();
}
else
{
sql = "select a.newsid,a.URLaddress,a.NewsType,a.SavePath,a.FileName,a.FileEXName,b.SavePath as SavePath1,b.SaveClassframe,a.isDelPoint from " + Pre + "news a," + Pre + "news_class b where a.classid=b.classid and a.NewsID=@ID";
IDataReader dt = DbHelper.ExecuteReader(CommandType.Text, sql, param);
while (dt.Read())
{
if (dt["NewsType"].ToString() != "2")
{
if (dt["isDelPoint"].ToString() != "0")
{
newspath1 = dim + "/content.aspx?id=" + dt["NewsID"].ToString() + "";
}
else
{
if (ReadType == "1")
{
newspath1 = dim + "/content.aspx?id=" + dt["NewsID"].ToString() + "";
}
else
{
newspath1 = dim + "/" + dt["SavePath1"].ToString() + "/" + dt["SaveClassframe"].ToString() + "/" + dt["SavePath"].ToString() + "/" + dt["FileName"].ToString() + dt["FileEXName"].ToString();
}
}
newspath = newspath1.Replace("//", "/").Replace(@"\\", @"\");
}
else
{
if (dt["URLaddress"].ToString().IndexOf("http://") > -1)
{
newspath = dt["URLaddress"].ToString();
}
else
{
newspath = "http://" + dt["URLaddress"].ToString();
}
}
} dt.Close();
}
}
else
{
//专题地址
sql = "select SpecialID,SavePath,saveDirPath,FileName,FileEXName,isDelPoint from " + Pre + "news_special where SpecialID=@ID";
IDataReader dt = DbHelper.ExecuteReader(CommandType.Text, sql, param);
while (dt.Read())
{
if (dt["isDelPoint"].ToString() != "0")
{
newspath1 = dim + "/special-" + dt["SpecialID"].ToString() + ".aspx";
}
else
{
if (ReadType == "1")
{
newspath1 = dim + "/special-" + dt["SpecialID"].ToString() + ".aspx";
}
else
{
newspath1 = dim + "/" + dt["SavePath"].ToString() + "/" + dt["saveDirPath"].ToString() + "/" + dt["FileName"].ToString() + dt["FileEXName"].ToString();
}
}
newspath = newspath1.Replace("//", "/").Replace(@"\\", @"\");
}
dt.Close();
}
return newspath;
#endregion
}
/// <summary>
/// 更新导航
/// </summary>
/// <param name="ClassID"></param>
/// <returns></returns>
public void updateReplaceNavi(string ClassID)
{
#region
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
try
{
cn.Open();
string NewsPosition = "";
string url = "";
string dim = NetCMS.Config.UIConfig.dirDumm;
if (dim.Trim() != string.Empty)
{
dim = "/" + dim;
}
string sql = "select ClassID,SavePath,SaveClassframe,ClassSaveRule,NaviPosition,NewsPosition from " + Pre + "news_class where ClassID=@ClassID";
SqlParameter Prm = new SqlParameter("@ClassID", ClassID);
IDataReader rd = DbHelper.ExecuteReader(cn, CommandType.Text, sql, Prm);
if (rd.Read())
{
NewsPosition = rd["NewsPosition"].ToString();
url = dim + "/" + rd["SavePath"].ToString() + "/" + rd["SaveClassframe"].ToString() + "/" + rd["ClassSaveRule"].ToString();
NewsPosition = NewsPosition.Replace("{@ClassURL}", url).Replace("//", "/");
}
rd.Close();
string Usql = "update " + Pre + "news_class set NewsPosition=@NewsPosition where ClassID=@ClassID";
SqlParameter[] Param = new SqlParameter[]
{
new SqlParameter("@NewsPosition",NewsPosition),new SqlParameter("@ClassID",ClassID)
};
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Usql, Param);
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
#endregion
}
/// <summary>
/// 根据ID获得NewsID
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public string GetNewsIDfromID1(int id)
{
string flg = "0|0";
string sql = "select NewsID,ClassID from " + Pre + "news where id=" + id;
IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, sql, null);
if (rd.Read())
{
flg = rd.GetString(0) + "|" + rd.GetString(1);
}
rd.Close();
return flg;
}
/// <summary>
/// 新闻统计
/// </summary>
/// <param name="siteid"></param>
/// <param name="flg"></param>
/// <returns></returns>
public int newsstat(string siteid, string flg)
{
#region
SqlParameter param = new SqlParameter("@SiteID", siteid);
string sql = "";
switch (flg)
{
case "m":
sql = "select count(id) from " + Pre + "news where SiteID=@SiteID and DateDiff(month,[CreatTime] ,Getdate())=0";
break;
case "pm":
sql = "select count(id) from " + Pre + "news where SiteID=@SiteID and DateDiff(month,[CreatTime] ,Getdate())=1";
break;
case "pz":
sql = "select count(id) from " + Pre + "news where SiteID=@SiteID and DateDiff(week,[CreatTime] ,Getdate())=1";
break;
case "z":
sql = "select count(id) from " + Pre + "news where SiteID=@SiteID and DateDiff(week,[CreatTime] ,Getdate())=0";
break;
case "pd":
sql = "select count(id) from " + Pre + "news where SiteID=@SiteID and DateDiff(Day,[CreatTime] ,Getdate())=1";
break;
case "d":
sql = "select count(id) from " + Pre + "news where SiteID=@SiteID and DateDiff(Day,[CreatTime] ,Getdate())=0";
break;
case "c":
sql = "select count(id) from " + Pre + "news_class where SiteID=@SiteID";
break;
case "s":
sql = "select count(id) from " + Pre + "news_special where SiteID=@SiteID";
break;
case "a":
sql = "select count(id) from " + Pre + "sys_admin where SiteID=@SiteID";
break;
case "de":
sql = "select count(id) from " + Pre + "define_data where SiteID=@SiteID";
break;
case "v":
sql = "select count(id) from " + Pre + "news where SiteID=@SiteID and vURL!='' and vURL!=null";
break;
case "mo":
sql = "select count(id) from " + Pre + "sys_channel where SiteID=@SiteID";
break;
case "u":
sql = "select count(id) from " + Pre + "sys_user where SiteID=@SiteID";
break;
case "co":
sql = "select count(id) from " + Pre + "news where SiteID=@SiteID and isconstr=1";
break;
default:
sql = "select count(id) from " + Pre + "news where SiteID=@SiteID";
break;
}
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
#endregion
}
public void addSpecialTo(string NewsID, string SpecialID)
{
#region
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@NewsID", SqlDbType.Int, 4);
param[0].Value = int.Parse(NewsID);
param[1] = new SqlParameter("@SpecialID", SqlDbType.NVarChar, 20);
param[1].Value = SpecialID;
string gsql = "select NewsID from " + Pre + "news where ID=@NewsID";
string NewsIDstr = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, gsql, param));
string Sql = "insert into " + Pre + "special_news(";
Sql += "SpecialID,NewsID";
Sql += ") values (@SpecialID,'" + NewsIDstr + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public IDataReader getNewsPath(string id)
{
SqlParameter param = new SqlParameter("@ID", id);
string sql = "select SavePath,FileName,FileEXName from NT_News where Id=@ID";
return DbHelper.ExecuteReader(CommandType.Text,sql,param);
}
}
} | 0575kaoshicj | trunk/NetCMS.DALSQLServer/ContentManage.cs | C# | asf20 | 133,771 |
//======================================================
//== (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 NetCMS.Common;
using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class rootPublic : DbBase, IrootPublic
{
/// <summary>
/// 获得站点ID是否存在
/// </summary>
/// <param name="SiteID"></param>
/// <returns></returns>
public int getSiteID(string SiteID)
{
int intflg = 0;
SqlParameter param = new SqlParameter("@SiteID", SiteID);
string Sql = "Select id From " + Pre + "news_site Where ChannelID=@SiteID and isRecyle=0 and isLock=0";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
intflg = 1;
}
rdr.Clear(); rdr.Dispose();
}
return intflg;
}
/// <summary>
/// 获取会员名称
/// </summary>
/// <param name="UserNum">传入的会员编号</param>
/// <returns>返回名称</returns>
public string getUserName(string UserNum)
{
string uflg = "找不到用户";
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "Select id,UserName From " + Pre + "sys_user Where UserNum=@UserNum";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
uflg = rdr.Rows[0]["UserName"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return uflg;
}
/// <summary>
/// 获取会员名称
/// </summary>
public int getUserName_uid(string UserNum)
{
int uflg = 0;
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "Select id From " + Pre + "sys_user Where UserNum=@UserNum";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
uflg = int.Parse(rdr.Rows[0]["id"].ToString());
}
rdr.Clear(); rdr.Dispose();
}
return uflg;
}
/// <summary>
/// 根据ID获取会员编号
/// </summary>
/// <param name="UserNum">传入的会员ID</param>
/// <returns>返回名称</returns>
public string getUidUserNum(int Uid)
{
string uflg = "找不到用户";
SqlParameter param = new SqlParameter("@Uid", Uid);
string Sql = "Select id,UserNum From " + Pre + "sys_user Where id=@Uid";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
uflg = rdr.Rows[0]["UserNum"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return uflg;
}
/// <summary>
/// 根据用户名获得用户编号
/// </summary>
/// <param name="UserName"></param>
/// <returns></returns>
public string getUserNameUserNum(string UserName)
{
string uflg = "0";
SqlParameter param = new SqlParameter("@UserName", UserName);
string Sql = "Select UserNum From " + Pre + "sys_user Where UserName=@UserName";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
uflg = rdr.Rows[0]["UserNum"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return uflg;
}
/// <summary>
/// 根据会员组ID获取编号
/// </summary>
/// <param name="Gid"></param>
/// <returns></returns>
public string getGidGroupNumber(int Gid)
{
string uflg = "0";
SqlParameter param = new SqlParameter("@Gid", Gid);
string Sql = "Select GroupNumber From " + Pre + "user_Group Where Id=@Gid";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
uflg = rdr.Rows[0]["GroupNumber"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return uflg;
}
/// <summary>
/// 获取会员组名称
/// </summary>
/// <param name="GroupNumber">传入的会员组编号</param>
/// <returns></returns>
public string getGroupName(string GroupNumber)
{
string uflg = "不属于任何组";
SqlParameter param = new SqlParameter("@GroupNumber", GroupNumber);
string Sql = "Select id,GroupName From " + Pre + "user_Group Where GroupNumber=@GroupNumber";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
uflg = rdr.Rows[0]["GroupName"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return uflg;
}
/// <summary>
/// 根据用户编号获得用户组编号
/// </summary>
/// <param name="strUserNum"></param>
/// <returns></returns>
public string getUserGroupNumber(string strUserNum)
{
string USQL = "Select UserGroupNumber From " + Pre + "sys_user Where UserNum=@UserNum and SiteID='" + NetCMS.Global.Current.SiteID + "'";
SqlParameter Param = new SqlParameter("@UserNum", strUserNum);
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, USQL, Param));
}
/// <summary>
/// 根据用户组获得用户标志
/// </summary>
/// <param name="UserNum"></param>
/// <returns></returns>
public string getGroupNameFlag(string UserNum)
{
string uflg = string.Empty;
SqlParameter Param = new SqlParameter("@UserNum", UserNum);
string USQL = "Select UserGroupNumber From " + Pre + "sys_user Where UserNum=@UserNum and SiteID='" + NetCMS.Global.Current.SiteID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, USQL, Param);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
string Sql = "Select UserFlag From " + Pre + "user_Group Where GroupNumber='" + dt.Rows[0]["UserGroupNumber"].ToString() + "'";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
uflg = rdr.Rows[0]["UserFlag"].ToString();
}
}
rdr.Dispose();
}
dt.Clear(); dt.Dispose();
}
return uflg;
}
/// <summary>
/// 通过用户编号获取会员组名称
/// </summary>
/// <param name="UserNum">传入的会员编号</param>
/// <returns></returns>
public string getUserGroupName(string UserNum)
{
string uflg = "找不到用户";
SqlParameter Param = new SqlParameter("@UserNum", UserNum);
string Sql = "Select id,UserGroupNumber From " + Pre + "sys_User Where UserNum=@UserNum";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, Param);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
string SQL1 = "Select id,GroupName From " + Pre + "user_Group Where GroupNumber='" + rdr.Rows[0]["UserGroupNumber"].ToString() + "'";
DataTable gdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (gdr != null)
{
if (gdr.Rows.Count > 0) { uflg = gdr.Rows[0]["GroupName"].ToString(); }
else { uflg = "找不到会员组"; }
gdr.Dispose();
}
else { uflg = "找不到会员组"; }
}
else { uflg = "找不到会员组"; }
}
rdr.Dispose();
return uflg;
}
/// <summary>
/// 通过用户猪编号获取会员组ID
/// </summary>
/// <param name="UserNum">传入的会员编号</param>
/// <returns></returns>
public string getIDGroupNumber(string GroupNumber)
{
string uflg = "0";
SqlParameter GroupNumberParam = new SqlParameter("@GroupNumber", GroupNumber);
string Sql = "Select id From " + Pre + "user_Group Where GroupNumber=@GroupNumber and SiteID='" + NetCMS.Global.Current.SiteID + "'";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, GroupNumberParam);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
uflg = rdr.Rows[0]["Id"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return uflg;
}
/// <summary>
/// 得到G币名称
/// </summary>
/// <returns></returns>
public string getgPointName()
{
string gflg = "NetCMS币";
string Sql = "Select GpointName From " + Pre + "sys_PramUser";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = rdr.Rows[0]["GpointName"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 得到站点名称
/// </summary>
public string siteName()
{
string gflg = "NetCMS网站内容管理系统";
string Sql = "Select SiteName From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = rdr.Rows[0]["SiteName"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 得到前台版权信息
/// </summary>
/// <returns></returns>
public string siteCopyRight()
{
string gflg = "(c)2008 aspxcms Inc. by NetCMS 1.0";
string Sql = "Select CopyRight From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = rdr.Rows[0]["CopyRight"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 得到站点域名
/// </summary>
/// <returns></returns>
public string sitedomain()
{
string Sql = "Select SiteDomain From " + Pre + "sys_param";
object obj = DbHelper.ExecuteScalar(CommandType.Text, Sql, null);
if (obj != null && obj != DBNull.Value)
{
return obj.ToString();
}
else
{
return string.Empty;
}
}
/// <summary>
/// 得到主页模板
/// </summary>
/// <returns></returns>
public string indexTempletfile()
{
string gflg = "/{@dirTemplet}/index.html|index.html";
string Sql = "Select IndexTemplet,IndexFileName From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = rdr.Rows[0]["IndexTemplet"].ToString() + "|" + rdr.Rows[0]["IndexFileName"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 得到其他模板(栏目,内容)
/// </summary>
/// <returns></returns>
public string allTemplet()
{
string gflg = "/{@dirTemplet}/Content/news.html|/{@dirTemplet}/Content/class.html|/{@dirTemplet}/Content/special.html|html";
string Sql = "Select ReadNewsTemplet,ClassListTemplet,SpecialTemplet,FileEXName From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = rdr.Rows[0]["ReadNewsTemplet"].ToString() + "|" + rdr.Rows[0]["ClassListTemplet"].ToString() + "|" + rdr.Rows[0]["SpecialTemplet"].ToString() + "|" + rdr.Rows[0]["FileEXName"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 得到生成方式
/// </summary>
/// <returns></returns>
public int ReadType()
{
int gflg = 0;
string Sql = "Select ReadType From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = int.Parse(rdr.Rows[0]["ReadType"].ToString());
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 得到站点Email
/// </summary>
/// <returns></returns>
public string SiteEmail()
{
string gflg = "";
string Sql = "Select Email From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = rdr.Rows[0]["Email"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 得到连接方式
/// </summary>
/// <returns></returns>
public int LinkType()
{
int gflg = 0;
string Sql = "Select LinkType From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = int.Parse(rdr.Rows[0]["LinkType"].ToString());
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 获取审核机制
/// </summary>
/// <returns></returns>
public int CheckInt()
{
int gflg = 0;
string Sql = "Select CheckInt From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = int.Parse(rdr.Rows[0]["CheckInt"].ToString());
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
public int CheckNewsTitle()
{
int gflg = 0;
string Sql = "Select CheckNewsTitle From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = int.Parse(rdr.Rows[0]["CheckNewsTitle"].ToString());
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 得到会员所在组的折扣率
/// </summary>
/// <param name="UserNum"></param>
/// <returns></returns>
public double getDiscount(string UserNum)
{
double discout = 1;
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "Select UserGroupNumber From " + Pre + "sys_user where UserNum=@UserNum";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
string SQL_1 = "Select Discount from " + Pre + "user_Group where GroupNumber='" + rdr.Rows[0]["UserGroupNumber"] + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, SQL_1, null);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
discout = double.Parse(dt.Rows[0]["Discount"].ToString());
}
dt.Clear(); dt.Dispose();
}
}
rdr.Clear(); rdr.Dispose();
}
return discout;
}
public DataTable getWaterInfo()
{
string Sql = "Select PrintWord,Printfontsize,Printfontfamily,Printfontcolor,PrintBTF,PintPicURL,PrintPicsize,PintPictrans,PrintPosition From " + Pre + "sys_parmPrint";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return rdr;
}
/// <summary>
/// 得到签名
/// </summary>
/// <param name="UserNum"></param>
/// <returns></returns>
public string getUserChar(string UserNum)
{
string _STR = "";
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "Select Userinfo From " + Pre + "sys_user where UserNum=@UserNum";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
_STR = rdr.Rows[0]["Userinfo"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return _STR;
}
/// <summary>
/// 获取栏目保存路径
/// </summary>
/// <returns></returns>
public string SaveClassFilePath(string siteid)
{
string gflg = "/html";
if (siteid == "0")
{
string Sql = "Select SaveClassFilePath From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null && rdr.Rows.Count > 0)
{
gflg = rdr.Rows[0]["SaveClassFilePath"].ToString();
rdr.Clear(); rdr.Dispose();
}
}
else
{
SqlParameter param = new SqlParameter("@siteid", siteid);
string sqls = "select SaveDirPath,EName from " + Pre + "news_site where ChannelID=@siteid";
DataTable rdrs = DbHelper.ExecuteTable(CommandType.Text, sqls, param);
if (rdrs != null && rdrs.Rows.Count > 0)
{
if (NetCMS.Config.UIConfig.dirHtml == "")
{
gflg = rdrs.Rows[0]["SaveDirPath"].ToString() + "/" + rdrs.Rows[0]["EName"].ToString();
}
else
{
gflg = rdrs.Rows[0]["SaveDirPath"].ToString() + "/" + rdrs.Rows[0]["EName"].ToString() + "/" + NetCMS.Config.UIConfig.dirHtml;
}
rdrs.Clear(); rdrs.Dispose();
}
}
return gflg;
}
/// <summary>
/// 获取索引页规则
/// </summary>
/// <returns></returns>
public string SaveIndexPage()
{
string gflg = "{@year04}/{@month}-{@day}";
string Sql = "Select SaveIndexPage From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = rdr.Rows[0]["SaveIndexPage"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 生成新闻的文件保存路径
/// </summary>
/// <returns></returns>
public string SaveNewsDirPath()
{
string gflg = "{@year04}/{@month}-{@day}";
string Sql = "Select SaveNewsDirPath From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = rdr.Rows[0]["SaveNewsDirPath"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 生成新闻的文件保存路径
/// </summary>
/// <returns></returns>
public string SaveNewsFilePath()
{
string gflg = "{@year04}{@month}{@day}{@hour}{@minute}{@second}";
string Sql = "Select SaveNewsFilePath From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = rdr.Rows[0]["SaveNewsFilePath"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 得到会员默认注册会员组
/// </summary>
/// <returns></returns>
public string GetRegGroupNumber()
{
string gflg = "0";
string Sql = "Select RegGroupNumber From " + Pre + "sys_PramUser";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = rdr.Rows[0]["RegGroupNumber"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 图片域名服务器
/// </summary>
/// <returns></returns>
public string PicServerDomain()
{
string gflg = "";
string Sql = "Select PicServerDomain From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = rdr.Rows[0]["PicServerDomain"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 是否独立图片域名服务器
/// </summary>
/// <returns></returns>
public int PicServerTF()
{
int gflg = 0;
string Sql = "Select PicServerTF From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = int.Parse(rdr.Rows[0]["PicServerTF"].ToString());
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 是否允许投稿
/// </summary>
/// <returns></returns>
public int ConstrTF()
{
int gflg = 0;
string Sql = "Select ConstrTF From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = int.Parse(rdr.Rows[0]["ConstrTF"].ToString());
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 得到上传的扩展名
/// </summary>
/// <returns></returns>
public string upfileType()
{
string gflg = "jpg,gif,bmp,ico,rar,zip,jpeg,png,swf|500";
string Sql = "Select UpfilesType,UpFilesSize From " + Pre + "sys_param";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
if (rdr != null)
{
if (rdr.Rows.Count > 0)
{
gflg = rdr.Rows[0]["UpfilesType"].ToString() + "|" + rdr.Rows[0]["UpFilesSize"].ToString();
}
rdr.Clear(); rdr.Dispose();
}
return gflg;
}
/// <summary>
/// 保存日志入库及日志文件
/// </summary>
/// <param name="num">标识,0表示写入数据库,1表示写入数据同时写入日志文件</param>
/// <param name="_num">用户标志,0表示用户,1表示管理员</param>
/// <param name="UserNum">传入的用户编号</param>
/// <param name="Title">日志标题</param>
/// <param name="Content">日志描述</param>
public void SaveUserAdminLogs(int num, int _num, string UserNum, string Title, string Content)
{
using (SqlConnection cn = new SqlConnection(DBConfig.CmsConString))
{
cn.Open();
SaveUserAdminLogs(cn, num, _num, UserNum, Title, Content);
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
/// <summary>
/// 保存日志入库及日志文件
/// </summary>
/// <param name="cn">已打开的数据库连接对象</param>
/// <param name="num">标识,0表示写入数据库,1表示写入数据同时写入日志文件</param>
/// <param name="_num">用户标志,0表示用户,1表示管理员</param>
/// <param name="UserNum">传入的用户编号</param>
/// <param name="Title">日志标题</param>
/// <param name="Content">日志描述</param>
public void SaveUserAdminLogs(SqlConnection cn, int num, int _num, string UserNum, string Title, string Content)
{
SqlParameter[] param = new SqlParameter[5];
param[0] = new SqlParameter("@num", SqlDbType.Int, 4);
param[0].Value = num;
param[1] = new SqlParameter("@_num", SqlDbType.Int, 4);
param[1].Value = _num;
param[2] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
param[2].Value = UserNum;
param[3] = new SqlParameter("@Title", SqlDbType.NVarChar, 50);
param[3].Value = Title;
param[4] = new SqlParameter("@Content", SqlDbType.NText);
param[4].Value = Content;
//string _UserNum = UserNum.Replace("'", "‘");
//string _Title = Title.Replace("'", "‘");
//string _Content = Content.Replace("'", "‘");
string Sql = "insert into " + Pre + "sys_logs (";
Sql += "title,content,creatTime,IP,usernum,SiteID,ismanage";
Sql += ") values (";
Sql += "@Title,@Content,'" + System.DateTime.Now + "','" + NetCMS.Common.Public.getUserIP() + "',@UserNum,'0',@_num )";
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, param);
if (num == 1)
{
NetCMS.Common.Public.saveLogFiles(_num, UserNum, Title, Content);
}
}
/// <summary>
/// 得到会员组DataTable
/// </summary>
/// <returns></returns>
public IDataReader GetGroupList()
{
string Sql = "select id,GroupNumber,GroupName from " + Pre + "user_Group where SiteID='" + NetCMS.Global.Current.SiteID + "'";
return DbHelper.ExecuteReader(CommandType.Text, Sql, null);
}
/// <summary>
/// 得到帮助ID
/// </summary>
/// <param name="helpId"></param>
/// <returns></returns>
public DataTable GetHelpId(string helpId)
{
SqlParameter param = new SqlParameter("@helpId", helpId);
string Sql = "Select TitleCN,ContentCN From "+ Pre +"sys_Help where HelpID=@helpId";
DataTable rdr = DbHelper.ExecuteTable(DBConfig.HelpConString, CommandType.Text, Sql, param);
return rdr;
}
/// <summary>
/// 得到站点列表
/// </summary>
/// <returns></returns>
public DataTable GetselectNewsList()
{
string Sql = "Select id,ChannelID,ParentID,CName from " + Pre + "news_site where isRecyle=0 and isLock=0 and IsURL =0 and ParentID='" + NetCMS.Global.Current.SiteID + "' order by id desc";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return rdr;
}
/// <summary>
/// 得到标签风格
/// </summary>
/// <returns></returns>
public DataTable GetselectLabelList()
{
string Sql = "Select id,ClassID,Sname,(Select Count(id) from " + Pre + "sys_LabelStyle where a.ClassId=ClassID and isRecyle=0 and siteID='" + NetCMS.Global.Current.SiteID + "') as HasSub from " + Pre + "sys_styleclass a where isRecyle=0 and siteID='" + NetCMS.Global.Current.SiteID + "' order by id desc";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return rdr;
}
/// <summary>
/// 得到标签风格
/// </summary>
/// <param name="ClassID"></param>
/// <returns></returns>
public DataTable GetselectLabelList1(string ClassID)
{
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string Sql = "select ID,styleID,ClassID,StyleName,Description,Content from " + Pre + "sys_LabelStyle where ClassId=@ClassID and siteID='" + NetCMS.Global.Current.SiteID + "' order by id desc";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
return rdr;
}
/// <summary>
/// 得到栏目
/// </summary>
/// <param name="ParentId"></param>
/// <returns></returns>
public IDataReader GetajaxsNewsList(string ParentId)
{
SqlParameter param = new SqlParameter("@ParentId", ParentId);
string Sql = "Select ClassID,ClassCName,(Select Count(id) from " + Pre + "news_Class where ParentID=a.ClassID and isRecyle=0 and isUrl=0 and isPage=0 and islock=0) as HasSub from " + Pre + "news_Class a where ParentID=@ParentId and isRecyle=0 and isUrl=0 and SiteID='" + NetCMS.Global.Current.SiteID + "' and isPage=0 and islock=0 order by OrderID desc,id desc";
return DbHelper.ExecuteReader(CommandType.Text, Sql, param);
}
/// <summary>
/// 根据栏目得到SiteID
/// </summary>
/// <param name="ClassID"></param>
/// <returns></returns>
public string getSiteIDFromClass(string ClassID)
{
string SiteID = "0";
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string Sql = "Select SiteID from " + Pre + "news_Class where ClassID=@ClassID";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (rdr != null && rdr.Rows.Count > 0)
{
SiteID = rdr.Rows[0]["SiteID"].ToString();
rdr.Clear(); rdr.Dispose();
}
return SiteID;
}
/// <summary>
/// 得到新闻表
/// </summary>
/// <returns></returns>
public DataTable getNewsTableIndex()
{
string Sql = "select TableName from " + Pre + "sys_NewsIndex";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return rdr;
}
/// <summary>
/// 得到专题列表
/// </summary>
/// <param name="ParentId"></param>
/// <returns></returns>
public IDataReader GetajaxsspecialList(string ParentId)
{
SqlParameter param = new SqlParameter("@ParentId", ParentId);
string Sql = "Select SpecialID,SpecialCName,(Select Count(id) from " + Pre + "news_special where ParentID=a.SpecialID and isRecyle=0) as HasSub from " + Pre + "news_special a where ParentID=@ParentId and isRecyle=0 and SiteID='" + NetCMS.Global.Current.SiteID + "' order by id desc";
return DbHelper.ExecuteReader(CommandType.Text, Sql, param);
}
/// <summary>
/// 得到栏目列表
/// </summary>
/// <param name="ParentID"></param>
/// <returns></returns>
public DataTable getClassListPublic(string ParentID)
{
SqlParameter param = new SqlParameter("@ParentID", ParentID);
string Sql = "Select ClassID,ClassCName,ParentID from " + Pre + "news_class where isURL=0 and isLock=0 and isRecyle=0 and isPage!=1 and ParentID=@ParentID and SiteID ='" + NetCMS.Global.Current.SiteID + "' order by OrderID desc,Id desc";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
return rdr;
}
/// <summary>
/// 得到专题列表
/// </summary>
/// <param name="ParentID"></param>
/// <returns></returns>
public DataTable getSpecialListPublic(string ParentID)
{
SqlParameter param = new SqlParameter("@ParentID", ParentID);
string Sql = "Select SpecialID,SpecialCName,ParentID from " + Pre + "news_special where isLock=0 and isRecyle=0 and ParentID=@ParentID and SiteID ='" + NetCMS.Global.Current.SiteID + "' order by Id desc";
DataTable rdr = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
return rdr;
}
public DataTable getUploadInfo()
{
string Sql = "Select UpfilesType,UpFilesSize From " + Pre + "sys_param";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, null);
return dt;
}
public DataTable getGroupUpInfo(string UserNum)
{
string UserGroupNumber = "0";
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string USQL = "select UserGroupNumber from " + Pre + "sys_User where UserNum=@UserNum";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, USQL, param);
if (dt != null && dt.Rows.Count > 0)
{
UserGroupNumber = dt.Rows[0]["UserGroupNumber"].ToString();
dt.Clear(); dt.Dispose();
}
SqlParameter paramType = new SqlParameter("@UserGroupNumber", UserGroupNumber);
string Sql = "select upfileType,upfileSize from " + Pre + "user_Group where GroupNumber=@UserGroupNumber";
return DbHelper.ExecuteTable(CommandType.Text, Sql, paramType);
}
/// <summary>
/// 得到站点中文名称
/// </summary>
/// <param name="SiteID">传入的站点编号</param>
/// <returns>站点名称</returns>
public string getChName(string SiteID)
{
string _Str = "";
SqlParameter param = new SqlParameter("@SiteID", SiteID);
string SQL = "select CName from " + Pre + "news_site where ChannelID=@SiteID";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, SQL, param);
if (dt != null && dt.Rows.Count > 0)
{
_Str = dt.Rows[0]["CName"].ToString();
}
return _Str;
}
public string getResultPage(string _Content, DateTime _DateTime, string ClassID, string EName)
{
string _Str = "";
if (_Content != string.Empty)
{
_Str = _Content.ToLower();
string year02 = ((_DateTime.Year).ToString()).PadRight(2);
string year04 = (_DateTime.Year).ToString();
string month = (_DateTime.Month).ToString();
string day = (_DateTime.Day).ToString();
string hour = (_DateTime.Hour).ToString();
string minute = (_DateTime.Minute).ToString();
string second = (_DateTime.Second).ToString();
_Str = _Str.Replace("{@year02}", year02);
_Str = _Str.Replace("{@year04}", year04);
_Str = _Str.Replace("{@month}", month);
_Str = _Str.Replace("{@day}", day);
_Str = _Str.Replace("{@second}", second);
_Str = _Str.Replace("{@minute}", minute);
_Str = _Str.Replace("{@hour}", hour);
if (ClassID == "0") { _Str = _Str.Replace("{@ename}", EName); }
else { _Str = _Str.Replace("{@ename}", getClassEName(ClassID)); }
if (_Str.IndexOf("{@ram", 0) != -1)
{
for (int i = 0; i <= 9; i++)
{
_Str = _Str.Replace("{@ram" + i + "_0}", NetCMS.Common.Rand.Number(i));
_Str = _Str.Replace("{@ram" + i + "_1}", NetCMS.Common.Rand.Str_char(i));
_Str = _Str.Replace("{@ram" + i + "_2}", NetCMS.Common.Rand.Str(i));
}
}
}
return _Str;
}
/// <summary>
/// 得到英文名称
/// </summary>
/// <param name="ClassID"></param>
/// <returns></returns>
public string getClassEName(string ClassID)
{
string _STR = "";
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string Sql = "Select ClassEName From " + Pre + "news_class where ClassID=@ClassID and SiteID ='" + NetCMS.Global.Current.SiteID + "'";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
_STR = dt.Rows[0]["ClassEName"].ToString();
}
dt.Clear(); dt.Dispose();
}
return _STR;
}
#region 用户登陆
public int getUserLoginCode()
{
string Sql = "Select UserLoginCodeTF From " + Pre + "sys_PramUser";
object obj = DbHelper.ExecuteScalar(CommandType.Text, Sql, null);
if (obj == null || obj == DBNull.Value)
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
}
/// <summary>
/// 得到会员用户积分和G币
/// </summary>
/// <param name="UserNum"></param>
/// <returns></returns>
public string getGIPoint(string UserNum)
{
string flg = "0|0";
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "Select iPoint,gPoint From " + Pre + "sys_User where UserNum=@UserNum";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
flg = dt.Rows[0]["iPoint"].ToString() + "|" + dt.Rows[0]["gPoint"].ToString();
}
dt.Clear(); dt.Dispose();
}
return flg;
}
/// <summary>
/// 得到魅力值
/// </summary>
/// <param name="UserNum"></param>
/// <returns></returns>
public int getcPoint(string UserNum)
{
int flg = 0;
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "Select cPoint From " + Pre + "sys_User where UserNum=@UserNum";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
flg = int.Parse(dt.Rows[0]["cPoint"].ToString());
}
dt.Clear(); dt.Dispose();
}
return flg;
}
/// <summary>
/// 得到用户是否允许签名
/// </summary>
/// <param name="UserNum"></param>
/// <returns></returns>
public int getUserUserInfo(string UserNum)
{
int intflg = 0;
string UserGroupNumber = "";
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Usql = "select UserGroupNumber from " + Pre + "sys_User where UserNum=@UserNum";
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Usql, param);
if (dt != null && dt.Rows.Count > 0)
{
UserGroupNumber = dt.Rows[0]["UserGroupNumber"].ToString();
dt.Clear(); dt.Dispose();
}
SqlParameter paramGroup = new SqlParameter("@UserGroupNumber", UserGroupNumber);
string SQL = "select CharTF from " + Pre + "user_Group where GroupNumber=@UserGroupNumber";
DataTable dts = DbHelper.ExecuteTable(CommandType.Text, SQL, paramGroup);
if (dts != null && dts.Rows.Count > 0)
{
intflg = int.Parse(dts.Rows[0]["CharTF"].ToString());
dts.Clear(); dts.Dispose();
}
return intflg;
}
#endregion 用户登陆
#region 删除所有用户信息
public void delUserAllInfo(string UserNum)
{
//删除投稿
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string consql = "delete " + Pre + "user_Constr where UserNum = @UserNum and SiteID='" + NetCMS.Global.Current.SiteID + "'";
DbHelper.ExecuteNonQuery(CommandType.Text, consql, param);
//投稿分类
SqlParameter paramClass = new SqlParameter("@UserNum", UserNum);
string concsql = "delete " + Pre + "user_ConstrClass where UserNum = @UserNum";
DbHelper.ExecuteNonQuery(CommandType.Text, concsql, paramClass);
//支付记录
SqlParameter paramPay = new SqlParameter("@UserNum", UserNum);
string constrPaysql = "delete " + Pre + "user_constrPay where UserNum =@UserNum";
DbHelper.ExecuteNonQuery(CommandType.Text, constrPaysql, paramPay);
}
#endregion
#region 删除所有的频道资料
public void delSiteAllInfo(string SiteID)
{
}
#endregion 删除所有的频道资料
#region 删除所有的新闻/静态文件
public void delNewsAllInfo(string SiteID)
{
}
#endregion 删除所有的新闻
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/rootPublic.cs | C# | asf20 | 45,819 |
//======================================================
//== (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 NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class News : DbBase, INews
{
public DataTable GetTables()
{
string Sql = "select TableName from " + Pre + "sys_NewsIndex";
return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
}
#region 归档新闻
public DataTable CoverTabNews1(string SeleStr, string TableID_Sql, string boxs)
{
string Cover_SqlS = "Select " + SeleStr + "," + TableID_Sql + " From " + Pre + "old_News as a, " + Pre + "sys_NewsIndex as b where a.id=" + boxs + " and a.DataLib = b.TableName";
return DbHelper.ExecuteTable(CommandType.Text, Cover_SqlS, null);
}
public int delPP(string boxs)
{
string His_Sql = "Delete From " + Pre + "old_News where id in(" + boxs + ")";
return DbHelper.ExecuteNonQuery(CommandType.Text, His_Sql, null);
}
public int locks(string boxs)
{
string His_Sql = "Update " + Pre + "old_News Set isLock=1 where id in(" + boxs + ")";
return DbHelper.ExecuteNonQuery(CommandType.Text, His_Sql, null);
}
public int unlovkc(string boxs)
{
string His_Sql = "Update " + Pre + "old_News Set isLock=0 where id in(" + boxs + ")";
return DbHelper.ExecuteNonQuery(CommandType.Text, His_Sql, null);
}
public int delalpl()
{
string His_Sql = "Delete From " + Pre + "old_News";
return DbHelper.ExecuteNonQuery(CommandType.Text, His_Sql, null);
}
#endregion
/// <summary>
/// 添加新闻点击
/// </summary>
/// <param name="NewsID">新闻编号</param>
public int AddNewsClick(string NewsID)
{
SqlParameter param = new SqlParameter("@NewsID", NewsID);
string Sql = "Update " + Pre + "news Set Click=Click+1 Where NewsID=@NewsID";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
Sql = "Select Click From " + Pre + "news Where NewsID=@NewsID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
/// <summary>
/// 取得评论列表
/// </summary>
/// <param name="NewsID">新闻编号</param>
/// <returns>返回数据表</returns>
public DataTable getCommentList(string NewsID)
{
SqlParameter param = new SqlParameter("@NewsID", NewsID);
string Sql = "Select Commid,Title,Content,UserNum,creatTime,IP,commtype,QID,id,GoodTitle From " + Pre + "api_commentary Where InfoID=@NewsID And isRecyle=0 And islock=0 Order By OrderID desc,creatTime Desc,id desc";
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
}
/// <summary>
/// 添加评论信息
/// </summary>
/// <param name="ci">实体类</param>
/// <returns>如果添加成功返回1</returns>
public int AddComment(NetCMS.Model.CommentInfo ci)
{
SqlParameter[] param = GetCommentParameters(ci);
string Commid = NetCMS.Common.Rand.Number(12);
while (true)
{
string checkSql = "select count(ID) from " + Pre + "api_commentary where Commid='" + Commid + "'";
int recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
if (recordCount < 1)
break;
else
Commid = NetCMS.Common.Rand.Number(12, true);
}
string Sql = "Insert Into " + Pre + "api_commentary(Commid,InfoID,APIID,DataLib,Title,Content,creatTime,IP,QID,UserNum,isRecyle,islock,OrderID,GoodTitle,isCheck,SiteID,commtype) Values('" + Commid + "',@InfoID,@APIID,@DataLib,@Title,@Content,@creatTime,@IP,@QID,@UserNum,@isRecyle,@islock,@OrderID,@GoodTitle,@isCheck,@SiteID,@commtype)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
/// <summary>
/// 获得构造参数
/// </summary>
/// <param name="ci"></param>
/// <returns></returns>
private SqlParameter[] GetCommentParameters(NetCMS.Model.CommentInfo ci)
{
SqlParameter[] param = new SqlParameter[18];
param[0] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[0].Value = ci.Id;
param[1] = new SqlParameter("@Commid", SqlDbType.NVarChar, 12);
param[1].Value = ci.Commid;
param[2] = new SqlParameter("@InfoID", SqlDbType.NVarChar, 12);
param[2].Value = ci.InfoID;
param[3] = new SqlParameter("@APIID", SqlDbType.NVarChar, 20);
param[3].Value = ci.APIID;
param[4] = new SqlParameter("@DataLib", SqlDbType.NVarChar, 20);
param[4].Value = ci.DataLib;
param[5] = new SqlParameter("@Title", SqlDbType.NVarChar, 200);
param[5].Value = ci.Title;
param[6] = new SqlParameter("@Content", SqlDbType.NVarChar, 200);
param[6].Value = ci.Content;
param[7] = new SqlParameter("@creatTime", SqlDbType.DateTime, 8);
param[7].Value = ci.creatTime;
param[8] = new SqlParameter("@IP", SqlDbType.NVarChar, 20);
param[8].Value = ci.IP;
param[9] = new SqlParameter("@QID", SqlDbType.NVarChar, 12);
param[9].Value = ci.QID;
param[10] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 15);
param[10].Value = ci.UserNum;
param[11] = new SqlParameter("@isRecyle", SqlDbType.Int, 4);
param[11].Value = ci.isRecyle;
param[12] = new SqlParameter("@islock", SqlDbType.Int, 4);
param[12].Value = ci.islock;
param[13] = new SqlParameter("@OrderID", SqlDbType.Int, 4);
param[13].Value = ci.OrderID;
param[14] = new SqlParameter("@GoodTitle", SqlDbType.Int, 4);
param[14].Value = ci.GoodTitle;
param[15] = new SqlParameter("@isCheck", SqlDbType.Int, 4);
param[15].Value = ci.isCheck;
param[16] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[16].Value = ci.SiteID;
param[17] = new SqlParameter("@commtype", SqlDbType.TinyInt, 1);
param[17].Value = ci.commtype;
return param;
}
/// <summary>
/// 得到评论观点
/// </summary>
/// <param name="infoID"></param>
/// <param name="num"></param>
/// <returns></returns>
public int returnCommentGD(string infoID, int num)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@InfoID", SqlDbType.NVarChar, 12);
param[0].Value = infoID;
param[1] = new SqlParameter("@commtype", SqlDbType.NVarChar, 4);
param[1].Value = num;
int perstr = 100;
string sql = "select count(id) from " + Pre + "api_commentary where InfoID=@InfoID";
int recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, sql, param);
string sql1 = "select count(id) from " + Pre + "api_commentary where InfoID=@InfoID and commtype=@commtype";
int recordCount1 = (int)DbHelper.ExecuteScalar(CommandType.Text, sql1, param);
perstr = (recordCount1 * 100 / recordCount);
return perstr;
}
/// <summary>
/// 得到新闻的DIG数
/// </summary>
/// <param name="NewsID"></param>
/// <returns></returns>
public int gettopnum(string NewsID, string getNum)
{
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@NewsID", SqlDbType.NVarChar, 12);
param[0].Value = NewsID;
int intnum = 0;
if (getNum == "1")
{
string usql = "update " + Pre + "news set TopNum=TopNum+1 where NewsID=@NewsID";
DbHelper.ExecuteNonQuery(CommandType.Text, usql, param);
}
string sql = "select TopNum from " + Pre + "news where NewsID=@NewsID";
intnum = (int)DbHelper.ExecuteScalar(CommandType.Text, sql, param);
return intnum;
}
/// <summary>
/// 得到评论数
/// </summary>
/// <param name="NewsID"></param>
/// <param name="Todays"></param>
/// <returns></returns>
public string getCommCounts(string NewsID, string Todays)
{
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@NewsID", SqlDbType.NVarChar, 12);
param[0].Value = NewsID;
string whereSTR = "";
if (Todays == "1")
{
whereSTR = "And DateDiff(Day,[creatTime] ,Getdate()) = 0 ";
}
string Sql = "Select Count(ID) From [" + Pre + "api_commentary] Where [InfoID]=@NewsID " + whereSTR + " and islock=0";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
}
/// <summary>
/// 得到投票
/// </summary>
/// <param name="NewsID"></param>
/// <returns></returns>
public DataTable getvote(string NewsID)
{
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@NewsID", SqlDbType.NVarChar, 12);
param[0].Value = NewsID;
string Sql = "Select NewsID,voteTitle,voteContent,isTimeOutTime,ismTF,isMember,creattime From [" + Pre + "news_vote] Where [NewsID]=@NewsID and DateDiff(Day,[isTimeOutTime] ,Getdate()) <= 0";//投票过期
DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Sql, param);
return dt;
}
public string getChannelTable(int ChID)
{
string TableStr = "#";
string TmpTable = string.Empty;
int GetTableRecord = 0;
SqlParameter param = new SqlParameter("@ChID", ChID);
string sql = "select DataLib from " + Pre + "sys_channel where ID=@ChID";
IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, param);
if (dr.Read())
{
TmpTable = dr["DataLib"].ToString();
string TableSQL = "select count(*) from sysobjects where id = object_id(N'[" + TmpTable + "]') and OBJECTPROPERTY(id, N'IsUserTable') = 1";
GetTableRecord = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, TableSQL, null));
if (GetTableRecord > 0)
{
TableStr = TmpTable;
}
}
dr.Close();
return TableStr;
}
public IDataReader getNewsInfo(string NewsID,int ChID)
{
string Sql = string.Empty;
SqlParameter[] param = new SqlParameter[1];
if (ChID != 0)
{
param[0] = new SqlParameter("@NewsID", SqlDbType.Int, 4);
param[0].Value = int.Parse(NewsID);
Sql = "Select * From [" + getChannelTable(ChID) + "] Where [id]=@NewsID";
}
else
{
param[0] = new SqlParameter("@NewsID", SqlDbType.NVarChar, 12);
param[0].Value = NewsID;
Sql = "Select * From [" + Pre + "news] Where [NewsID]=@NewsID";
}
return DbHelper.ExecuteReader(CommandType.Text, Sql, param);
}
public IDataReader getClassInfo(string ClassID, int ChID)
{
string Sql = string.Empty;
SqlParameter[] param = new SqlParameter[1];
if (ChID != 0)
{
param[0] = new SqlParameter("@ClassID", SqlDbType.Int, 4);
param[0].Value = int.Parse(ClassID);
Sql = "Select id,SavePath,FileName From [" + Pre + "sys_channelclass] Where [id]=@ClassID";
}
else
{
param[0] = new SqlParameter("@ClassID", SqlDbType.NVarChar, 12);
param[0].Value = ClassID;
Sql = "Select ClassID,SavePath,SaveClassframe From [" + Pre + "news_class] Where [ClassID]=@ClassID";
}
return DbHelper.ExecuteReader(CommandType.Text, Sql, param);
}
}
} | 0575kaoshicj | trunk/NetCMS.DALSQLServer/News.cs | C# | asf20 | 13,210 |
//======================================================
//== (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 NetCMS.Common;
using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Friend : DbBase, IFriend
{
public DataTable sel_friendInfo(string UserNum,int flag)
{
#region
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = null;
if (flag == 0)//friend_add.aspx
{
Sql = "Select FriendName,HailFellow From " + Pre + "User_FriendClass where UserNum=@UserNum or gdfz='1'";
}
else if (flag == 1)
{
Sql = "Select Addfriendbs,UserNum,UserName From " + Pre + "sys_User where UserName=@UserNum";
}
else if (flag == 2)
{
Sql = "Select top 15 UserName From " + Pre + "User_Friend where UserNum=@UserNum";
}
else if (flag == 3)
{
Sql = "Select UserName,UserGroupNumber From " + Pre + "sys_user where UserNum=@UserNum";
}
return DbHelper.ExecuteTable(CommandType.Text, Sql, param);
#endregion
}
public string sel_userInfo(string UserNum,int flag)
{
#region
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = null;
if (flag == 0)
{
Sql = "select ReadUser from " + Pre + "user_Group where GroupNumber=@UserNum";
}
else if (flag == 1)
{
Sql = "select qUsername from " + Pre + "User_Requestinformation where bUsername=@UserNum and ischick=1 order by id desc";
}
else if (flag == 2)//Requestinformation.aspx
{
Sql = "select Content from " + Pre + "User_Requestinformation where bUsername=@UserNum";
}
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
#endregion
}
public int sel_friendClass(string UserNum,int flag)
{
#region
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = null;
if (flag == 0)
{
Sql="select count(*) from " + Pre + "User_FriendClass where UserNum=@UserNum";
}
else if (flag == 1)
{
Sql = "Select count(*) From " + Pre + "sys_user where UserName=@UserNum";
}
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
#endregion
}
public int add_Reformation(STRequestinformation Req, int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "insert into " + Pre + "User_Requestinformation (qUsername,bUsername,datatime,Content,ischick) values(@qUserName,@bUserName,@CreatTime,@Content,1)";
}
else if (flag == 1)
{
Sql = "insert into " + Pre + "User_Requestinformation (qUsername,bUsername,datatime,Content,ischick) values(@qUserName,@bUserName,@CreatTime,@Content,0)";
}
SqlParameter[] parm = GetRequestinformation(Req);
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
#endregion
}
public int add_Friend(STFriend Fri, string UserNum,int flag)
{
#region
string Sql = null;
if (flag == 0)
{
Sql = "insert into " + Pre + "User_Friend (FriendUserNum,UserNum,UserName,bUserNum,HailFellow,CreatTime,hyyz) values(@FriendUserNum,@UserNum,@bUserName,@bdUserName,@HailFellow,@CreatTime,1)";
}
else if (flag == 1)
{
Sql = "insert into " + Pre + "User_Friend (FriendUserNum,UserNum,UserName,bUserNum,HailFellow,CreatTime,hyyz) values(@FriendUserNum,@UserNum,@bUserName,@bdUserName,@HailFellow,@CreatTime,0)";
}
SqlParameter[] parm = GetFriend(Fri);
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 del_Friend(string FriendUserNum,int flag)
{
#region
SqlParameter param = new SqlParameter("@FriendUserNum", FriendUserNum);
string Sql = null;
if (flag == 0)//friendList.aspx
{
Sql = "Delete " + Pre + "User_Friend where FriendUserNum=@FriendUserNum";
}
else if (flag == 1)//friendmanage.aspx
{
Sql = "Delete " + Pre + "User_FriendClass where HailFellow=@FriendUserNum";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
public int update_Information(string bUsername, string qUsername,int flag)
{
#region
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@bUserName", bUsername), new SqlParameter("@qUsername", qUsername) };
string Sql = null;
if (flag == 0)
{
Sql = "update " + Pre + "User_Requestinformation set ischick=0 where bUsername=@bUserName and qUsername=@qUsername";
}
else if (flag == 1)
{
Sql = "update " + Pre + "User_Friend set hyyz='0' where bUserNum=@bUserName and UserNum=@qUsername";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
#endregion
}
#region friend_add.aspx
public int sel_userFriend(string UserNum, string bUserName)
{
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@UserNum", UserNum), new SqlParameter("@bUserName", bUserName) };
string Sql = "Select count(*) From " + Pre + "User_Friend where UserNum=@UserNum and UserName=@bUserName";
return (int)DbHelper.ExecuteScalar(CommandType.Text, Sql, param);
}
private SqlParameter[] GetRequestinformation(STRequestinformation Req)
{
#region
SqlParameter[] parm = new SqlParameter[4];
parm[0] = new SqlParameter("@qUserName", SqlDbType.NVarChar, 50);
parm[0].Value = Req.qUsername;
parm[1] = new SqlParameter("@bUserName", SqlDbType.NVarChar, 50);
parm[1].Value = Req.bUsername;
parm[2] = new SqlParameter("@Content", SqlDbType.NVarChar, 50);
parm[2].Value = Req.Content;
parm[3] = new SqlParameter("@CreatTime", SqlDbType.DateTime);
parm[3].Value = DateTime.Now;
return parm;
#endregion
}
private SqlParameter[] GetFriend(STFriend Fri)
{
#region
SqlParameter[] parm = new SqlParameter[5];
parm[0] = new SqlParameter("@bUserName", SqlDbType.NVarChar, 50);
parm[0].Value = Fri.UserName;
parm[1] = new SqlParameter("@bdUserName", SqlDbType.NVarChar, 50);
parm[1].Value = Fri.bUserNum;
parm[2] = new SqlParameter("@HailFellow", SqlDbType.NVarChar, 50);
parm[2].Value = Fri.HailFellow;
parm[3] = new SqlParameter("@CreatTime", SqlDbType.DateTime);
parm[3].Value = DateTime.Now;
parm[4] = new SqlParameter("@FriendUserNum", SqlDbType.NVarChar, 50);
parm[4].Value = Rand.Number(12);
return parm;
#endregion
}
#endregion
#region friend_Establishment.aspx
public string sel_sysUser(string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "Select Addfriendbs From " + Pre + "sys_user where UserNum=@UserNum";
string ret = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
if (ret == null && ret == "")
throw new Exception("对不起,数据错误!");
else
return ret;
}
public int Update(int FE, string UserNum)
{
SqlParameter param = new SqlParameter("@UserNum", UserNum);
string Sql = "update " + Pre + "sys_user set Addfriendbs='" + FE + "'where UserNum=@UserNum";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion
#region friendmanage_add.aspx
public string sel_friendClass()
{
string Sql = "select HailFellow from " + Pre + "User_FriendClass";
return (string)DbHelper.ExecuteScalar(CommandType.Text, Sql, null);
}
public int add_friendClass(STFriendClass FCl, string UserNum)
{
string Sql = "insert into " + Pre + "User_FriendClass(UserNum,FriendName,Content,CreatTime,HailFellow)values(@UserNum,@FriendName,@Contents,@CreatTime,@HailFellow)";
SqlParameter[] parm = GetFriendClass(FCl);
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);
}
private SqlParameter[] GetFriendClass(STFriendClass FCl)
{
#region
SqlParameter[] parm = new SqlParameter[4];
parm[0] = new SqlParameter("@FriendName", SqlDbType.NVarChar, 50);
parm[0].Value = FCl.FriendName;
parm[1] = new SqlParameter("@Contents", SqlDbType.NVarChar, 50);
parm[1].Value = FCl.Content;
parm[2] = new SqlParameter("@HailFellow", SqlDbType.NVarChar, 50);
parm[2].Value = FCl.HailFellow;
parm[3] = new SqlParameter("@CreatTime", SqlDbType.DateTime);
parm[3].Value = DateTime.Now;
return parm;
#endregion
}
#endregion
#region Requestinformation.aspx
public int add_userFriend(string FriendUserNum, string UserNum, string bUserName, string bdUserName, string Hail_Fellow, DateTime CreatTime)
{
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@FriendUserNum", FriendUserNum), new SqlParameter("@UserNum", UserNum), new SqlParameter("@bUserName", bUserName), new SqlParameter("@bdUserName", bdUserName), new SqlParameter("@Hail_Fellow", Hail_Fellow), new SqlParameter("@CreatTime", CreatTime) };
string Sql = "insert into " + Pre + "User_Friend (FriendUserNum,UserNum,UserName,bUserNum,HailFellow,CreatTime,hyyz) values(@FriendUserNum,@UserNum,@bUserName,@bdUserName,@Hail_Fellow,@CreatTime,0)";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public int del_userInfo(string UserName, int ID)
{
SqlParameter param = new SqlParameter("@UserName", UserName);
string Sql = "delete " + Pre + "User_Requestinformation where bUserName=@UserName and ID=" + ID + "";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
#endregion
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Friend.cs | C# | asf20 | 12,095 |
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Text;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using NetCMS.DALFactory;
using NetCMS.Model;
using NetCMS.DALProfile;
using NetCMS.Config;
using NetCMS.Common;
namespace NetCMS.DALSQLServer
{
public class UserLogin : DbBase, IUserLogin
{
protected struct AdminDataInfo
{
public byte isSuper;
public string adminGroupNumber;
public int ID;
public byte isChannel;
}
protected struct UserLoginSucceedInfo
{
public string UserNum;
public string IP;
public int IPoint;
public int GPoint;
public int CPoint;
public int APoint;
}
private static readonly string SQL_SYS = "select islock,EmailATF,isMobile,isIDcard,UserGroupNumber from " + DBConfig.TableNamePrefix + "sys_User where UserNum=@UserNum";
private static readonly string SQL_PRAM = "select top 1 IPLimt,returnemail,returnmobile,LoginLock,cPointParam,aPointparam from " + DBConfig.TableNamePrefix + "sys_PramUser";
private static readonly string SQL_ADMIN = "select Iplimited,isLock,isSuper,adminGroupNumber,[ID],[isChannel] from " + DBConfig.TableNamePrefix + "sys_admin where UserNum=@UserNum";
private static readonly string SQL_USERGROUP = "select IsCert,LoginPoint,Rtime from " + DBConfig.TableNamePrefix + "user_Group where GroupNumber=@GroupNumber";
private static readonly string SQL_DEFUSERGROUP = "select top 1 a.IsCert,a.LoginPoint,a.Rtime from " + DBConfig.TableNamePrefix + "user_Group a inner join " + DBConfig.TableNamePrefix + "sys_PramUser b on a.GroupNumber=b.RegGroupNumber";
EnumLoginState IUserLogin.CheckUserLogin(string UserNum, bool IsCert)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
try
{
cn.Open();
return CheckUserLogin(cn, UserNum, IsCert);
}
catch
{
return EnumLoginState.Err_DbException;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
protected EnumLoginState CheckUserLogin(SqlConnection cn, string UserNum, bool IsCert)
{
#region 局部变量
string LimitedIP = string.Empty;
bool bisLock = true;
bool bEmailATF = false;
bool bisMobile = false;
string sUserGroupNumber = string.Empty;
bool bisIDcard = false;
#endregion 局部变量
bool flag = true;
IDataReader rd = this.GetSysUser(cn, UserNum);
if (rd.Read())
{
#region 取值
if (!rd.IsDBNull(0) && rd.GetByte(0) == 0X0)
bisLock = false;
if (!rd.IsDBNull(1) && rd.GetByte(1) != 0X0)
bEmailATF = true;
if (!rd.IsDBNull(2) && rd.GetByte(2) != 0X0)
bisMobile = true;
if (!rd.IsDBNull(3) && rd.GetByte(3) != 0X0)
bisIDcard = true;
if (!rd.IsDBNull(4))
sUserGroupNumber = rd.GetString(4);
flag = false;
#endregion 取值
}
rd.Close();
if (flag)
return EnumLoginState.Err_UserNumInexistent;
if (bisLock)
return EnumLoginState.Err_Locked;
bool bReturnEmail = false;
bool bReturnMobile = false;
rd = GetParamUser(cn);
if (rd.Read())
{
if (!rd.IsDBNull(0))
LimitedIP = rd.GetString(0);
if (!rd.IsDBNull(1) && rd.GetByte(1) != 0X00)
bReturnEmail = true;
if (!rd.IsDBNull(2) && rd.GetByte(2) != 0X00)
bReturnMobile = true;
}
rd.Close();
if (LimitedIP.Trim() != string.Empty && !Public.ValidateIP(LimitedIP))
return EnumLoginState.Err_IPLimited;
if (bReturnEmail && !bEmailATF)
return EnumLoginState.Err_UnEmail;
if (bReturnMobile && !bisMobile)
return EnumLoginState.Err_UnMobile;
if (IsCert)
{
rd = GetUserGroupInfo(cn, sUserGroupNumber);
if (rd.Read())
{
if (!bisIDcard && rd["IsCert"] != DBNull.Value && Convert.ToInt32(rd["IsCert"]) != 0X00)
{
rd.Close();
return EnumLoginState.Err_UnCert;
}
}
rd.Close();
return EnumLoginState.Succeed;
}
else
{
return EnumLoginState.Succeed;
}
}
protected EnumLoginState CheckAdminLogin(SqlConnection cn, string UserNum, out AdminDataInfo info)
{
info.adminGroupNumber = string.Empty;
info.ID = 0;
info.isChannel = 0;
info.isSuper = 0;
string LimitedIP = string.Empty;
bool bisLock = true;
bool flag = true;
IDataReader rd = GetSysUser(cn, UserNum);
if (rd.Read())
{
if (!rd.IsDBNull(0) && rd.GetByte(0) == 0X0)
bisLock = false;
flag = false;
}
rd.Close();
if (flag)
return EnumLoginState.Err_UserNumInexistent;
if (bisLock)
return EnumLoginState.Err_Locked;
flag = true;
bisLock = true;
rd = DbHelper.ExecuteReader(cn, CommandType.Text, SQL_ADMIN, new SqlParameter("@UserNum", UserNum));
if (rd.Read())
{
if (!rd.IsDBNull(0)) LimitedIP = rd.GetString(0);
if (!rd.IsDBNull(1) && rd.GetByte(1) == 0X0)
bisLock = false;
if (!rd.IsDBNull(2))
info.isSuper = rd.GetByte(2);
if (!rd.IsDBNull(3))
info.adminGroupNumber = rd.GetString(3);
info.ID = rd.GetInt32(4);
if (!rd.IsDBNull(5))
info.isChannel = rd.GetByte(5);
flag = false;
}
rd.Close();
if (flag)
return EnumLoginState.Err_AdminNumInexistent;
if (bisLock)
return EnumLoginState.Err_AdminLocked;
if (LimitedIP.Trim() != string.Empty && !Public.ValidateIP(LimitedIP))
return EnumLoginState.Err_IPLimited;
return EnumLoginState.Succeed;
}
EnumLoginState IUserLogin.CheckAdminLogin(string UserNum)
{
SqlConnection cn = new SqlConnection(NetCMS.Config.DBConfig.CmsConString);
try
{
cn.Open();
AdminDataInfo info;
return CheckAdminLogin(cn, UserNum, out info);
}
catch
{
return EnumLoginState.Err_DbException;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
protected IDataReader GetParamUser(SqlConnection cn)
{
return DbHelper.ExecuteReader(cn, CommandType.Text, SQL_PRAM, null);
}
protected IDataReader GetSysUser(SqlConnection cn, string UserNum)
{
SqlParameter Param = new SqlParameter("@UserNum", UserNum);
return DbHelper.ExecuteReader(cn, CommandType.Text, SQL_SYS, Param);
}
protected IDataReader GetUserGroupInfo(SqlConnection cn, string GroupNum)
{
SqlParameter Param = new SqlParameter("@GroupNumber", GroupNum);
SqlDataReader rd = (SqlDataReader)DbHelper.ExecuteReader(cn, CommandType.Text, SQL_USERGROUP, Param);
if (!rd.HasRows)
{
rd.Close();
rd = (SqlDataReader)DbHelper.ExecuteReader(cn, CommandType.Text, SQL_DEFUSERGROUP, null);
}
return rd;
}
protected string GetAdminPopList(SqlConnection cn, int id)
{
string Sql = "select PopList from " + Pre + "sys_Admin where [ID]=" + id;
return Convert.ToString(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null));
}
protected IDataReader GetAdminGroupList(SqlConnection cn, string GroupNum)
{
string Sql = "select ClassList,SpecialList,channelList from " + Pre + "sys_admingroup where adminGroupNumber=@adminGroupNumber";
SqlParameter Param = new SqlParameter("@adminGroupNumber", GroupNum);
return DbHelper.ExecuteReader(cn, CommandType.Text, Sql, Param);
}
/// <summary>
/// 权限处理
/// </summary>
/// <param name="PopCode">权限代码</param>
/// <param name="ClassID">栏目ID</param>
/// <param name="SpecialID">专题ID</param>
/// <param name="SiteID">频道ID</param>
/// <returns></returns>
EnumLoginState IUserLogin.CheckAdminAuthority(string PopCode, string ClassID, string SpecialID, string SiteID)
{
string UserNum = NetCMS.Global.Current.UserNum;
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
try
{
cn.Open();
AdminDataInfo info;
EnumLoginState state = CheckAdminLogin(cn, UserNum, out info);
if (state != EnumLoginState.Succeed)
return state;
if (info.isSuper == 0X01)
return EnumLoginState.Succeed;
string PopList = GetAdminPopList(cn, info.ID);
if (PopList.IndexOf(PopCode) < 0)
return EnumLoginState.Err_NoAuthority;
string ClassList = string.Empty;
string SpecialList = string.Empty;
string SiteList = string.Empty;
IDataReader rd = GetAdminGroupList(cn, info.adminGroupNumber);
if (rd.Read())
{
if (!rd.IsDBNull(0))
{
ClassList = rd.GetString(0);
}
if (!rd.IsDBNull(1))
{
SpecialList = rd.GetString(1);
}
if (!rd.IsDBNull(2))
{
SiteList = rd.GetString(2);
}
}
rd.Close();
if (SpecialID == null || SpecialID == string.Empty)
{
SpecialList = "0";
}
if (SiteID == null || SiteID == string.Empty)
{
SiteList = "0";
}
if ((ClassList.IndexOf(ClassID) >= 0 && SpecialList.IndexOf(SpecialID) >= 0) || (SiteList.IndexOf(SiteID) >= 0))
return EnumLoginState.Succeed;
else
return EnumLoginState.Err_NoAuthority;
}
catch
{
return EnumLoginState.Err_DbException;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
EnumLoginState IUserLogin.PersonLogin(string UserName, string PassWord, out GlobalUserInfo info)
{
info = new GlobalUserInfo(string.Empty, string.Empty, string.Empty);
if (UserName == null || UserName.Trim() == string.Empty || PassWord == null || PassWord.Trim() == string.Empty)
{
return EnumLoginState.Err_UserNameOrPwdError;
}
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
try
{
string LogIP = NetCMS.Common.Public.getUserIP();
DateTime Now = DateTime.Now;
cn.Open();
#region 基本信息表
string UserNum = string.Empty;
string SiteID = string.Empty;
string PWD = string.Empty;
byte IsLock = 0X01;
int ipnt = 0;
int gpnt = 0;
int cpnt = 0;
int apnt = 0;
string sUserGroup = string.Empty;
DateTime dtUserRegDate = DateTime.Now;
SqlParameter Param = new SqlParameter("@UserName", UserName);
string Sql = "select UserPassword,UserNum,islock,SiteID,UserGroupNumber,RegTime,iPoint,gPoint,cPoint,aPoint from " + Pre + "sys_User where UserName=@UserName";
bool bexist = false;
IDataReader rd = DbHelper.ExecuteReader(cn, CommandType.Text, Sql, Param);
if (rd.Read())
{
PWD = rd.GetString(0);
UserNum = rd.GetString(1);
IsLock = rd.GetByte(2);
if (!rd.IsDBNull(3))
SiteID = rd.GetString(3);
sUserGroup = rd.GetString(4);
dtUserRegDate = rd.GetDateTime(5);
ipnt = rd.GetInt32(6);
gpnt = rd.GetInt32(7);
cpnt = rd.GetInt32(8);
apnt = rd.GetInt32(9);
bexist = true;
}
rd.Close();
if (!bexist)
return EnumLoginState.Err_UserNameOrPwdError;
#endregion
#region 对登录错误的检查和处理
//连续登录错误锁定
string sCPParam = string.Empty;
string sAPParam = string.Empty;
string LoginLock = string.Empty;
rd = GetParamUser(cn);
if (rd.Read())
{
if (rd["LoginLock"] != DBNull.Value)
LoginLock = rd["LoginLock"].ToString();
if (rd["cPointParam"] != DBNull.Value)
sCPParam = rd["cPointParam"].ToString();
if (rd["aPointparam"] != DBNull.Value)
sAPParam = rd["aPointparam"].ToString();
}
rd.Close();
//int nErrorNum = 0;
string pattern = @"^(?<n>\d+)\|(?<t>\d+)";
Regex reg = new Regex(pattern, RegexOptions.Compiled);
Match m = reg.Match(LoginLock);
if (m.Success)
{
int number = int.Parse(m.Groups["n"].Value);
int time = int.Parse(m.Groups["t"].Value);
rd = GetErrorLogInfo(cn, UserNum, LogIP);
if (rd.Read())
{
int num = rd.GetInt32(0);
DateTime dtLast = rd.GetDateTime(1);
if (num >= number && dtLast.AddMinutes(time) > Now)
{
rd.Close();
return EnumLoginState.Err_DurativeLogError;
}
}
rd.Close();
}
#endregion
if (PWD != NetCMS.Common.Input.MD5(PassWord))
{
//记录错误
UpdateErrorNum(cn, UserNum, LogIP);
return EnumLoginState.Err_UserNameOrPwdError;
}
else
{
ClearErrorNum(cn, UserNum, LogIP);
}
if (IsLock != 0X00)
{
return EnumLoginState.Err_Locked;
}
EnumLoginState state = CheckUserLogin(cn, UserNum, true);
if (state == EnumLoginState.Succeed)
{
info.SiteID = SiteID;
info.UserName = UserName;
info.UserNum = UserNum;
}
else
{
return state;
}
#region 会员组超时
int nGroupExp = 0;
bool bgrp = false;
string LogPoint = string.Empty;
rd = GetUserGroupInfo(cn, sUserGroup);
if (rd.Read())
{
if (rd["Rtime"] != DBNull.Value)
nGroupExp = Convert.ToInt32(rd["Rtime"]);
if (rd["LoginPoint"] != DBNull.Value)
LogPoint = rd["LoginPoint"].ToString();
bgrp = true;
}
rd.Close();
if (!bgrp)
return state;
if (nGroupExp != 0 && dtUserRegDate.AddDays(nGroupExp) <= Now)
{
LockUser(cn, UserNum);
return EnumLoginState.Err_GroupExpire;
}
#endregion
#region 积分计算
m = reg.Match(LogPoint);
if (m.Success)
{
int ci = int.Parse(m.Groups["n"].Value);
int cg = int.Parse(m.Groups["t"].Value);
ipnt += ci;
gpnt += cg;
}
string p = @"^(?<n>\d+)\|";
Regex r = new Regex(p, RegexOptions.Compiled);
Match match = r.Match(sCPParam);
if (match.Success)
{
int cc = int.Parse(m.Groups["n"].Value);
cpnt += cc;
}
match = r.Match(sAPParam);
if (match.Success)
{
int ca = int.Parse(m.Groups["n"].Value);
apnt += ca;
}
UserLoginSucceedInfo ul;
ul.UserNum = UserNum;
ul.IP = LogIP;
ul.IPoint = ipnt;
ul.GPoint = gpnt;
ul.APoint = apnt;
ul.CPoint = cpnt;
UpdateUserLogin(cn, ul);
return EnumLoginState.Succeed;
#endregion
}
catch
{
return EnumLoginState.Err_DbException;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
EnumLoginState IUserLogin.AdminLogin(string UserName, string PassWord, out GlobalUserInfo info)
{
info = new GlobalUserInfo(string.Empty, string.Empty, string.Empty);
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
try
{
cn.Open();
string UserNum = string.Empty;
string SiteID = string.Empty;
#region 基本信息表
SqlParameter Param = new SqlParameter("@UserName", UserName);
string Sql = "select UserPassword,UserNum,isAdmin,islock,SiteID from " + Pre + "sys_User where UserName=@UserName";
EnumLoginState state = EnumLoginState.Succeed;
IDataReader rd = DbHelper.ExecuteReader(cn, CommandType.Text, Sql, Param);
if (rd.Read())
{
string pwd = rd.GetString(0);
UserNum = rd.GetString(1);
byte isAdmin = rd.GetByte(2);
byte isLock = rd.GetByte(3);
if (!rd.IsDBNull(4))
SiteID = rd.GetString(4);
if (pwd != NetCMS.Common.Input.MD5(PassWord))
state = EnumLoginState.Err_AdminNameOrPwdError;
else if (isAdmin != 0X01)
state = EnumLoginState.Err_NotAdmin;
else if (isLock != 0X00)
state = EnumLoginState.Err_Locked;
}
else
{
state = EnumLoginState.Err_AdminNameOrPwdError;
}
rd.Close();
if (state != EnumLoginState.Succeed)
return state;
#endregion
//检查管理员表
AdminDataInfo adinfo;
state = CheckAdminLogin(cn, UserNum, out adinfo);
if (state == EnumLoginState.Succeed)
{
info.SiteID = SiteID;
info.UserName = UserName;
info.UserNum = UserNum;
}
try
{
Sql = "update " + Pre + "SYS_USER set LastLoginTime='" + DateTime.Now + "',LastIP='" + Public.getUserIP() + "',LoginNumber=LoginNumber+1 where UserNum='" + UserNum + "'";
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, Param);
rootPublic rtp = new rootPublic();
rtp.SaveUserAdminLogs(cn, 1, 1, UserName, "登陆成功", "用户名:" + UserName);
}
catch
{ }
return state;
}
catch
{
return EnumLoginState.Err_DbException;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
/// <summary>
/// 查找错误的登录记录
/// </summary>
/// <param name="cn"></param>
/// <param name="UserNum"></param>
/// <param name="IP"></param>
/// <returns></returns>
protected IDataReader GetErrorLogInfo(SqlConnection cn, string UserNum, string IP)
{
string Sql = "select ErrorNum,LastErrorTime from " + Pre + "user_Guser where UserNum=@UserNum and IP=@IP order by LastErrorTime desc";
SqlParameter[] Param = new SqlParameter[] { new SqlParameter("@UserNum", UserNum), new SqlParameter("@IP", IP) };
return DbHelper.ExecuteReader(cn, CommandType.Text, Sql, Param);
}
/// <summary>
/// 更新或添加错误登录记录
/// </summary>
/// <param name="cn"></param>
/// <param name="UserNum"></param>
/// <param name="IP"></param>
protected void UpdateErrorNum(SqlConnection cn, string UserNum, string IP)
{
string Sql = "select top 1 id from " + Pre + "user_Guser where UserNum=@UserNum and IP=@IP order by LastErrorTime desc";
SqlParameter[] Param = new SqlParameter[] { new SqlParameter("@UserNum", UserNum), new SqlParameter("@IP", IP) };
object obj = DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, Param);
if (obj != null && obj != DBNull.Value)
{
Sql = "update " + Pre + "user_Guser set ErrorNum=ErrorNum+1,LastErrorTime='" + DateTime.Now + "' where id=" + obj;
DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null);
}
else
{
Sql = "insert into " + Pre + "user_Guser (UserNum,CreatTime,ErrorNum,IP,LastErrorTime) values (@UserNum,'" + DateTime.Now + "'";
Sql += ",1,@IP,'" + DateTime.Now + "')";
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, Param);
}
}
/// <summary>
/// 清除错误登录记录
/// </summary>
/// <param name="cn"></param>
/// <param name="UserNum"></param>
/// <param name="IP"></param>
protected void ClearErrorNum(SqlConnection cn, string UserNum, string IP)
{
string Sql = "delete from " + Pre + "user_Guser where UserNum=@UserNum and IP=@IP";
SqlParameter[] Param = new SqlParameter[] { new SqlParameter("@UserNum", UserNum), new SqlParameter("@IP", IP) };
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, Param);
}
protected void LockUser(SqlConnection cn, string UserNum)
{
string Sql = "update " + Pre + "SYS_USER set isLock=1 where UserNum=@UserNum";
SqlParameter Param = new SqlParameter("@UserNum", UserNum);
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, Param);
}
protected void UpdateUserLogin(SqlConnection cn, UserLoginSucceedInfo info)
{
try
{
string Sql = "select top 1 GroupNumber from " + Pre + "user_Group where Gpoint>=" + info.GPoint + " and iPoint>=" + info.IPoint;
Sql += " order by Gpoint Desc,iPoint Desc";
string newGroup = Convert.ToString(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null));
Sql = "update " + Pre + "SYS_USER set LastLoginTime='" + DateTime.Now + "',LastIP=@LastIP,iPoint=" + info.IPoint;
Sql += ",gPoint=" + info.GPoint + ",cPoint=" + info.CPoint + ",aPoint=" + info.APoint + ",LoginNumber=LoginNumber+1";
if (newGroup != string.Empty)
Sql += ",UserGroupNumber=@UserGroupNumber";
Sql += " where UserNum=@UserNum";
SqlParameter[] Param = new SqlParameter[3];
Param[0] = new SqlParameter("@LastIP", SqlDbType.NVarChar, 15);
Param[0].Value = info.IP;
Param[1] = new SqlParameter("@UserGroupNumber", SqlDbType.NVarChar, 20);
Param[1].Value = newGroup;
Param[2] = new SqlParameter("@UserNum", SqlDbType.NVarChar, 20);
Param[2].Value = info.UserNum;
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, Param);
}
catch
{
}
}
int IUserLogin.GetLoginSpan()
{
string Sql = "select top 1 LoginLock from " + Pre + "sys_PramUser";
string s = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, null));
string pattern = @"^\d+\|(?<n>\d+)$";
Regex reg = new Regex(pattern, RegexOptions.Compiled);
Match m = reg.Match(s);
if (m.Success)
{
return Convert.ToInt32(m.Groups["n"].Value);
}
return 0;
}
}
} | 0575kaoshicj | trunk/NetCMS.DALSQLServer/UserLogin.cs | C# | asf20 | 27,673 |
//======================================================
//== (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.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class Model : DbBase, IModel
{
#region 公共部分
public IDataReader GetTopicInfo(int ID, int ChID)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[0].Value = ID;
param[1] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[1].Value = ChID;
string DTable = getChannelTable(ChID);
string sql = "select * from " + DTable + " where ID=@ID";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public string getUrl(string Type, int ID, int ChID)
{
SqlParameter param = new SqlParameter("@ID", ID);
string urls = string.Empty;
string sql = string.Empty;
switch (Type)
{
case "content":
sql = "select a.SavePath,a.FileName,a.isDelPoint,b.savePath as savePath1 from " + getChannelTable(ChID) + " a," + Pre + "sys_channelclass b Where a.ID=@ID and a.ClassID=b.id";
break;
case "class":
sql = "select SavePath,FileName,isDelPoint from " + Pre + "sys_channelclass Where ID=@ID and ChID=" + ChID + "";
break;
case "special":
sql = "select SavePath,FileName from " + Pre + "sys_channelspecial Where ID=@ID and ChID=" + ChID + "";
break;
}
IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, param);
if (dr.Read())
{
switch (Type)
{
case "content":
if (dr["isDelPoint"].ToString() != "0")
{
urls = "/content.aspx?id=" + ID + "&ChID=" + ChID + "";
}
else
{
urls = "/" + dr["savePath1"].ToString() + "/" + dr["SavePath"].ToString() + "/" + dr["FileName"].ToString();
}
break;
case "class":
if (dr["isDelPoint"].ToString() != "0")
{
urls = "/list.aspx?id=" + ID + "&ChID=" + ChID + "";
}
else
{
urls = "/" + dr["SavePath"].ToString() + "/" + dr["FileName"].ToString();
}
break;
case "special":
urls = "/" + dr["SavePath"].ToString() + "/" + dr["FileName"].ToString();
break;
}
urls = urls.Replace("//", "/");
}
dr.Close();
return urls;
}
/// <summary>
/// 获取频道英文名称
/// </summary>
public string GetChannEName(int ChID)
{
SqlParameter param = new SqlParameter("@ChID", ChID);
string sql = "select channelEItem from " + Pre + "sys_channel where ID=@ChID";
return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
public int GetTopChID(string EName)
{
SqlParameter param = new SqlParameter("@EName", EName);
string sql = "select top 1 id from " + Pre + "sys_channel where channelEItem=@EName";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
#endregion
#region 基础,创建频道部分
public IDataReader getModelTemplet(int ParentID)
{
SqlParameter param = new SqlParameter("@ParentID", ParentID);
string Sql = "select a.id,a.channelName,a.ParentID,(select count(id) from " + Pre + "sys_channel b where b.islock=0 and b.ParentID=a.id) as hashCount from " + Pre + "sys_channel a where a.islock=0 and a.ParentID=@ParentID order by a.id asc";
return DbHelper.ExecuteReader(CommandType.Text, Sql, param);
}
public IDataReader getModelTempletisConstr(int ParentID)
{
SqlParameter param = new SqlParameter("@ParentID", ParentID);
string Sql = "select a.*,(select count(id) from " + Pre + "sys_channel b where b.islock=0 and b.isConstr=1 and b.ParentID=a.ID) as HashCount from " + Pre + "sys_channel a where a.islock=0 and a.isConstr=1 and a.ParentID=@ParentID order by a.id asc";
return DbHelper.ExecuteReader(CommandType.Text, Sql, param);
}
public IDataReader getModelinfo(int ID)
{
SqlParameter param = new SqlParameter("@ID", ID);
string Sql = "select * from " + Pre + "sys_channel where ID=@ID order by id desc";
IDataReader dt = DbHelper.ExecuteReader(CommandType.Text, Sql, param);
return dt;
}
public IDataReader GetChannelClassList(int ParentID)
{
SqlParameter param = new SqlParameter("@ParentID", ParentID);
string sql = "select * from " + Pre + "sys_channel where ParentID=@ParentID order by ID DESC";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
/// <summary>
/// 创建表
/// </summary>
/// <param name="DataTable"></param>
/// <param name="channelType"></param>
public void creatModeltable(string DataTable, int channelType, int isConstr)
{
//根据模型标志读取默认配置
string getModelContentField = NetCMS.Common.Public.getModelContentField(channelType.ToString());
//string[] getDefaultValue = null;
//string[] getDefaultItemValue = null;
//string CreatField = "";
//if (getModelContentField.IndexOf(",") > -1)
//{
// getDefaultValue = getModelContentField.Split(',');
// for (int i = 0; i < getDefaultValue.Length; i++)
// {
// getDefaultItemValue = getDefaultValue[i].Split('|');
// CreatField += "[" + getDefaultItemValue[0] + "] [" + getDefaultItemValue[1] + "]";
// if (getDefaultItemValue[1].Trim().ToLower() == "nvarchar" || getDefaultItemValue[1].Trim().ToLower() == "varchar" || getDefaultItemValue[1].Trim().ToLower() == "char" || getDefaultItemValue[1].Trim().ToLower() == "nchar" || getDefaultItemValue[1].Trim().ToLower() == "varbinary")
// {
// CreatField += " (" + getDefaultItemValue[2] + ") " + getDefaultItemValue[3] + ",";
// }
// else
// {
// CreatField += " " + getDefaultItemValue[3] + ",";
// }
// }
//}
string Sql = "CREATE TABLE [" + DataTable + "](" +
"[Id] [int] IDENTITY (1, 1) NOT NULL ," +
"[ChID] [int] NOT NULL ," +//信息ID
"[title] [nvarchar](100) NOT NULL ," +//标题
"[ClassID] [int] NOT NULL ," +//栏目
"[SpecialID] [nvarchar] (200) NULL ," +//专题
"[TitleColor] [nvarchar] (10) NULL ," +//标题颜色
"[TitleITF] [tinyint] NULL ," +//标题是否为斜体
"[TitleBTF] [tinyint] NULL ," +//标题是否为粗体
"[PicURL] [nvarchar] (200) NULL ," +//图片地址
"[Content] [ntext] NULL ," +//内容描述
"[NaviContent] [nvarchar] (200) NULL ," +//内容导读
"[ContentProperty] [nvarchar] (9) NULL ," +//属性,推荐|热点|幻灯|滚动|头条
"[Author] [nvarchar] (100) NULL ," +//作者
"[Editor] [nvarchar] (50) NULL ," +//编辑
"[Souce] [nvarchar] (100) NULL ," +//来源
"[OrderID] [tinyint] NOT NULL ," +//权重
"[Tags] [nvarchar] (100) NULL ," +//关键字
"[Templet] [nvarchar] (200) NULL ," +//模板
"[SavePath] [nvarchar] (200) NULL ," +
"[FileName] [nvarchar] (100) NULL ," +//包含扩展名
"[isDelPoint] [tinyint] NOT NULL ," +//是否具有浏览权限
"[Gpoint] [int] NULL ," +//G币
"[iPoint] [int] NULL ," +//积分
"[GroupNumber] [ntext] NULL ," +//会员组
"[Metakeywords] [nvarchar] (200) NULL ," +//meta关键字
"[Metadesc] [nvarchar] (200) NULL ," +//meta描述
"[Click] [int] NULL ," +//点击
"[CreatTime] [datetime] NULL ," +//创建日期
"[isHTML] [tinyint] NOT NULL ," +//是否生成了静态
"[isConstr] [tinyint] NOT NULL ," + //专区
"[ConstrTF] [tinyint] NOT NULL ,"; //投稿审核
Sql += "[islock] [tinyint] NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]";
Sql += "ALTER TABLE [" + DataTable + "] WITH NOCHECK ADD CONSTRAINT [PK_" + DataTable + "] PRIMARY KEY CLUSTERED([Id]) ON [PRIMARY] ";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
//根据模型类型插入字段
}
/// <summary>
/// 插入记录
/// </summary>
/// <param name="uc"></param>
public void updateDate(NetCMS.Model.ChannelInfo uc)
{
string Sql = "insert into " + Pre + "sys_channel (";
Sql += "channelType,channelName,ParentID,channelItem,channelDescript,DataLib,islock,channelunit,htmldir,indexFileName,upfilessize,upfiletype,ischeck,indextemplet,classtemplet,specialtemplet,newstemplet,isHTML,SiteID,issys,isConstr,channelEItem,ClassSave,ClassFileName,SavePath,FileName,binddomain,TempletPath,isDelPoint,Gpoint,iPoint,GroupNumber";
Sql += ") values (";
Sql += "@channelType,@channelName,@ParentID,@channelItem,@channelDescript,@DataLib,0,@channelunit,@htmldir,@indexFileName,@upfilessize,@upfiletype,@ischeck,@indextemplet,@classtemplet,@specialtemplet,@newstemplet,@isHTML,'0',0,@isConstr,@channelEItem,@ClassSave,@ClassFileName,@SavePath,@FileName,@binddomain,@TempletPath,@isDelPoint,@Gpoint,@iPoint,@GroupNumber)";
SqlParameter[] parm = InsertParameters(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
/// <summary>
/// 更新记录记录
/// </summary>
/// <param name="uc"></param>
public void updateDate1(NetCMS.Model.ChannelInfo uc)
{
string Sql = "Update " + Pre + "sys_channel set channelName=@channelName,ParentID=@ParentID,channelItem=@channelItem,channelDescript=@channelDescript,channelunit=@channelunit,htmldir=@htmldir,indexFileName=@indexFileName,upfilessize=@upfilessize,upfiletype=@upfiletype,ischeck=@ischeck,indextemplet=@indextemplet,classtemplet=@classtemplet,specialtemplet=@specialtemplet,newstemplet=@newstemplet,isHTML=@isHTML,isConstr=@isConstr,ClassSave=@ClassSave,ClassFileName=@ClassFileName,SavePath=@SavePath,FileName=@FileName,issys=@issys,binddomain=@binddomain,TempletPath=@TempletPath,isDelPoint=@isDelPoint,Gpoint=@Gpoint,iPoint=@iPoint,GroupNumber=@GroupNumber where ID=" + uc.Id + "";
SqlParameter[] parm = InsertParameters(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, parm);
}
private SqlParameter[] InsertParameters(NetCMS.Model.ChannelInfo uc1)
{
SqlParameter[] param = new SqlParameter[32];
param[0] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[0].Value = uc1.Id;
param[1] = new SqlParameter("@isConstr", SqlDbType.TinyInt, 1);
param[1].Value = uc1.isConstr;
param[2] = new SqlParameter("@channelType", SqlDbType.TinyInt, 1);
param[2].Value = uc1.channelType;
param[3] = new SqlParameter("@channelName", SqlDbType.NVarChar, 50);
param[3].Value = uc1.channelName;
param[4] = new SqlParameter("@channelItem", SqlDbType.NVarChar, 50);
param[4].Value = uc1.channelItem;
param[5] = new SqlParameter("@channelDescript", SqlDbType.NVarChar, 200);
param[5].Value = uc1.channelDescript;
param[6] = new SqlParameter("@DataLib", SqlDbType.NVarChar, 30);
param[6].Value = uc1.DataLib;
param[7] = new SqlParameter("@islock", SqlDbType.TinyInt, 1);
param[7].Value = uc1.islock;
param[8] = new SqlParameter("@channelunit", SqlDbType.NVarChar, 50);
param[8].Value = uc1.channelunit;
param[9] = new SqlParameter("@htmldir", SqlDbType.NVarChar, 100);
param[9].Value = uc1.htmldir;
param[10] = new SqlParameter("@upfilessize", SqlDbType.Int, 4);
param[10].Value = uc1.upfilessize;
param[11] = new SqlParameter("@upfiletype", SqlDbType.NVarChar, 100);
param[11].Value = uc1.upfiletype;
param[12] = new SqlParameter("@ischeck", SqlDbType.TinyInt, 1);
param[12].Value = uc1.ischeck;
param[13] = new SqlParameter("@indextemplet", SqlDbType.NVarChar, 200);
param[13].Value = uc1.indextemplet;
param[14] = new SqlParameter("@classtemplet", SqlDbType.NVarChar, 200);
param[14].Value = uc1.classtemplet;
param[15] = new SqlParameter("@specialtemplet", SqlDbType.NVarChar, 200);
param[15].Value = uc1.specialtemplet;
param[16] = new SqlParameter("@newstemplet", SqlDbType.NVarChar, 200);
param[16].Value = uc1.newstemplet;
param[17] = new SqlParameter("@isHTML", SqlDbType.TinyInt, 1);
param[17].Value = uc1.isHTML;
param[18] = new SqlParameter("@channelEItem", SqlDbType.NVarChar, 20);
param[18].Value = uc1.channelEItem;
param[19] = new SqlParameter("@ClassSave", SqlDbType.NVarChar, 50);
param[19].Value = uc1.ClassSave;
param[20] = new SqlParameter("@ClassFileName", SqlDbType.NVarChar, 50);
param[20].Value = uc1.ClassFileName;
param[21] = new SqlParameter("@SavePath", SqlDbType.NVarChar, 50);
param[21].Value = uc1.SavePath;
param[22] = new SqlParameter("@FileName", SqlDbType.NVarChar, 50);
param[22].Value = uc1.FileName;
param[23] = new SqlParameter("@issys", SqlDbType.TinyInt, 1);
param[23].Value = uc1.issys;
param[24] = new SqlParameter("@binddomain", SqlDbType.NVarChar, 150);
param[24].Value = uc1.binddomain;
param[25] = new SqlParameter("@TempletPath", SqlDbType.NVarChar, 100);
param[25].Value = uc1.TempletPath;
param[26] = new SqlParameter("@indexFileName", SqlDbType.NVarChar, 50);
param[26].Value = uc1.indexFileName;
param[27] = new SqlParameter("@isDelPoint", SqlDbType.TinyInt);
param[27].Value = uc1.isDelPoint;
param[28] = new SqlParameter("@Gpoint", SqlDbType.Int, 4);
param[28].Value = uc1.Gpoint;
param[29] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
param[29].Value = uc1.iPoint;
param[30] = new SqlParameter("@GroupNumber", SqlDbType.NVarChar, 200);
param[30].Value = uc1.GroupNumber;
param[31] = new SqlParameter("@ParentID", SqlDbType.Int, 4);
param[31].Value = uc1.ParentID;
return param;
}
public int getItemCount(string eName, int ChID)
{
SqlParameter param = new SqlParameter("@eName", eName);
string wStr = string.Empty;
if (ChID != 0)
{
wStr = " and ID<>" + ChID + "";
}
string sql = "select count(id) from " + Pre + "sys_channel where channelEItem=@eName " + wStr + "";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
public int getDbCount(string Table, int ChID)
{
SqlParameter param = new SqlParameter("@Table", Table);
string wStr = string.Empty;
if (ChID != 0)
{
wStr = " and ID<>" + ChID + "";
}
string sql = "select count(id) from " + Pre + "sys_channel where DataLib=@Table " + wStr + "";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
public int getSysCord(int ID)
{
SqlParameter param = new SqlParameter("@ID", ID);
string sql = "select issys from " + Pre + "sys_channel where ID=@ID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
public void delModel(int ID)
{
SqlParameter param = new SqlParameter("@ID", ID);
string gSQL = "select Datalib from " + Pre + "sys_channel where ID=@ID";
string DbTable = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, gSQL, param));
string sql = "delete from " + Pre + "sys_channel where ID=@ID";
DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
try
{
string delDB = "drop table [" + DbTable + "]";
DbHelper.ExecuteNonQuery(CommandType.Text, delDB, null);
}
catch
{ }
}
public void ModelStat(int ID, int isLock)
{
SqlParameter param = new SqlParameter("@ID", ID);
string sql = "update " + Pre + "sys_channel set islock=" + isLock + " where ID=@ID";
DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public IDataReader getChInfoMenu(int ChID)
{
SqlParameter param = new SqlParameter("@ID", ChID);
string sql = "select a.id,a.channelName,a.channelItem,a.TempletPath,a.isConstr,(select count(id) from " + Pre + "sys_channel b where b.parentID=a.id) as hashCount from " + Pre + "sys_channel a where a.ID=@ID";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public IDataReader getChValue(int ID)
{
SqlParameter param = new SqlParameter("@ID", ID);
string sql = "select * from " + Pre + "sys_channelvalue where ID=@ID";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public int getChannelParentCount(int ID)
{
SqlParameter param = new SqlParameter("@ID", ID);
string sql = "select count(id) from "+Pre+"sys_channel where ParentID=@ID";
return Convert.ToInt16(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
public string getChannelTable(int ChID)
{
string TableStr = "#";
string TmpTable = string.Empty;
int GetTableRecord = 0;
SqlParameter param = new SqlParameter("@ChID", ChID);
string sql = "select DataLib from " + Pre + "sys_channel where ID=@ChID";
IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, param);
if (dr.Read())
{
TmpTable = dr["DataLib"].ToString();
string TableSQL = "select count(*) from sysobjects where id = object_id(N'[" + TmpTable + "]') and OBJECTPROPERTY(id, N'IsUserTable') = 1";
GetTableRecord = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, TableSQL, null));
if (GetTableRecord > 0)
{
TableStr = TmpTable;
}
}
dr.Close();
return TableStr;
}
public bool getChannelValueTF(int ChID, string EName, int vID)
{
SqlParameter param = new SqlParameter("@ChID", @ChID);
string sql = "select Count(id) from " + Pre + "sys_channelvalue where ChID=@ChID and EName='" + EName + "' and ID<>" + vID + "";
int count = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
if (count > 0)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 插入字段入数据库进行保存
/// </summary>
/// <param name="uc"></param>
public void insertFields(NetCMS.Model.ChannelValue uc, string TableSTR)
{
string Sql = "insert into " + Pre + "sys_channelvalue (";
Sql += "ChID,OrderID,CName,EName,vDescript,vType,vLength,vValue,isNulls,isUser,vitem,isLock,SiteID,fieldLength,HTMLedit,isSearch,vHeight";
Sql += ") values (";
Sql += "@ChID,@OrderID,@CName,@EName,@vDescript,@vType,@vLength,@vValue,@isNulls,@isUser,@vitem,@isLock,@SiteID,@fieldLength,@HTMLedit,@isSearch,@vHeight)";
SqlParameter[] param = ValueParameters(uc);
//创建数据库字段
string CreateSql = "ALTER TABLE [" + TableSTR + "] ADD [" + uc.EName + "] " + CreatevType(uc.vType) + "";
DbHelper.ExecuteNonQuery(CommandType.Text, CreateSql, param);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
/// <summary>
/// 更新字段
/// </summary>
/// <param name="uc"></param>
/// <param name="TableSTR"></param>
public void UpdateFields(NetCMS.Model.ChannelValue uc, string TableSTR)
{
string Sql = "update " + Pre + "sys_channelvalue set ";
Sql += "OrderID=@OrderID,CName=@CName,vDescript=@vDescript,vLength=@vLength,vValue=@vValue,isNulls=@isNulls,isUser=@isUser,vitem=@vitem,isLock=@isLock,isSearch=@isSearch,vHeight=@vHeight,HTMLedit=@HTMLedit where ID=@Id and SiteID=@SiteID";
SqlParameter[] param = ValueParameters(uc);
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
/// <summary>
/// 得到字段类型
/// </summary>
/// <param name="vType"></param>
/// <returns></returns>
protected string CreatevType(int vType)
{
string LenStr = string.Empty;
string NullStr = "NULL";
switch (vType)
{
case 0:
LenStr = "[nvarchar] (20) " + NullStr + "";
break;
case 1:
LenStr = "[nvarchar] (50) " + NullStr + "";
break;
case 2:
LenStr = "[nvarchar] (100) " + NullStr + "";
break;
case 3:
LenStr = "[nvarchar] (180) " + NullStr + "";
break;
case 4:
LenStr = "[nvarchar] (225) " + NullStr + "";
break;
case 5:
LenStr = "[ntext] " + NullStr + "";
break;
case 6:
LenStr = "[nvarchar] (200) " + NullStr + "";
break;
case 7:
LenStr = "[int] " + NullStr + "";
break;
case 8:
LenStr = "[tinyint] " + NullStr + "";
break;
case 9:
LenStr = "[money] " + NullStr + "";
break;
case 10:
LenStr = "[datetime] " + NullStr + "";
break;
case 11:
LenStr = "[smalldatetime] " + NullStr + "";
break;
case 12:
LenStr = "[nvarchar] (200) " + NullStr + "";
break;
case 13:
LenStr = "[ntext] " + NullStr + "";
break;
case 14:
LenStr = "[nvarchar] (200) " + NullStr + "";
break;
case 15:
LenStr = "[ntext] " + NullStr + "";
break;
case 16:
LenStr = "[ntext] " + NullStr + "";
break;
case 17:
LenStr = "[ntext] " + NullStr + "";
break;
default:
LenStr = "[nvarchar] (200) " + NullStr + "";
break;
}
return LenStr;
}
/// <summary>
/// 得到所有参数
/// </summary>
/// <param name="uc1"></param>
/// <returns></returns>
private SqlParameter[] ValueParameters(NetCMS.Model.ChannelValue uc1)
{
SqlParameter[] param = new SqlParameter[18];
param[0] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[0].Value = uc1.Id;
param[1] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[1].Value = uc1.ChID;
param[2] = new SqlParameter("@OrderID", SqlDbType.TinyInt, 1);
param[2].Value = uc1.OrderID;
param[3] = new SqlParameter("@CName", SqlDbType.NVarChar, 50);
param[3].Value = uc1.CName;
param[4] = new SqlParameter("@EName", SqlDbType.NVarChar, 50);
param[4].Value = uc1.EName;
param[5] = new SqlParameter("@vDescript", SqlDbType.NVarChar, 200);
param[5].Value = uc1.vDescript;
param[6] = new SqlParameter("@vType", SqlDbType.TinyInt, 1);
param[6].Value = uc1.vType;
param[7] = new SqlParameter("@vLength", SqlDbType.NVarChar, 10);
param[7].Value = uc1.vLength;
param[8] = new SqlParameter("@vValue", SqlDbType.NVarChar, 150);
param[8].Value = uc1.vValue;
param[9] = new SqlParameter("@isNulls", SqlDbType.TinyInt, 1);
param[9].Value = uc1.isNulls;
param[10] = new SqlParameter("@isUser", SqlDbType.TinyInt, 1);
param[10].Value = uc1.isUser;
param[11] = new SqlParameter("@vitem", SqlDbType.NText);
param[11].Value = uc1.vitem;
param[12] = new SqlParameter("@isLock", SqlDbType.TinyInt, 1);
param[12].Value = uc1.isLock;
param[13] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[13].Value = uc1.SiteID;
param[14] = new SqlParameter("@fieldLength", SqlDbType.NVarChar, 5);
param[14].Value = uc1.fieldLength;
param[15] = new SqlParameter("@isSearch", SqlDbType.TinyInt, 1);
param[15].Value = uc1.isSearch;
param[16] = new SqlParameter("@HTMLedit", SqlDbType.TinyInt, 1);
param[16].Value = uc1.HTMLedit;
param[17] = new SqlParameter("@vHeight", SqlDbType.NVarChar, 6);
param[17].Value = uc1.vHeight;
return param;
}
/// <summary>
/// 删除字段
/// </summary>
/// <param name="ID"></param>
/// <param name="TableStr"></param>
public void delFileds(int ID, string TableStr)
{
SqlParameter param = new SqlParameter("@ID", ID);
string gSQL = "select EName from " + Pre + "sys_channelvalue where ID=@ID";
IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, gSQL, param);
if (dr.Read())
{
string DeleteSql = "ALTER TABLE [" + TableStr + "] Drop column [" + dr["EName"].ToString() + "]";
DbHelper.ExecuteNonQuery(CommandType.Text, DeleteSql, param);
string delSQL = "delete from " + Pre + "sys_channelvalue where ID=@ID";
DbHelper.ExecuteNonQuery(CommandType.Text, delSQL, param);
}
dr.Close();
}
/// <summary>
/// 更新字段数据锁定状态
/// </summary>
/// <param name="ID"></param>
/// <param name="Num"></param>
public void updateValueFileds(int ID, int Num)
{
SqlParameter param = new SqlParameter("@ID", ID);
string sql = "update " + Pre + "sys_channelvalue set isLock=" + Num + " where ID=@ID";
DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
#endregion
#region 栏目部分
public void updateOrder(int ID, int OrderID, int Num)
{
SqlParameter param = new SqlParameter("@ID", ID);
string sql = string.Empty;
if (Num == 0)
{
sql = "update " + Pre + "sys_channelclass set OrderID=" + OrderID + " where ID=@ID";
}
else
{
sql = "update " + Pre + "sys_channelspecial set OrderID=" + OrderID + " where ID=@ID";
}
DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public string getClassName(int ClassID)
{
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string sql = "select classCName from " + Pre + "sys_channelclass where ID=@ClassID";
string CName = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
if (CName == string.Empty)
{
CName = "根栏目";
}
return CName;
}
/// <summary>
/// 继承频道信息
/// </summary>
/// <param name="ChID">频道ID</param>
/// <returns>记录集</returns>
public IDataReader ChannelInfo(int ChID)
{
SqlParameter param = new SqlParameter("@ChID", ChID);
string sql = "select * from " + Pre + "sys_channel where ID=@ChID";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public int getClassInfoCord(string EName, int ID)
{
SqlParameter param = new SqlParameter("@ID", ID);
string sql = "select count(id) from " + Pre + "sys_channelclass where ID<>@ID and classEName='" + EName + "'";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
/// <summary>
/// 插入栏目数据
/// </summary>
/// <param name="uc"></param>
public void insertClassInfo(NetCMS.Model.ChannelClassInfo uc)
{
SqlParameter[] param = ClassInfoParameter(uc);
string Sql = "insert into " + Pre + "sys_channelclass (";
Sql += "ChID,OrderID,ParentID,classCName,classEName,isPage,PageContent,Templet,ContentTemplet,SavePath,FileName,ContentSavePath,ContentFileNameRule,isShowNavi,NaviContent,KeyMeta,DescMeta,PicURL,isDelPoint,Gpoint,iPoint,GroupNumber,isLock,ClassNavi,ContentNavi,SiteID";
Sql += ") values (";
Sql += "@ChID,@OrderID,@ParentID,@classCName,@classEName,@isPage,@PageContent,@Templet,@ContentTemplet,@SavePath,@FileName,@ContentSavePath,@ContentFileNameRule,@isShowNavi,@NaviContent,@KeyMeta,@DescMeta,@PicURL,@isDelPoint,@Gpoint,@iPoint,@GroupNumber,@isLock,@ClassNavi,@ContentNavi,@SiteID)";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public void updateClassInfo(NetCMS.Model.ChannelClassInfo uc)
{
SqlParameter[] param = ClassInfoParameter(uc);
string Sql = "update " + Pre + "sys_channelclass set ";
Sql += "OrderID=@OrderID,classCName=@classCName,classEName=@classEName,FileName=@FileName,isPage=@isPage,PageContent=@PageContent,Templet=@Templet,ContentTemplet=@ContentTemplet,SavePath=@SavePath,ContentSavePath=@ContentSavePath,ContentFileNameRule=@ContentFileNameRule,isShowNavi=@isShowNavi,NaviContent=@NaviContent,KeyMeta=@KeyMeta,DescMeta=@DescMeta,PicURL=@PicURL,isDelPoint=@isDelPoint,Gpoint=@Gpoint,iPoint=@iPoint,GroupNumber=@GroupNumber,isLock=@isLock,ClassNavi=@ClassNavi,ContentNavi=@ContentNavi,SiteID=@SiteID where id=" + uc.Id + "";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
private SqlParameter[] ClassInfoParameter(NetCMS.Model.ChannelClassInfo uc1)
{
SqlParameter[] param = new SqlParameter[27];
param[0] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[0].Value = uc1.Id;
param[1] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[1].Value = uc1.ChID;
param[2] = new SqlParameter("@OrderID", SqlDbType.TinyInt, 1);
param[2].Value = uc1.OrderID;
param[3] = new SqlParameter("@ParentID", SqlDbType.Int, 4);
param[3].Value = uc1.ParentID;
param[4] = new SqlParameter("@classCName", SqlDbType.NVarChar, 50);
param[4].Value = uc1.classCName;
param[5] = new SqlParameter("@classEName", SqlDbType.NVarChar, 50);
param[5].Value = uc1.classEName;
param[6] = new SqlParameter("@isPage", SqlDbType.TinyInt, 1);
param[6].Value = uc1.isPage;
param[7] = new SqlParameter("@PageContent", SqlDbType.NText);
param[7].Value = uc1.PageContent;
param[8] = new SqlParameter("@Templet", SqlDbType.NVarChar, 200);
param[8].Value = uc1.Templet;
param[9] = new SqlParameter("@ContentTemplet", SqlDbType.NVarChar, 200);
param[9].Value = uc1.ContentTemplet;
param[10] = new SqlParameter("@SavePath", SqlDbType.NVarChar, 100);
param[10].Value = uc1.SavePath;
param[11] = new SqlParameter("@FileName", SqlDbType.NVarChar, 100);
param[11].Value = uc1.FileName;
param[12] = new SqlParameter("@ContentSavePath", SqlDbType.NVarChar, 100);
param[12].Value = uc1.ContentSavePath;
param[13] = new SqlParameter("@ContentFileNameRule", SqlDbType.NVarChar, 150);
param[13].Value = uc1.ContentFileNameRule;
param[14] = new SqlParameter("@isShowNavi", SqlDbType.TinyInt, 1);
param[14].Value = uc1.isShowNavi;
param[15] = new SqlParameter("@NaviContent", SqlDbType.NVarChar, 200);
param[15].Value = uc1.NaviContent;
param[16] = new SqlParameter("@KeyMeta", SqlDbType.NVarChar, 100);
param[16].Value = uc1.KeyMeta;
param[17] = new SqlParameter("@DescMeta", SqlDbType.NVarChar, 150);
param[17].Value = uc1.DescMeta;
param[18] = new SqlParameter("@PicURL", SqlDbType.NVarChar, 200);
param[18].Value = uc1.PicURL;
param[19] = new SqlParameter("@isDelPoint", SqlDbType.TinyInt, 1);
param[19].Value = uc1.isDelPoint;
param[20] = new SqlParameter("@Gpoint", SqlDbType.Int, 4);
param[20].Value = uc1.Gpoint;
param[21] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
param[21].Value = uc1.iPoint;
param[22] = new SqlParameter("@GroupNumber", SqlDbType.NVarChar, 200);
param[22].Value = uc1.GroupNumber;
param[23] = new SqlParameter("@isLock", SqlDbType.TinyInt, 1);
param[23].Value = uc1.isLock;
param[24] = new SqlParameter("@ClassNavi", SqlDbType.NText);
param[24].Value = uc1.ClassNavi;
param[25] = new SqlParameter("@ContentNavi", SqlDbType.NText);
param[25].Value = uc1.ContentNavi;
param[26] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[26].Value = uc1.SiteID;
return param;
}
public IDataReader GetClassInfo(int ClassID)
{
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string sql = "select * from " + Pre + "sys_channelclass where ID=@ClassID";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public int GetTopClassID()
{
string sql = "select top 1 id from " + Pre + "sys_channelclass order by id desc";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, null));
}
public int getClassNumber(int ClassID)
{
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string sql = "select count(id) from " + Pre + "sys_channelclass where ParentID=@ClassID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
public IDataReader getClassList(int ClassID, int ChID)
{
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string sql = "select id,ClassCName from " + Pre + "sys_channelclass where ParentID=@ClassID and isPage=0 and islock=0 and ChID=" + ChID + " order by Orderid desc,id desc";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public int delClass(int ClassID)
{
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string sql = "delete from " + Pre + "sys_channelclass where ID=@ClassID";
delcClass(ClassID);
return DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public void delcClass(int ClassID)
{
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string sqlc = "select id from " + Pre + "sys_channelclass where ParentID=@ClassID order by id desc";
IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sqlc, param);
while (dr.Read())
{
int gID = int.Parse(dr["id"].ToString());
string sql = "delete from " + Pre + "sys_channelclass where ID=" + gID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, sql, null);
delcClass(gID);
}
dr.Close();
}
public int Reset_allClass(int ClassID, int ChID)
{
string dTable = getChannelTable(ChID);
if (dTable != string.Empty)
{
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string sql = "delete from " + dTable + " where ClassID=@ClassID";
return DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
else
{
return 0;
}
}
public int lockstat(int ClassID, int num)
{
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string sql = "update " + Pre + "sys_channelclass set islock=" + num + " where Id=@ClassID";
return DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public void utilClass(int sClassID, int tClassID, int ChID)
{
//Copy content
SqlParameter param = new SqlParameter("@ChID", ChID);
string sql = "select DataLib from " + Pre + "sys_channel where ID=@ChID";
string dbTable = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
if (dbTable != string.Empty)
{
string usql = "update " + dbTable + " set ClassID=" + tClassID + " where ClassID=" + sClassID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, usql, null);
}
//更新源栏目下级的父类
string ssql = "select ParentID from " + Pre + "sys_channelclass where ID=" + sClassID + "";
string ParentID = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, ssql, null));
if (ParentID != string.Empty)
{
string usql = "update " + Pre + "sys_channelclass set ParentID=" + int.Parse(ParentID) + " where ParentID=" + sClassID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, usql, null);
}
//删除源栏目
string delsql = "delete from " + Pre + "sys_channelclass where id=" + sClassID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, delsql, null);
}
public void moveClass(int sClassID, int tClassID)
{
string sql = "update " + Pre + "sys_channelclass set ParentID=" + tClassID + " where Id=" + sClassID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, sql, null);
}
#endregion
#region 内容部分
public DataTable GetChannelValueFormInfo(int ChID, string DTable, int ID)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = ChID;
param[1] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[1].Value = ID;
string sql = string.Empty;
if (ID != 0)
{
sql = "select a.*,b.* from " + Pre + "sys_channelvalue a," + DTable + " b where a.ChID=@ChID and b.ID=@ID and a.isLock=0 order by a.OrderID desc,a.id desc";
}
else
{
sql = "select * from " + Pre + "sys_channelvalue where ChID=@ChID and isLock=0 order by OrderID desc,id desc";
}
return DbHelper.ExecuteTable(CommandType.Text, sql, param);
}
public DataTable GetChannelUserValueFormInfo(int ChID, string DTable, int ID)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = ChID;
param[1] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[1].Value = ID;
string sql = string.Empty;
if (ID != 0)
{
sql = "select a.*,b.* from " + Pre + "sys_channelvalue a," + DTable + " b where a.ChID=@ChID and b.ID=@ID and a.isLock=0 and a.isUser=1 order by a.OrderID desc,a.id desc";
}
else
{
sql = "select * from " + Pre + "sys_channelvalue where ChID=@ChID and isLock=0 and isUser=1 order by OrderID desc,id desc";
}
return DbHelper.ExecuteTable(CommandType.Text, sql, param);
}
public DataTable GetPage(string keywords, string islock, string author, string ClassID, string SpecialID, string stat, int ChID, string dbTable, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
string sFilter = " where a.ChID=" + ChID + " and a.ClassID=b.id";
if (ClassID != "#0")
{
sFilter += " and a.ClassID=" + int.Parse(ClassID) + "";
}
if (islock != "#0")
{
sFilter += " and a.islock=" + int.Parse(islock) + "";
}
if (SpecialID != "#0")
{
sFilter += " and a.SpecialID like '%" + SpecialID + "%'";
}
if (keywords != "#0")
{
sFilter += " and (a.Content like '%" + keywords + "%' or a.Author like '%" + keywords + "%' or a.Title like '%" + keywords + "%')";
}
string gSQLstr = "order by a.OrderID desc";
if (stat != "#0")
{
switch (stat)//推荐|热点|幻灯|滚动|头条
{
case "rec":
sFilter += " And ContentProperty like '1%'";
break;
case "hot":
sFilter += " And ContentProperty like '__1%'";
break;
case "filt":
sFilter += " And ContentProperty like '____1%'";
break;
case "mar":
sFilter += " And ContentProperty like '______1%'";
break;
case "hnews":
sFilter += " And ContentProperty like '________1%'";
break;
case "constr":
sFilter += " and isConstr=1";
break;
case "isadmin":
sFilter += " and isConstr=0";
break;
case "unlock":
sFilter += " and a.islock=0";
break;
case "lock":
sFilter += " and a.islock=1";
break;
case "click":
gSQLstr = "order by a.click desc";
break;
default:
if (stat.IndexOf("SP|") > -1)
{
string[] SPSTRARR = stat.Split('|');
sFilter += " and a.SpecialID='" + SPSTRARR[1] + "'";
}
break;
}
}
if (author != "#0")
{
sFilter += " and a.author='" + author + "'";
}
string AllFields = "a.*";
string Condition = dbTable + " a," + Pre + "sys_channelclass b" + sFilter;
string IndexField = "a.Id";
string OrderFields = gSQLstr + ",a.Id desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, null);
}
public int delContent(int id, int ChID, int Num)
{
string sql = string.Empty;
SqlParameter param = new SqlParameter("@id", id);
string dTable = getChannelTable(ChID);
if (Num == 0)
{
sql = "delete from " + dTable + " where id=@id and ChID=" + ChID + "";
}
else
{
if (id == 0)
{
sql = "delete from " + dTable + " where ChID=" + ChID + "";
}
else
{
sql = "delete from " + dTable + " where ClassID=@id and ChID=" + ChID + "";
}
}
return DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public int inserContentInfo(NetCMS.Model.ChInfoContent uc, string DTable)
{
SqlParameter[] param = GetChInfoParams(uc);
string Sql = "insert into " + DTable + " (";
Sql += "ChID,ClassID,SpecialID,title,TitleColor,TitleITF,TitleBTF,PicURL,NaviContent,Content,Author,Souce,OrderID,Tags,";
Sql += "Templet,SavePath,FileName,isDelPoint,Gpoint,iPoint,GroupNumber,Metakeywords,Metadesc,Click,CreatTime,isHTML,isConstr,islock,ContentProperty,Editor,ConstrTF";
Sql += ") values (";
Sql += "@ChID,@ClassID,@SpecialID,@title,@TitleColor,@TitleITF,@TitleBTF,@PicURL,@NaviContent,@Content,@Author,@Souce,@OrderID,@Tags,";
Sql += "@Templet,@SavePath,@FileName,@isDelPoint,@Gpoint,@iPoint,@GroupNumber,@Metakeywords,@Metadesc,@Click,'" + DateTime.Now + "',@isHTML,@isConstr,@islock,@ContentProperty,@Editor,0)";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
string sqlid = "select top 1 id from " + DTable + " where title=@title and FileName=@FileName order by id desc";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sqlid, param));
}
public void updateContentInfo(NetCMS.Model.ChInfoContent uc, string DTable)
{
SqlParameter[] param = GetChInfoParams(uc);
string Sql = "update " + DTable + " set ";
Sql += "ChID=@ChID,ClassID=@ClassID,SpecialID=@SpecialID,title=@title,TitleColor=@TitleColor,TitleITF=@TitleITF,TitleBTF=@TitleBTF,PicURL=@PicURL,NaviContent=@NaviContent,Content=@Content,Author=@Author,Souce=@Souce,OrderID=@OrderID,Tags=@Tags,";
Sql += "Templet=@Templet,SavePath=@SavePath,FileName=@FileName,isDelPoint=@isDelPoint,Gpoint=@Gpoint,iPoint=@iPoint,GroupNumber=@GroupNumber,Metakeywords=@Metakeywords,Metadesc=@Metadesc,Click=@Click,isHTML=@isHTML,isConstr=@isConstr,islock=@islock,ContentProperty=@ContentProperty,Editor=@Editor where ID=@Id";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public void updateUserContentInfo(NetCMS.Model.ChInfoContent uc, string DTable)
{
SqlParameter[] param = GetChInfoParams1(uc);
string Sql = "update " + DTable + " set ";
Sql += "ChID=@ChID,ClassID=@ClassID,title=@title,PicURL=@PicURL,NaviContent=@NaviContent,Content=@Content,Author=@Author,Souce=@Souce,Tags=@Tags,";
Sql += "isConstr=@isConstr,islock=@islock where ID=@Id";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public void updatePreContentInfo(int ID, string PreContentName, object PreContent, string DTable)
{
SqlParameter param = null;
string gSQL = "select vType from " + Pre + "sys_channelvalue where EName='" + PreContentName + "'";
string getType = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, gSQL, null));
switch (getType)
{
case "7":
if (PreContent != null)
{
param = new SqlParameter("@ContentParam", Convert.ToInt16(PreContent));
}
else
{
int gparam0 = 0;
param = new SqlParameter("@ContentParam", gparam0);
}
break;
case "8":
if (PreContent != null)
{
param = new SqlParameter("@ContentParam", Convert.ToInt16(PreContent));
}
else
{
int gparam8 = 0;
param = new SqlParameter("@ContentParam", gparam8);
}
break;
case "9":
if (PreContent != null)
{
param = new SqlParameter("@ContentParam", Convert.ToDouble(PreContent));
}
else
{
int gparam9 = 0;
param = new SqlParameter("@ContentParam", gparam9);
}
break;
case "10":
if (PreContent != null)
{
param = new SqlParameter("@ContentParam", Convert.ToDateTime(PreContent));
}
else
{
param = new SqlParameter("@ContentParam", "");
}
break;
case "11":
if (PreContent != null)
{
param = new SqlParameter("@ContentParam", Convert.ToDateTime(PreContent));
}
else
{
param = new SqlParameter("@ContentParam", "");
}
break;
default:
if (PreContent != null)
{
param = new SqlParameter("@ContentParam", PreContent);
}
else
{
param = new SqlParameter("@ContentParam", "");
}
break;
}
string sql = "update " + DTable + " set " + PreContentName + "=@ContentParam where ID=" + ID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
private SqlParameter[] GetChInfoParams(NetCMS.Model.ChInfoContent uc1)
{
SqlParameter[] param = new SqlParameter[30];
param[0] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[0].Value = uc1.Id;
param[1] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[1].Value = uc1.ChID;
param[2] = new SqlParameter("@ClassID", SqlDbType.Int, 4);
param[2].Value = uc1.ClassID;
param[3] = new SqlParameter("@SpecialID", SqlDbType.NVarChar, 200);
param[3].Value = uc1.SpecialID;
param[4] = new SqlParameter("@title", SqlDbType.NVarChar, 100);
param[4].Value = uc1.title;
param[5] = new SqlParameter("@TitleColor", SqlDbType.NVarChar, 10);
param[5].Value = uc1.TitleColor;
param[6] = new SqlParameter("@TitleITF", SqlDbType.TinyInt, 1);
param[6].Value = uc1.TitleITF;
param[7] = new SqlParameter("@TitleBTF", SqlDbType.TinyInt, 1);
param[7].Value = uc1.TitleBTF;
param[8] = new SqlParameter("@PicURL", SqlDbType.NVarChar, 200);
param[8].Value = uc1.PicURL;
param[9] = new SqlParameter("@NaviContent", SqlDbType.NVarChar, 200);
param[9].Value = uc1.NaviContent;
param[10] = new SqlParameter("@Content", SqlDbType.NText);
param[10].Value = uc1.Content;
param[11] = new SqlParameter("@Author", SqlDbType.NVarChar, 100);
param[11].Value = uc1.Author;
param[12] = new SqlParameter("@Souce", SqlDbType.NVarChar, 100);
param[12].Value = uc1.Souce;
param[13] = new SqlParameter("@OrderID", SqlDbType.TinyInt, 1);
param[13].Value = uc1.OrderID;
param[14] = new SqlParameter("@Tags", SqlDbType.NVarChar, 100);
param[14].Value = uc1.Tags;
param[15] = new SqlParameter("@Templet", SqlDbType.NVarChar, 200);
param[15].Value = uc1.Templet;
param[16] = new SqlParameter("@SavePath", SqlDbType.NVarChar, 200);
param[16].Value = uc1.SavePath;
param[17] = new SqlParameter("@FileName", SqlDbType.NVarChar, 100);
param[17].Value = uc1.FileName;
param[18] = new SqlParameter("@isDelPoint", SqlDbType.TinyInt, 1);
param[18].Value = uc1.isDelPoint;
param[19] = new SqlParameter("@Gpoint", SqlDbType.Int, 4);
param[19].Value = uc1.Gpoint;
param[20] = new SqlParameter("@iPoint", SqlDbType.Int, 4);
param[20].Value = uc1.iPoint;
param[21] = new SqlParameter("@GroupNumber", SqlDbType.NText);
param[21].Value = uc1.GroupNumber;
param[22] = new SqlParameter("@Metakeywords", SqlDbType.NVarChar, 200);
param[22].Value = uc1.Metakeywords;
param[23] = new SqlParameter("@Metadesc", SqlDbType.NVarChar, 200);
param[23].Value = uc1.Metadesc;
param[24] = new SqlParameter("@Click", SqlDbType.Int, 4);
param[24].Value = uc1.Click;
param[25] = new SqlParameter("@isHTML", SqlDbType.TinyInt, 1);
param[25].Value = uc1.isHTML;
param[26] = new SqlParameter("@isConstr", SqlDbType.TinyInt, 1);
param[26].Value = uc1.isConstr;
param[27] = new SqlParameter("@islock", SqlDbType.TinyInt, 1);
param[27].Value = uc1.islock;
param[28] = new SqlParameter("@Editor", SqlDbType.NVarChar, 150);
param[28].Value = uc1.Editor;
param[29] = new SqlParameter("@ContentProperty", SqlDbType.NVarChar, 9);
param[29].Value = uc1.ContentProperty;
return param;
}
private SqlParameter[] GetChInfoParams1(NetCMS.Model.ChInfoContent uc1)
{
SqlParameter[] param = new SqlParameter[12];
param[0] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[0].Value = uc1.Id;
param[1] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[1].Value = uc1.ChID;
param[2] = new SqlParameter("@ClassID", SqlDbType.Int, 4);
param[2].Value = uc1.ClassID;
param[3] = new SqlParameter("@title", SqlDbType.NVarChar, 100);
param[3].Value = uc1.title;
param[4] = new SqlParameter("@PicURL", SqlDbType.NVarChar, 200);
param[4].Value = uc1.PicURL;
param[5] = new SqlParameter("@NaviContent", SqlDbType.NVarChar, 200);
param[5].Value = uc1.NaviContent;
param[6] = new SqlParameter("@Content", SqlDbType.NText);
param[6].Value = uc1.Content;
param[7] = new SqlParameter("@Author", SqlDbType.NVarChar, 100);
param[7].Value = uc1.Author;
param[8] = new SqlParameter("@Souce", SqlDbType.NVarChar, 100);
param[8].Value = uc1.Souce;
param[9] = new SqlParameter("@Tags", SqlDbType.NVarChar, 100);
param[9].Value = uc1.Tags;
param[10] = new SqlParameter("@isConstr", SqlDbType.TinyInt, 1);
param[10].Value = uc1.isConstr;
param[11] = new SqlParameter("@islock", SqlDbType.TinyInt, 1);
param[11].Value = uc1.islock;
return param;
}
public int lockContent(int id, int ChID, int num)
{
string sql = string.Empty;
SqlParameter param = new SqlParameter("@id", id);
string dTable = getChannelTable(ChID);
if (num != 2)
{
sql = "update " + dTable + " set islock=" + num + " where id=@id and ChID=" + ChID + "";
}
else
{
sql = "update " + dTable + " set orderId=0 where id=@id and ChID=" + ChID + "";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public void setOrderContent(int id, int ChID, int num)
{
SqlParameter param = new SqlParameter("@id", id);
string dTable = getChannelTable(ChID);
string sql = "update " + dTable + " set orderId=" + num + " where id=@id and ChID=" + ChID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public IDataReader getContentAll(int ChID, int ID)
{
SqlParameter param = new SqlParameter("@ID", ID);
string DTable = getChannelTable(ChID);
if (DTable != "#")
{
string sql = "select * from " + DTable + " where ID=@ID";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
else
{
throw new Exception("找不到数据库表,可能是数据库表已被移除");
}
}
#endregion
#region 专题部分
public string getSpecialName(int SpecialID)
{
SqlParameter param = new SqlParameter("@SpecialID", SpecialID);
string sql = "select specialCName from " + Pre + "sys_channelspecial where ID=@SpecialID";
string CName = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
if (CName == string.Empty)
{
CName = "根专题";
}
return CName;
}
public IDataReader getSpecialInfo(int SpecialID)
{
SqlParameter param = new SqlParameter("@SpecialID", SpecialID);
string sql = "select * from " + Pre + "sys_channelspecial where ID=@SpecialID";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
/// <summary>
/// 得到专题英文名称是否重复
/// </summary>
/// <param name="EName"></param>
/// <param name="speicalId"></param>
/// <returns></returns>
public int getSpecialCord(string EName, int speicalId)
{
SqlParameter param = new SqlParameter("@speicalId", speicalId);
string sql = "select count(id) from " + Pre + "sys_channelspecial where ID<>@speicalId and specialEName='" + EName + "'";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
public void insertSpecialInfo(NetCMS.Model.ChannelSpecialInfo uc)
{
SqlParameter[] param = SpecialInfoParameter(uc);
string Sql = "insert into " + Pre + "sys_channelspecial (";
Sql += "ChID,OrderID,ParentID,specialCName,specialEName,binddomain,navicontent,savePath,filename,templet,islock,isRec,PicURL";
Sql += ") values (";
Sql += "@ChID,@OrderID,@ParentID,@specialCName,@specialEName,@binddomain,@navicontent,@savePath,@filename,@templet,@islock,@isRec,@PicURL)";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public void updateSpecialInfo(NetCMS.Model.ChannelSpecialInfo uc)
{
SqlParameter[] param = SpecialInfoParameter(uc);
string Sql = "update " + Pre + "sys_channelspecial set ";
Sql += "OrderID=@OrderID,specialCName=@specialCName,specialEName=@specialEName,binddomain=@binddomain,navicontent=@navicontent,savePath=@savePath,filename=@filename,templet=@templet,islock=@islock,isRec=@isRec,PicURL=@PicURL";
Sql += " where ID=@Id";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
private SqlParameter[] SpecialInfoParameter(NetCMS.Model.ChannelSpecialInfo uc1)
{
SqlParameter[] param = new SqlParameter[14];
param[0] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[0].Value = uc1.Id;
param[1] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[1].Value = uc1.ChID;
param[2] = new SqlParameter("@ParentID", SqlDbType.Int, 4);
param[2].Value = uc1.ParentID;
param[3] = new SqlParameter("@OrderID", SqlDbType.TinyInt, 1);
param[3].Value = uc1.OrderID;
param[4] = new SqlParameter("@specialCName", SqlDbType.NVarChar, 100);
param[4].Value = uc1.specialCName;
param[5] = new SqlParameter("@specialEName", SqlDbType.NVarChar, 100);
param[5].Value = uc1.specialEName;
param[6] = new SqlParameter("@binddomain", SqlDbType.NVarChar, 100);
param[6].Value = uc1.binddomain;
param[7] = new SqlParameter("@navicontent", SqlDbType.NVarChar, 200);
param[7].Value = uc1.navicontent;
param[8] = new SqlParameter("@savePath", SqlDbType.NVarChar, 100);
param[8].Value = uc1.savePath;
param[9] = new SqlParameter("@filename", SqlDbType.NVarChar, 100);
param[9].Value = uc1.filename;
param[10] = new SqlParameter("@templet", SqlDbType.NVarChar, 200);
param[10].Value = uc1.templet;
param[11] = new SqlParameter("@islock", SqlDbType.TinyInt, 1);
param[11].Value = uc1.islock;
param[12] = new SqlParameter("@isRec", SqlDbType.TinyInt, 1);
param[12].Value = uc1.isRec;
param[13] = new SqlParameter("@PicURL", SqlDbType.NVarChar, 200);
param[13].Value = uc1.PicURL;
return param;
}
public int getSpecialNumber(int SpecialID)
{
SqlParameter param = new SqlParameter("@SpecialID", SpecialID);
string sql = "select count(id) from " + Pre + "sys_channelspecial where ParentID=@SpecialID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
public int Reset_allSpecial(int SpecialID, int ChID)
{
SqlParameter paramd = new SqlParameter("@ChID", ChID);
string sqld = "select DataLib from " + Pre + "sys_channel where ID=@ChID";
string dTable = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sqld, paramd));
if (dTable != string.Empty)
{
SqlParameter param = new SqlParameter("@SpecialID", SpecialID);
string sql = "update " + dTable + " set SpecialID = replace('SpecialID','" + SpecialID + "' , '')";
return DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
else
{
return 0;
}
}
public int lockstatSpecial(int SpecialID, int num)
{
SqlParameter param = new SqlParameter("@SpecialID", SpecialID);
string sql = "update " + Pre + "sys_channelspecial set islock=" + num + " where Id=@SpecialID";
return DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public int delSpecial(int SpecialID)
{
SqlParameter param = new SqlParameter("@SpecialID", SpecialID);
string sql = "delete from " + Pre + "sys_channelspecial where ID=@SpecialID";
delcSpecial(SpecialID);
return DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public void delcSpecial(int SpecialID)
{
SqlParameter param = new SqlParameter("@SpecialID", SpecialID);
string sqlc = "select id from " + Pre + "sys_channelspecial where ParentID=@SpecialID order by id desc";
IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sqlc, param);
while (dr.Read())
{
int gID = int.Parse(dr["id"].ToString());
string sql = "delete from " + Pre + "sys_channelspecial where ID=" + gID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, sql, null);
delcClass(gID);
}
dr.Close();
}
public IDataReader getSpecialList(int SpecialID, int ChID)
{
SqlParameter param = new SqlParameter("@SpecialID", SpecialID);
string sql = "select id,specialCName from " + Pre + "sys_channelspecial where ParentID=@SpecialID and islock=0 and ChID=" + ChID + " order by Orderid desc,id desc";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public void utilSpecial(int sSpecialID, int tSpecialID, int ChID)
{
//Copy content
SqlParameter param = new SqlParameter("@ChID", ChID);
string sql = "select DataLib from " + Pre + "sys_channel where ID=@ChID";
string dbTable = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
if (dbTable != string.Empty)
{
string usql = "update " + dbTable + " set SpecialID=replace('SpecialID','" + sSpecialID + "' , '" + tSpecialID + "')";
DbHelper.ExecuteNonQuery(CommandType.Text, usql, null);
}
//更新源栏目下级的父类
string ssql = "select ParentID from " + Pre + "sys_channelspecial where ID=" + sSpecialID + "";
string ParentID = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, ssql, null));
if (ParentID != string.Empty)
{
string usql = "update " + Pre + "sys_channelspecial set ParentID=" + int.Parse(ParentID) + " where ParentID=" + sSpecialID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, usql, null);
}
//删除源栏目
string delsql = "delete from " + Pre + "sys_channelspecial where id=" + sSpecialID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, delsql, null);
}
public void moveSpecial(int sSpecialID, int tSpecialID)
{
string sql = "update " + Pre + "sys_channelspecial set ParentID=" + tSpecialID + " where Id=" + sSpecialID + "";
DbHelper.ExecuteNonQuery(CommandType.Text, sql, null);
}
public int GetSpecialInfoCount(int ID, int ChID)
{
SqlParameter param = new SqlParameter("@ID", ID.ToString());
string sql = "select count(id) from " + getChannelTable(ChID) + " where SpecialID=@ID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
#endregion
public IDataReader getStyleClassList(int ClassID, int ChID)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = ChID;
param[1] = new SqlParameter("@ClassID", SqlDbType.Int, 4);
param[1].Value = ClassID;
string sql = "select ID,ParentID,cName,ChID,SiteID from " + Pre + "sys_channelstyleclass where ParentID=@ClassID and ChID=@ChID order by id desc";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public DataTable GetStylePage(string keywords, string ClassID, int ChID, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
string sFilter = " where a.ChID=" + ChID + " and a.ClassID=b.id";
if (ClassID != "#0")
{
sFilter += " and a.ClassID=" + int.Parse(ClassID) + "";
}
if (keywords != "#0")
{
sFilter += " and (a.styleName like '%" + keywords + "%' or a.styleContent like '%" + keywords + "%' or a.styleDescript like '%" + keywords + "%')";
}
string AllFields = "a.*";
string Condition = Pre + "sys_channelstyle a," + Pre + "sys_channelstyleclass b" + sFilter;
string IndexField = "a.Id";
string OrderFields = "order by a.Id desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, null);
}
public string getStyleClassName(int ClassID)
{
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string sql = "select cName from " + Pre + "sys_channelstyleclass where ID=@ClassID";
string CName = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
if (CName == string.Empty)
{
CName = "根栏目";
}
return CName;
}
public int delStyleContent(int id, int ChID, int Num)
{
string sql = string.Empty;
SqlParameter param = new SqlParameter("@id", id);
if (Num == 0)
{
sql = "delete from " + Pre + "sys_channelstyle where id=@id and ChID=" + ChID + "";
}
else
{
if (id == 0)
{
sql = "delete from " + Pre + "sys_channelstyle where ChID=" + ChID + "";
}
else
{
sql = "delete from " + Pre + "sys_channelstyle where ClassID=@id and ChID=" + ChID + "";
}
}
return DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public int lockStyleContent(int id, int ChID, int num)
{
string sql = string.Empty;
SqlParameter param = new SqlParameter("@id", id);
if (num != 2)
{
sql = "update " + Pre + "sys_channelstyle set islock=" + num + " where id=@id and ChID=" + ChID + "";
}
else
{
sql = "update " + Pre + "sys_channelstyle set orderId=0 where id=@id and ChID=" + ChID + "";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public void InsertStyleContent(NetCMS.Model.styleChContent uc)
{
SqlParameter[] param = StyleChInfoParameter(uc);
string Sql = "insert into " + Pre + "sys_channelstyle (";
Sql += "ChID,classID,styleName,styleContent,isLock,styleDescript,SiteID,creattime";
Sql += ") values (";
Sql += "@ChID,@classID,@styleName,@styleContent,@isLock,@styleDescript,@SiteID,@creattime)";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public void UpdateStyleContent(NetCMS.Model.styleChContent uc)
{
SqlParameter[] param = StyleChInfoParameter(uc);
string Sql = "update " + Pre + "sys_channelstyle set ";
Sql += "classID=@classID,styleName=@styleName,styleContent=@styleContent,isLock=@isLock,styleDescript=@styleDescript,SiteID=@SiteID where id=@Id";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
private SqlParameter[] StyleChInfoParameter(NetCMS.Model.styleChContent uc1)
{
SqlParameter[] param = new SqlParameter[9];
param[0] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[0].Value = uc1.Id;
param[1] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[1].Value = uc1.ChID;
param[2] = new SqlParameter("@styleName", SqlDbType.NVarChar, 50);
param[2].Value = uc1.styleName;
param[3] = new SqlParameter("@styleContent", SqlDbType.NText);
param[3].Value = uc1.styleContent;
param[4] = new SqlParameter("@isLock", SqlDbType.TinyInt, 1);
param[4].Value = uc1.isLock;
param[5] = new SqlParameter("@styleDescript", SqlDbType.NVarChar, 200);
param[5].Value = uc1.styleDescript;
param[6] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[6].Value = uc1.SiteID;
param[7] = new SqlParameter("@creattime", SqlDbType.DateTime, 8);
param[7].Value = uc1.creattime;
param[8] = new SqlParameter("@classID", SqlDbType.Int, 4);
param[8].Value = uc1.classID;
return param;
}
public IDataReader GetStyleContent(int Id, int ChID)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = ChID;
param[1] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[1].Value = Id;
string sql = "select * from " + Pre + "sys_channelstyle where Id=@Id and ChID=@ChID";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public int GetStyleRecord(string CName, int ID, int ChID)
{
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[0].Value = ID;
param[1] = new SqlParameter("@CName", SqlDbType.NVarChar, 50);
param[1].Value = CName;
param[2] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[2].Value = ChID;
string sql = "select count(id) from " + Pre + "sys_channelstyle where ChID=@ChID and styleName=@CName and ID<>@ID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
public int GetStyleClassRecord(string cName, int ID, int ChID)
{
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[0].Value = ID;
param[1] = new SqlParameter("@CName", SqlDbType.NVarChar, 50);
param[1].Value = cName;
param[2] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[2].Value = ChID;
string sql = "select count(id) from " + Pre + "sys_channelstyleclass where ChID=@ChID and cName=@CName and ID<>@ID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
public void InsertStyleClassContent(int ID, int ChID, string cName)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = ChID;
param[1] = new SqlParameter("@cName", SqlDbType.NVarChar, 50);
param[1].Value = cName;
string Sql = "insert into " + Pre + "sys_channelstyleclass (";
Sql += "ChID,cName,SiteID,ParentID";
Sql += ") values (";
Sql += "@ChID,@cName,'0',0)";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public void UpdateStyleClassContent(int ID, int ChID, string cName)
{
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = ChID;
param[1] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[1].Value = ID;
param[2] = new SqlParameter("@cName", SqlDbType.NVarChar, 50);
param[2].Value = cName;
string Sql = "update " + Pre + "sys_channelstyleclass set ";
Sql += "cName=@cName where id=@Id and ChID=@ChID";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public IDataReader GetStyleClassListManage(int ChID, int ParentID)
{
SqlParameter param = new SqlParameter("@ChID", ChID);
string sql = "select * from " + Pre + "sys_channelstyleclass where ChID=@ChID and ParentID=" + ParentID + " order by ID desc";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public IDataReader GetStyleClassInfo(int id, int ChID)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = ChID;
param[1] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[1].Value = id;
string sql = "select * from " + Pre + "sys_channelstyleclass where ChID=@ChID and ID=@Id";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public IDataReader GetDefineStyle(int ChID)
{
SqlParameter param = new SqlParameter("@ChID", ChID);
string sql = "select id,CName,EName,vType,isNulls,isLock from " + Pre + "sys_channelvalue where ChID=@ChID and isLock=0 order by OrderID desc,id desc";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public IDataReader GetDefineUserStyle(int ChID)
{
SqlParameter param = new SqlParameter("@ChID", ChID);
string sql = "select id,CName,EName,vType,isNulls,isLock from " + Pre + "sys_channelvalue where ChID=@ChID and isUser=1 order by OrderID desc,id desc";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public IDataReader GetLabelClassList(int ChID, int ParentID)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = ChID;
param[1] = new SqlParameter("@ParentID", SqlDbType.Int, 4);
param[1].Value = ParentID;
string sql = "select id,ClassName,ParentID from " + Pre + "sys_channellabelclass where ChID=@ChID and ParentID=@ParentID order by id desc";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public IDataReader GetLabelContent(int ChID, int ID)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = ChID;
param[1] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[1].Value = ID;
string sql = "select * from " + Pre + "sys_channellabel where ID=@ID and ChID=@ChID order by id desc";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public int GetLabelNameTF(int ChID, string CName, int ID)
{
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = ChID;
param[1] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[1].Value = ID;
param[2] = new SqlParameter("@CName", SqlDbType.NVarChar, 80);
param[2].Value = CName;
string sql = "select count(ID) from " + Pre + "sys_channellabel where ID<>@ID and LabelName=@CName and ChID=@ChID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
public void InsertLabelContent(NetCMS.Model.LabelChContent uc)
{
SqlParameter[] param = LabelChInfoParameter(uc);
string Sql = "insert into " + Pre + "sys_channellabel (";
Sql += "ChID,ClassID,LabelName,LabelContent,isLock,LabelDescript,SiteID,creattime";
Sql += ") values (";
Sql += "@ChID,@ClassID,@LabelName,@LabelContent,@isLock,@LabelDescript,@SiteID,@CreatTime)";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public void UpdateLabelContent(NetCMS.Model.LabelChContent uc)
{
SqlParameter[] param = LabelChInfoParameter(uc);
string Sql = "update " + Pre + "sys_channellabel set ";
Sql += "ClassID=@ClassID,LabelName=@LabelName,LabelContent=@LabelContent,isLock=@isLock,LabelDescript=@LabelDescript,SiteID=@SiteID where id=@Id";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
private SqlParameter[] LabelChInfoParameter(NetCMS.Model.LabelChContent uc1)
{
SqlParameter[] param = new SqlParameter[9];
param[0] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[0].Value = uc1.Id;
param[1] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[1].Value = uc1.ChID;
param[2] = new SqlParameter("@LabelName", SqlDbType.NVarChar, 80);
param[2].Value = uc1.LabelName;
param[3] = new SqlParameter("@LabelContent", SqlDbType.NText);
param[3].Value = uc1.LabelContent;
param[4] = new SqlParameter("@isLock", SqlDbType.TinyInt, 1);
param[4].Value = uc1.isLock;
param[5] = new SqlParameter("@LabelDescript", SqlDbType.NVarChar, 200);
param[5].Value = uc1.LabelDescript;
param[6] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
param[6].Value = uc1.SiteID;
param[7] = new SqlParameter("@creattime", SqlDbType.DateTime, 8);
param[7].Value = uc1.CreatTime;
param[8] = new SqlParameter("@ClassID", SqlDbType.Int, 4);
param[8].Value = uc1.ClassID;
return param;
}
public DataTable GetLabelPage(string keywords, string ClassID, int ChID, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
string sFilter = " where a.ChID=" + ChID + " and a.ClassID=b.id";
if (ClassID != "#0")
{
sFilter += " and a.ClassID=" + int.Parse(ClassID) + "";
}
if (keywords != "#0")
{
sFilter += " and (a.LabelName like '%" + keywords + "%' or a.LabelContent like '%" + keywords + "%' or a.LabelDescript like '%" + keywords + "%')";
}
string AllFields = "a.*";
string Condition = Pre + "sys_channellabel a," + Pre + "sys_channellabelclass b" + sFilter;
string IndexField = "a.Id";
string OrderFields = "order by a.Id desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, null);
}
public string getLabelClassName(int ClassID)
{
SqlParameter param = new SqlParameter("@ClassID", ClassID);
string sql = "select ClassName from " + Pre + "sys_channellabelclass where ID=@ClassID";
string CName = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
if (CName == string.Empty)
{
CName = "根栏目";
}
return CName;
}
public int delLabelContent(int id, int ChID, int Num)
{
string sql = string.Empty;
SqlParameter param = new SqlParameter("@id", id);
if (Num == 0)
{
sql = "delete from " + Pre + "sys_channellabel where id=@id and ChID=" + ChID + "";
}
else
{
if (id == 0)
{
sql = "delete from " + Pre + "sys_channellabel where ChID=" + ChID + "";
}
else
{
sql = "delete from " + Pre + "sys_channellabel where ClassID=@id and ChID=" + ChID + "";
}
}
return DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public int lockLabelContent(int id, int ChID, int num)
{
string sql = string.Empty;
SqlParameter param = new SqlParameter("@id", id);
if (num != 2)
{
sql = "update " + Pre + "sys_channellabel set islock=" + num + " where id=@id and ChID=" + ChID + "";
}
else
{
sql = "update " + Pre + "sys_channellabel set orderId=0 where id=@id and ChID=" + ChID + "";
}
return DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public IDataReader GetLabelClassInfo(int id, int ChID)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = ChID;
param[1] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[1].Value = id;
string sql = "select * from " + Pre + "sys_channellabelclass where ChID=@ChID and ID=@Id";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public int GetLabelClassRecord(string cName, int ID, int ChID)
{
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[0].Value = ID;
param[1] = new SqlParameter("@ClassName", SqlDbType.NVarChar, 80);
param[1].Value = cName;
param[2] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[2].Value = ChID;
string sql = "select count(id) from " + Pre + "sys_channellabelclass where ChID=@ChID and ClassName=@ClassName and ID<>@ID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
public void InsertLabelClassContent(int ID, int ChID, string cName)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = ChID;
param[1] = new SqlParameter("@ClassName", SqlDbType.NVarChar, 80);
param[1].Value = cName;
string Sql = "insert into " + Pre + "sys_channellabelclass (";
Sql += "ChID,ClassName,SiteID,ParentID";
Sql += ") values (";
Sql += "@ChID,@ClassName,'0',0)";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public void UpdateLabelClassContent(int ID, int ChID, string cName)
{
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = ChID;
param[1] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[1].Value = ID;
param[2] = new SqlParameter("@ClassName", SqlDbType.NVarChar, 80);
param[2].Value = cName;
string Sql = "update " + Pre + "sys_channellabelclass set ";
Sql += "ClassName=@ClassName where id=@Id and ChID=@ChID";
DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public IDataReader GetLabelClassListManage(int ChID, int ParentID)
{
SqlParameter param = new SqlParameter("@ChID", ChID);
string sql = "select * from " + Pre + "sys_channellabelclass where ChID=@ChID and ParentID=" + ParentID + " order by ID desc";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
public int delLabelClassContent(int id, int chid)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = chid;
param[1] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[1].Value = id;
string dsql = "delete from " + Pre + "sys_channellabel where ClassID=" + id + "";
DbHelper.ExecuteNonQuery(CommandType.Text, dsql, null);
string Sql = "delete from " + Pre + "sys_channellabelclass where id=@Id and ChID=@ChID";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public int delStyleClassContent(int id, int chid)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[0].Value = chid;
param[1] = new SqlParameter("@Id", SqlDbType.Int, 4);
param[1].Value = id;
string dsql = "delete from " + Pre + "sys_channelstyle where ClassID=" + id + "";
DbHelper.ExecuteNonQuery(CommandType.Text, dsql, null);
string Sql = "delete from " + Pre + "sys_channelstyleclass where id=@Id and ChID=@ChID";
return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
}
public DataTable GetSLabelPage(int ChID, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
string sFilter = string.Empty;
if (ChID != 0)
{
sFilter = " where ChID=" + ChID + " and islock=0";
}
else
{
sFilter = " where islock=0";
}
string AllFields = "*";
string Condition = Pre + "sys_channellabel" + sFilter;
string IndexField = "Id";
string OrderFields = "order by Id desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, null);
}
/// <summary>
/// 得到所有样式分类
/// </summary>
/// <param name="ChID"></param>
/// <returns></returns>
public IDataReader GetStyleListAll(int ChID)
{
SqlParameter param = new SqlParameter("@ChID", ChID);
string sql = "select id,styleName from " + Pre + "sys_channelstyle where ChID=@ChID and islock=0 order by id desc";
return DbHelper.ExecuteReader(CommandType.Text, sql, param);
}
/// <summary>
/// 频道栏目是否是单页面
/// </summary>
/// <param name="ClassID"></param>
/// <returns></returns>
public int getclassPage(int ClassID)
{
string sql = "select isPage from " + Pre + "sys_channelclass where ID=@ClassID";
SqlParameter Param = new SqlParameter("@ClassID", ClassID);
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, Param));
}
public int getClassIDfromTable(int ID, int ChID)
{
SqlParameter param = new SqlParameter("@ID", ID);
string sql = "select ClassID from " + getChannelTable(ChID) + " where Id=@ID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
}
public void updateInfoSpecial(string ID, string SpecialID,int ChID)
{
string sql = "update " + getChannelTable(ChID) + " set SpecialID='" + SpecialID + "' where Id in (" + ID + ")";
DbHelper.ExecuteNonQuery(CommandType.Text, sql, null);
}
public int getCContentTopID(int ChID)
{
int getID = 0;
string sql = "select top 1 id from " + getChannelTable(ChID) + " order by id desc";
IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, null);
if (dr.Read())
{
getID = int.Parse(dr["id"].ToString());
}
dr.Close();
return getID;
}
#region 前台会员部分
public DataTable GetUserChannelPage(string Author, string keywords, string ClassID, int ChID, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@keywords", SqlDbType.NVarChar, 100);
param[0].Value = keywords;
param[1] = new SqlParameter("@ClassID", SqlDbType.Int, 4);
param[1].Value = int.Parse(ClassID);
string sqlcon = " where Author='" + Author + "'";
if (keywords != string.Empty)
{
sqlcon += " and (title like '%@keywords%' or content like '%@keywords%')";
}
if (ClassID != "0")
{
sqlcon += " and ClassID=@ClassID";
}
string dbTable = getChannelTable(ChID);
string AllFields = "*";
string Condition = dbTable + sqlcon;
string IndexField = "Id";
string OrderFields = "order by OrderID desc,Id desc";
return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, param);
}
public void updateUserInfo(int Id, int ChID, int Num, string UserName)
{
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[0].Value = Id;
param[1] = new SqlParameter("@Num", SqlDbType.TinyInt, 1);
param[1].Value = Num;
param[2] = new SqlParameter("@UserName", SqlDbType.NVarChar, 30);
param[2].Value = UserName;
string DTalbe = getChannelTable(ChID);
string sql = string.Empty;
if (Num == 2)
{
sql = "delete from " + DTalbe + " where ID=@ID and Author=@UserName";
}
else
{
sql = "update " + DTalbe + " set ConstrTF=@Num where ID=@ID and Author=@UserName";
}
DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
}
public string getfUrl(int ID, int ChID)
{
string DTable = getChannelTable(ChID);
string UrlStr = string.Empty;
SqlParameter param = new SqlParameter("@ID", ID);
string sql = "select * from " + DTable + " where ID=@ID";
string dirHTML = NetCMS.Common.Public.readCHparamConfig("htmldir", ChID);
dirHTML = dirHTML.Replace("{@dirHTML}", NetCMS.Config.UIConfig.dirHtml);
string dimm = NetCMS.Config.UIConfig.dirDumm;
if (dimm.Trim() != string.Empty)
{
dimm = "/" + dimm;
}
IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, param);
if (dr.Read())
{
IDataReader cdr = GetClassInfo(int.Parse(dr["ClassID"].ToString()));
if (cdr.Read())
{
UrlStr = "<a href=\"" + dimm + "/" + dirHTML + "/" + cdr["SavePath"].ToString() + "/" + dr["SavePath"].ToString() + "/" + dr["FileName"] + "\" target=\"_blank\" class=\"list_link\">" + dr["Title"].ToString() + "</a>";
}
cdr.Close();
}
dr.Close();
UrlStr = UrlStr.Replace("//", "/");
return UrlStr;
}
public int AddinfoClick(int ID, int ChID)
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ID", SqlDbType.Int, 4);
param[0].Value = ID;
param[1] = new SqlParameter("@ChID", SqlDbType.Int, 4);
param[1].Value = ChID;
string DTable = getChannelTable(ChID);
string sql = "update " + DTable + " set click=click+1 where ID=@ID";
DbHelper.ExecuteNonQuery(CommandType.Text, sql, param);
string csql = "select click from " + DTable + " where ID=@ID";
return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, csql, param));
}
#endregion
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/Channel.cs | C# | asf20 | 99,581 |
//======================================================
//== (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 System.Collections.Generic;
using System.Text;
using NetCMS.DALFactory;
using NetCMS.Model;
using NetCMS.Global;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
public class FreeLabel : DbBase, IFreeLabel
{
public IList<FreeLablelDBInfo> GetTables()
{
IList<FreeLablelDBInfo> Tables = new List<FreeLablelDBInfo>();
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
DataTable dt = cn.GetSchema("Tables");
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows[i].ItemArray[3].ToString() == "BASE TABLE")
{
string TabNm = dt.Rows[i][2].ToString();
if (!TabNm.ToLower().Equals("dtproperties"))
Tables.Add(new FreeLablelDBInfo(TabNm, TabNm, ""));
}
}
cn.Close();
return Tables;
}
public IList<FreeLablelDBInfo> GetFields(string TableName)
{
IList<FreeLablelDBInfo> Fields = new List<FreeLablelDBInfo>();
string Sql = "select top 1 * from " + TableName + " where 1=0";
IDataReader rd = DbHelper.ExecuteReader(DBConfig.CmsConString, CommandType.Text, Sql, null);
for (int i = 0; i < rd.FieldCount; i++)
{
string fdnm = rd.GetName(i);
Fields.Add(new FreeLablelDBInfo(fdnm, fdnm, rd.GetDataTypeName(i)));
}
if (rd.IsClosed == false)
rd.Close();
return Fields;
}
public bool IsNameRepeat(int id, string Name)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
bool flag = IsRepeat(cn, id, Name);
return flag;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
private bool IsRepeat(SqlConnection cn, int id, string Name)
{
string Sql = "select count(*) from " + Pre + "sys_LabelFree where SiteID='" + Current.SiteID + "' and LabelName=@LabelName";
if (id > 0)
Sql += " and id<>" + id;
SqlParameter param = new SqlParameter("@LabelName", SqlDbType.NVarChar, 30);
param.Value = Name;
int n = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
if (n > 0)
return true;
else
return false;
}
public bool Add(FreeLabelInfo info)
{
return Edit(info);
}
public bool Update(FreeLabelInfo info)
{
return Edit(info);
}
private bool Edit(FreeLabelInfo info)
{
SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
cn.Open();
try
{
if (IsRepeat(cn, info.Id, info.LabelName))
return false;
string Sql = "";
if (info.Id < 1)
{
string LblID = NetCMS.Common.Rand.Number(12);
while (Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, "select count(*) from " + Pre + "sys_LabelFree where LabelID='" + LblID + "'", null)) > 0)
{
LblID = NetCMS.Common.Rand.Number(12, true);
}
Sql = "insert into " + Pre + "sys_LabelFree (LabelID,LabelName,LabelSQL,StyleContent,Description,CreatTime,SiteID) values ('" + LblID + "',@LabelName,@LabelSQL,@StyleContent,@Description,'" + DateTime.Now + "','" + Current.SiteID + "')";
}
else
{
Sql = "update " + Pre + "sys_LabelFree set LabelName=@LabelName,LabelSQL=@LabelSQL,StyleContent=@StyleContent,Description=@Description where SiteID='" + Current.SiteID + "' and Id=" + info.Id;
}
SqlParameter[] parm = new SqlParameter[4];
parm[0] = new SqlParameter("@LabelName", SqlDbType.NVarChar, 30);
parm[0].Value = info.LabelName;
parm[1] = new SqlParameter("@LabelSQL", SqlDbType.NVarChar, 4000);
parm[1].Value = info.LabelSQL;
parm[2] = new SqlParameter("@StyleContent", SqlDbType.NVarChar, 4000);
parm[2].Value = info.StyleContent;
parm[3] = new SqlParameter("@Description", SqlDbType.NVarChar, 200);
parm[3].Value = info.Description.Equals("") ? DBNull.Value : (object)info.Description;
DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, parm);
return true;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}
public FreeLabelInfo GetSingle(int id)
{
string Sql = "select LabelName,LabelSQL,StyleContent,Description,CreatTime,SiteID from " + Pre + "sys_LabelFree where SiteID='" + Current.SiteID + "' and Id=" + id;
IDataReader rd = DbHelper.ExecuteReader(DBConfig.CmsConString, CommandType.Text, Sql, null);
if (rd.Read())
{
string desc = "";
if (!rd.IsDBNull(3)) desc = rd.GetString(3);
FreeLabelInfo info = new FreeLabelInfo(id, rd.GetString(0), rd.GetString(1), rd.GetString(2), desc);
rd.Close();
return info;
}
else
{
rd.Close();
throw new Exception("没有找到相关的自由标签记录!");
}
}
public bool Delete(int id)
{
string Sql = "delete from " + Pre + "sys_LabelFree where SiteID='" + Current.SiteID + "' and Id=" + id;
int n = DbHelper.ExecuteNonQuery(DBConfig.CmsConString, CommandType.Text, Sql, null);
if (n > 0)
return true;
else
return false;
}
public DataTable TestSQL(string Sql)
{
DataTable tb = DbHelper.ExecuteTable(DBConfig.CmsConString, CommandType.Text, Sql, null);
return tb;
}
}
}
| 0575kaoshicj | trunk/NetCMS.DALSQLServer/FreeLabel.cs | C# | asf20 | 6,936 |
/***************************************
*
* Android Bluetooth Oscilloscope
* yus - projectproto.blogspot.com
* September 2010
*
***************************************/
package org.projectproto.yuscope;
import android.graphics.Canvas;
import android.view.SurfaceHolder;
public class WaveformPlotThread extends Thread {
private SurfaceHolder holder;
private WaveformView plot_area;
private boolean _run = false;
public WaveformPlotThread(SurfaceHolder surfaceHolder, WaveformView view){
holder = surfaceHolder;
plot_area = view;
}
public void setRunning(boolean run){
_run = run;
}
@Override
public void run(){
Canvas c;
while(_run){
c = null;
try{
c = holder.lockCanvas(null);
synchronized (holder) {
plot_area.PlotPoints(c);
}
}finally{
if(c!=null){
holder.unlockCanvasAndPost(c);
}
}
}
}
}
| 064sasa-androscope | AndroidBluetoothOscilloscope/src/org/projectproto/yuscope/WaveformPlotThread.java | Java | asf20 | 873 |
/***************************************
*
* Android Bluetooth Oscilloscope
* yus - projectproto.blogspot.com
* September 2010
*
***************************************/
package org.projectproto.yuscope;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
public class BluetoothOscilloscope extends Activity implements Button.OnClickListener{
// Message types sent from the BluetoothRfcommClient Handler
public static final int MESSAGE_STATE_CHANGE = 1;
public static final int MESSAGE_READ = 2;
public static final int MESSAGE_WRITE = 3;
public static final int MESSAGE_DEVICE_NAME = 4;
public static final int MESSAGE_TOAST = 5;
// Key names received from the BluetoothRfcommClient Handler
public static final String DEVICE_NAME = "device_name";
public static final String TOAST = "toast";
// Intent request codes
private static final int REQUEST_CONNECT_DEVICE = 1;
private static final int REQUEST_ENABLE_BT = 2;
// bt-uart constants
private static final int MAX_SAMPLES = 640;
private static final int MAX_LEVEL = 240;
private static final int DATA_START = (MAX_LEVEL + 1);
private static final int DATA_END = (MAX_LEVEL + 2);
private static final byte REQ_DATA = 0x00;
private static final byte ADJ_HORIZONTAL = 0x01;
private static final byte ADJ_VERTICAL = 0x02;
private static final byte ADJ_POSITION = 0x03;
private static final byte CHANNEL1 = 0x01;
private static final byte CHANNEL2 = 0x02;
// Run/Pause status
private boolean bReady = false;
// receive data
private int[] ch1_data = new int[MAX_SAMPLES/2];
private int[] ch2_data = new int[MAX_SAMPLES/2];
private int dataIndex=0, dataIndex1=0, dataIndex2=0;
private boolean bDataAvailable=false;
// Layout Views
private TextView mBTStatus;
private Button mConnectButton;
private RadioButton rb1, rb2;
private TextView ch1pos_label, ch2pos_label;
private Button btn_pos_up, btn_pos_down;
private TextView ch1_scale, ch2_scale;
private Button btn_scale_up, btn_scale_down;
private TextView time_per_div;
private Button timebase_inc, timebase_dec;
private ToggleButton run_buton;
public WaveformView mWaveform = null;
// Name of the connected device
private String mConnectedDeviceName = null;
// Local Bluetooth adapter
private BluetoothAdapter mBluetoothAdapter = null;
// Member object for the RFCOMM services
private BluetoothRfcommClient mRfcommClient = null;
static String[] timebase = {"5us", "10us", "20us", "50us", "100us", "200us", "500us", "1ms", "2ms", "5ms", "10ms", "20ms", "50ms" };
static String[] ampscale = {"10mV", "20mV", "50mV", "100mV", "200mV", "500mV", "1V", "2V", "GND"};
static byte timebase_index = 5;
static byte ch1_index = 4, ch2_index = 5;
static byte ch1_pos = 24, ch2_pos = 17; // 0 to 40
// stay awake
protected PowerManager.WakeLock mWakeLock;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up the window layout
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
// Get local Bluetooth adapter
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
// If the adapter is null, then Bluetooth is not supported
if (mBluetoothAdapter == null) {
Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
finish();
return;
}
// Prevent phone from sleeping
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
this.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "My Tag");
this.mWakeLock.acquire();
}
@Override
public void onStart(){
super.onStart();
// If BT is not on, request that it be enabled.
if (!mBluetoothAdapter.isEnabled()){
Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
}
// Otherwise, setup the Oscillosope session
else{
if (mRfcommClient == null) setupOscilloscope();
}
}
@Override
public synchronized void onResume(){
super.onResume();
// Performing this check in onResume() covers the case in which BT was
// not enabled during onStart(), so we were paused to enable it...
// onResume() will be called when ACTION_REQUEST_ENABLE activity returns.
if (mRfcommClient != null) {
// Only if the state is STATE_NONE, do we know that we haven't started already
if (mRfcommClient.getState() == BluetoothRfcommClient.STATE_NONE) {
// Start the Bluetooth RFCOMM services
mRfcommClient.start();
}
}
}
@Override
public void onClick(View v){
int buttonID;
buttonID = v.getId();
switch (buttonID){
case R.id.btn_position_up :
if(rb1.isChecked() && (ch1_pos<38) ){
ch1_pos += 1; ch1pos_label.setPadding(0, toScreenPos(ch1_pos), 0, 0);
sendMessage( new String(new byte[] {ADJ_POSITION, CHANNEL1, ch1_pos}) );
}
else if(rb2.isChecked() && (ch2_pos<38) ){
ch2_pos += 1; ch2pos_label.setPadding(0, toScreenPos(ch2_pos), 0, 0);
sendMessage( new String(new byte[] {ADJ_POSITION, CHANNEL2, ch2_pos}) );
}
break;
case R.id.btn_position_down :
if(rb1.isChecked() && (ch1_pos>4) ){
ch1_pos -= 1; ch1pos_label.setPadding(0, toScreenPos(ch1_pos), 0, 0);
sendMessage( new String(new byte[] {ADJ_POSITION, CHANNEL1, ch1_pos}) );
}
else if(rb2.isChecked() && (ch2_pos>4) ){
ch2_pos -= 1; ch2pos_label.setPadding(0, toScreenPos(ch2_pos), 0, 0);
sendMessage( new String(new byte[] {ADJ_POSITION, CHANNEL2, ch2_pos}) );
}
break;
case R.id.btn_scale_increase :
if(rb1.isChecked() && (ch1_index>0)){
ch1_scale.setText(ampscale[--ch1_index]);
sendMessage( new String(new byte[] {ADJ_VERTICAL, CHANNEL1, ch1_index}) );
}
else if(rb2.isChecked() && (ch2_index>0)){
ch2_scale.setText(ampscale[--ch2_index]);
sendMessage( new String(new byte[] {ADJ_VERTICAL, CHANNEL2, ch2_index}) );
}
break;
case R.id.btn_scale_decrease :
if(rb1.isChecked() && (ch1_index<(ampscale.length-1))){
ch1_scale.setText(ampscale[++ch1_index]);
sendMessage( new String(new byte[] {ADJ_VERTICAL, CHANNEL1, ch1_index}) );
}
else if(rb2.isChecked() && (ch2_index<(ampscale.length-1))){
ch2_scale.setText(ampscale[++ch2_index]);
sendMessage( new String(new byte[] {ADJ_VERTICAL, CHANNEL2, ch2_index}) );
}
break;
case R.id.btn_timebase_increase :
if(timebase_index<(timebase.length-1)){
time_per_div.setText(timebase[++timebase_index]);
sendMessage( new String(new byte[] {ADJ_HORIZONTAL, timebase_index}) );
}
break;
case R.id.btn_timebase_decrease :
if(timebase_index>0){
time_per_div.setText(timebase[--timebase_index]);
sendMessage( new String(new byte[] {ADJ_HORIZONTAL, timebase_index}) );
}
break;
case R.id.tbtn_runtoggle :
if(run_buton.isChecked()){
sendMessage( new String(new byte[] {
ADJ_HORIZONTAL, timebase_index,
ADJ_VERTICAL, CHANNEL1, ch1_index,
ADJ_VERTICAL, CHANNEL2, ch2_index,
ADJ_POSITION, CHANNEL1, ch1_pos,
ADJ_POSITION, CHANNEL2, ch2_pos,
REQ_DATA}) );
bReady = true;
}else{
bReady = false;
}
break;
}
}
@Override
public void onDestroy(){
super.onDestroy();
// Stop the Bluetooth RFCOMM services
if (mRfcommClient != null) mRfcommClient.stop();
// release screen being on
if (mWakeLock.isHeld()) {
mWakeLock.release();
}
}
/**
* Sends a message.
* @param message A string of text to send.
*/
private void sendMessage(String message){
// Check that we're actually connected before trying anything
if (mRfcommClient.getState() != BluetoothRfcommClient.STATE_CONNECTED) {
Toast.makeText(this, R.string.not_connected, Toast.LENGTH_SHORT).show();
return;
}
// Check that there's actually something to send
if (message.length() > 0) {
// Get the message bytes and tell the BluetoothRfcommClient to write
byte[] send = message.getBytes();
mRfcommClient.write(send);
}
}
private void setupOscilloscope(){
mBTStatus = (TextView) findViewById(R.id.txt_btstatus);
mConnectButton = (Button) findViewById(R.id.button_connect);
mConnectButton.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
BTConnect();
}
});
rb1 = (RadioButton)findViewById(R.id.rbtn_ch1);
rb2 = (RadioButton)findViewById(R.id.rbtn_ch2);
ch1pos_label = (TextView) findViewById(R.id.txt_ch1pos);
ch2pos_label = (TextView) findViewById(R.id.txt_ch2pos);
ch1pos_label.setPadding(0, toScreenPos(ch1_pos), 0, 0);
ch2pos_label.setPadding(0, toScreenPos(ch2_pos), 0, 0);
btn_pos_up = (Button) findViewById(R.id.btn_position_up);
btn_pos_down = (Button) findViewById(R.id.btn_position_down);
btn_pos_up.setOnClickListener(this);
btn_pos_down.setOnClickListener(this);
ch1_scale = (TextView) findViewById(R.id.txt_ch1_scale);
ch2_scale = (TextView) findViewById(R.id.txt_ch2_scale);
ch1_scale.setText(ampscale[ch1_index]);
ch2_scale.setText(ampscale[ch2_index]);
btn_scale_up = (Button) findViewById(R.id.btn_scale_increase);
btn_scale_down = (Button) findViewById(R.id.btn_scale_decrease);
btn_scale_up.setOnClickListener(this);
btn_scale_down.setOnClickListener(this);
time_per_div = (TextView)findViewById(R.id.txt_timebase);
time_per_div.setText(timebase[timebase_index]);
timebase_inc = (Button) findViewById(R.id.btn_timebase_increase);
timebase_dec = (Button) findViewById(R.id.btn_timebase_decrease);
timebase_inc.setOnClickListener(this);
timebase_dec.setOnClickListener(this);
run_buton = (ToggleButton) findViewById(R.id.tbtn_runtoggle);
run_buton.setOnClickListener(this);
// Initialize the BluetoothRfcommClient to perform bluetooth connections
mRfcommClient = new BluetoothRfcommClient(this, mHandler);
// waveform / plot area
mWaveform = (WaveformView)findViewById(R.id.WaveformArea);
}
private void BTConnect(){
Intent serverIntent = new Intent(this, DeviceListActivity.class);
startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
}
private int toScreenPos(byte position){
//return ( (int)MAX_LEVEL - (int)position*6 );
return ( (int)MAX_LEVEL - (int)position*6 - 7);
}
// The Handler that gets information back from the BluetoothRfcommClient
private final Handler mHandler = new Handler(){
@Override
public void handleMessage(Message msg){
switch (msg.what){
case MESSAGE_STATE_CHANGE:
switch (msg.arg1){
case BluetoothRfcommClient.STATE_CONNECTED:
mBTStatus.setText(R.string.title_connected_to);
mBTStatus.append("\n" + mConnectedDeviceName);
break;
case BluetoothRfcommClient.STATE_CONNECTING:
mBTStatus.setText(R.string.title_connecting);
break;
case BluetoothRfcommClient.STATE_NONE:
mBTStatus.setText(R.string.title_not_connected);
break;
}
break;
case MESSAGE_READ: // todo: implement receive data buffering
byte[] readBuf = (byte[]) msg.obj;
int data_length = msg.arg1;
for(int x=0; x<data_length; x++){
int raw = UByte(readBuf[x]);
if( raw>MAX_LEVEL ){
if( raw==DATA_START ){
bDataAvailable = true;
dataIndex = 0; dataIndex1=0; dataIndex2=0;
}
else if( (raw==DATA_END) || (dataIndex>=MAX_SAMPLES) ){
bDataAvailable = false;
dataIndex = 0; dataIndex1=0; dataIndex2=0;
mWaveform.set_data(ch1_data, ch2_data);
if(bReady){ // send "REQ_DATA" again
BluetoothOscilloscope.this.sendMessage( new String(new byte[] {REQ_DATA}) );
}
//break;
}
}
else if( (bDataAvailable) && (dataIndex<(MAX_SAMPLES)) ){ // valid data
if((dataIndex++)%2==0) ch1_data[dataIndex1++] = raw; // even data
else ch2_data[dataIndex2++] = raw; // odd data
}
}
break;
case MESSAGE_DEVICE_NAME:
// save the connected device's name
mConnectedDeviceName = msg.getData().getString(DEVICE_NAME);
Toast.makeText(getApplicationContext(), "Connected to "
+ mConnectedDeviceName, Toast.LENGTH_SHORT).show();
break;
case MESSAGE_TOAST:
Toast.makeText(getApplicationContext(), msg.getData().getString(TOAST),
Toast.LENGTH_SHORT).show();
break;
}
}
// signed to unsigned
private int UByte(byte b){
if(b<0) // if negative
return (int)( (b&0x7F) + 128 );
else
return (int)b;
}
};
public void onActivityResult(int requestCode, int resultCode, Intent data){
switch (requestCode) {
case REQUEST_CONNECT_DEVICE:
// When DeviceListActivity returns with a device to connect
if (resultCode == Activity.RESULT_OK){
// Get the device MAC address
String address = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
// Get the BLuetoothDevice object
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
// Attempt to connect to the device
mRfcommClient.connect(device);
}
break;
case REQUEST_ENABLE_BT:
// When the request to enable Bluetooth returns
if (resultCode == Activity.RESULT_OK){
// Bluetooth is now enabled, so set up the oscilloscope
setupOscilloscope();
}else{
// User did not enable Bluetooth or an error occured
Toast.makeText(this, R.string.bt_not_enabled_leaving, Toast.LENGTH_SHORT).show();
finish();
}
break;
}
}
}
| 064sasa-androscope | AndroidBluetoothOscilloscope/src/org/projectproto/yuscope/BluetoothOscilloscope.java | Java | asf20 | 15,481 |
/***************************************
*
* Android Bluetooth Oscilloscope
* yus - projectproto.blogspot.com
* September 2010
*
***************************************/
package org.projectproto.yuscope;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
/**
*
**/
public class BluetoothRfcommClient {
// Unique UUID for this application
private static final UUID MY_UUID =
//UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");
UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
// Member fields
private final BluetoothAdapter mAdapter;
private final Handler mHandler;
private ConnectThread mConnectThread;
private ConnectedThread mConnectedThread;
private int mState;
// Constants that indicate the current connection state
public static final int STATE_NONE = 0; // we're doing nothing
//public static final int STATE_LISTEN = 1; // now listening for incoming connections
public static final int STATE_CONNECTING = 2; // now initiating an outgoing connection
public static final int STATE_CONNECTED = 3; // now connected to a remote device
/**
* Constructor. Prepares a new BluetoothChat session.
* - context - The UI Activity Context
* - handler - A Handler to send messages back to the UI Activity
*/
public BluetoothRfcommClient(Context context, Handler handler) {
mAdapter = BluetoothAdapter.getDefaultAdapter();
mState = STATE_NONE;
mHandler = handler;
}
/**
* Set the current state o
* */
private synchronized void setState(int state) {
mState = state;
// Give the new state to the Handler so the UI Activity can update
mHandler.obtainMessage(BluetoothOscilloscope.MESSAGE_STATE_CHANGE, state, -1).sendToTarget();
}
/**
* Return the current connection state. */
public synchronized int getState() {
return mState;
}
/**
* Start the Rfcomm client service.
* */
public synchronized void start() {
// Cancel any thread attempting to make a connection
if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}
// Cancel any thread currently running a connection
if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}
setState(STATE_NONE);
}
/**
* Start the ConnectThread to initiate a connection to a remote device.
* - device - The BluetoothDevice to connect
*/
public synchronized void connect(BluetoothDevice device) {
// Cancel any thread attempting to make a connection
if (mState == STATE_CONNECTING) {
if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}
}
// Cancel any thread currently running a connection
if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}
// Start the thread to connect with the given device
mConnectThread = new ConnectThread(device);
mConnectThread.start();
setState(STATE_CONNECTING);
}
/**
* Start the ConnectedThread to begin managing a Bluetooth connection
* - socket - The BluetoothSocket on which the connection was made
* - device - The BluetoothDevice that has been connected
*/
public synchronized void connected(BluetoothSocket socket, BluetoothDevice device) {
// Cancel the thread that completed the connection
if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}
// Cancel any thread currently running a connection
if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}
// Start the thread to manage the connection and perform transmissions
mConnectedThread = new ConnectedThread(socket);
mConnectedThread.start();
// Send the name of the connected device back to the UI Activity
Message msg = mHandler.obtainMessage(BluetoothOscilloscope.MESSAGE_DEVICE_NAME);
Bundle bundle = new Bundle();
bundle.putString(BluetoothOscilloscope.DEVICE_NAME, device.getName());
msg.setData(bundle);
mHandler.sendMessage(msg);
setState(STATE_CONNECTED);
}
/**
* Stop all threads
*/
public synchronized void stop() {
if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}
if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}
setState(STATE_NONE);
}
/**
* Write to the ConnectedThread in an unsynchronized manner
* - out - The bytes to write - ConnectedThread#write(byte[])
*/
public void write(byte[] out) {
// Create temporary object
ConnectedThread r;
// Synchronize a copy of the ConnectedThread
synchronized (this) {
if (mState != STATE_CONNECTED) return;
r = mConnectedThread;
}
// Perform the write unsynchronized
r.write(out);
}
/**
* Indicate that the connection attempt failed and notify the UI Activity.
*/
private void connectionFailed() {
setState(STATE_NONE);
// Send a failure message back to the Activity
Message msg = mHandler.obtainMessage(BluetoothOscilloscope.MESSAGE_TOAST);
Bundle bundle = new Bundle();
bundle.putString(BluetoothOscilloscope.TOAST, "Unable to connect device");
msg.setData(bundle);
mHandler.sendMessage(msg);
}
/**
* Indicate that the connection was lost and notify the UI Activity.
*/
private void connectionLost() {
setState(STATE_NONE);
// Send a failure message back to the Activity
Message msg = mHandler.obtainMessage(BluetoothOscilloscope.MESSAGE_TOAST);
Bundle bundle = new Bundle();
bundle.putString(BluetoothOscilloscope.TOAST, "Device connection was lost");
msg.setData(bundle);
mHandler.sendMessage(msg);
}
/**
* This thread runs while attempting to make an outgoing connection
* with a device. It runs straight through; the connection either
* succeeds or fails.
*/
private class ConnectThread extends Thread {
private final BluetoothSocket mmSocket;
private final BluetoothDevice mmDevice;
public ConnectThread(BluetoothDevice device) {
mmDevice = device;
BluetoothSocket tmp = null;
// Get a BluetoothSocket for a connection with the given BluetoothDevice
try {
tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) {
//
}
mmSocket = tmp;
}
public void run() {
setName("ConnectThread");
// Always cancel discovery because it will slow down a connection
mAdapter.cancelDiscovery();
// Make a connection to the BluetoothSocket
try {
// This is a blocking call and will only return on a successful connection or an exception
mmSocket.connect();
} catch (IOException e) {
connectionFailed();
// Close the socket
try {
mmSocket.close();
} catch (IOException e2) {
//
}
// Start the service over to restart listening mode
BluetoothRfcommClient.this.start();
return;
}
// Reset the ConnectThread because we're done
synchronized (BluetoothRfcommClient.this) {
mConnectThread = null;
}
// Start the connected thread
connected(mmSocket, mmDevice);
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
//
}
}
}
/**
* This thread runs during a connection with a remote device.
* It handles all incoming and outgoing transmissions.
*/
private class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInStream;
private final OutputStream mmOutStream;
public ConnectedThread(BluetoothSocket socket) {
mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;
// Get the BluetoothSocket input and output streams
try {
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
} catch (IOException e) {
}
mmInStream = tmpIn;
mmOutStream = tmpOut;
}
public void run() {
byte[] buffer = new byte[1024];
int bytes;
// Keep listening to the InputStream while connected
while (true) {
try {
// Read from the InputStream
bytes = mmInStream.read(buffer);
// Send the obtained bytes to the UI Activity
mHandler.obtainMessage(BluetoothOscilloscope.MESSAGE_READ, bytes, -1, buffer)
.sendToTarget();
} catch (IOException e) {
//
connectionLost();
break;
}
}
}
/**
* Write to the connected OutStream.
*/
public void write(byte[] buffer) {
try {
mmOutStream.write(buffer);
// Share the sent message back to the UI Activity
mHandler.obtainMessage(BluetoothOscilloscope.MESSAGE_WRITE, -1, -1, buffer)
.sendToTarget();
} catch (IOException e) {
//
}
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
//
}
}
}
}
| 064sasa-androscope | AndroidBluetoothOscilloscope/src/org/projectproto/yuscope/BluetoothRfcommClient.java | Java | asf20 | 10,507 |
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.projectproto.yuscope;
import java.util.Set;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
/**
* This Activity appears as a dialog. It lists any paired devices and
* devices detected in the area after discovery. When a device is chosen
* by the user, the MAC address of the device is sent back to the parent
* Activity in the result Intent.
*/
public class DeviceListActivity extends Activity {
// Return Intent extra
public static String EXTRA_DEVICE_ADDRESS = "device_address";
// Member fields
private BluetoothAdapter mBtAdapter;
private ArrayAdapter<String> mPairedDevicesArrayAdapter;
private ArrayAdapter<String> mNewDevicesArrayAdapter;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
// Setup the window
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.device_list);
// Set result CANCELED incase the user backs out
setResult(Activity.RESULT_CANCELED);
// Initialize the button to perform device discovery
Button scanButton = (Button) findViewById(R.id.button_scan);
scanButton.setOnClickListener(new OnClickListener(){
public void onClick(View v){
doDiscovery();
v.setVisibility(View.GONE);
}
});
// Initialize array adapters. One for already paired devices and
// one for newly discovered devices
mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
// Find and set up the ListView for paired devices
ListView pairedListView = (ListView) findViewById(R.id.paired_devices);
pairedListView.setAdapter(mPairedDevicesArrayAdapter);
pairedListView.setOnItemClickListener(mDeviceClickListener);
// Find and set up the ListView for newly discovered devices
ListView newDevicesListView = (ListView) findViewById(R.id.new_devices);
newDevicesListView.setAdapter(mNewDevicesArrayAdapter);
newDevicesListView.setOnItemClickListener(mDeviceClickListener);
// Register for broadcasts when a device is discovered
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
this.registerReceiver(mReceiver, filter);
// Register for broadcasts when discovery has finished
filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
this.registerReceiver(mReceiver, filter);
// Get the local Bluetooth adapter
mBtAdapter = BluetoothAdapter.getDefaultAdapter();
// Get a set of currently paired devices
Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
// If there are paired devices, add each one to the ArrayAdapter
if (pairedDevices.size() > 0){
findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
for (BluetoothDevice device : pairedDevices){
mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
}else{
String noDevices = getResources().getText(R.string.none_paired).toString();
mPairedDevicesArrayAdapter.add(noDevices);
}
}
@Override
protected void onDestroy(){
super.onDestroy();
// Make sure we're not doing discovery anymore
if (mBtAdapter != null) {
mBtAdapter.cancelDiscovery();
}
// Unregister broadcast listeners
this.unregisterReceiver(mReceiver);
}
/**
* Start device discover with the BluetoothAdapter
*/
private void doDiscovery(){
// Indicate scanning in the title
setProgressBarIndeterminateVisibility(true);
setTitle(R.string.scanning);
// Turn on sub-title for new devices
findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);
// If we're already discovering, stop it
if (mBtAdapter.isDiscovering()) {
mBtAdapter.cancelDiscovery();
}
// Request discover from BluetoothAdapter
mBtAdapter.startDiscovery();
}
// The on-click listener for all devices in the ListViews
private OnItemClickListener mDeviceClickListener = new OnItemClickListener(){
public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3){
// Cancel discovery because it's costly and we're about to connect
mBtAdapter.cancelDiscovery();
// Get the device MAC address, which is the last 17 chars in the View
String info = ((TextView) v).getText().toString();
String address = info.substring(info.length() - 17);
// Create the result Intent and include the MAC address
Intent intent = new Intent();
intent.putExtra(EXTRA_DEVICE_ADDRESS, address);
// Set result and finish this Activity
setResult(Activity.RESULT_OK, intent);
finish();
}
};
// The BroadcastReceiver that listens for discovered devices and
// changes the title when discovery is finished
private final BroadcastReceiver mReceiver = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent){
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)){
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// If it's already paired, skip it, because it's been listed already
if (device.getBondState() != BluetoothDevice.BOND_BONDED){
mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
}
// When discovery is finished, change the Activity title
else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)){
setProgressBarIndeterminateVisibility(false);
setTitle(R.string.select_device);
if (mNewDevicesArrayAdapter.getCount() == 0){
String noDevices = getResources().getText(R.string.none_found).toString();
mNewDevicesArrayAdapter.add(noDevices);
}
}
}
};
}
| 064sasa-androscope | AndroidBluetoothOscilloscope/src/org/projectproto/yuscope/DeviceListActivity.java | Java | asf20 | 7,793 |
/***************************************
*
* Android Bluetooth Oscilloscope
* yus - projectproto.blogspot.com
* September 2010
*
***************************************/
package org.projectproto.yuscope;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public class WaveformView extends SurfaceView implements SurfaceHolder.Callback{
// plot area size
private final static int WIDTH = 320;
private final static int HEIGHT = 240;
private static int[] ch1_data = new int[WIDTH];
private static int[] ch2_data = new int[WIDTH];
private static int ch1_pos = 100; //HEIGHT/2;
private static int ch2_pos = 140; //HEIGHT/2;
private WaveformPlotThread plot_thread;
private Paint ch1_color = new Paint();
private Paint ch2_color = new Paint();
private Paint grid_paint = new Paint();
private Paint cross_paint = new Paint();
private Paint outline_paint = new Paint();
public WaveformView(Context context, AttributeSet attrs){
super(context, attrs);
getHolder().addCallback(this);
// initial values
for(int x=0; x<WIDTH; x++){
ch1_data[x] = ch1_pos;
ch2_data[x] = ch2_pos;
}
plot_thread = new WaveformPlotThread(getHolder(), this);
ch1_color.setColor(Color.YELLOW);
ch2_color.setColor(Color.RED);
grid_paint.setColor(Color.rgb(100, 100, 100));
cross_paint.setColor(Color.rgb(70, 100, 70));
outline_paint.setColor(Color.GREEN);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height){
}
@Override
public void surfaceCreated(SurfaceHolder holder){
plot_thread.setRunning(true);
plot_thread.start();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder){
boolean retry = true;
plot_thread.setRunning(false);
while (retry){
try{
plot_thread.join();
retry = false;
}catch(InterruptedException e){
}
}
}
@Override
public void onDraw(Canvas canvas){
PlotPoints(canvas);
}
public void set_data(int[] data1, int[] data2 ){
plot_thread.setRunning(false);
for(int x=0; x<WIDTH; x++){
// channel 1
if(x<(data1.length)){
ch1_data[x] = HEIGHT-data1[x]+1;
}else{
ch1_data[x] = ch1_pos;
}
// channel 2
if(x<(data1.length)){
ch2_data[x] = HEIGHT-data2[x]+1;
}else{
ch2_data[x] = ch2_pos;
}
}
plot_thread.setRunning(true);
}
public void PlotPoints(Canvas canvas){
// clear screen
canvas.drawColor(Color.rgb(20, 20, 20));
// draw vertical grids
for(int vertical = 1; vertical<10; vertical++){
canvas.drawLine(
vertical*(WIDTH/10)+1, 1,
vertical*(WIDTH/10)+1, HEIGHT+1,
grid_paint);
}
// draw horizontal grids
for(int horizontal = 1; horizontal<10; horizontal++){
canvas.drawLine(
1, horizontal*(HEIGHT/10)+1,
WIDTH+1, horizontal*(HEIGHT/10)+1,
grid_paint);
}
// draw outline
canvas.drawLine(0, 0, (WIDTH+1), 0, outline_paint); // top
canvas.drawLine((WIDTH+1), 0, (WIDTH+1), (HEIGHT+1), outline_paint); //right
canvas.drawLine(0, (HEIGHT+1), (WIDTH+1), (HEIGHT+1), outline_paint); // bottom
canvas.drawLine(0, 0, 0, (HEIGHT+1), outline_paint); //left
// plot data
for(int x=0; x<(WIDTH-1); x++){
canvas.drawLine(x+1, ch2_data[x], x+2, ch2_data[x+1], ch2_color);
canvas.drawLine(x+1, ch1_data[x], x+2, ch1_data[x+1], ch1_color);
}
}
}
| 064sasa-androscope | AndroidBluetoothOscilloscope/src/org/projectproto/yuscope/WaveformView.java | Java | asf20 | 3,558 |
#ifndef _TIMER_H_
#define _TIMER_H_
#define FCY 40000000 // 40MIPS
#define SAMPLES_PER_DIV 32
#define PERIOD_5us (unsigned int)(FCY * 5E-6 / SAMPLES_PER_DIV ) // 6
#define PERIOD_10us (unsigned int)(FCY * 10E-6 / SAMPLES_PER_DIV ) // 12
#define PERIOD_20us (unsigned int)(FCY * 20E-6 / SAMPLES_PER_DIV )
#define PERIOD_50us (unsigned int)(FCY * 50E-6 / SAMPLES_PER_DIV )
#define PERIOD_100us (unsigned int)(FCY * 100E-6 / SAMPLES_PER_DIV )
#define PERIOD_200us (unsigned int)(FCY * 200E-6 / SAMPLES_PER_DIV )
#define PERIOD_500us (unsigned int)(FCY * 500E-6 / SAMPLES_PER_DIV )
#define PERIOD_1ms (unsigned int)(FCY * 1E-3 / SAMPLES_PER_DIV )
#define PERIOD_2ms (unsigned int)(FCY * 2E-3 / SAMPLES_PER_DIV )
#define PERIOD_5ms (unsigned int)(FCY * 5E-3 / SAMPLES_PER_DIV )
#define PERIOD_10ms (unsigned int)(FCY * 10E-3 / SAMPLES_PER_DIV ) // 12500
#define PERIOD_20ms (unsigned int)(FCY * 20E-3 / SAMPLES_PER_DIV )
#define PERIOD_50ms (unsigned int)(FCY * 50E-3 / SAMPLES_PER_DIV ) // 62500
extern volatile unsigned int sampling_period;
extern const unsigned int PERIODS[];
extern void timer1_init(void);
extern void set_sampling_period(unsigned int period);
#endif // _TIMER_H_
| 064sasa-androscope | RemoteDevice/dsPIC Bluetooth Oscilloscope/timer.h | C | asf20 | 1,227 |
#include "p33fxxxx.h"
#include "adc.h"
#include "timer.h"
volatile unsigned int adc_value_1;
volatile unsigned int adc_value_2;
volatile unsigned int raw_data[MAX_SAMPLES];
volatile unsigned int samples_count;
const long VOLT_PER_DIV[]={
SCALE_10mV,
SCALE_20mV,
SCALE_50mV,
SCALE_100mV,
SCALE_200mV,
SCALE_500mV,
SCALE_1V,
SCALE_2V,
SCALE_GND
};
void adc_init(void)
{
ADCONbits.ADON = 0; // Temporarily Turn off ADC to allow for initialization settings
aux_pll_init();
ADCONbits.FORM = 0; // Output in Integer Format
ADCONbits.EIE = 1; // Enable Early Interrupt (7TAD)
//ADCONbits.ORDER = 0; // Normal Order of conversion
//ADCONbits.SEQSAMP = 0; // Simultaneous sampling
ADCONbits.ASYNCSAMP = 1; // Asynchronous sampling
ADCONbits.SLOWCLK = 0; // High Frequency Clock input (use aux pll)
ADCONbits.ADCS = 0; //5; // Clock divider selection
ADCPC1bits.TRGSRC2 = 0b01100; // Timer1 period match (trigger source)
ADPCFGbits.PCFG4 = 0; // AN4 is configured as analog input
ADPCFGbits.PCFG5 = 0; // AN5 is configured as analog input
IPC28bits.ADCP2IP = 0x01; // Set ADC Pair 2 Interrupt Priority (Level 1)
IFS7bits.ADCP2IF = 0; // Clear ADC Pair 2 Interrupt Flag
//IEC7bits.ADCP2IE = 1; // Enable ADC Pair 2 Interrupt
ADCONbits.ADON = 1; // Enable ADC module
}
/* ADC Pair 2 ISR*/
void __attribute__((interrupt, no_auto_psv)) _ADCP2Interrupt (void)
{
raw_data[samples_count++] = ADCBUF4; // Read AN4 conversion result;
raw_data[samples_count++] = ADCBUF5; // Read AN5 conversion result;
IFS7bits.ADCP2IF = 0; // Clear ADC Pair 2 Interrupt Flag
}
void store_raw_data(void)
{
unsigned int total_samples;
total_samples = get_total_samples();
samples_count = 0; // reset counter
//IEC0bits.U1RXIE = 0; // disable RX interrupt
IEC7bits.ADCP2IE = 1; // enable ADC Pair 2 Interrupt
TMR1 = 0x0000; // reset timer 1
T1CONbits.TON = 1; // Starts 16-bit Timer1
while(samples_count<total_samples); // wait until samples are completed
IEC7bits.ADCP2IE = 0; // disable ADC Pair 2 Interrupt
T1CONbits.TON = 0; // Stops 16-bit Timer1
//IEC0bits.U1RXIE = 1; // Enable RX interrupt
}
unsigned int get_total_samples(void)
{
if(sampling_period==PERIOD_5us)
return (MAX_SAMPLES/4);
else if(sampling_period==PERIOD_10us)
return (MAX_SAMPLES/2);
else
return (MAX_SAMPLES);
}
void aux_pll_init(void)
{
ACLKCONbits.FRCSEL = 1; // Internal FRC is clock source for auxiliary PLL
ACLKCONbits.ENAPLL = 1; // APLL is enabled
ACLKCONbits.SELACLK = 1; // Auxiliary PLL provides the source clock for the clock divider
ACLKCONbits.APSTSCLR = 7; // Auxiliary Clock Output Divider is Divide by 1
while(ACLKCONbits.APLLCK != 1){}; // Wait for Auxiliary PLL to Lock
}
| 064sasa-androscope | RemoteDevice/dsPIC Bluetooth Oscilloscope/adc.c | C | asf20 | 2,805 |
/************************************
Bluetooth Oscilloscope
yus - projectproto.blogspot.com
September 2010
*************************************/
#include "main.h"
_FOSCSEL(FNOSC_FRC); // Select Internal FRC at POR
_FOSC(FCKSM_CSECMD & OSCIOFNC_OFF); // Enable Clock Switching and Configure
_FICD(ICS_PGD1 & JTAGEN_OFF);
int main(void)
{
unsigned char c;
osc_init();
port_init();
ser_init();
adc_init();
timer1_init();
//initial values;
ch1_position = 120;
ch2_position = 120;
ch1_gain = VOLT_PER_DIV[4];
ch2_gain = VOLT_PER_DIV[5];
while(1)
{
if(ser_isrx()){
led_off();
c = ser_getch(); //get 1 character from receive buffer
switch(c){
case REQ_DATA:
store_raw_data();
ser_putch(DATA_START);
send_data();
ser_putch(DATA_END);
break;
case ADJ_HORIZONTAL:
c = ser_getch();
if( (c<13) ){
set_sampling_period( PERIODS[c] ); // refer to "timer.h"
}
break;
case ADJ_VERTICAL:
c = ser_getch();
if(c==CHANNEL1) ch1_gain = VOLT_PER_DIV[ser_getch()]; // refer to "adc.h"
else if(c==CHANNEL2) ch2_gain = VOLT_PER_DIV[ser_getch()];
break;
case ADJ_POSITION:
c = ser_getch();
if(c==CHANNEL1) ch1_position = (long)ser_getch() * 6;
else if(c==CHANNEL2) ch2_position = (long)ser_getch() * 6;
break;
default:
break;
} // switch(command)
led_on();
}//if-ser_isrx()
}//while-true
}
void osc_init(void)
{
// Configure PLL prescaler, PLL postscaler, PLL divisor
PLLFBD = 41; // M = 43
CLKDIVbits.PLLPOST=0; // N1 = 2
CLKDIVbits.PLLPRE=0; // N2 = 2
// Initiate Clock Switch to Internal FRC with PLL (NOSC = 0b001)
__builtin_write_OSCCONH(0x01);
__builtin_write_OSCCONL(0x01);
// Wait for Clock switch to occur
while (OSCCONbits.COSC != 0b001);
// Wait for PLL to lock
while(OSCCONbits.LOCK!=1) {};
}
void port_init(void)
{
// LED Pin Configuration:I/O Port RC3; pin 5
PORTCbits.RC3 = 0; // Configure as Output
TRISCbits.TRISC3 = 0; // Configure as Output
LATCbits.LATC3 = 1; // Initialize to zero
RPINR18bits.U1RXR = 28; //RX -> pin 20 (RP28)
RPOR13bits.RP27R = 0b00011; //TX -> pin 19 (RP27)
ADPCFGbits.PCFG4 = 0; // AN4 is configured as analog input
ADPCFGbits.PCFG5 = 0; // AN5 is configured as analog input
}
void send_data(void)
{
#define bits 10
unsigned int i, total;
unsigned int repeat, n;
unsigned char plot_data1, plot_data2;
signed long temp;
total = get_total_samples();
repeat = MAX_SAMPLES / total;
i=0;
while( i<total )
{
/*** CHANNEL 1 ***/
// refer to "adc.xmcd" (mathcad) for the computation
temp = (ch1_position<<bits) / (long)MAX_LEVEL;
temp = (long)OFFSET1 + temp - (long)raw_data[i++];
temp = temp * (long)MAX_LEVEL * ch1_gain;
temp = (temp>>bits) + (ch1_position<<2) - (ch1_position*ch1_gain);
temp = temp>>2;
plot_data1 = clamp_value( temp );
/*** CHANNEL 2 ***/
temp = (ch2_position<<bits) / (long)MAX_LEVEL;
temp = (long)OFFSET2 + temp - (long)raw_data[i++];
temp = temp * (long)MAX_LEVEL * ch2_gain;
temp = (temp>>bits) + (ch2_position<<2) - (ch2_position*ch2_gain);
temp = temp>>2;
plot_data2 = clamp_value( temp );
n=repeat;
while(n--){
ser_putch( plot_data1 );
ser_putch( plot_data2 );
}
}
}
unsigned char clamp_value(long value)
{
if(value<0)
return 0;
else if (value>(long)MAX_LEVEL)
return ((unsigned char) MAX_LEVEL);
else
return (unsigned char) value;
}
| 064sasa-androscope | RemoteDevice/dsPIC Bluetooth Oscilloscope/main.c | C | asf20 | 3,588 |
#define _SER_C_
#include "p33fxxxx.h"
#include "ser.h"
unsigned char txfifo[SER_BUFFER_SIZE];
volatile unsigned char txiptr, txoptr;
unsigned char rxfifo[SER_BUFFER_SIZE];
volatile unsigned char rxiptr, rxoptr;
unsigned char ser_tmp;
void ser_init(void)
{
//RPINR18bits.U1RXR = 28; //RX -> pin 20 (RP28)
//RPOR13bits.RP27R = 0b00011; //TX -> pin 19 (RP27)
U1MODEbits.STSEL = 0; // 1-stop bit
U1MODEbits.PDSEL = 0; // No Parity, 8-data bits
U1MODEbits.ABAUD = 0; // Auto-Baud Disabled
U1MODEbits.BRGH = 1; //High-Speed mode
U1BRG = BRGVAL; // BAUD Rate Setting
U1STAbits.UTXISEL0 = 0; // Interrupt after one Tx character is transmitted
U1STAbits.UTXISEL1 = 0;
U1STAbits.URXISEL = 0b00; // Interrupt after one RX character is received;
IEC0bits.U1RXIE = 1; //Enable RX interrupt
U1MODEbits.UARTEN = 1; // Enable UART
U1STAbits.UTXEN = 1; // Enable UART Tx
//set ring pointers to empty (zero receive/transmit)
rxiptr=rxoptr=txiptr=txoptr=0;
}
void ser_putch(unsigned char byte)
{
// wait until buffer has an empty slot.
//while (((txiptr+1) & SER_FIFO_MASK)==txoptr)
while (U1STAbits.UTXBF)
continue;
txfifo[txiptr] = byte; //place character in buffer
//increase ring input pointer and set it to zer0 if
//it has rolled-it over.
txiptr=(txiptr+1) & SER_FIFO_MASK;
IEC0bits.U1TXIE = 1; //enable interrupt driven
//serial transmission
}
void ser_puts(unsigned char * s)
{
while(*s) //while pointer s is not at end of string
ser_putch(*s++); // send the current character,
// then increment pointer
}
void ser_puthex(unsigned char v)
{
unsigned char c; //define temp variable
c = v >> 4; //get the high nibble and place it in c
if (c>9) { //if more than 9
ser_putch('A'-10+c); // send the difference from 10 + 'A'
} else { //else
ser_putch('0'+c); // send '0' + the high nibble
}
c = v & 0x0F; //get the lower nibble
if (c>9) { //process the character
ser_putch('A'-10+c); //and send it same as above
} else { //
ser_putch('0'+c); //
}
}
unsigned char ser_isrx(void)
{
if(U1STAbits.OERR) //error in reception?
{
U1STAbits.OERR = 0; //must clear the overrun error to keep uart receiving
return 0; // return no characters in buffer
}
return (rxiptr!=rxoptr); //checks buffer if char is present
}
unsigned char ser_getch(void)
{
unsigned char c; //define
while (ser_isrx()==0) //wait until a character is present
continue; //
c=rxfifo[rxoptr]; //get oldest character received
++rxoptr; //move the pointer to discard buffer
rxoptr &= SER_FIFO_MASK; //if the pointer is at end, roll-it over.
return c; //return it
}
void __attribute__((interrupt, no_auto_psv)) _U1TXInterrupt(void)
{
U1TXREG = txfifo[txoptr];
++txoptr;
txoptr &= SER_FIFO_MASK;
if (txoptr==txiptr) IEC0bits.U1TXIE = 0;
}
void __attribute__((interrupt, no_auto_psv)) _U1RXInterrupt(void)
{
rxfifo[rxiptr]=U1RXREG;
ser_tmp=(rxiptr+1) & SER_FIFO_MASK;
if (ser_tmp!=rxoptr) rxiptr=ser_tmp;
IFS0bits.U1RXIF = 0;
}
| 064sasa-androscope | RemoteDevice/dsPIC Bluetooth Oscilloscope/ser.c | C | asf20 | 3,132 |
#include "p33fxxxx.h"
#include "timer.h"
volatile unsigned int sampling_period;
const unsigned int PERIODS[]={
PERIOD_5us,
PERIOD_10us,
PERIOD_20us,
PERIOD_50us,
PERIOD_100us,
PERIOD_200us,
PERIOD_500us,
PERIOD_1ms,
PERIOD_2ms,
PERIOD_5ms,
PERIOD_10ms,
PERIOD_20ms,
PERIOD_50ms
};
void timer1_init(void)
{
T1CONbits.TON = 0; // Stops 16-bit Timer1
T1CONbits.TCKPS = 0b00; // Timer1 Input Clock Prescale Select bits
T1CONbits.TCS = 0; // Internal clock (FCY)
T1CONbits.TGATE = 0; // Gated time accumulation disabled
set_sampling_period(PERIOD_200us);
//T1CONbits.TON = 1; // Starts 16-bit Timer1
}
void set_sampling_period(unsigned int period)
{
#if 0
PR1 = period;
#else // adc speed limitation
if( (period==PERIOD_5us) || (period==PERIOD_10us) )
PR1 = PERIOD_20us;
else
PR1 = period;
#endif
sampling_period = period;
}
| 064sasa-androscope | RemoteDevice/dsPIC Bluetooth Oscilloscope/timer.c | C | asf20 | 903 |
#include "p33fxxxx.h"
#include "ser.h"
#include "adc.h"
#include "timer.h"
#define MAX_LEVEL 240
#define DATA_START (MAX_LEVEL + 1)
#define DATA_END (MAX_LEVEL + 2)
#define REQ_DATA 0x00
#define ADJ_HORIZONTAL 0x01
#define ADJ_VERTICAL 0x02
#define ADJ_POSITION 0x03
#define CHANNEL1 0x01
#define CHANNEL2 0x02
#define OFFSET1 510 //511
#define OFFSET2 495 //511
#define led_on() PORTCbits.RC3 = 1
#define led_off() PORTCbits.RC3 = 0
void osc_init(void);
void port_init(void);
void store_data(void);
void send_data(void);
unsigned char clamp_value(long value);
long ch1_gain, ch2_gain;
long ch1_position, ch2_position;
| 064sasa-androscope | RemoteDevice/dsPIC Bluetooth Oscilloscope/main.h | C | asf20 | 674 |
#ifndef _SER_H_
#define _SER_H_
#define FCY 40000000 // = Fclk/2
#define BAUDRATE 115200 // bps
#define BRGVAL ((FCY/BAUDRATE)/4)-1 // for high-speed mode
/* Valid buffer size value are only power of 2 (ex: 2,4,..,64,128) */
#define SER_BUFFER_SIZE 64
#define SER_FIFO_MASK (SER_BUFFER_SIZE-1)
extern void ser_init(void);
extern void ser_putch(unsigned char byte);
extern void ser_puts(unsigned char * s);
extern void ser_puthex(unsigned char v);
extern unsigned char ser_isrx(void);
extern unsigned char ser_getch(void);
extern void __attribute__((interrupt, no_auto_psv)) _U1TXInterrupt(void);
extern void __attribute__((interrupt, no_auto_psv)) _U1RXInterrupt(void);
extern unsigned char txfifo[SER_BUFFER_SIZE];
extern volatile unsigned char txiptr, txoptr;
extern unsigned char rxfifo[SER_BUFFER_SIZE];
extern volatile unsigned char rxiptr, rxoptr;
extern unsigned char ser_tmp;
#endif // end _SER_H_
| 064sasa-androscope | RemoteDevice/dsPIC Bluetooth Oscilloscope/ser.h | C | asf20 | 952 |
#ifndef _ADC_H_
#define _ADC_H_
#define MAX_SAMPLES 640 // 320 * 2 channels
#define kSCALE 6.2
#define SCALE_10mV (long)(kSCALE / 0.01)
#define SCALE_20mV (long)(kSCALE / 0.02)
#define SCALE_50mV (long)(kSCALE / 0.05)
#define SCALE_100mV (long)(kSCALE / 0.1)
#define SCALE_200mV (long)(kSCALE / 0.2)
#define SCALE_500mV (long)(kSCALE / 0.5)
#define SCALE_1V (long)(kSCALE / 1.0)
#define SCALE_2V (long)(kSCALE / 2.0)
#define SCALE_GND (long)(0)
extern volatile unsigned int adc_value_1;
extern volatile unsigned int adc_value_2;
extern volatile unsigned int raw_data[MAX_SAMPLES];
extern const long VOLT_PER_DIV[];
extern void adc_init(void);
extern void aux_pll_init(void);
extern void store_raw_data(void);
extern unsigned int get_total_samples(void);
#endif // end _ADC_H_
| 064sasa-androscope | RemoteDevice/dsPIC Bluetooth Oscilloscope/adc.h | C | asf20 | 819 |
/*
Author: Alberto Gil Tesa
WebSite: http://giltesa.com
License: CC BY-NC-SA 3.0
http://goo.gl/CTYnN
Project: Task Calendar
Package: com.giltesa.taskcalendar.activity
File: /TaskCalendar/src/com/giltesa/taskcalendar/activity/NewTask.java
*/
/*
NOTAS DEL ACTIVITY:
Desde este Activity no se realiza ninguna modificacion de las tareas. Simplemente se reciben datos y se devuelven.
Sera el padre, es decir el que llamo a esta tarea, el que se encargue de hacer lo que convenga con esos datos.
Por ejemplo, si es el Activity Main quien abre un NewTask, al hacerlo le enviara los datos, estos pueden ser:
Solo la posicion del tag en la que nos encotrabamos para que aparezca por defecto en el formulario.
O ademas los datos de la tarea si le hemos dado a editar.
En ambos casos cuando se termine esos datos se devolveran al Activity y este hara la insercion, actualizacion o nada.
Esto ha de hacerse asi ya que es la unica forma con la que he sabido refrescar despues la pantalla principal (o la del Activity padre)
*/
package com.giltesa.taskcalendar.activity;
import java.util.ArrayList;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.giltesa.taskcalendar.R;
import com.giltesa.taskcalendar.adapter.TagArrayListAdapter;
import com.giltesa.taskcalendar.helper.PreferenceHelper;
import com.giltesa.taskcalendar.helper.TagHelper;
import com.giltesa.taskcalendar.helper.TaskHelper;
import com.giltesa.taskcalendar.util.Tag;
import com.giltesa.taskcalendar.util.Task;
public class NewTask extends Activity
{
private EditText EditTextTitle;
private EditText EditTextDescription;
private Spinner ListSpinnerTag;
private Bundle dataReceived;
private static TaskHelper taskHelper;
/**
* Al crearse el activity se recuperan todos los controles y se autorellenan si es necesario.
*/
@TargetApi( Build.VERSION_CODES.HONEYCOMB )
@SuppressLint( "NewApi" )
public void onCreate(Bundle savedInstanceState)
{
// Se establece el theme del Activity:
setTheme(new PreferenceHelper(this).getTheme());
super.onCreate(savedInstanceState);
setContentView(R.layout.new_task);
// Activa el icono del ActionBar como boton Return:
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
// Se recuperan los campos del activity:
EditTextTitle = (EditText)findViewById(R.id.main_newtask_title_text);
EditTextDescription = (EditText)findViewById(R.id.main_newtask_description_text);
ListSpinnerTag = (Spinner)findViewById(R.id.main_newtask_tag_spinner);
// Se carga la lista de etiquetas en el Spinner:
ArrayList< Tag > tagArrayList = new TagHelper(this).getTagArrayList();
TagArrayListAdapter tagArrayListAdapter = new TagArrayListAdapter(this, R.layout.settings_tags_listitem_spinner, tagArrayList);
ListSpinnerTag.setAdapter(tagArrayListAdapter);
// Al construirse el activity hay que preconfigurar el formulario segun si le hemos dado a "Nueva tarea" o a "Editar tarea".
dataReceived = getIntent().getBundleExtra("dataActivity");
// En ambos casos se autoselecciona el item del Spinner para que coincida con la ultima pagina vista:
ListSpinnerTag.setSelection(dataReceived.getInt("positionSlider"));
// Ademas si le hemos dado a "Editar Tarea" se mostrara la informacion que ya contuviera la tarea:
if( !dataReceived.getBoolean("isNewTask") )
{
EditTextTitle.setText(dataReceived.getString("title"));
EditTextDescription.setText(dataReceived.getString("description"));
}
taskHelper = new TaskHelper(this);
}
/**
* Se carga el ActionBar en el activity
*/
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.new_task_actionbar, menu);
return true;
}
/**
* Se tratan los eventos de los botones del ActionBar
*/
@SuppressLint( "SimpleDateFormat" )
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch( item.getItemId() )
{
case android.R.id.home:
setResult(Main.BACK, null);
finish();
break;
case R.id.main_newtask_actionbar_save:
if( EditTextTitle.getText().length() == 0 )
{
Toast.makeText(this, getString(R.string.main_newtask_requeridFields), Toast.LENGTH_LONG).show();
}
else
{
Intent intent = new Intent(this, Main.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Bundle dataReturned = new Bundle();
dataReturned.putInt("positionSlider", ListSpinnerTag.getSelectedItemPosition());
intent.putExtra("dataActivity", dataReturned);
Task task = new Task(dataReceived.getInt("id"), ( (Tag)ListSpinnerTag.getSelectedItem() ).getID(), null, EditTextTitle.getText().toString(), EditTextDescription.getText().toString(), null);
if( dataReceived.getBoolean("isNewTask") )
{
taskHelper.insertTask(task);
Toast.makeText(this, getString(R.string.main_newtask_taskInserted), Toast.LENGTH_LONG).show();
}
else
{
taskHelper.updateTask(task);
Toast.makeText(this, getString(R.string.main_newtask_taskUpdated), Toast.LENGTH_LONG).show();
}
startActivity(intent);
}
break;
default:
break;
}
return true;
}
}
| 05-android-task-calendar | TaskCalendar/src/com/giltesa/taskcalendar/activity/NewTask.java | Java | oos | 5,633 |
/*
Author: Alberto Gil Tesa
WebSite: http://giltesa.com
License: CC BY-NC-SA 3.0
http://goo.gl/CTYnN
Project: Task Calendar
Package: com.giltesa.taskcalendar.activity
File: /TaskCalendar/src/com/giltesa/taskcalendar/activity/SettingsAbout.java
*/
package com.giltesa.taskcalendar.activity;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import com.giltesa.taskcalendar.R;
import com.giltesa.taskcalendar.helper.PreferenceHelper;
public class SettingsAbout extends Activity implements OnClickListener
{
protected PreferenceHelper prefs;
/**
*
*/
@TargetApi( Build.VERSION_CODES.HONEYCOMB )
@SuppressLint( "NewApi" )
@Override
public void onCreate(Bundle savedInstanceState)
{
prefs = new PreferenceHelper(this);
setTheme(prefs.getTheme());
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_about);
//Permite que el icono de la barra de name se comporte como el boton atras, y su evento sea tratado desde onOptionsItemSelected()
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
TextView version = (TextView)findViewById(R.id.settings_about_version);
version.setText(getString(R.string.about_version) + " " + prefs.getVersionName());
}
/**
*
*/
public void onClick(View view)
{
if( view.getId() == R.id.settings_about_url )
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_blog_url))));
}
/**
*
*/
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch( item.getItemId() )
{
case android.R.id.home:
finish();
break;
default:
break;
}
return true;
}
}
| 05-android-task-calendar | TaskCalendar/src/com/giltesa/taskcalendar/activity/SettingsAbout.java | Java | oos | 2,035 |
/*
Author: Alberto Gil Tesa
WebSite: http://giltesa.com
License: CC BY-NC-SA 3.0
http://goo.gl/CTYnN
Project: Task Calendar
Package: com.giltesa.taskcalendar.adapter
File: /TaskCalendar/src/com/giltesa/taskcalendar/taskArrayListAdapter/TagArrayListAdapter.java
Class:
public class TagArrayListAdapter
private class TagViewHolder
*/
package com.giltesa.taskcalendar.adapter;
import java.util.ArrayList;
import android.app.Activity;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.giltesa.taskcalendar.R;
import com.giltesa.taskcalendar.util.Tag;
public class TagArrayListAdapter extends ArrayAdapter< Tag >
{
Activity context;
ArrayList< Tag > tagArrayList;
/**
* @param context
* @param tagArrayList
*/
public TagArrayListAdapter(Activity context, ArrayList< Tag > tagArrayList)
{
super(context, R.layout.settings_tags_listitem, tagArrayList);
this.context = context;
this.tagArrayList = tagArrayList;
}
/**
* @param context
* @param simpleSpinnerItem
* @param tagArrayList
*/
public TagArrayListAdapter(Activity context, int simpleSpinnerItem, ArrayList< Tag > tagArrayList)
{
super(context, simpleSpinnerItem, tagArrayList);
this.context = context;
this.tagArrayList = tagArrayList;
}
/**
*
*/
public View getView(int position, View item, ViewGroup parent)
{
TagViewHolder holder;
if( item == null )
{
LayoutInflater inflater = context.getLayoutInflater();
item = inflater.inflate(R.layout.settings_tags_listitem, null);
holder = new TagViewHolder();
holder.id = (TextView)item.findViewById(R.id.tags_listitem_id);
holder.name = (TextView)item.findViewById(R.id.tags_listitem_name);
holder.color = (TextView)item.findViewById(R.id.tags_listitem_color);
holder.counter = (TextView)item.findViewById(R.id.tags_listitem_counter);
item.setTag(holder);
}
else
{
holder = (TagViewHolder)item.getTag();
}
holder.id.setText(tagArrayList.get(position).getID() + "");
holder.name.setText(tagArrayList.get(position).getName());
holder.color.setBackgroundColor(Color.parseColor(tagArrayList.get(position).getColor()));
holder.counter.setText(tagArrayList.get(position).getCounter() + " " + context.getResources().getString(R.string.settings_tags_task));
return( item );
}
/**
* Clase TagViewHolder
*/
private class TagViewHolder
{
public TextView id;
public TextView name;
public TextView color;
public TextView counter;
}
}
| 05-android-task-calendar | TaskCalendar/src/com/giltesa/taskcalendar/adapter/TagArrayListAdapter.java | Java | oos | 2,817 |
/*
Author: Alberto Gil Tesa
WebSite: http://giltesa.com
License: CC BY-NC-SA 3.0
http://goo.gl/CTYnN
Project: Task Calendar
Package: com.giltesa.taskcalendar.adapter
File: /TaskCalendar/src/com/giltesa/taskcalendar/taskArrayListAdapter/TagArrayListAdapter.java
Class:
public class BackupArrayAdapter
private class BackupViewHolder
*/
package com.giltesa.taskcalendar.adapter;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.giltesa.taskcalendar.R;
import com.giltesa.taskcalendar.util.Backup;
public class BackupArrayAdapter extends ArrayAdapter< Backup >
{
Activity context;
Backup[] arrayBackups;
/**
* @param context
* @param backup
*/
public BackupArrayAdapter(Activity context, Backup[] backup)
{
super(context, R.layout.settings_backup_listitem, backup);
this.context = context;
this.arrayBackups = backup;
}
/**
*
*/
public View getView(int position, View item, ViewGroup parent)
{
BackupViewHolder holder;
if( item == null )
{
LayoutInflater inflater = context.getLayoutInflater();
item = inflater.inflate(R.layout.settings_backup_listitem, null);
holder = new BackupViewHolder();
holder.date = (TextView)item.findViewById(R.id.backup_listitem_date);
holder.length = (TextView)item.findViewById(R.id.backup_listitem_length);
item.setTag(holder);
}
else
{
holder = (BackupViewHolder)item.getTag();
}
holder.date.setText(arrayBackups[position].getDate());
holder.length.setText(arrayBackups[position].getLength());
return( item );
}
/**
* Clase TagViewHolder:
*/
private class BackupViewHolder
{
public TextView date;
public TextView length;
}
}
| 05-android-task-calendar | TaskCalendar/src/com/giltesa/taskcalendar/adapter/BackupArrayAdapter.java | Java | oos | 1,985 |
/*
Author: Alberto Gil Tesa
WebSite: http://giltesa.com
License: CC BY-NC-SA 3.0
http://goo.gl/CTYnN
Project: Task Calendar
Package: com.giltesa.taskcalendar.adapter
File: /TaskCalendar/src/com/giltesa/taskcalendar/taskArrayListAdapter/TaskArrayListAdapter.java
Class:
public class TaskArrayListAdapter
private class TaskViewHolder
*/
package com.giltesa.taskcalendar.adapter;
import java.util.ArrayList;
import android.app.Activity;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.giltesa.taskcalendar.R;
import com.giltesa.taskcalendar.util.Task;
public class TaskArrayListAdapter extends ArrayAdapter< Task >
{
Activity context;
ArrayList< Task > taskArrayList;
/**
* @param context
* @param tasks
*/
public TaskArrayListAdapter(Activity context, ArrayList< Task > taskArrayList)
{
super(context, R.layout.settings_tags_listitem, taskArrayList);
this.context = context;
this.taskArrayList = taskArrayList;
}
/**
* @param context
* @param simpleSpinnerItem
* @param tasks
*/
public TaskArrayListAdapter(Activity context, int simpleSpinnerItem, ArrayList< Task > taskArrayList)
{
super(context, simpleSpinnerItem, taskArrayList);
this.context = context;
this.taskArrayList = taskArrayList;
}
/**
*
*/
public View getView(int position, View item, ViewGroup parent)
{
TaskViewHolder holder;
if( item == null )
{
LayoutInflater inflater = context.getLayoutInflater();
item = inflater.inflate(R.layout.main_tasks_listitem, null);
holder = new TaskViewHolder();
holder.id = (TextView)item.findViewById(R.id.task_listitem_id);
holder.idTag = (TextView)item.findViewById(R.id.task_listitem_idTag);
holder.date = (TextView)item.findViewById(R.id.task_listitem_date);
holder.title = (TextView)item.findViewById(R.id.task_listitem_title);
holder.description = (TextView)item.findViewById(R.id.task_listitem_description);
holder.color = (TextView)item.findViewById(R.id.task_listitem_color);
item.setTag(holder);
}
else
{
holder = (TaskViewHolder)item.getTag();
}
holder.id.setText(taskArrayList.get(position).getID() + "");
holder.idTag.setText(taskArrayList.get(position).getIDTag() + "");
holder.date.setText(taskArrayList.get(position).getDate());
holder.title.setText(taskArrayList.get(position).getTitle());
holder.description.setText(taskArrayList.get(position).getDescription());
holder.color.setBackgroundColor(Color.parseColor(taskArrayList.get(position).getColor()));
return( item );
}
/**
* Clase TaskViewHolder:
*/
private class TaskViewHolder
{
public TextView id;
public TextView idTag;
public TextView date;
public TextView title;
public TextView description;
public TextView color;
}
}
| 05-android-task-calendar | TaskCalendar/src/com/giltesa/taskcalendar/adapter/TaskArrayListAdapter.java | Java | oos | 3,119 |
/*
Author: Alberto Gil Tesa
WebSite: http://giltesa.com
License: CC BY-NC-SA 3.0
http://goo.gl/CTYnN
Project: Task Calendar
Package: com.giltesa.taskcalendar.util
File: /TaskCalendar/src/com/giltesa/taskcalendar/helper/PreferenceHelper.java
*/
package com.giltesa.taskcalendar.helper;
import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.preference.PreferenceManager;
import com.giltesa.taskcalendar.R;
public final class PreferenceHelper
{
private Activity context;
private static final String PREF_SORT = "main_menu_settings_app_sortTasksBy_key";
private static final String PREF_THEME = "main_menu_settings_app_theme_key";
private static final String PREF_EXIT = "main_menu_settings_app_confirmExit_key";
private static final String PREF_DIR = "main_menu_settings_calendar_directoryStorage_key";
//private static final String PREF_ABOUT = "main_menu_settings_about_about_key";
//private static final String PREF_SHARE = "main_menu_settings_about_share_key";
/**
* @param context
*/
public PreferenceHelper(Activity context)
{
this.context = context;
}
/**
* @return
*/
public String getSortTask()
{
String order = PreferenceManager.getDefaultSharedPreferences(context).getString(PREF_SORT, "");
String result = "";
String[] listOrders = context.getResources().getStringArray(R.array.main_menu_settings_app_sortTasksBy_listOptions);
if( order.equals(listOrders[0]) ) // Oldest first
result += "ORDER BY creation_date ASC";
else if( order.equals(listOrders[1]) ) // Newest first
result += "ORDER BY creation_date DESC";
return result;
}
/**
* @return
*/
public int getTheme()
{
String[] listThemes = context.getResources().getStringArray(R.array.main_menu_settings_app_theme_listOptions);
String theme = PreferenceManager.getDefaultSharedPreferences(context).getString(PREF_THEME, "");
if( theme.equals(listThemes[0]) )
return android.R.style.Theme_Holo;
else
return android.R.style.Theme_Holo_Light_DarkActionBar;
}
/**
* @return
*/
public boolean isConfirmExit()
{
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(PREF_EXIT, false);
}
/**
* @return
*/
public String getDirectory()
{
return PreferenceManager.getDefaultSharedPreferences(context).getString(PREF_DIR, context.getResources().getString(R.string.main_menu_settings_calendar_directoryStorage_defaultValue));
}
/**
* @return
*/
public String getVersionName()
{
PackageManager pm = context.getPackageManager();
try
{
PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
return pi.versionName;
}
catch( NameNotFoundException e )
{
return "";
}
}
}
| 05-android-task-calendar | TaskCalendar/src/com/giltesa/taskcalendar/helper/PreferenceHelper.java | Java | oos | 3,011 |
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.giltesa.taskcalendar.util;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.SweepGradient;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
public class ColorPickerDialog extends Dialog
{
public interface OnColorChangedListener
{
void colorChanged(int color);
}
private OnColorChangedListener mListener;
private int mInitialColor;
private static class ColorPickerView extends View
{
private Paint mPaint;
private Paint mCenterPaint;
private final int[] mColors;
private OnColorChangedListener mListener;
ColorPickerView(Context c, OnColorChangedListener l, int color)
{
super(c);
mListener = l;
mColors = new int[] { 0xFFFF0000, 0xFFFF00FF, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00, 0xFFFFFF00, 0xFFFF0000 };
Shader s = new SweepGradient(0, 0, mColors, null);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setShader(s);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(60);//32
mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCenterPaint.setColor(color);
mCenterPaint.setStrokeWidth(5);
}
private boolean mTrackingCenter;
private boolean mHighlightCenter;
@SuppressLint( "DrawAllocation" )
@Override
protected void onDraw(Canvas canvas)
{
float r = CENTER_X - mPaint.getStrokeWidth() * 0.5f;
canvas.translate(CENTER_X, CENTER_X);
canvas.drawOval(new RectF(-r, -r, r, r), mPaint);
canvas.drawCircle(0, 0, CENTER_RADIUS, mCenterPaint);
if( mTrackingCenter )
{
int c = mCenterPaint.getColor();
mCenterPaint.setStyle(Paint.Style.STROKE);
if( mHighlightCenter )
{
mCenterPaint.setAlpha(0xFF);
}
else
{
mCenterPaint.setAlpha(0x80);
}
canvas.drawCircle(0, 0, CENTER_RADIUS + mCenterPaint.getStrokeWidth(), mCenterPaint);
mCenterPaint.setStyle(Paint.Style.FILL);
mCenterPaint.setColor(c);
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
setMeasuredDimension(CENTER_X * 2, CENTER_Y * 2);
}
private static final int CENTER_X = 150; //100
private static final int CENTER_Y = 150; //100
private static final int CENTER_RADIUS = 60; //32
private int floatToByte(float x)
{
int n = java.lang.Math.round(x);
return n;
}
private int pinToByte(int n)
{
if( n < 0 )
{
n = 0;
}
else if( n > 255 )
{
n = 255;
}
return n;
}
private int ave(int s, int d, float p)
{
return s + java.lang.Math.round(p * ( d - s ));
}
private int interpColor(int colors[], float unit)
{
if( unit <= 0 )
{
return colors[0];
}
if( unit >= 1 )
{
return colors[colors.length - 1];
}
float p = unit * ( colors.length - 1 );
int i = (int)p;
p -= i;
// now p is just the fractional part [0...1) and i is the index
int c0 = colors[i];
int c1 = colors[i + 1];
int a = ave(Color.alpha(c0), Color.alpha(c1), p);
int r = ave(Color.red(c0), Color.red(c1), p);
int g = ave(Color.green(c0), Color.green(c1), p);
int b = ave(Color.blue(c0), Color.blue(c1), p);
return Color.argb(a, r, g, b);
}
@SuppressWarnings( "unused" )
private int rotateColor(int color, float rad)
{
float deg = rad * 180 / 3.1415927f;
int r = Color.red(color);
int g = Color.green(color);
int b = Color.blue(color);
ColorMatrix cm = new ColorMatrix();
ColorMatrix tmp = new ColorMatrix();
cm.setRGB2YUV();
tmp.setRotate(0, deg);
cm.postConcat(tmp);
tmp.setYUV2RGB();
cm.postConcat(tmp);
final float[] a = cm.getArray();
int ir = floatToByte(a[0] * r + a[1] * g + a[2] * b);
int ig = floatToByte(a[5] * r + a[6] * g + a[7] * b);
int ib = floatToByte(a[10] * r + a[11] * g + a[12] * b);
return Color.argb(Color.alpha(color), pinToByte(ir), pinToByte(ig), pinToByte(ib));
}
private static final float PI = 3.1415926f;
@Override
public boolean onTouchEvent(MotionEvent event)
{
float x = event.getX() - CENTER_X;
float y = event.getY() - CENTER_Y;
boolean inCenter = java.lang.Math.sqrt(x * x + y * y) <= CENTER_RADIUS;
switch( event.getAction() )
{
case MotionEvent.ACTION_DOWN:
mTrackingCenter = inCenter;
if( inCenter )
{
mHighlightCenter = true;
invalidate();
break;
}
case MotionEvent.ACTION_MOVE:
if( mTrackingCenter )
{
if( mHighlightCenter != inCenter )
{
mHighlightCenter = inCenter;
invalidate();
}
}
else
{
float angle = (float)java.lang.Math.atan2(y, x);
// need to turn angle [-PI ... PI] into unit [0....1]
float unit = angle / ( 2 * PI );
if( unit < 0 )
{
unit += 1;
}
mCenterPaint.setColor(interpColor(mColors, unit));
invalidate();
}
break;
case MotionEvent.ACTION_UP:
if( mTrackingCenter )
{
if( inCenter )
{
mListener.colorChanged(mCenterPaint.getColor());
}
mTrackingCenter = false; // so we draw w/o halo
invalidate();
}
break;
}
return true;
}
}
public ColorPickerDialog(Context context, OnColorChangedListener listener, int initialColor)
{
super(context);
mListener = listener;
mInitialColor = initialColor;
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
OnColorChangedListener l = new OnColorChangedListener()
{
public void colorChanged(int color)
{
mListener.colorChanged(color);
dismiss();
}
};
setContentView(new ColorPickerView(getContext(), l, mInitialColor));
//setTitle("Pick a Color");
}
}
| 05-android-task-calendar | TaskCalendar/src/com/giltesa/taskcalendar/util/ColorPickerDialog.java | Java | oos | 6,889 |
/*
Author: Alberto Gil Tesa
WebSite: http://giltesa.com
License: CC BY-NC-SA 3.0
http://goo.gl/CTYnN
Project: Task Calendar
Package: com.giltesa.taskcalendar.util
File: /TaskCalendar/src/com/giltesa/taskcalendar/util/Backup.java
*/
package com.giltesa.taskcalendar.util;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import android.annotation.SuppressLint;
public class Backup
{
private File file;
private String date;
private String length;
/**
* @param file
*/
@SuppressLint( "SimpleDateFormat" )
public Backup(File file)
{
this.file = file;
this.date = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(file.lastModified());
this.length = file.length() / Byte.SIZE + " KB";
}
/**
* @param file
* @param modified
* @param size
*/
@SuppressLint( "SimpleDateFormat" )
public Backup(File file, String modified, String size)
{
String[] words = modified.split(" ");
try
{
Date date = new SimpleDateFormat("MMM", Locale.ENGLISH).parse(words[2]);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int month = cal.get(Calendar.MONTH) + 1;
words[2] = ( month < 10 ) ? "0" + month : "" + month;
}
catch( ParseException e )
{
e.printStackTrace();
}
this.file = file;
this.date = words[3] + "/" + words[2] + "/" + words[1] + " " + words[4];
this.length = size;
}
public File getFile()
{
return file;
}
public String getDate()
{
return date;
}
public String getLength()
{
return length;
}
}
| 05-android-task-calendar | TaskCalendar/src/com/giltesa/taskcalendar/util/Backup.java | Java | oos | 1,775 |
/*
Author: Alberto Gil Tesa
WebSite: http://giltesa.com
License: CC BY-NC-SA 3.0
http://goo.gl/CTYnN
Project: Task Calendar
Package: com.giltesa.taskcalendar.util
File: /TaskCalendar/src/com/giltesa/taskcalendar/util/Tag.java
*/
package com.giltesa.taskcalendar.util;
public class Task
{
private int id;
private int idTag;
private String title;
private String description;
private String date;
private String color;
public Task(int id, int idTag, String date, String title, String description, String color)
{
this.id = id;
this.idTag = idTag;
this.date = date;
this.title = title;
this.description = description;
this.color = color;
}
public int getID()
{
return id;
}
public int getIDTag()
{
return idTag;
}
public String getTitle()
{
return title;
}
public String getDescription()
{
return description;
}
public String getDate()
{
return date;
}
public String getColor()
{
return color;
}
public void setId(int id)
{
this.id = id;
}
public void setIdTag(int idTag)
{
this.idTag = idTag;
}
public void setTitle(String title)
{
this.title = title;
}
public void setDescription(String description)
{
this.description = description;
}
public void setDate(String date)
{
this.date = date;
}
public void setColor(String color)
{
this.color = color;
}
@Override
public String toString()
{
return title;
}
}
| 05-android-task-calendar | TaskCalendar/src/com/giltesa/taskcalendar/util/Task.java | Java | oos | 1,635 |
/*
Author: Alberto Gil Tesa
WebSite: http://giltesa.com
License: CC BY-NC-SA 3.0
http://goo.gl/CTYnN
Project: Task Calendar
Package: com.giltesa.taskcalendar.util
File: /TaskCalendar/src/com/giltesa/taskcalendar/util/Tag.java
*/
package com.giltesa.taskcalendar.util;
public class Tag
{
private int id;
private String name;
private String color;
private int counter;
public Tag(int id, String name, String color, int counter)
{
this.id = id;
this.name = name;
this.color = color;
this.counter = counter;
}
public int getID()
{
return id;
}
public String getName()
{
return name;
}
public String getColor()
{
return color;
}
public int getCounter()
{
return counter;
}
public void setID(int id)
{
this.id = id;
}
public void setName(String name)
{
this.name = name;
}
public void setColor(String color)
{
this.color = color;
}
public void setCounter(int counter)
{
this.counter = counter;
}
public String toString()
{
return name;
}
}
| 05-android-task-calendar | TaskCalendar/src/com/giltesa/taskcalendar/util/Tag.java | Java | oos | 1,192 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
<title>Creative Commons Legal Code</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">
body{min-width:96%;text-align:center;font:10pt/12pt Arial, "Trebuchet MS", Verdana, sans-serif;background-color:#fff;color:#000;margin-top:.35in}
h3{margin:0!important;padding:0}
#cc-logo{float:left}
#cc-logo img{width:.8in;height:.8in;padding-top:.01in;margin-right:.1in}
#deed{width:95%;text-align:left;margin:0 auto}
#deed-head h1{margin-left:.9in;font-size:15pt;padding-top:.02in;padding-bottom:.06in;border-bottom:.05in solid #000}
#deed-main,#deed-rights,#deed-conditions,#deed-foot{margin:.5in 10px 0 0}
#deed-main img{float:right;border:.01in solid #888;margin-bottom:.2in}
#deed-license{margin:0}
#deed-license h2{font-size:13px;display:inline;padding-bottom:.024in;}
#deed-foot{font-size:8pt;padding-top:.06in;color:#888}
#deed-foot p{margin-top:0;margin-bottom:.01in}
#deed-foot a{text-decoration:none}
#deed-conditions ul{margin-top:.66in}
ul.license-properties{margin-top:.125in!important;margin-bottom:.25in}
li.license{list-style:none;width:4.5in;min-height:.3in;position:relative;margin:0 0 .125in .33in;padding:0}
li.license p{position:absolute;top:-0;margin:0;padding:0}
li.share{list-style-image:url(/images/deed/share.png);list-style-position:outside}
li.remix{list-style-image:url(/images/deed/remix.png);list-style-position:outside}
li.devnations{list-style-image:url(/images/deed/devnations.png);list-style-position:outside}
li.by{list-style-image:url(/images/deed/by.png);list-style-position:outside}
li.nc{list-style-image:url(/images/deed/nc.png);list-style-position:outside}
li.sa{list-style-image:url(/images/deed/sa.png);list-style-position:outside}
li.nd{list-style-image:url(/images/deed/nd.png);list-style-position:outside}
blockquote{font-style:oblique;clear:both;margin:.25in .1in;padding:0}
#libre{position:absolute;top:2in;right:0;padding-left:.25in}
#libre img,#libre a,#librepd img,#librepd a{border:none!important}
#more-container{list-style:none}
.rtl{direction:rtl}
.rtl #deed{text-align:right}
.rtl blockquote{font-family:Tahoma, Geneva, sans-serif}
.rtl ol.arabic-markers,.rtl li.arabic-markers,.rtl p{list-style-type:none}
.rtl li,.rtl ol li,.rtl ol ol li{margin:10px 0}
p{text-align:justify}
#header,#footer,#campaignBanner,#disclaimer{display:none}
</style>
</head>
<body>
<p align="center" id="header"><a href="http://creativecommons.org/">Creative Commons</a></p>
<div id="deed" class="yellow">
<div id="deed-head">
<div id="cc-logo">
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEBLAEsAAD/4QE2RXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAeAAAAcgEyAAIAAAAUAAAAkIdpAAQAAAABAAAApAAAANAALcbAAAAnEAAtxsAAACcQQWRvYmUgUGhvdG9zaG9wIENTMiBNYWNpbnRvc2gAMjAwNzowMjoxNCAxNDo0NzozMwAAA6ABAAMAAAAB//8AAKACAAQAAAABAAAAlqADAAQAAAABAAAAlgAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAAAAAAAAAAAAAAEgAAAABAAAASAAAAAH/7SQ4UGhvdG9zaG9wIDMuMAA4QklNBCUAAAAAABAAAAAAAAAAAAAAAAAAAAAAOEJJTQPqAAAAAB2wPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0IFBVQkxJQyAiLS8vQXBwbGUgQ29tcHV0ZXIvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3dy5hcHBsZS5jb20vRFREcy9Qcm9wZXJ0eUxpc3QtMS4wLmR0ZCI+CjxwbGlzdCB2ZXJzaW9uPSIxLjAiPgo8ZGljdD4KCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1Ib3Jpem9udGFsUmVzPC9rZXk+Cgk8ZGljdD4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY3JlYXRvcjwva2V5PgoJCTxzdHJpbmc+Y29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW5nPgoJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5pdGVtQXJyYXk8L2tleT4KCQk8YXJyYXk+CgkJCTxkaWN0PgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQuUGFnZUZvcm1hdC5QTUhvcml6b250YWxSZXM8L2tleT4KCQkJCTxyZWFsPjcyPC9yZWFsPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDwva2V5PgoJCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnRpbmdtYW5hZ2VyPC9zdHJpbmc+CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJCQkJPGRhdGU+MjAwNy0wMi0xNFQyMjo0NTo1M1o8L2RhdGU+CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuc3RhdGVGbGFnPC9rZXk+CgkJCQk8aW50ZWdlcj4wPC9pbnRlZ2VyPgoJCQk8L2RpY3Q+CgkJPC9hcnJheT4KCTwvZGljdD4KCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1PcmllbnRhdGlvbjwva2V5PgoJPGRpY3Q+CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+CgkJPGFycmF5PgoJCQk8ZGljdD4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1PcmllbnRhdGlvbjwva2V5PgoJCQkJPGludGVnZXI+MTwvaW50ZWdlcj4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5jbGllbnQ8L2tleT4KCQkJCTxzdHJpbmc+Y29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW5nPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0Lm1vZERhdGU8L2tleT4KCQkJCTxkYXRlPjIwMDctMDItMTRUMjI6NDU6NTNaPC9kYXRlPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LnN0YXRlRmxhZzwva2V5PgoJCQkJPGludGVnZXI+MDwvaW50ZWdlcj4KCQkJPC9kaWN0PgoJCTwvYXJyYXk+Cgk8L2RpY3Q+Cgk8a2V5PmNvbS5hcHBsZS5wcmludC5QYWdlRm9ybWF0LlBNU2NhbGluZzwva2V5PgoJPGRpY3Q+CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+CgkJPGFycmF5PgoJCQk8ZGljdD4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1TY2FsaW5nPC9rZXk+CgkJCQk8cmVhbD4xPC9yZWFsPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDwva2V5PgoJCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnRpbmdtYW5hZ2VyPC9zdHJpbmc+CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJCQkJPGRhdGU+MjAwNy0wMi0xNFQyMjo0NTo1M1o8L2RhdGU+CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuc3RhdGVGbGFnPC9rZXk+CgkJCQk8aW50ZWdlcj4wPC9pbnRlZ2VyPgoJCQk8L2RpY3Q+CgkJPC9hcnJheT4KCTwvZGljdD4KCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1WZXJ0aWNhbFJlczwva2V5PgoJPGRpY3Q+CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+CgkJPGFycmF5PgoJCQk8ZGljdD4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1WZXJ0aWNhbFJlczwva2V5PgoJCQkJPHJlYWw+NzI8L3JlYWw+CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY2xpZW50PC9rZXk+CgkJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+CgkJCQk8ZGF0ZT4yMDA3LTAyLTE0VDIyOjQ1OjUzWjwvZGF0ZT4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCTxpbnRlZ2VyPjA8L2ludGVnZXI+CgkJCTwvZGljdD4KCQk8L2FycmF5PgoJPC9kaWN0PgoJPGtleT5jb20uYXBwbGUucHJpbnQuUGFnZUZvcm1hdC5QTVZlcnRpY2FsU2NhbGluZzwva2V5PgoJPGRpY3Q+CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+CgkJPGFycmF5PgoJCQk8ZGljdD4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1WZXJ0aWNhbFNjYWxpbmc8L2tleT4KCQkJCTxyZWFsPjE8L3JlYWw+CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY2xpZW50PC9rZXk+CgkJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+CgkJCQk8ZGF0ZT4yMDA3LTAyLTE0VDIyOjQ1OjUzWjwvZGF0ZT4KCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCTxpbnRlZ2VyPjA8L2ludGVnZXI+CgkJCTwvZGljdD4KCQk8L2FycmF5PgoJPC9kaWN0PgoJPGtleT5jb20uYXBwbGUucHJpbnQuc3ViVGlja2V0LnBhcGVyX2luZm9fdGlja2V0PC9rZXk+Cgk8ZGljdD4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYWdlRm9ybWF0LlBNQWRqdXN0ZWRQYWdlUmVjdDwva2V5PgoJCTxkaWN0PgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY3JlYXRvcjwva2V5PgoJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0Lml0ZW1BcnJheTwva2V5PgoJCQk8YXJyYXk+CgkJCQk8ZGljdD4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYWdlRm9ybWF0LlBNQWRqdXN0ZWRQYWdlUmVjdDwva2V5PgoJCQkJCTxhcnJheT4KCQkJCQkJPHJlYWw+MC4wPC9yZWFsPgoJCQkJCQk8cmVhbD4wLjA8L3JlYWw+CgkJCQkJCTxyZWFsPjczNDwvcmVhbD4KCQkJCQkJPHJlYWw+NTc2PC9yZWFsPgoJCQkJCTwvYXJyYXk+CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDwva2V5PgoJCQkJCTxzdHJpbmc+Y29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW5nPgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+CgkJCQkJPGRhdGU+MjAwNy0wMi0xNFQyMjo0NTo1M1o8L2RhdGU+CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LnN0YXRlRmxhZzwva2V5PgoJCQkJCTxpbnRlZ2VyPjA8L2ludGVnZXI+CgkJCQk8L2RpY3Q+CgkJCTwvYXJyYXk+CgkJPC9kaWN0PgoJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1BZGp1c3RlZFBhcGVyUmVjdDwva2V5PgoJCTxkaWN0PgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY3JlYXRvcjwva2V5PgoJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0Lml0ZW1BcnJheTwva2V5PgoJCQk8YXJyYXk+CgkJCQk8ZGljdD4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYWdlRm9ybWF0LlBNQWRqdXN0ZWRQYXBlclJlY3Q8L2tleT4KCQkJCQk8YXJyYXk+CgkJCQkJCTxyZWFsPi0xODwvcmVhbD4KCQkJCQkJPHJlYWw+LTE4PC9yZWFsPgoJCQkJCQk8cmVhbD43NzQ8L3JlYWw+CgkJCQkJCTxyZWFsPjU5NDwvcmVhbD4KCQkJCQk8L2FycmF5PgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5jbGllbnQ8L2tleT4KCQkJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJCQkJCTxkYXRlPjIwMDctMDItMTRUMjI6NDU6NTNaPC9kYXRlPgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCQk8aW50ZWdlcj4wPC9pbnRlZ2VyPgoJCQkJPC9kaWN0PgoJCQk8L2FycmF5PgoJCTwvZGljdD4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYXBlckluZm8uUE1QYXBlck5hbWU8L2tleT4KCQk8ZGljdD4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5nPgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+CgkJCTxhcnJheT4KCQkJCTxkaWN0PgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhcGVySW5mby5QTVBhcGVyTmFtZTwva2V5PgoJCQkJCTxzdHJpbmc+bmEtbGV0dGVyPC9zdHJpbmc+CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDwva2V5PgoJCQkJCTxzdHJpbmc+Y29tLmFwcGxlLnByaW50LnBtLlBvc3RTY3JpcHQ8L3N0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJCQkJCTxkYXRlPjIwMDMtMDctMDFUMTc6NDk6MzZaPC9kYXRlPgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCQk8aW50ZWdlcj4xPC9pbnRlZ2VyPgoJCQkJPC9kaWN0PgoJCQk8L2FycmF5PgoJCTwvZGljdD4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYXBlckluZm8uUE1VbmFkanVzdGVkUGFnZVJlY3Q8L2tleT4KCQk8ZGljdD4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5nPgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+CgkJCTxhcnJheT4KCQkJCTxkaWN0PgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhcGVySW5mby5QTVVuYWRqdXN0ZWRQYWdlUmVjdDwva2V5PgoJCQkJCTxhcnJheT4KCQkJCQkJPHJlYWw+MC4wPC9yZWFsPgoJCQkJCQk8cmVhbD4wLjA8L3JlYWw+CgkJCQkJCTxyZWFsPjczNDwvcmVhbD4KCQkJCQkJPHJlYWw+NTc2PC9yZWFsPgoJCQkJCTwvYXJyYXk+CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDwva2V5PgoJCQkJCTxzdHJpbmc+Y29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW5nPgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+CgkJCQkJPGRhdGU+MjAwNy0wMi0xNFQyMjo0NTo1M1o8L2RhdGU+CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LnN0YXRlRmxhZzwva2V5PgoJCQkJCTxpbnRlZ2VyPjA8L2ludGVnZXI+CgkJCQk8L2RpY3Q+CgkJCTwvYXJyYXk+CgkJPC9kaWN0PgoJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhcGVySW5mby5QTVVuYWRqdXN0ZWRQYXBlclJlY3Q8L2tleT4KCQk8ZGljdD4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5nPgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+CgkJCTxhcnJheT4KCQkJCTxkaWN0PgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LlBhcGVySW5mby5QTVVuYWRqdXN0ZWRQYXBlclJlY3Q8L2tleT4KCQkJCQk8YXJyYXk+CgkJCQkJCTxyZWFsPi0xODwvcmVhbD4KCQkJCQkJPHJlYWw+LTE4PC9yZWFsPgoJCQkJCQk8cmVhbD43NzQ8L3JlYWw+CgkJCQkJCTxyZWFsPjU5NDwvcmVhbD4KCQkJCQk8L2FycmF5PgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5jbGllbnQ8L2tleT4KCQkJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJCQkJCTxkYXRlPjIwMDctMDItMTRUMjI6NDU6NTNaPC9kYXRlPgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCQk8aW50ZWdlcj4wPC9pbnRlZ2VyPgoJCQkJPC9kaWN0PgoJCQk8L2FycmF5PgoJCTwvZGljdD4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYXBlckluZm8ucHBkLlBNUGFwZXJOYW1lPC9rZXk+CgkJPGRpY3Q+CgkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5jcmVhdG9yPC9rZXk+CgkJCTxzdHJpbmc+Y29tLmFwcGxlLnByaW50LnBtLlBvc3RTY3JpcHQ8L3N0cmluZz4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0Lml0ZW1BcnJheTwva2V5PgoJCQk8YXJyYXk+CgkJCQk8ZGljdD4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYXBlckluZm8ucHBkLlBNUGFwZXJOYW1lPC9rZXk+CgkJCQkJPHN0cmluZz5VUyBMZXR0ZXI8L3N0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY2xpZW50PC9rZXk+CgkJCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5nPgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+CgkJCQkJPGRhdGU+MjAwMy0wNy0wMVQxNzo0OTozNlo8L2RhdGU+CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LnN0YXRlRmxhZzwva2V5PgoJCQkJCTxpbnRlZ2VyPjE8L2ludGVnZXI+CgkJCQk8L2RpY3Q+CgkJCTwvYXJyYXk+CgkJPC9kaWN0PgoJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5BUElWZXJzaW9uPC9rZXk+CgkJPHN0cmluZz4wMC4yMDwvc3RyaW5nPgoJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5wcml2YXRlTG9jazwva2V5PgoJCTxmYWxzZS8+CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LnR5cGU8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludC5QYXBlckluZm9UaWNrZXQ8L3N0cmluZz4KCTwvZGljdD4KCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5BUElWZXJzaW9uPC9rZXk+Cgk8c3RyaW5nPjAwLjIwPC9zdHJpbmc+Cgk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQucHJpdmF0ZUxvY2s8L2tleT4KCTxmYWxzZS8+Cgk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQudHlwZTwva2V5PgoJPHN0cmluZz5jb20uYXBwbGUucHJpbnQuUGFnZUZvcm1hdFRpY2tldDwvc3RyaW5nPgo8L2RpY3Q+CjwvcGxpc3Q+CjhCSU0D6QAAAAAAeAADAAAASABIAAAAAALeAkD/7v/uAwYCUgNnBSgD/AACAAAASABIAAAAAALYAigAAQAAAGQAAAABAAMDAwAAAAF//wABAAEAAAAAAAAAAAAAAABoCAAZAZAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADhCSU0D7QAAAAAAEAEsAAAAAQABASwAAAABAAE4QklNBCYAAAAAAA4AAAAAAAAAAAAAP4AAADhCSU0EDQAAAAAABAAAAHg4QklNBBkAAAAAAAQAAAAeOEJJTQPzAAAAAAAJAAAAAAAAAAABADhCSU0ECgAAAAAAAQAAOEJJTScQAAAAAAAKAAEAAAAAAAAAAThCSU0D9QAAAAAASAAvZmYAAQBsZmYABgAAAAAAAQAvZmYAAQChmZoABgAAAAAAAQAyAAAAAQBaAAAABgAAAAAAAQA1AAAAAQAtAAAABgAAAAAAAThCSU0D+AAAAAAAcAAA/////////////////////////////wPoAAAAAP////////////////////////////8D6AAAAAD/////////////////////////////A+gAAAAA/////////////////////////////wPoAAA4QklNBAAAAAAAAAIAAThCSU0EAgAAAAAABAAAAAA4QklNBDAAAAAAAAIBAThCSU0ELQAAAAAABgABAAAAAjhCSU0ECAAAAAAAEAAAAAEAAAJAAAACQAAAAAA4QklNBB4AAAAAAAQAAAAAOEJJTQQaAAAAAANJAAAABgAAAAAAAAAAAAAAlgAAAJYAAAAKAFUAbgB0AGkAdABsAGUAZAAtADEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAJYAAACWAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAABudWxsAAAAAgAAAAZib3VuZHNPYmpjAAAAAQAAAAAAAFJjdDEAAAAEAAAAAFRvcCBsb25nAAAAAAAAAABMZWZ0bG9uZwAAAAAAAAAAQnRvbWxvbmcAAACWAAAAAFJnaHRsb25nAAAAlgAAAAZzbGljZXNWbExzAAAAAU9iamMAAAABAAAAAAAFc2xpY2UAAAASAAAAB3NsaWNlSURsb25nAAAAAAAAAAdncm91cElEbG9uZwAAAAAAAAAGb3JpZ2luZW51bQAAAAxFU2xpY2VPcmlnaW4AAAANYXV0b0dlbmVyYXRlZAAAAABUeXBlZW51bQAAAApFU2xpY2VUeXBlAAAAAEltZyAAAAAGYm91bmRzT2JqYwAAAAEAAAAAAABSY3QxAAAABAAAAABUb3AgbG9uZwAAAAAAAAAATGVmdGxvbmcAAAAAAAAAAEJ0b21sb25nAAAAlgAAAABSZ2h0bG9uZwAAAJYAAAADdXJsVEVYVAAAAAEAAAAAAABudWxsVEVYVAAAAAEAAAAAAABNc2dlVEVYVAAAAAEAAAAAAAZhbHRUYWdURVhUAAAAAQAAAAAADmNlbGxUZXh0SXNIVE1MYm9vbAEAAAAIY2VsbFRleHRURVhUAAAAAQAAAAAACWhvcnpBbGlnbmVudW0AAAAPRVNsaWNlSG9yekFsaWduAAAAB2RlZmF1bHQAAAAJdmVydEFsaWduZW51bQAAAA9FU2xpY2VWZXJ0QWxpZ24AAAAHZGVmYXVsdAAAAAtiZ0NvbG9yVHlwZWVudW0AAAARRVNsaWNlQkdDb2xvclR5cGUAAAAATm9uZQAAAAl0b3BPdXRzZXRsb25nAAAAAAAAAApsZWZ0T3V0c2V0bG9uZwAAAAAAAAAMYm90dG9tT3V0c2V0bG9uZwAAAAAAAAALcmlnaHRPdXRzZXRsb25nAAAAAAA4QklNBCgAAAAAAAwAAAABP/AAAAAAAAA4QklNBBEAAAAAAAEBADhCSU0EFAAAAAAABAAAAAI4QklNBCEAAAAAAFUAAAABAQAAAA8AQQBkAG8AYgBlACAAUABoAG8AdABvAHMAaABvAHAAAAATAEEAZABvAGIAZQAgAFAAaABvAHQAbwBzAGgAbwBwACAAQwBTADIAAAABADhCSU0EBgAAAAAABwAGAAAAAQEA/+E6bmh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8APD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iMy4xLjEtMTExIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIj4KICAgICAgICAgPGRjOmZvcm1hdD5pbWFnZS9qcGVnPC9kYzpmb3JtYXQ+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp4YXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iPgogICAgICAgICA8eGFwOkNyZWF0b3JUb29sPkFkb2JlIFBob3Rvc2hvcCBDUzIgTWFjaW50b3NoPC94YXA6Q3JlYXRvclRvb2w+CiAgICAgICAgIDx4YXA6Q3JlYXRlRGF0ZT4yMDA3LTAyLTE0VDE0OjQ3OjMzLTA4OjAwPC94YXA6Q3JlYXRlRGF0ZT4KICAgICAgICAgPHhhcDpNb2RpZnlEYXRlPjIwMDctMDItMTRUMTQ6NDc6MzMtMDg6MDA8L3hhcDpNb2RpZnlEYXRlPgogICAgICAgICA8eGFwOk1ldGFkYXRhRGF0ZT4yMDA3LTAyLTE0VDE0OjQ3OjMzLTA4OjAwPC94YXA6TWV0YWRhdGFEYXRlPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6eGFwTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iCiAgICAgICAgICAgIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIj4KICAgICAgICAgPHhhcE1NOkRvY3VtZW50SUQ+dXVpZDoyQzgyNzI2MUJDQzYxMURCQTgxNUY2NDJDQTI2MTlGRDwveGFwTU06RG9jdW1lbnRJRD4KICAgICAgICAgPHhhcE1NOkluc3RhbmNlSUQ+dXVpZDoyQzgyNzI2MkJDQzYxMURCQTgxNUY2NDJDQTI2MTlGRDwveGFwTU06SW5zdGFuY2VJRD4KICAgICAgICAgPHhhcE1NOkRlcml2ZWRGcm9tIHJkZjpwYXJzZVR5cGU9IlJlc291cmNlIj4KICAgICAgICAgICAgPHN0UmVmOmluc3RhbmNlSUQ+dXVpZDoyQzgyNzI2MEJDQzYxMURCQTgxNUY2NDJDQTI2MTlGRDwvc3RSZWY6aW5zdGFuY2VJRD4KICAgICAgICAgICAgPHN0UmVmOmRvY3VtZW50SUQ+dXVpZDoyQzgyNzI2MEJDQzYxMURCQTgxNUY2NDJDQTI2MTlGRDwvc3RSZWY6ZG9jdW1lbnRJRD4KICAgICAgICAgPC94YXBNTTpEZXJpdmVkRnJvbT4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIj4KICAgICAgICAgPHRpZmY6T3JpZW50YXRpb24+MTwvdGlmZjpPcmllbnRhdGlvbj4KICAgICAgICAgPHRpZmY6WFJlc29sdXRpb24+MzAwMDAwMC8xMDAwMDwvdGlmZjpYUmVzb2x1dGlvbj4KICAgICAgICAgPHRpZmY6WVJlc29sdXRpb24+MzAwMDAwMC8xMDAwMDwvdGlmZjpZUmVzb2x1dGlvbj4KICAgICAgICAgPHRpZmY6UmVzb2x1dGlvblVuaXQ+MjwvdGlmZjpSZXNvbHV0aW9uVW5pdD4KICAgICAgICAgPHRpZmY6TmF0aXZlRGlnZXN0PjI1NiwyNTcsMjU4LDI1OSwyNjIsMjc0LDI3NywyODQsNTMwLDUzMSwyODIsMjgzLDI5NiwzMDEsMzE4LDMxOSw1MjksNTMyLDMwNiwyNzAsMjcxLDI3MiwzMDUsMzE1LDMzNDMyOzQyRDlFMkJGQUVBMkRBMENGQkYyRTU5RDkzOUE4RkE3PC90aWZmOk5hdGl2ZURpZ2VzdD4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOmV4aWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vZXhpZi8xLjAvIj4KICAgICAgICAgPGV4aWY6UGl4ZWxYRGltZW5zaW9uPjE1MDwvZXhpZjpQaXhlbFhEaW1lbnNpb24+CiAgICAgICAgIDxleGlmOlBpeGVsWURpbWVuc2lvbj4xNTA8L2V4aWY6UGl4ZWxZRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpDb2xvclNwYWNlPi0xPC9leGlmOkNvbG9yU3BhY2U+CiAgICAgICAgIDxleGlmOk5hdGl2ZURpZ2VzdD4zNjg2NCw0MDk2MCw0MDk2MSwzNzEyMSwzNzEyMiw0MDk2Miw0MDk2MywzNzUxMCw0MDk2NCwzNjg2NywzNjg2OCwzMzQzNCwzMzQzNywzNDg1MCwzNDg1MiwzNDg1NSwzNDg1NiwzNzM3NywzNzM3OCwzNzM3OSwzNzM4MCwzNzM4MSwzNzM4MiwzNzM4MywzNzM4NCwzNzM4NSwzNzM4NiwzNzM5Niw0MTQ4Myw0MTQ4NCw0MTQ4Niw0MTQ4Nyw0MTQ4OCw0MTQ5Miw0MTQ5Myw0MTQ5NSw0MTcyOCw0MTcyOSw0MTczMCw0MTk4NSw0MTk4Niw0MTk4Nyw0MTk4OCw0MTk4OSw0MTk5MCw0MTk5MSw0MTk5Miw0MTk5Myw0MTk5NCw0MTk5NSw0MTk5Niw0MjAxNiwwLDIsNCw1LDYsNyw4LDksMTAsMTEsMTIsMTMsMTQsMTUsMTYsMTcsMTgsMjAsMjIsMjMsMjQsMjUsMjYsMjcsMjgsMzA7QUZCRTBGRkExQzU1RTU2Mzc1NUQ1OTlDRjYxMzEyNEI8L2V4aWY6TmF0aXZlRGlnZXN0PgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIj4KICAgICAgICAgPHBob3Rvc2hvcDpIaXN0b3J5Lz4KICAgICAgICAgPHBob3Rvc2hvcDpDb2xvck1vZGU+MzwvcGhvdG9zaG9wOkNvbG9yTW9kZT4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz7/7gAOQWRvYmUAZEAAAAAB/9sAhAACAgICAgICAgICAwICAgMEAwICAwQFBAQEBAQFBgUFBQUFBQYGBwcIBwcGCQkKCgkJDAwMDAwMDAwMDAwMDAwMAQMDAwUEBQkGBgkNCgkKDQ8ODg4ODw8MDAwMDA8PDAwMDAwMDwwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCACWAJYDAREAAhEBAxEB/90ABAAT/8QBogAAAAcBAQEBAQAAAAAAAAAABAUDAgYBAAcICQoLAQACAgMBAQEBAQAAAAAAAAABAAIDBAUGBwgJCgsQAAIBAwMCBAIGBwMEAgYCcwECAxEEAAUhEjFBUQYTYSJxgRQykaEHFbFCI8FS0eEzFmLwJHKC8SVDNFOSorJjc8I1RCeTo7M2F1RkdMPS4ggmgwkKGBmElEVGpLRW01UoGvLj88TU5PRldYWVpbXF1eX1ZnaGlqa2xtbm9jdHV2d3h5ent8fX5/c4SFhoeIiYqLjI2Oj4KTlJWWl5iZmpucnZ6fkqOkpaanqKmqq6ytrq+hEAAgIBAgMFBQQFBgQIAwNtAQACEQMEIRIxQQVRE2EiBnGBkTKhsfAUwdHhI0IVUmJy8TMkNEOCFpJTJaJjssIHc9I14kSDF1STCAkKGBkmNkUaJ2R0VTfyo7PDKCnT4/OElKS0xNTk9GV1hZWltcXV5fVGVmZ2hpamtsbW5vZHV2d3h5ent8fX5/c4SFhoeIiYqLjI2Oj4OUlZaXmJmam5ydnp+So6SlpqeoqaqrrK2ur6/9oADAMBAAIRAxEAPwD7+Yq7FXYq7FXYq85/Mv8AN78sPyc0NvMn5o+e9G8jaP8AEILnVrpIXnZdyltCSZZ3p+xErN7Yq/KX83P+f0n5L+WnudP/ACg8ga7+Z95GSsWt6k40HS2r0eP1I7i7cDurwRV8e+KvgHzv/wA/jP8AnLDzI08fla08nfl3attbPpulvfXSDY1eTUprmJm7VEKinau+KvnfVv8An4v/AM5q61L615+f2twvyLUsLXTbBKtSvwWdpCtNthSgxVKP+h/P+cyf/YhPNf8AyOh/6pYqzDQP+fmP/Obfl5oxB+eF3qUKAK1vqulaRfBwK0rJPZNJXfqHBPfFX1P5A/5/U/n3ok0Uf5h/lx5P8+6clPUbT/reh37+NZxJewCvaltt+GKv0e/Jv/n7h/zi3+ZU1tpfnO41b8mtcnIQDzDCLjS3kb9lNRs/UVAO7XEcK++Kv0y0PX9C8z6TZa95a1qw8w6HqUYm07WdMuYru0uIz0eKeFnR1PipOKptirsVdirsVdir/9D7+Yq7FXYqgtS1LTtG0++1bV7+20rStMgkutS1O8lSC3t4IVLySzSyFUREUEszEADc4q/Cj/nLj/n8BZ6TNqvkP/nFi2g1e9hL217+b2pw87SNhQE6TZSgetQ1AmnHDb4Y5FKvir8GPPX5heefzO8xXnm38w/Nmq+c/Ml+f9J1jV7mS6m41JEamQngi1+FFoqjZQBirDsVXIjyOscal3chURRUknYAAda4q9Y8v/kD+e3myJZvK35K+fPMsLrzSbSvLeqXilaK1QYLdxSjKfkR44qyX/oU7/nKf/2Gn81f/CN1z/sjxV535o/K78zfI6u3nX8uvM/lBYzR21vSL3Twp5Fd/rMUdN1I+YxVgmKuxV71+Rf/ADk3+dv/ADjjra6z+U/nq+0CCSZZtU8tyN9Z0i/40BW7sZaxOSo48wBIo+w6nfFX9Hn/ADh7/wA/P/yt/wCchpNM8j/mPHa/lV+bl0UgtbGaU/oXWJmPEDT7qU1jkY9IJjy3AR5TWir9RsVdirsVdir/AP/R+/mKuxViXnvz35R/LLyjr3nzz5r1r5Z8p+WbVrzWdZvG4xxRrQAAAFnd2IVEUFnYhVBYgYq/lJ/5zi/5+D+ev+cqdXu/KPllrzyV+R2n3H+43ymsvG51hoXrHeas0ezEkB0gBMcZp9t19TFX5zYq90/In/nG385P+ckPMh8t/lN5Nutfa2ZBrGuyD6vpWnI52e8vXAjjqKkJUuwB4IxGKv3e/Ib/AJ8yflX5XhstY/P7zde/mZrgCvceVNEeXStDjb9qJ7hSt7cio2dWt9tinfFX6oflz+Q35LflFbxW/wCWf5W+WPJbRCn13TNNt4rt9uNZbvgZ5DTaruTir1rFXYq0QGBVgGVhRlO4IOKvmP8ANP8A5wz/AOcYPzlhuR57/Jjy5c6jcqQ3mHTLYaTqYbfixvdPNvM/EmoDsy+IIqMVfkL/AM5D/wDPl/VtPhvvMP8AzjV52bX0QtKv5dea5IoLsjr6dnqkaxwuamirOkYA+1Mx6qvxI88+QvOn5Z+ZtS8mfmB5Y1Hyh5p0hwmoaJqkD286V3VwGHxI43R1JVhupI3xViQJUhlJVlNQRsQRir91P+ff/wDz9BvfLs+ifkr/AM5L67Lf+XZmisfJn5sX0hefT2YlUttZmdi0kBqFS4PxRf7srH8car+iSOSOaOOWKRZYpVDxSoQysrCoII2IIxVfirsVf//S+/mKoS/v7HSrG91TU7uHT9N02CS61C/uHWOGCCFS8ksjsQqqigkkmgGKv5MP+fhn/Oceq/8AOUnnmTyh5Ou5rH8jvJN6w8tWNODaxeR8o21a5WgajBisCN9hPiIDuwCr83cVfqN/zgZ/z7k8x/8AOTclr+ZX5kSXnlD8kLS4K28sQ9LUfMUkTESRWBdSI4FYFZJyDvVIwWDtGq/qC/L/APLryN+VXlXTfJH5deVtP8n+VdITjY6Np0QijBoA0jndpJHpV5HLOx3ZicVZpirsVdirsVdirsVdir55/wCciv8AnF/8of8AnJ/yi3lb80PLqXVzapIfLnmyz4w6tpUzj+8tLmhPEmhaNw0b0HJTQUVfyg/85b/84c/md/ziR5zGjeaoTr3krWJXPkv8xLOF1sdQjBJEUoNRBdIorJCWNOqM6UcqvkfFX77/APPrD/nPO5Fzof8Azi5+cOsGa3kVLP8AJvzXduAYioomh3EjdVI2tWY1B/c7gxKqr+gXFXYq/wD/0/v5ir8K/wDn77/zlzN5d0q2/wCcW/IepmHVvMdtFqP5tX1u1Hg06Sj2el8lNQbmnqzDY+l6a7rKwxV/Ovir9Pv+fcv/ADglP/zk55rk/ML8xrG4tvyO8m3YjvUDNC/mDUUo/wCj4JFowhQEG4dSDQhEIZi0ar+q/StK0zQ9M0/RdF0+20nR9JtorPS9Ls4kgt7a3gQJFDDEgCoiKAFUCgGwxVH4q7FXYq7FXYq7FXYq7FXYq84/Nr8qPI/53fl/5j/LP8xNHTWvK/mW2MF3CaCaCQbxXNtIQ3pzQvR43A2YdxUFV/HX/wA5bf8AOLnnL/nFD819R8g+Y+ep+Xr71L7yD5vVOMOq6YXojkdEmi2SaP8AZfpVGRmVfMtrdXNlc297ZXEtpeWkqTWl3C7RyxSxsGR0dSCrKQCCDUHFX9fv/PvD/nK5f+co/wAj7WbzDeLL+an5dGDRPzEjNA90xQ/U9UAG1LxI2LUApKkoAC8aqvvjFX//1Pt1+bH5kaF+T/5aeefzQ8yknRPIujXer3kCMFknNvGWjt4y23OaTjGlf2mGKv4ffzL/ADB8yfmv+YHnD8yfN119c8yeddVudW1WUV4LJcOWEUQJPGOJaIi/sqoUbDFWaf8AOO35H+Zv+ci/zh8mflL5WBhuvMt3/uV1Uryj0/TYB6t7eSdBSKJWKgkcn4oN2GKv7Vvyz/Ljyj+UXkLyt+W3kTS00fyp5QsI7DSbNaFyqbvLM4A5yyuWkkciruzMdzirOsVdirsVdirsVdirsVdirsVdirsVfH//ADm7/wA4u6T/AM5U/kfrvk9baCPz9oCSav8AljrcgVWt9UiSv1ZpCV4w3ir6MlTxFVkoWjXFX8Z+oaffaTqF9pWp2kthqWmXEtpqFhOhjlgnhcpJHIjUKsjAgg9Dir7Y/wCfef8AzkPN/wA48f8AOS3k3VdQvmtvI3nqaPyr59iZ+MK2l/IqQXjjcD6pccJSaV4B1H2sVf2MYq//1et/8/o/zfk8s/kz5B/JzTroxXv5oa2+p69EjD4tK0H05BFKtagSXc8Dqe5iPhir+aTFX9Jn/Pmb8gLfy1+WXmr/AJyE1qxH6e/Me6l0LyhcuN49D02bjcvGaCn1i9jZW6/3C06nFX7YYq7FXyl/zkN/zmp/zj1/zjIv1T8y/OiyeaniWa28g6JGNQ1qRHHJHa3VlWBWG6vcPGrfsknFX5wav/z/AAPy9hv5o9B/ITzFqWmKf9HvNQ1m0sZ2FT9qCKC7VdvCU4qyjyR/z+v/ACS1e/jtPPn5V+bPJVtM4RdT0+a01mGIEj45lrZyhR34I58AcVfqd+UP54flR+fPllfN35S+d9O86aKpVLxrNytzZyuOSxXlrKEnt3IFQsqKSNxtvir1bFXm35p/nB+WP5JeVp/Of5redNN8k+XIG9Nb2/kPqTy0r6Vtbxh5riSlT6cSM1ATSgOKvyo89/8AP638j9F1CSz8g/lh5r89W8LlH1a9lttFt5R/PArfW5iP+MkaH2xViGmf8/wfIMt5Gms/kF5gsLA/3tzZa1a3cy7j7MUltbKdq/7sGKv0L/5x8/5zw/5xr/5yTuYdG8iedTpHnKcExeQvMsa6Zq0lAWpboXkhuSACStvLIVAqwAxV9iYq7FX8q/8Az9x/IeH8q/8AnI+L8w9EsRaeWPzvspNbYRrxjXXLRlh1ZV61MnOG5Y93mbbFX5V4q/q5i/5yt1Gb/n1xcf8AOQcN/PJ5ytPIQ8uXWqLvcR+Yjcr5aF4wrs31t1uPkQaUxV//1vJv/P4Hz3J5p/5y7ufK4kP1b8tPKuj6MIK/CJ71H1eSSlTuyX0an2UYq/LaCCa5mhtreNpp7h1jghQVZ3c0VQB1JJpir+6T8j/y4s/yh/J78s/yxsokij8keXNP0q5Me4luoYFF1MT3Ms3OQ+7HFXqeKvzX/wCfkP8AzmnP/wA4s/l5p3ljyJPC35yfmPFOnlyaRUlXR9PiolxqkkTVDPyb07dXHFn5MeQiZGVfye6xrOr+YdV1HXde1S71rW9XuJLvVdXvpnuLm5nlYtJLNNIWd3YmpLGpxV7L+Uv/ADjD+f8A+elrc6h+VH5U675x0qzkMNxrdvCsGnrKoq0QvLloYC4BBKB+QqNtxiqA/Nz/AJx1/O/8h5bGP83Py01ryRFqjFNM1G9iWSyuJAvNo4ryBpIHdV3KK5YdxiqF/I/88vzG/wCcevzB0f8AMj8s9cl0jWtMcLe2ZZms9RtCwMtlfQggSwyAbg7qaOhV1Vgq/rug/wCcu/y+i/5xRtf+csNcs73QvK03l9dVk8u3aGK9a/Z/qy6dD6ip6jS3X7qKQDi6kS/YNcVfyWf85Ff85G/mV/zk5+YmofmF+Y+qGaVy8Pl7y7AzDT9Hsi1UtLOJieKigLMfidvick4q878g/lx59/NPzFbeUvy48n6t528yXSmSLR9HtZLqYRqQGlkEYIjjWo5O5Cr3IxV7t5+/5wf/AOcsPyy8t3vm7zp+R/mDTfLmmIZdT1S2+r6gltEoq0s62M1w0cagVZ2AUdzir5ctLu6sLq2vrG5lsr6ylSezvIHaOWKWNgySRupDKysAQQag4q/qq/59g/8AOYfmv/nJL8vdc8lfmTHdah+YH5XpbRy+czC/o6zp0wKQyXEwHAXcRXjLUgyKVkHJvUIVfqVir8o/+fw/5cRebf8AnFSLztFCDqH5V+Z9O1M3IFWFlqbHS54/k01zAx/1Bir+V/FX6sfkr55k1b/n1N/zmT+X88vqt5L83eU9UtQTVo7fW9b0dFjArsvq2ErDbqzYq//X+Xf/ADnxrUmv/wDOY/8AzkLfSli0Hm2404cgAeOmxx2K9O3GAU9uuKvN/wDnGDy7F5t/5yR/IPy3cRCa01j8wvLdvfxEgVtm1O3M/wBrY/uw23fFX9xGKuxV/HR/z8f/ADLvfzN/5zF/OG5nuTNp/krUR5N0S3581t4dDX6tPGtCaBrsTyEdmc98VfMv5Nfl3c/m3+bX5bfljazNbSeffMumaHJeLStvDe3KRTT7g/3UbM/Q9Oh6Yq/uJ8leS/LH5deUvL/kbyXo9voHlbytZRafomkWq8Y4YIhQe7MxqzMaszEsxLEnFWPfm7+U/kr87vy88zfll5/0mLVvLfme0e3nV1Uy20xB9G7tmYH05oHo8bjow8MVfD3/ADjV/wA+uf8AnHn8hZdP8x+ZrVvzm/MGzIkj8weYrdF022lH7dnpAaSFSDQhp2mdWFUZcVfJ/wDz+3/Mm807yl+Sf5R2FyYbLzDqGo+ZtftY2C8l0yOK1sVZQalS11MaH4aoDuV2Vfzu4q/r+/59r/kNoH5Lf84ueQNVg06KPzh+bOmWnnDzhrBAM866jH6+n25anJUt7WRFCVoHMjbFzir79IDAqwDKwoyncEHFX5V3X/PpD/nHXWfzw83/AJo+YbjULjyRr1+upaT+TumD9G6ba3Eiq10stzC/rNBJMXeOGH0RGCFDFAFCr9LvJ3kryj+Xvl3TvKXkby1pvlLyzpKenp+h6VbR2ttEO5EcYUFmO7Md2O5JOKsnxV8sf85v+X4vM3/OIf8AzkXp0yCRLbyJq+qhSQPi0mA6ih+IEbNbg+PhQ74q/iqxV9m/kLrLwf8AOKv/ADnd5eEwVNU8veQNRa39ShY2HnKxiDCOvxBfrhFabVp+1ir/AP/Q+T3/ADmt/wCtcf8AORv/AJsDXP8AqLfFXf8AOFP/AK1x/wA45f8AmwND/wCotMVf2u4q7FX8Qn/OWaOn/OVH/OSodShP5qecWAYUNG1u7IP0g1GKs5/5wJnht/8AnMb/AJx5knkWJG83WsasxoC8qSRovzZmAHvir+0LFXYq7FX84f8Az+9Rx+aP5GyFSEbytqSq9NiVvVJAPtUYq/D/ABV/cv8A845zw3P/ADj3+RFzbyLNBcfl55XkgmQ1V0fSbYqwPcEGuKvZcVdirsVdirwD/nLH/wBZY/5yW/8ANVecv+6HeYq/iCxV9Q/kkjn8jv8AnMuQKSi+QPLSs9NgW89+XSAT4mhxV//R+Zv/AD8N8vnyz/zmj/zkBprIIzc+YY9W4jw1ayttRB6t1+sV/gOmKvCfyF81x+RPzx/JvzrPKIbbyl538v6vdyEkL6NnqME0oahU8SiEEVFRir+6TFXYq/kg/wCfp/5R3v5Y/wDOXPnLW1tTF5f/ADXt7bzboVwFojSzoLfUELDYuLuGRyOoV0J6glV8EeS/NmseQvOPlTzz5emFvr/k3WLHXNEnYVVLvT50uYSw2qA8YqMVf2jf844f85TflL/zk35J0jzR5C8y2X6bntkbzH5FmuIxq2lXXGssM9sSJCisCElVeDgVU9aKr/8AnIv/AJym/KH/AJxl8m6n5o/MLzNaDVoIGbQfI1tcRNrGq3HGscNva8i4ViRylYBEBqx6VVfh7+Rn/P5j8zvL/mW/t/z48rWvnryTquo3F1b3uhxRWWsaTDcStIlvCpMdvdxQKQiLJwkIFWmY4q9k/wCfoa+Vv+cn/wDnFj8nv+crfykludb8q+TtXvbK/u5rKazmTT9XkjtJpJUnVGIt7+yjh+HkvKRirFanFX892Kv6bv8An15/zmv+Xvmr8oPK/wCQn5hearDyv+ZH5eRfonywmqXC20et6SrE2YtpZeMZmt1YQGHlzKorryq/BV+tXmzzj5T8iaJe+ZfOvmTTPKnl/To2lvdZ1a6itLeNUBY1klZRWg6dTir+ev8AOX/n8J+YGlf85C32pfkpb6d5i/InQ4ItKi8ua1aGI628UjtcapHOFS6tXk58IQSVCKjyQliyhV+sn/OJP/OdH5Tf85d2+oaf5RsdX8s+efL9it/5l8n6nbtItvC0ixerDfwqbeVDI4VeRSQ7n0gAcVfamKvkL/nPrzPH5R/5w3/5yF1WSUwrd+U59FDqxQltbli0tVqCNmN0AR3rTfFX8YGKvt/8gtBmm/5w9/5z38z8XFvp2lflzpYbojPe+braYgbblRa9jtXfqMVf/9Lzt/z+Z/L6by3/AM5L+WvPUUDLpv5keULR5LkjZtQ0iaSznQdvht/qx6/tYq/IjFX9vH/OKX5rQ/nb/wA46flB+ZSXP1q91/y5ax6/ITUjVbEGy1EGu+11BJSvUUOKvoTFXyF/zmf/AM4k+V/+cuvysPlLULmPQvOvlySXUPy783shcWV66BZIZwvxNb3IVVlUbiiOAWRRir+Rr85PyM/NT8gvNt35L/NXyffeVtWgdxZ3E0Zayv4kP9/Y3SgxXEZqPiRjT7LcWBAVeS4q7FX6F/8AOFX/AD79/Mv/AJyj8w6V5i17Tr3yX+SFlcRza750uYzBJqcKOPUtNHWRf30kgBUzBTFFuWLOFjdV/VdJ+VH5eS/lg35Mv5Vsj+WbaD/hk+UwpFv+jPR+r+iCCGBCdHB5Bvi5ct8Vfykf85m/8+//AMz/APnFrzBqmuaTp9952/JW5nZ9B8928XqyWUT7rbaukQpBIn2fVoIpNivFiY1Vfn7irsVevfkt+RH5qf8AOQXnC08k/lV5Su/MuqzugvrxFKWOnwuaG4vroj04I1oTVjU/ZQMxClV/XD/zhj/ziR5V/wCcRvytj8p6fPFrnnfzC8d/+YnnFEKfXrxVISGEN8S29sGKxKetWcgM7DFX17ir8dP+fz/5n2/lr/nH7yZ+WME4XVvzN8zpcz29d20zQo/XnNB/y8zW1K+/0Kv5jsVfr1+U3kKTy/8A8+hf+cpfPNzB6Vx+YPnHQFspeIHqWGka/olvG3LqaXD3Ap2p7nFX/9P07/z9/wDyYk/MT/nGqz/MTS7M3OufkvrCapKyLyf9DalwtNQVQBX4ZPq8zHoEjYnxCr+WLFX76/8APmD/AJyJgt5/Of8AzjP5ivwj3zy+a/y4WVgOcioqarZx13JKIlwqjsszeOKv6B8VdirF/N/kjyZ+YOiz+XPPflPR/Ofl+5IafRNcsYL+1Zl+yxhuEdOQ7GlR2xV8d6t/z7O/5we1q9e/vPyHsoZ5BRo7DWdd0+HqTtBZ6jDEOvZcVZT5G/5wA/5w4/LvUItU8tfkJ5fkv7eQS28+tvea96cikFXRdXuLxVKkAggbHcYq+v4YYreKKCCJIIIEWOGGNQqIiiiqqigAAFABiqpiqnNDFcRSwTxJPBOjRzQyKGR0YUZWU1BBBoQcVfInnr/nAT/nDv8AMe/l1TzP+Qvl5L+4f1Li40VrvQTI5pVnGjz2YZjSpJFSak9TirENK/59mf8AODuj3sV/afkRaTTwmqR32t69fQmhB+KC71GWJundTir7E8neRfJf5eaJB5b8heUtH8l+X7clodF0SygsLYMQAX9K3RFLGgqxFT3OKsqxV2Kv5Bv+fln/ADkJD+fv/OTnmU6HffXPI/5Yxnyh5TkjasM7Wcjtf3aUJUia6Zwrj7cSRnFXwHa21xe3NvZ2kD3N3dypDa20SlnkkkIVEVRuSxIAAxV/Yl/0KdB/0IR/0Kl6cX6X/wCVf/UOfJfR/wAT/wDHT9etePD9K/vPtdO/fFX/1PvD5l8u6N5v8ua95T8xWKanoHmbTrrStb06T7E9peRNDPG3syORir+JD/nJH8jtf/5xz/Ojzz+Uuv8AOY+W75joequKC/0q4/e2N2KDjWSFlLgbK/JOqnFXn35fefPM/wCV/nfyt+YfkzUG0vzR5O1KDVNFvVqQJoHDcJFBHONxVHQ7MpKnYnFX9ov/ADi//wA5FeUf+cn/AMofLv5oeVmS1ubpPqfmzy4ZA82latCo+s2kncrUh42IHONlagrQKvobFXYq7FXYq7FXYq7FXYq7FXYq7FX5jf8APzT/AJzDtf8AnHj8p7r8vfJ+qBPzi/NKyltNHEDr6ukaTITFdam46qzjlFbnb95ycH90QVX8nmKv03/59W/8443H50/85F6b561nTzN5B/JNofMOqzSLWKfV+R/RFoCerCZDcHYjjCVNOS4q/rFxV//V+/mKvy6/5+ef84cyf85E/lhH+Y3kTSvrf5v/AJWWksthawJWfWdFBaa504AbvJGS01uNyW5xqKy1Cr+UkgqSrAqymhB2IIxV9Z/84ff85bed/wDnEj8yo/Nmgo+t+T9cEVp5/wDJDytHBqVojErInVUuYOTGGQg0qymqOwKr+vr8n/zg8gfnt5A0P8yvy11yPXfLGux1RxRbi1uFA9a0u4akxTRE0dD7EEqVYqvTsVdirsVdirsVdirsVdirsVfH/wDzmD/zmN+Xn/OJHkSTWNcmh178wNZhdfIn5exTBbq+m3UTz0q0NrGw/eSkduCcnIGKv5BvzV/NLzt+dPn/AMyfmX+YWsPrXmrzTdG5v7lqiONQOMVvAhJ9OGFAEjQGiqAMVSLyZ5O8y/mD5r8veSPJ2kz675o8038Om6HpNuKvNcTsFUeCgVqzEgKoLMQATir+zn/nET/nG3Qv+cWfyS8t/lnprQ32vEHVPPnmCJafpDWblV+sSKSFJjjCrDFUA+mi1+LkSq+ncVf/1vv5irsVfzz/APPzn/n3rd6de+YP+clfyN0L19GuvU1D82PI1hH8dpNu02sWUKDeF92uUUVRqyiqF/TVfg3ir6g/5xc/5y1/Nb/nFDzn/iTyFqAv9A1JkTzd5Dvnc6ZqsKkfbUV9KZR/dzIOS9DyQsjKv6n/APnFz/nNj8k/+cq9Ft28m62mhee4YPU138stVlSPVbVkA9V4F2F3ApO0sVQARzWNjxCr69xV2KuxV2KuxV2KuxV+VP8AzmJ/z9F/K78ibfU/Jf5R3Fh+a35sqHt5WtpfV0LRpQCC15cwmlxKjbehC1QQRI8ZFGVfzKfmV+Znnv8AN/zlrP5gfmR5lu/Nfm3XpfU1DVbxgTQbJFEigJFFGPhSNFCKNlAGKsOsbG91O9s9N02zn1DUdQnjtrCwto2lmnmlYJHFFGgLOzsQFUCpOwxV/Ut/z7c/5wIj/wCcdNBj/Nr809Oil/O7zRaFLTTXKyr5a0+YfFbIwqPrUyn9+4J4j90hp6hkVfq5irsVf//X+/mKuxVogMCrAMrCjKdwQcVfgD/znx/z60uJbnWvzm/5xg0QzfWnkvvOH5PWiqCjGryXOhxgDYmrNa9Qa+jtxiCr8CLi3uLS4ntLuCS1urWRorm2lUpJHIhKsjqwBUqRQg9MVROl6rqeh6jZaxouo3Wj6tpsyXGnapZTPb3NvNGapJFLGVdGU7gqQRir9VfyF/5+9f8AOQn5YxWWifmhY2X53+WrYLGLrUZDp+vRoooANRhjdJadSZ4JHY/7sGKv1a/Lb/n7j/ziJ53hhj8z6zr35V6m4Cva+YdLmuIDIaVEdzpf1xePg0gj9wMVfXHl7/nLb/nF3zTEsuif85C/l7clgWFrL5i0+2uAoAJJt7iaOUAchuV67dcVZN/0ML+QX/l8fy//APCm0r/spxV5t5r/AOc4f+cRPJkMk+s/85EeSLgRCskWjapFrcw3K09HS/rUlQRuONR3xV8P/mp/z+c/5x+8sQ3dr+VvlHzJ+aOrIGFpeXEa6HpTnoCZrkSXXvT6qPmOyr8fP+cif+fjP/OS/wDzkTb6joOqeZ4vIXkLUFMU/kbyor2VvPEagpeXTO91cBhs6NIIj1EYxV8H4qy7yL5C85/mb5p0nyT5A8t3/mzzVrkoh0zRNOiMs0h7sabIijd3chVWrMQATir+n/8A5wP/AOfbvlj/AJxuhsPzL/NFbLzj+d80fOyKfvtO8th1IMdiWUepclWpJORt9iKi8nkVfqfirsVdir//0Pv5irsVdirsVfAH/OWn/Puz8lP+cpBd+ZBD/wAq3/Nd0/d/mDo9ujC8YCijVbOsaXYGw58klACj1OA44q/nK/5yG/5wP/5yP/5xumvbzzd5Km8xeS7Ylk/MPy0smo6T6QNA9wyoJbTqB/pEaAnZS3XFXxvirsVdirsVdirsVV7a1ub24gtLO3lu7u5dYra1hQySSOxoqoigliTsABir9Pv+cbv+fU3/ADkH+cs1hrn5i2j/AJI+Q5Ssk11rkDHXLmI7kW2lEpJGT05XJip9oK/TFX9FP/OO3/OKf5K/84v+Xm0T8rPK6WupXkSxa/5zvytzrWp8TyH1q74r8AO4jjVIwdwgNTir6OxV2KuxV2Kv/9H7+Yq7FXYq7FXYqtfhwb1KcKHny6U71rir8ff+cpbD/n0lqes3dl+bWteUPL3naeWVb3V/y/S9fUIbmv7xr1fLcFzCZa9frcbNXFX5XeefyH/59wXck835bf8AOdOs6FFUm307zJ5D1/VSR/K1zaafp9Pn6J+XfFXzfq/5Kfk3DNx0H/nMP8utSgqayX/l/wA+2L0oKHhF5Yux1r+1/Yqk/wDypv8ALr/2LH8qv+4b+Yf/AIxuKs18u/kZ/wA463MkQ82/85teTdEhIX130jyf531RlJB5cVn0XTw1DSlSK79KUKr6v/Lz8nP+fT2gvBc/mN/zl35r/MKeEKZLOw8q69oVjKf2uca6TeXAB7BbgEeJxV+0/wDziMP+ffwgjH/OKR8iNrQiYM0PP/FBi35GX9MU1Xh1+18OKvvLFXYq7FXYq7FXYq//2Q==" alt="cc-logo.jpg" />
</div>
<h1><span>Creative Commons Legal Code</span></h1>
<div id="deed-license">
<h2>Attribution-NonCommercial-ShareAlike 3.0 Unported</h2>
</div>
</div>
<div id="deed-main">
<div id="deed-main-content">
<h3><em>License</em></h3>
<p>THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS
OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR
"LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER
APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS
PROHIBITED.</p>
<p>BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU
ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE.
TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A
CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE
IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
CONDITIONS.</p>
<p><strong>1. Definitions</strong></p>
<ol type="a">
<li><strong>"Adaptation"</strong> means a work based upon
the Work, or upon the Work and other pre-existing works,
such as a translation, adaptation, derivative work,
arrangement of music or other alterations of a literary
or artistic work, or phonogram or performance and
includes cinematographic adaptations or any other form in
which the Work may be recast, transformed, or adapted
including in any form recognizably derived from the
original, except that a work that constitutes a
Collection will not be considered an Adaptation for the
purpose of this License. For the avoidance of doubt,
where the Work is a musical work, performance or
phonogram, the synchronization of the Work in
timed-relation with a moving image ("synching") will be
considered an Adaptation for the purpose of this
License.</li>
<li><strong>"Collection"</strong> means a collection of
literary or artistic works, such as encyclopedias and
anthologies, or performances, phonograms or broadcasts,
or other works or subject matter other than works listed
in Section 1(g) below, which, by reason of the selection
and arrangement of their contents, constitute
intellectual creations, in which the Work is included in
its entirety in unmodified form along with one or more
other contributions, each constituting separate and
independent works in themselves, which together are
assembled into a collective whole. A work that
constitutes a Collection will not be considered an
Adaptation (as defined above) for the purposes of this
License.</li>
<li><strong>"Distribute"</strong> means to make available
to the public the original and copies of the Work or
Adaptation, as appropriate, through sale or other
transfer of ownership.</li>
<li><strong>"License Elements"</strong> means the
following high-level license attributes as selected by
Licensor and indicated in the title of this License:
Attribution, Noncommercial, ShareAlike.</li>
<li><strong>"Licensor"</strong> means the individual,
individuals, entity or entities that offer(s) the Work
under the terms of this License.</li>
<li><strong>"Original Author"</strong> means, in the case
of a literary or artistic work, the individual,
individuals, entity or entities who created the Work or
if no individual or entity can be identified, the
publisher; and in addition (i) in the case of a
performance the actors, singers, musicians, dancers, and
other persons who act, sing, deliver, declaim, play in,
interpret or otherwise perform literary or artistic works
or expressions of folklore; (ii) in the case of a
phonogram the producer being the person or legal entity
who first fixes the sounds of a performance or other
sounds; and, (iii) in the case of broadcasts, the
organization that transmits the broadcast.</li>
<li><strong>"Work"</strong> means the literary and/or
artistic work offered under the terms of this License
including without limitation any production in the
literary, scientific and artistic domain, whatever may be
the mode or form of its expression including digital
form, such as a book, pamphlet and other writing; a
lecture, address, sermon or other work of the same
nature; a dramatic or dramatico-musical work; a
choreographic work or entertainment in dumb show; a
musical composition with or without words; a
cinematographic work to which are assimilated works
expressed by a process analogous to cinematography; a
work of drawing, painting, architecture, sculpture,
engraving or lithography; a photographic work to which
are assimilated works expressed by a process analogous to
photography; a work of applied art; an illustration, map,
plan, sketch or three-dimensional work relative to
geography, topography, architecture or science; a
performance; a broadcast; a phonogram; a compilation of
data to the extent it is protected as a copyrightable
work; or a work performed by a variety or circus
performer to the extent it is not otherwise considered a
literary or artistic work.</li>
<li><strong>"You"</strong> means an individual or entity
exercising rights under this License who has not
previously violated the terms of this License with
respect to the Work, or who has received express
permission from the Licensor to exercise rights under
this License despite a previous violation.</li>
<li><strong>"Publicly Perform"</strong> means to perform
public recitations of the Work and to communicate to the
public those public recitations, by any means or process,
including by wire or wireless means or public digital
performances; to make available to the public Works in
such a way that members of the public may access these
Works from a place and at a place individually chosen by
them; to perform the Work to the public by any means or
process and the communication to the public of the
performances of the Work, including by public digital
performance; to broadcast and rebroadcast the Work by any
means including signs, sounds or images.</li>
<li><strong>"Reproduce"</strong> means to make copies of
the Work by any means including without limitation by
sound or visual recordings and the right of fixation and
reproducing fixations of the Work, including storage of a
protected performance or phonogram in digital form or
other electronic medium.</li>
</ol>
<p><strong>2. Fair Dealing Rights.</strong> Nothing in this
License is intended to reduce, limit, or restrict any uses
free from copyright or rights arising from limitations or
exceptions that are provided for in connection with the
copyright protection under copyright law or other
applicable laws.</p>
<p><strong>3. License Grant.</strong> Subject to the terms
and conditions of this License, Licensor hereby grants You
a worldwide, royalty-free, non-exclusive, perpetual (for
the duration of the applicable copyright) license to
exercise the rights in the Work as stated below:</p>
<ol type="a">
<li>to Reproduce the Work, to incorporate the Work into
one or more Collections, and to Reproduce the Work as
incorporated in the Collections;</li>
<li>to create and Reproduce Adaptations provided that any
such Adaptation, including any translation in any medium,
takes reasonable steps to clearly label, demarcate or
otherwise identify that changes were made to the original
Work. For example, a translation could be marked "The
original work was translated from English to Spanish," or
a modification could indicate "The original work has been
modified.";</li>
<li>to Distribute and Publicly Perform the Work including
as incorporated in Collections; and,</li>
<li>to Distribute and Publicly Perform Adaptations.</li>
</ol>
<p>The above rights may be exercised in all media and
formats whether now known or hereafter devised. The above
rights include the right to make such modifications as are
technically necessary to exercise the rights in other media
and formats. Subject to Section 8(f), all rights not
expressly granted by Licensor are hereby reserved,
including but not limited to the rights described in
Section 4(e).</p>
<p><strong>4. Restrictions.</strong> The license granted in
Section 3 above is expressly made subject to and limited by
the following restrictions:</p>
<ol type="a">
<li>You may Distribute or Publicly Perform the Work only
under the terms of this License. You must include a copy
of, or the Uniform Resource Identifier (URI) for, this
License with every copy of the Work You Distribute or
Publicly Perform. You may not offer or impose any terms
on the Work that restrict the terms of this License or
the ability of the recipient of the Work to exercise the
rights granted to that recipient under the terms of the
License. You may not sublicense the Work. You must keep
intact all notices that refer to this License and to the
disclaimer of warranties with every copy of the Work You
Distribute or Publicly Perform. When You Distribute or
Publicly Perform the Work, You may not impose any
effective technological measures on the Work that
restrict the ability of a recipient of the Work from You
to exercise the rights granted to that recipient under
the terms of the License. This Section 4(a) applies to
the Work as incorporated in a Collection, but this does
not require the Collection apart from the Work itself to
be made subject to the terms of this License. If You
create a Collection, upon notice from any Licensor You
must, to the extent practicable, remove from the
Collection any credit as required by Section 4(d), as
requested. If You create an Adaptation, upon notice from
any Licensor You must, to the extent practicable, remove
from the Adaptation any credit as required by Section
4(d), as requested.</li>
<li>You may Distribute or Publicly Perform an Adaptation
only under: (i) the terms of this License; (ii) a later
version of this License with the same License Elements as
this License; (iii) a Creative Commons jurisdiction
license (either this or a later license version) that
contains the same License Elements as this License (e.g.,
Attribution-NonCommercial-ShareAlike 3.0 US) ("Applicable
License"). You must include a copy of, or the URI, for
Applicable License with every copy of each Adaptation You
Distribute or Publicly Perform. You may not offer or
impose any terms on the Adaptation that restrict the
terms of the Applicable License or the ability of the
recipient of the Adaptation to exercise the rights
granted to that recipient under the terms of the
Applicable License. You must keep intact all notices that
refer to the Applicable License and to the disclaimer of
warranties with every copy of the Work as included in the
Adaptation You Distribute or Publicly Perform. When You
Distribute or Publicly Perform the Adaptation, You may
not impose any effective technological measures on the
Adaptation that restrict the ability of a recipient of
the Adaptation from You to exercise the rights granted to
that recipient under the terms of the Applicable License.
This Section 4(b) applies to the Adaptation as
incorporated in a Collection, but this does not require
the Collection apart from the Adaptation itself to be
made subject to the terms of the Applicable License.</li>
<li>You may not exercise any of the rights granted to You
in Section 3 above in any manner that is primarily
intended for or directed toward commercial advantage or
private monetary compensation. The exchange of the Work
for other copyrighted works by means of digital
file-sharing or otherwise shall not be considered to be
intended for or directed toward commercial advantage or
private monetary compensation, provided there is no
payment of any monetary compensation in con-nection with
the exchange of copyrighted works.</li>
<li>If You Distribute, or Publicly Perform the Work or
any Adaptations or Collections, You must, unless a
request has been made pursuant to Section 4(a), keep
intact all copyright notices for the Work and provide,
reasonable to the medium or means You are utilizing: (i)
the name of the Original Author (or pseudonym, if
applicable) if supplied, and/or if the Original Author
and/or Licensor designate another party or parties (e.g.,
a sponsor institute, publishing entity, journal) for
attribution ("Attribution Parties") in Licensor's
copyright notice, terms of service or by other reasonable
means, the name of such party or parties; (ii) the title
of the Work if supplied; (iii) to the extent reasonably
practicable, the URI, if any, that Licensor specifies to
be associated with the Work, unless such URI does not
refer to the copyright notice or licensing information
for the Work; and, (iv) consistent with Section 3(b), in
the case of an Adaptation, a credit identifying the use
of the Work in the Adaptation (e.g., "French translation
of the Work by Original Author," or "Screenplay based on
original Work by Original Author"). The credit required
by this Section 4(d) may be implemented in any reasonable
manner; provided, however, that in the case of a
Adaptation or Collection, at a minimum such credit will
appear, if a credit for all contributing authors of the
Adaptation or Collection appears, then as part of these
credits and in a manner at least as prominent as the
credits for the other contributing authors. For the
avoidance of doubt, You may only use the credit required
by this Section for the purpose of attribution in the
manner set out above and, by exercising Your rights under
this License, You may not implicitly or explicitly assert
or imply any connection with, sponsorship or endorsement
by the Original Author, Licensor and/or Attribution
Parties, as appropriate, of You or Your use of the Work,
without the separate, express prior written permission of
the Original Author, Licensor and/or Attribution
Parties.</li>
<li>
<p>For the avoidance of doubt:</p>
<ol type="i">
<li><strong>Non-waivable Compulsory License
Schemes</strong>. In those jurisdictions in which the
right to collect royalties through any statutory or
compulsory licensing scheme cannot be waived, the
Licensor reserves the exclusive right to collect such
royalties for any exercise by You of the rights
granted under this License;</li>
<li><strong>Waivable Compulsory License
Schemes</strong>. In those jurisdictions in which the
right to collect royalties through any statutory or
compulsory licensing scheme can be waived, the
Licensor reserves the exclusive right to collect such
royalties for any exercise by You of the rights
granted under this License if Your exercise of such
rights is for a purpose or use which is otherwise
than noncommercial as permitted under Section 4(c)
and otherwise waives the right to collect royalties
through any statutory or compulsory licensing scheme;
and,</li>
<li><strong>Voluntary License Schemes</strong>. The
Licensor reserves the right to collect royalties,
whether individually or, in the event that the
Licensor is a member of a collecting society that
administers voluntary licensing schemes, via that
society, from any exercise by You of the rights
granted under this License that is for a purpose or
use which is otherwise than noncommercial as
permitted under Section 4(c).</li>
</ol>
</li>
<li>Except as otherwise agreed in writing by the Licensor
or as may be otherwise permitted by applicable law, if
You Reproduce, Distribute or Publicly Perform the Work
either by itself or as part of any Adaptations or
Collections, You must not distort, mutilate, modify or
take other derogatory action in relation to the Work
which would be prejudicial to the Original Author's honor
or reputation. Licensor agrees that in those
jurisdictions (e.g. Japan), in which any exercise of the
right granted in Section 3(b) of this License (the right
to make Adaptations) would be deemed to be a distortion,
mutilation, modification or other derogatory action
prejudicial to the Original Author's honor and
reputation, the Licensor will waive or not assert, as
appropriate, this Section, to the fullest extent
permitted by the applicable national law, to enable You
to reasonably exercise Your right under Section 3(b) of
this License (right to make Adaptations) but not
otherwise.</li>
</ol>
<p><strong>5. Representations, Warranties and
Disclaimer</strong></p>
<p>UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN
WRITING AND TO THE FULLEST EXTENT PERMITTED BY APPLICABLE
LAW, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO
REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE
WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING,
WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE
ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE
PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE.
SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED
WARRANTIES, SO THIS EXCLUSION MAY NOT APPLY TO YOU.</p>
<p><strong>6. Limitation on Liability.</strong> EXCEPT TO
THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL
LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY
SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY
DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK,
EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.</p>
<p><strong>7. Termination</strong></p>
<ol type="a">
<li>This License and the rights granted hereunder will
terminate automatically upon any breach by You of the
terms of this License. Individuals or entities who have
received Adaptations or Collections from You under this
License, however, will not have their licenses terminated
provided such individuals or entities remain in full
compliance with those licenses. Sections 1, 2, 5, 6, 7,
and 8 will survive any termination of this License.</li>
<li>Subject to the above terms and conditions, the
license granted here is perpetual (for the duration of
the applicable copyright in the Work). Notwithstanding
the above, Licensor reserves the right to release the
Work under different license terms or to stop
distributing the Work at any time; provided, however that
any such election will not serve to withdraw this License
(or any other license that has been, or is required to
be, granted under the terms of this License), and this
License will continue in full force and effect unless
terminated as stated above.</li>
</ol>
<p><strong>8. Miscellaneous</strong></p>
<ol type="a">
<li>Each time You Distribute or Publicly Perform the Work
or a Collection, the Licensor offers to the recipient a
license to the Work on the same terms and conditions as
the license granted to You under this License.</li>
<li>Each time You Distribute or Publicly Perform an
Adaptation, Licensor offers to the recipient a license to
the original Work on the same terms and conditions as the
license granted to You under this License.</li>
<li>If any provision of this License is invalid or
unenforceable under applicable law, it shall not affect
the validity or enforceability of the remainder of the
terms of this License, and without further action by the
parties to this agreement, such provision shall be
reformed to the minimum extent necessary to make such
provision valid and enforceable.</li>
<li>No term or provision of this License shall be deemed
waived and no breach consented to unless such waiver or
consent shall be in writing and signed by the party to be
charged with such waiver or consent.</li>
<li>This License constitutes the entire agreement between
the parties with respect to the Work licensed here. There
are no understandings, agreements or representations with
respect to the Work not specified here. Licensor shall
not be bound by any additional provisions that may appear
in any communication from You. This License may not be
modified without the mutual written agreement of the
Licensor and You.</li>
<li>The rights granted under, and the subject matter
referenced, in this License were drafted utilizing the
terminology of the Berne Convention for the Protection of
Literary and Artistic Works (as amended on September 28,
1979), the Rome Convention of 1961, the WIPO Copyright
Treaty of 1996, the WIPO Performances and Phonograms
Treaty of 1996 and the Universal Copyright Convention (as
revised on July 24, 1971). These rights and subject
matter take effect in the relevant jurisdiction in which
the License terms are sought to be enforced according to
the corresponding provisions of the implementation of
those treaty provisions in the applicable national law.
If the standard suite of rights granted under applicable
copyright law includes additional rights not granted
under this License, such additional rights are deemed to
be included in the License; this License is not intended
to restrict the license of any rights under applicable
law.</li>
</ol>
<!-- BREAKOUT FOR CC NOTICE. NOT A PART OF THE LICENSE -->
<blockquote>
<h3>Creative Commons Notice</h3>
<p>Creative Commons is not a party to this License, and
makes no warranty whatsoever in connection with the Work.
Creative Commons will not be liable to You or any party
on any legal theory for any damages whatsoever, including
without limitation any general, special, incidental or
consequential damages arising in connection to this
license. Notwithstanding the foregoing two (2) sentences,
if Creative Commons has expressly identified itself as
the Licensor hereunder, it shall have all rights and
obligations of Licensor.</p>
<p>Except for the limited purpose of indicating to the
public that the Work is licensed under the CCPL, Creative
Commons does not authorize the use by either party of the
trademark "Creative Commons" or any related trademark or
logo of Creative Commons without the prior written
consent of Creative Commons. Any permitted use will be in
compliance with Creative Commons' then-current trademark
usage guidelines, as may be published on its website or
otherwise made available upon request from time to time.
For the avoidance of doubt, this trademark restriction
does not form part of this License.</p>
<p>Creative Commons may be contacted at <a href="http://creativecommons.org/">http://creativecommons.org/</a>.</p>
</blockquote>
</div>
</div>
</div>
</body>
</html> | 05-android-task-calendar | TaskCalendar/res/raw/license.html | HTML | oos | 73,100 |
/** Automatically generated file. DO NOT MODIFY */
package com.giltesa.taskcalendar;
public final class BuildConfig {
public final static boolean DEBUG = true;
} | 05-android-task-calendar | TaskCalendar/gen/com/giltesa/taskcalendar/BuildConfig.java | Java | oos | 166 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package java.awt;
/**
*
* @author RUA
*/
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/java/awt/event.java | Java | oos | 157 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package quanlycuahangcongnghe;
/**
*
* @author RUA
*/
public class ThemLoaiHoaDon extends javax.swing.JFrame {
/**
* Creates new form ThemLoaiHoaDon
*/
public ThemLoaiHoaDon() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jTextField1 = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTextField1.setText("jTextField1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(156, 156, 156)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(185, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(104, 104, 104)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(176, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ThemLoaiHoaDon.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ThemLoaiHoaDon.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ThemLoaiHoaDon.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ThemLoaiHoaDon.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ThemLoaiHoaDon().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField jTextField1;
// End of variables declaration//GEN-END:variables
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/quanlycuahangcongnghe/ThemLoaiHoaDon.java | Java | oos | 3,875 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package quanlycuahangcongnghe;
import DAO.LoaiHoaDonDAO;
import DAO.NhaCungCapDAO;
import DAO.NhomLoaiSanPhamDAO;
import DAO.PhieuNhapDAO;
import DAO.TimSanPhamDAO;
import DAO.TrangThaiDAO;
import java.util.List;
import java.util.Date;
import org.hibernate.HibernateException;
import java.sql.*;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.table.DefaultTableModel;
import org.hibernate.Query;
import qlchcn.entity.LoaiHoaDon;
import qlchcn.entity.NhaCungCap;
import qlchcn.entity.NhomLoaiSanPham;
import qlchcn.entity.PhieuNhap;
import qlchcn.entity.SanPham;
import qlchcn.entity.TrangThai;
/**
*
* @author RUA
*/
public class Pages extends javax.swing.JFrame {
/**
* Creates new form Pages
*/
public Pages() {
initComponents();
//Thuc hien khi khoi tao form
loadTenNhom();
loadTrangThai();
loadNhaCungCap();
loadLoaiHoaDon();
loadPhieuNhap();
insertPhieuNhap();
loadNhaSanXuat();
loadNhomLoaiSanPham();
loadMenu();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel12 = new javax.swing.JLabel();
jScrollBar1 = new javax.swing.JScrollBar();
jScrollPane5 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
QuanLyCuaHang = new javax.swing.JTabbedPane();
TrangChu = new javax.swing.JPanel();
jButton5 = new javax.swing.JButton();
jLabel9 = new javax.swing.JLabel();
jButton8 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jLabel10 = new javax.swing.JLabel();
jButton9 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jLabel7 = new javax.swing.JLabel();
jButton10 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jLabel8 = new javax.swing.JLabel();
jButton11 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton12 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jButton7 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
HoaDon = new javax.swing.JPanel();
jLabel23 = new javax.swing.JLabel();
txtMaHoaDon_HoaDon = new javax.swing.JTextField();
jLabel24 = new javax.swing.JLabel();
txtSoChungTu_HoaDon = new javax.swing.JTextField();
jLabel25 = new javax.swing.JLabel();
spnNgayChungTu_HoaDon = new javax.swing.JSpinner();
jLabel26 = new javax.swing.JLabel();
jLabel28 = new javax.swing.JLabel();
spnNgayTao_HoaDon = new javax.swing.JSpinner();
cboLoaiHoaDon_HoaDon = new javax.swing.JComboBox();
jLabel29 = new javax.swing.JLabel();
jLabel30 = new javax.swing.JLabel();
cboTrangThai_HoaDon = new javax.swing.JComboBox();
jScrollPane3 = new javax.swing.JScrollPane();
txtDienGiai_HoaDon = new javax.swing.JTextArea();
btnTaoHoaDon_HoaDon = new javax.swing.JButton();
btnHuy_HoaDon = new javax.swing.JButton();
btnDanhSachHoaDon_HoaDon = new javax.swing.JButton();
btnThemHoaDon_HoaDon = new javax.swing.JButton();
btnThemTrangThai_HoaDon = new javax.swing.JButton();
jLabel31 = new javax.swing.JLabel();
txtKhachHang_HoaDon1 = new javax.swing.JTextField();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel2 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
txtKhachHang_HoaDon = new javax.swing.JTextField();
jLabel27 = new javax.swing.JLabel();
cboNhaSanXuat_HoaDon = new javax.swing.JComboBox();
jLabel32 = new javax.swing.JLabel();
jScrollPane4 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
jLabel33 = new javax.swing.JLabel();
jScrollPane6 = new javax.swing.JScrollPane();
jTable2 = new javax.swing.JTable();
jLabel34 = new javax.swing.JLabel();
btnXoaSanPham_HoaDon = new javax.swing.JButton();
cboTrangThai_HoaDon1 = new javax.swing.JComboBox();
jLabel35 = new javax.swing.JLabel();
PhieuNhap = new javax.swing.JPanel();
jLabel14 = new javax.swing.JLabel();
txtMaPhieu_PhieuNhap = new javax.swing.JTextField();
txtSoChungTu_PhieuNhap = new javax.swing.JTextField();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
cboLoaiHoaDon_PhieuNhap = new javax.swing.JComboBox();
jLabel18 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
cboNhaCungCap_PhieuNhap = new javax.swing.JComboBox();
btnThemLoaiHoaDon_PhieuNhap = new javax.swing.JButton();
jLabel20 = new javax.swing.JLabel();
cboTrangThai_PhieuNhap = new javax.swing.JComboBox();
jScrollPane1 = new javax.swing.JScrollPane();
txtDienGiai_PhieuNhap = new javax.swing.JTextArea();
jLabel21 = new javax.swing.JLabel();
btnThemPhieuNhap_PhieuNhap = new javax.swing.JButton();
btnHuy_PhieuNhap = new javax.swing.JButton();
btnThemTrangThai_PhieuNhap = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
tblPhieuNhap_PhieuNhap = new javax.swing.JTable();
spnNgayNhap_PhieuNhap = new javax.swing.JSpinner();
spnNgayChungTu_PhieuNhap = new javax.swing.JSpinner();
spnNgayTao_PhieuNhap = new javax.swing.JSpinner();
jLabel22 = new javax.swing.JLabel();
btnThemNhaCungCap_PhieuNhap = new javax.swing.JButton();
btnDanhSachPhieuNhap_PhieuNhap = new javax.swing.JButton();
QuyDinh = new javax.swing.JPanel();
TimKiem = new javax.swing.JPanel();
tabTimKiem = new javax.swing.JTabbedPane();
TimHoaDon = new javax.swing.JPanel();
TimPhieuNhap = new javax.swing.JPanel();
jLabel37 = new javax.swing.JLabel();
txtTenSanPham_TimKiem1 = new javax.swing.JTextField();
cboNhomLoaiSanPham_TimKiem1 = new javax.swing.JComboBox();
jLabel39 = new javax.swing.JLabel();
btnTim_TimKiem1 = new javax.swing.JButton();
TimSanPham = new javax.swing.JPanel();
txtTenSanPham = new javax.swing.JTextField();
jLabel36 = new javax.swing.JLabel();
jLabel38 = new javax.swing.JLabel();
cboNhomLoaiSanPham = new javax.swing.JComboBox();
btnTim = new javax.swing.JButton();
jScrollPane7 = new javax.swing.JScrollPane();
tblSanPham = new javax.swing.JTable();
ThongKe = new javax.swing.JPanel();
KhacHang = new javax.swing.JPanel();
LapPhieuThu = new javax.swing.JPanel();
KhuyenMai = new javax.swing.JPanel();
CuaHang = new javax.swing.JPanel();
SanPham = new javax.swing.JPanel();
NhanVien = new javax.swing.JPanel();
TaiKhoan = new javax.swing.JPanel();
jLabel12.setFont(new java.awt.Font("Tahoma", 1, 8)); // NOI18N
jLabel12.setText("NHÂN VIÊN");
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane5.setViewportView(jTable1);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Quản lý Chuỗi cửa hàng Công nghệ cao");
setBackground(new java.awt.Color(255, 255, 255));
setResizable(false);
QuanLyCuaHang.setRequestFocusEnabled(false);
jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/Pie-chart-icon.png"))); // NOI18N
jButton5.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel9.setText("QUẢN LÝ CỬA HÀNG");
jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/gift-card-icon.png"))); // NOI18N
jButton8.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/Search-icon.png"))); // NOI18N
jButton3.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel10.setText("QUẢN LÝ SẢN PHẨM");
jButton9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/office-building-icon.png"))); // NOI18N
jButton9.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});
jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/Settings-Backup-Sync-icon.png"))); // NOI18N
jButton4.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel7.setText("LẬP PHIẾU THU");
jButton10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/checklist-icon.png"))); // NOI18N
jButton10.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton10ActionPerformed(evt);
}
});
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/Cash-register-icon.png"))); // NOI18N
jButton1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel8.setText("KHUYẾN MÃI");
jButton11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/Settings-icon.png"))); // NOI18N
jButton11.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/history-icon.png"))); // NOI18N
jButton2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/Status-dialog-password-icon.png"))); // NOI18N
jButton12.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton12ActionPerformed(evt);
}
});
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel1.setText("QUẢN LÝ HÓA ĐƠN");
jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel11.setText("QUẢN LÝ NHÂN VIÊN");
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel2.setText("QUẢN LÝ PHIẾU NHẬP");
jLabel13.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel13.setText("TÀI KHOẢN");
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel3.setText("THAY ĐỔI QUY ĐỊNH");
jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/Note-icon.png"))); // NOI18N
jButton7.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/Group-Black-Folder-icon.png"))); // NOI18N
jButton6.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel4.setText("TÌM KIẾM");
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel6.setText("KHÁCH HÀNG");
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel5.setText("THỐNG KÊ");
javax.swing.GroupLayout TrangChuLayout = new javax.swing.GroupLayout(TrangChu);
TrangChu.setLayout(TrangChuLayout);
TrangChuLayout.setHorizontalGroup(
TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TrangChuLayout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(TrangChuLayout.createSequentialGroup()
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(TrangChuLayout.createSequentialGroup()
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TrangChuLayout.createSequentialGroup()
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(TrangChuLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel9)))
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TrangChuLayout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 96, Short.MAX_VALUE)
.addComponent(jLabel10)
.addGap(21, 21, 21))
.addGroup(TrangChuLayout.createSequentialGroup()
.addGap(82, 82, 82)
.addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(TrangChuLayout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TrangChuLayout.createSequentialGroup()
.addGap(117, 117, 117)
.addComponent(jLabel7))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, TrangChuLayout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel11)
.addGap(10, 10, 10))
.addGroup(TrangChuLayout.createSequentialGroup()
.addGap(83, 83, 83)
.addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, TrangChuLayout.createSequentialGroup()
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(TrangChuLayout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLabel1))
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 82, Short.MAX_VALUE)
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TrangChuLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel2))
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(87, 87, 87)
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(TrangChuLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel3))
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TrangChuLayout.createSequentialGroup()
.addGap(77, 77, 77)
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, TrangChuLayout.createSequentialGroup()
.addComponent(jLabel4)
.addGap(49, 49, 49))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, TrangChuLayout.createSequentialGroup()
.addComponent(jLabel8)
.addGap(39, 39, 39))))
.addComponent(jButton12, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, TrangChuLayout.createSequentialGroup()
.addComponent(jLabel13)
.addGap(43, 43, 43)))))
.addContainerGap(22, Short.MAX_VALUE))
);
TrangChuLayout.setVerticalGroup(
TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TrangChuLayout.createSequentialGroup()
.addGap(23, 23, 23)
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addGap(23, 23, 23)
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(jLabel8)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TrangChuLayout.createSequentialGroup()
.addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel9))
.addGroup(TrangChuLayout.createSequentialGroup()
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton10, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(TrangChuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel13)
.addComponent(jLabel11)
.addComponent(jLabel10))))
.addContainerGap(66, Short.MAX_VALUE))
);
QuanLyCuaHang.addTab("Trang chủ", TrangChu);
HoaDon.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jLabel23.setText("Mã hóa đơn:");
jLabel24.setText("Số chứng từ:");
jLabel25.setText("Ngày chứng từ:");
spnNgayChungTu_HoaDon.setModel(new javax.swing.SpinnerDateModel(new java.util.Date(), null, null, java.util.Calendar.DAY_OF_YEAR));
spnNgayChungTu_HoaDon.setToolTipText("");
spnNgayChungTu_HoaDon.setEditor(new javax.swing.JSpinner.DateEditor(spnNgayChungTu_HoaDon, "d/M/y"));
jLabel26.setText("Loại hóa đơn:");
jLabel28.setText("Ngày tạo:");
spnNgayTao_HoaDon.setModel(new javax.swing.SpinnerDateModel(new java.util.Date(), null, null, java.util.Calendar.DAY_OF_YEAR));
spnNgayTao_HoaDon.setToolTipText("");
spnNgayTao_HoaDon.setEditor(new javax.swing.JSpinner.DateEditor(spnNgayTao_HoaDon, "d/M/y"));
cboLoaiHoaDon_HoaDon.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jLabel29.setText("Trạng thái:");
jLabel30.setText("Diễn giải:");
cboTrangThai_HoaDon.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
txtDienGiai_HoaDon.setColumns(20);
txtDienGiai_HoaDon.setRows(5);
jScrollPane3.setViewportView(txtDienGiai_HoaDon);
btnTaoHoaDon_HoaDon.setText("Khởi tạo");
btnTaoHoaDon_HoaDon.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnTaoHoaDon_HoaDonActionPerformed(evt);
}
});
btnHuy_HoaDon.setText("Hủy");
btnHuy_HoaDon.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnHuy_HoaDonActionPerformed(evt);
}
});
btnDanhSachHoaDon_HoaDon.setText("Danh sách");
btnDanhSachHoaDon_HoaDon.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDanhSachHoaDon_HoaDonActionPerformed(evt);
}
});
btnThemHoaDon_HoaDon.setText("+");
btnThemHoaDon_HoaDon.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnThemHoaDon_HoaDonActionPerformed(evt);
}
});
btnThemTrangThai_HoaDon.setText("+");
jLabel31.setText("Nhân viên:");
txtKhachHang_HoaDon1.setEditable(false);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 513, Short.MAX_VALUE)
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 136, Short.MAX_VALUE)
);
jTabbedPane1.addTab("Khách hàng cũ", jPanel2);
jLabel27.setText("Khách hàng:");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(7, 7, 7)
.addComponent(jLabel27)
.addGap(18, 18, 18)
.addComponent(txtKhachHang_HoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(288, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtKhachHang_HoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel27))
.addContainerGap(105, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Thêm khách hàng mới", jPanel1);
cboNhaSanXuat_HoaDon.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jLabel32.setText("Nhà sản xuất:");
jList1.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane4.setViewportView(jList1);
jLabel33.setText("Sản phẩm:");
jTable2.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane6.setViewportView(jTable2);
jLabel34.setText("Danh sách sản phẩm được thêm:");
btnXoaSanPham_HoaDon.setText("Xóa");
btnXoaSanPham_HoaDon.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnXoaSanPham_HoaDonActionPerformed(evt);
}
});
cboTrangThai_HoaDon1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jLabel35.setText("Thuế:");
javax.swing.GroupLayout HoaDonLayout = new javax.swing.GroupLayout(HoaDon);
HoaDon.setLayout(HoaDonLayout);
HoaDonLayout.setHorizontalGroup(
HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(HoaDonLayout.createSequentialGroup()
.addContainerGap()
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(HoaDonLayout.createSequentialGroup()
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(HoaDonLayout.createSequentialGroup()
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel25)
.addComponent(jLabel28)
.addComponent(jLabel31)
.addComponent(jLabel32))
.addGap(6, 6, 6))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, HoaDonLayout.createSequentialGroup()
.addComponent(jLabel33)
.addGap(18, 18, 18)))
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jScrollPane4)
.addComponent(cboNhaSanXuat_HoaDon, 0, 144, Short.MAX_VALUE)
.addComponent(txtKhachHang_HoaDon1)
.addComponent(spnNgayTao_HoaDon)
.addComponent(spnNgayChungTu_HoaDon))
.addGap(18, 18, 18)
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(HoaDonLayout.createSequentialGroup()
.addComponent(jLabel34)
.addGap(0, 441, Short.MAX_VALUE))
.addGroup(HoaDonLayout.createSequentialGroup()
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(btnXoaSanPham_HoaDon)
.addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(btnTaoHoaDon_HoaDon, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
.addComponent(btnHuy_HoaDon, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
.addGroup(HoaDonLayout.createSequentialGroup()
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(HoaDonLayout.createSequentialGroup()
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel24)
.addComponent(jLabel23))
.addGap(22, 22, 22)
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtSoChungTu_HoaDon, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtMaHoaDon_HoaDon, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel26)
.addComponent(jLabel29))
.addGap(23, 23, 23)
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cboLoaiHoaDon_HoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cboTrangThai_HoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnThemHoaDon_HoaDon)
.addComponent(btnThemTrangThai_HoaDon)))
.addComponent(jTabbedPane1))
.addGap(18, 18, 18)
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane3)
.addGroup(HoaDonLayout.createSequentialGroup()
.addComponent(jLabel30)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, HoaDonLayout.createSequentialGroup()
.addComponent(jLabel35)
.addGap(18, 18, 18)
.addComponent(cboTrangThai_HoaDon1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE)
.addComponent(btnDanhSachHoaDon_HoaDon)))))
.addContainerGap())
);
HoaDonLayout.setVerticalGroup(
HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(HoaDonLayout.createSequentialGroup()
.addContainerGap()
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel26)
.addComponent(cboLoaiHoaDon_HoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnThemHoaDon_HoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtMaHoaDon_HoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel23))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cboTrangThai_HoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnThemTrangThai_HoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtSoChungTu_HoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel24)
.addComponent(jLabel29))
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(HoaDonLayout.createSequentialGroup()
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(HoaDonLayout.createSequentialGroup()
.addGap(29, 29, 29)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(HoaDonLayout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTabbedPane1)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, HoaDonLayout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel30)
.addGap(153, 153, 153)))
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnNgayChungTu_HoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel25))
.addComponent(jLabel34, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(HoaDonLayout.createSequentialGroup()
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnNgayTao_HoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel28))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtKhachHang_HoaDon1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel31))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cboNhaSanXuat_HoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel32))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel33)
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(HoaDonLayout.createSequentialGroup()
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(HoaDonLayout.createSequentialGroup()
.addGroup(HoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cboTrangThai_HoaDon1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel35)
.addComponent(btnDanhSachHoaDon_HoaDon))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnTaoHoaDon_HoaDon)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnHuy_HoaDon)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnXoaSanPham_HoaDon)))
.addContainerGap(58, Short.MAX_VALUE))
);
QuanLyCuaHang.addTab("Hóa đơn", null, HoaDon, "");
HoaDon.getAccessibleContext().setAccessibleName("");
HoaDon.getAccessibleContext().setAccessibleDescription("");
jLabel14.setText("Mã phiếu:");
txtSoChungTu_PhieuNhap.setToolTipText("");
jLabel15.setText("Số chứng từ:");
jLabel16.setText("Ngày chứng từ:");
jLabel17.setText("Hóa đơn:");
cboLoaiHoaDon_PhieuNhap.setEditable(true);
jLabel18.setText("Ngày nhập:");
jLabel19.setText("Nhà cung cấp:");
cboNhaCungCap_PhieuNhap.setEditable(true);
btnThemLoaiHoaDon_PhieuNhap.setText("+");
jLabel20.setText("Trạng thái:");
txtDienGiai_PhieuNhap.setColumns(20);
txtDienGiai_PhieuNhap.setRows(5);
jScrollPane1.setViewportView(txtDienGiai_PhieuNhap);
jLabel21.setText("Ghi chú:");
btnThemPhieuNhap_PhieuNhap.setText("Tạo phiếu nhập");
btnThemPhieuNhap_PhieuNhap.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnThemPhieuNhap_PhieuNhapActionPerformed(evt);
}
});
btnHuy_PhieuNhap.setText("Hủy");
btnHuy_PhieuNhap.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnHuy_PhieuNhapActionPerformed(evt);
}
});
btnThemTrangThai_PhieuNhap.setText("+");
tblPhieuNhap_PhieuNhap.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null}
},
new String [] {
"ID", "Mã phiếu", "Số chứng từ", "Ngày chứng từ", "Ngày nhập", "Ngày tạo", "Loại hóa đơn", "Nhà cung cấp", "Trạng thái", "Người tạo"
}
));
jScrollPane2.setViewportView(tblPhieuNhap_PhieuNhap);
spnNgayNhap_PhieuNhap.setModel(new javax.swing.SpinnerDateModel(new java.util.Date(), null, null, java.util.Calendar.DAY_OF_YEAR));
spnNgayNhap_PhieuNhap.setEditor(new javax.swing.JSpinner.DateEditor(spnNgayNhap_PhieuNhap, "d/M/y"));
spnNgayChungTu_PhieuNhap.setModel(new javax.swing.SpinnerDateModel(new java.util.Date(), null, null, java.util.Calendar.DAY_OF_YEAR));
spnNgayChungTu_PhieuNhap.setToolTipText("");
spnNgayChungTu_PhieuNhap.setEditor(new javax.swing.JSpinner.DateEditor(spnNgayChungTu_PhieuNhap, "d/M/y"));
spnNgayTao_PhieuNhap.setModel(new javax.swing.SpinnerDateModel(new java.util.Date(), null, null, java.util.Calendar.DAY_OF_YEAR));
spnNgayTao_PhieuNhap.setToolTipText("");
spnNgayTao_PhieuNhap.setEditor(new javax.swing.JSpinner.DateEditor(spnNgayTao_PhieuNhap, "d/M/y"));
spnNgayTao_PhieuNhap.setEnabled(false);
jLabel22.setText("Ngày tạo:");
btnThemNhaCungCap_PhieuNhap.setText("+");
btnDanhSachPhieuNhap_PhieuNhap.setText("Danh sách");
btnDanhSachPhieuNhap_PhieuNhap.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDanhSachPhieuNhap_PhieuNhapActionPerformed(evt);
}
});
javax.swing.GroupLayout PhieuNhapLayout = new javax.swing.GroupLayout(PhieuNhap);
PhieuNhap.setLayout(PhieuNhapLayout);
PhieuNhapLayout.setHorizontalGroup(
PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(PhieuNhapLayout.createSequentialGroup()
.addContainerGap()
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(PhieuNhapLayout.createSequentialGroup()
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(PhieuNhapLayout.createSequentialGroup()
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel14)
.addComponent(jLabel15))
.addGap(23, 23, 23)
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtMaPhieu_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtSoChungTu_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(PhieuNhapLayout.createSequentialGroup()
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(cboLoaiHoaDon_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cboTrangThai_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnThemTrangThai_PhieuNhap)
.addComponent(btnThemLoaiHoaDon_PhieuNhap)))
.addGroup(PhieuNhapLayout.createSequentialGroup()
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(PhieuNhapLayout.createSequentialGroup()
.addComponent(jLabel18)
.addGap(23, 23, 23)
.addComponent(spnNgayNhap_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(PhieuNhapLayout.createSequentialGroup()
.addComponent(jLabel19)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cboNhaCungCap_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnThemNhaCungCap_PhieuNhap))))
.addGroup(PhieuNhapLayout.createSequentialGroup()
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(PhieuNhapLayout.createSequentialGroup()
.addComponent(jLabel16)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(spnNgayChungTu_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(PhieuNhapLayout.createSequentialGroup()
.addComponent(jLabel22)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnNgayTao_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel20)
.addComponent(jLabel17))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE)
.addComponent(jLabel21)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PhieuNhapLayout.createSequentialGroup()
.addComponent(btnThemPhieuNhap_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnHuy_PhieuNhap)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnDanhSachPhieuNhap_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(37, 37, 37))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PhieuNhapLayout.createSequentialGroup()
.addComponent(jScrollPane2)
.addContainerGap())))
);
PhieuNhapLayout.setVerticalGroup(
PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(PhieuNhapLayout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(PhieuNhapLayout.createSequentialGroup()
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14)
.addComponent(txtMaPhieu_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel18)
.addComponent(spnNgayNhap_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel21))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel15)
.addComponent(txtSoChungTu_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel19)
.addComponent(cboNhaCungCap_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnThemNhaCungCap_PhieuNhap))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel16)
.addComponent(jLabel20)
.addComponent(cboTrangThai_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnThemTrangThai_PhieuNhap)
.addComponent(spnNgayChungTu_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel17)
.addComponent(spnNgayTao_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel22))
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnThemPhieuNhap_PhieuNhap)
.addComponent(btnHuy_PhieuNhap)
.addComponent(btnDanhSachPhieuNhap_PhieuNhap))
.addGroup(PhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cboLoaiHoaDon_PhieuNhap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnThemLoaiHoaDon_PhieuNhap)))
.addGap(18, 18, 18)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)
.addGap(19, 19, 19))
);
QuanLyCuaHang.addTab("Phiếu nhập", PhieuNhap);
javax.swing.GroupLayout QuyDinhLayout = new javax.swing.GroupLayout(QuyDinh);
QuyDinh.setLayout(QuyDinhLayout);
QuyDinhLayout.setHorizontalGroup(
QuyDinhLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 844, Short.MAX_VALUE)
);
QuyDinhLayout.setVerticalGroup(
QuyDinhLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 574, Short.MAX_VALUE)
);
QuanLyCuaHang.addTab("Quy định", QuyDinh);
javax.swing.GroupLayout TimHoaDonLayout = new javax.swing.GroupLayout(TimHoaDon);
TimHoaDon.setLayout(TimHoaDonLayout);
TimHoaDonLayout.setHorizontalGroup(
TimHoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 819, Short.MAX_VALUE)
);
TimHoaDonLayout.setVerticalGroup(
TimHoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 524, Short.MAX_VALUE)
);
tabTimKiem.addTab("Tìm Hóa đơn", TimHoaDon);
jLabel37.setText("Tên sản phẩm: ");
jLabel39.setText("Nhóm sản phẩm:");
btnTim_TimKiem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/smaller/Search-icon.png"))); // NOI18N
btnTim_TimKiem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnTim_TimKiem1ActionPerformed(evt);
}
});
javax.swing.GroupLayout TimPhieuNhapLayout = new javax.swing.GroupLayout(TimPhieuNhap);
TimPhieuNhap.setLayout(TimPhieuNhapLayout);
TimPhieuNhapLayout.setHorizontalGroup(
TimPhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TimPhieuNhapLayout.createSequentialGroup()
.addContainerGap()
.addGroup(TimPhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TimPhieuNhapLayout.createSequentialGroup()
.addGroup(TimPhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel37)
.addComponent(jLabel39))
.addGap(18, 18, 18)
.addGroup(TimPhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cboNhomLoaiSanPham_TimKiem1, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtTenSanPham_TimKiem1, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(btnTim_TimKiem1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(554, Short.MAX_VALUE))
);
TimPhieuNhapLayout.setVerticalGroup(
TimPhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TimPhieuNhapLayout.createSequentialGroup()
.addGap(30, 30, 30)
.addGroup(TimPhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtTenSanPham_TimKiem1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel37))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(TimPhieuNhapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cboNhomLoaiSanPham_TimKiem1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel39))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnTim_TimKiem1)
.addContainerGap(383, Short.MAX_VALUE))
);
tabTimKiem.addTab("Tìm Phiếu nhập", TimPhieuNhap);
jLabel36.setText("Tên sản phẩm: ");
jLabel38.setText("Nhóm sản phẩm:");
cboNhomLoaiSanPham.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cboNhomLoaiSanPhamActionPerformed(evt);
}
});
btnTim.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlycuahangcongnghe/images/smaller/Search-icon.png"))); // NOI18N
btnTim.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnTimActionPerformed(evt);
}
});
tblSanPham.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane7.setViewportView(tblSanPham);
javax.swing.GroupLayout TimSanPhamLayout = new javax.swing.GroupLayout(TimSanPham);
TimSanPham.setLayout(TimSanPhamLayout);
TimSanPhamLayout.setHorizontalGroup(
TimSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TimSanPhamLayout.createSequentialGroup()
.addContainerGap()
.addGroup(TimSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TimSanPhamLayout.createSequentialGroup()
.addGroup(TimSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel36)
.addComponent(jLabel38))
.addGap(18, 18, 18)
.addGroup(TimSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cboNhomLoaiSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtTenSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(btnTim, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 526, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
TimSanPhamLayout.setVerticalGroup(
TimSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TimSanPhamLayout.createSequentialGroup()
.addContainerGap()
.addGroup(TimSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TimSanPhamLayout.createSequentialGroup()
.addGap(17, 17, 17)
.addGroup(TimSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtTenSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel36))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(TimSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cboNhomLoaiSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel38))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnTim)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 502, Short.MAX_VALUE))
.addContainerGap())
);
tabTimKiem.addTab("Tìm sản phẩm", TimSanPham);
javax.swing.GroupLayout TimKiemLayout = new javax.swing.GroupLayout(TimKiem);
TimKiem.setLayout(TimKiemLayout);
TimKiemLayout.setHorizontalGroup(
TimKiemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TimKiemLayout.createSequentialGroup()
.addContainerGap()
.addComponent(tabTimKiem)
.addContainerGap())
);
TimKiemLayout.setVerticalGroup(
TimKiemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TimKiemLayout.createSequentialGroup()
.addContainerGap()
.addComponent(tabTimKiem)
.addContainerGap())
);
QuanLyCuaHang.addTab("Tìm kiếm", null, TimKiem, "");
javax.swing.GroupLayout ThongKeLayout = new javax.swing.GroupLayout(ThongKe);
ThongKe.setLayout(ThongKeLayout);
ThongKeLayout.setHorizontalGroup(
ThongKeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 844, Short.MAX_VALUE)
);
ThongKeLayout.setVerticalGroup(
ThongKeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 574, Short.MAX_VALUE)
);
QuanLyCuaHang.addTab("Thống kê", ThongKe);
javax.swing.GroupLayout KhacHangLayout = new javax.swing.GroupLayout(KhacHang);
KhacHang.setLayout(KhacHangLayout);
KhacHangLayout.setHorizontalGroup(
KhacHangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 844, Short.MAX_VALUE)
);
KhacHangLayout.setVerticalGroup(
KhacHangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 574, Short.MAX_VALUE)
);
QuanLyCuaHang.addTab("Khách hàng", KhacHang);
javax.swing.GroupLayout LapPhieuThuLayout = new javax.swing.GroupLayout(LapPhieuThu);
LapPhieuThu.setLayout(LapPhieuThuLayout);
LapPhieuThuLayout.setHorizontalGroup(
LapPhieuThuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 844, Short.MAX_VALUE)
);
LapPhieuThuLayout.setVerticalGroup(
LapPhieuThuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 574, Short.MAX_VALUE)
);
QuanLyCuaHang.addTab("Lập phiếu thu", LapPhieuThu);
javax.swing.GroupLayout KhuyenMaiLayout = new javax.swing.GroupLayout(KhuyenMai);
KhuyenMai.setLayout(KhuyenMaiLayout);
KhuyenMaiLayout.setHorizontalGroup(
KhuyenMaiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 844, Short.MAX_VALUE)
);
KhuyenMaiLayout.setVerticalGroup(
KhuyenMaiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 574, Short.MAX_VALUE)
);
QuanLyCuaHang.addTab("Khuyến mãi", KhuyenMai);
javax.swing.GroupLayout CuaHangLayout = new javax.swing.GroupLayout(CuaHang);
CuaHang.setLayout(CuaHangLayout);
CuaHangLayout.setHorizontalGroup(
CuaHangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 844, Short.MAX_VALUE)
);
CuaHangLayout.setVerticalGroup(
CuaHangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 574, Short.MAX_VALUE)
);
QuanLyCuaHang.addTab("Cửa hàng", CuaHang);
javax.swing.GroupLayout SanPhamLayout = new javax.swing.GroupLayout(SanPham);
SanPham.setLayout(SanPhamLayout);
SanPhamLayout.setHorizontalGroup(
SanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 844, Short.MAX_VALUE)
);
SanPhamLayout.setVerticalGroup(
SanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 574, Short.MAX_VALUE)
);
QuanLyCuaHang.addTab("Sản phẩm", SanPham);
javax.swing.GroupLayout NhanVienLayout = new javax.swing.GroupLayout(NhanVien);
NhanVien.setLayout(NhanVienLayout);
NhanVienLayout.setHorizontalGroup(
NhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 844, Short.MAX_VALUE)
);
NhanVienLayout.setVerticalGroup(
NhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 574, Short.MAX_VALUE)
);
QuanLyCuaHang.addTab("Nhân viên", NhanVien);
javax.swing.GroupLayout TaiKhoanLayout = new javax.swing.GroupLayout(TaiKhoan);
TaiKhoan.setLayout(TaiKhoanLayout);
TaiKhoanLayout.setHorizontalGroup(
TaiKhoanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 844, Short.MAX_VALUE)
);
TaiKhoanLayout.setVerticalGroup(
TaiKhoanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 574, Short.MAX_VALUE)
);
QuanLyCuaHang.addTab("Tài khoản", TaiKhoan);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(QuanLyCuaHang, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 849, javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(QuanLyCuaHang)
.addContainerGap())
);
QuanLyCuaHang.getAccessibleContext().setAccessibleName("Trang chủ");
pack();
}// </editor-fold>//GEN-END:initComponents
private void btnTimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTimActionPerformed
/*try {
List resultList = TimSanPhamDAO.getSanPham(txtTenSanPham.getText(), cboNhomLoaiSanPham.getSelectedIndex(), cboNhomLoaiSanPham.getSelectedIndex());
Vector<String> tableHeaders = new Vector<String>();
Vector<Object> tableData = new Vector<Object>();
tableHeaders.add("Tên sản phẩm");
tableHeaders.add("Nhóm sản phẩm");
tableHeaders.add("Giá");
tableHeaders.add("Nhóm sản phẩm");
tableHeaders.add("Mô tả");
for (Object o : resultList) {
Vector oneRow = new Vector();
SanPham sp = (SanPham) o;
oneRow.add(sp.getTenSanPham());
oneRow.add(sp.getNhomLoaiSanPham());
oneRow.add(sp.getDonGia());
oneRow.add(sp.getMoTa());
tableData.add(oneRow);
}
this.tblSanPham.setModel(new DefaultTableModel(tableData, tableHeaders));
} catch (HibernateException he) {
he.printStackTrace();
} */ // TODO add your handling code here:
}//GEN-LAST:event_btnTimActionPerformed
private void btnTim_TimKiem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTim_TimKiem1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_btnTim_TimKiem1ActionPerformed
private void btnDanhSachPhieuNhap_PhieuNhapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDanhSachPhieuNhap_PhieuNhapActionPerformed
try {
List resultList = PhieuNhapDAO.getPhieuNhap();
Vector<String> tableHeaders = new Vector<String>();
Vector<Object> tableData = new Vector<Object>();
tableHeaders.add("ID");
tableHeaders.add("Mã phiếu");
tableHeaders.add("Số chứng từ");
tableHeaders.add("Ngày chứng từ");
tableHeaders.add("Ngày nhập hàng");
tableHeaders.add("Ngày tạo");
tableHeaders.add("Loại hóa đơn");
tableHeaders.add("Nhà cung cấp");
tableHeaders.add("Trạng thái");
tableHeaders.add("Nhân viên");
for (Object o : resultList) {
Vector<Object> oneRow = new Vector<Object>();
PhieuNhap pn = (PhieuNhap) o;
oneRow.add(pn.getId());
oneRow.add(pn.getMaPhieu());
oneRow.add(pn.getSoChungTu());
oneRow.add(pn.getNgayChungTu());
oneRow.add(pn.getNgayNhapHang());
oneRow.add(pn.getNgayTao());
oneRow.add(pn.getLoaiHoaDon());
oneRow.add(pn.getNhaCungCap());
oneRow.add(pn.getTrangThai());
oneRow.add(pn.getNhanVien());
tableData.add(oneRow);
}
this.tblPhieuNhap_PhieuNhap.setModel(new DefaultTableModel(tableData, tableHeaders));
} catch (HibernateException he) {
he.printStackTrace();
} // TODO add your handling code here:
}//GEN-LAST:event_btnDanhSachPhieuNhap_PhieuNhapActionPerformed
private void btnHuy_PhieuNhapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHuy_PhieuNhapActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_btnHuy_PhieuNhapActionPerformed
private void btnThemPhieuNhap_PhieuNhapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnThemPhieuNhap_PhieuNhapActionPerformed
PhieuNhap pn = new PhieuNhap();
pn.setMaPhieu(txtMaPhieu_PhieuNhap.getText());
pn.setSoChungTu(txtSoChungTu_PhieuNhap.getText());
pn.setDienGiai(txtDienGiai_PhieuNhap.getText());
pn.setNhaCungCap((NhaCungCap) cboNhaCungCap_PhieuNhap.getSelectedItem());
pn.setTrangThai((TrangThai) cboTrangThai_PhieuNhap.getSelectedItem());
pn.setLoaiHoaDon((LoaiHoaDon) cboLoaiHoaDon_PhieuNhap.getSelectedItem());
pn.setNgayNhapHang((Date) spnNgayNhap_PhieuNhap.getModel().getValue());
pn.setNgayChungTu((Date) spnNgayChungTu_PhieuNhap.getModel().getValue());
pn.setNgayTao((Date) spnNgayTao_PhieuNhap.getModel().getValue());
boolean kq;
kq = PhieuNhapDAO.themPhieuNhap(pn);
tblPhieuNhap_PhieuNhap.clearSelection();
loadPhieuNhap();
}//GEN-LAST:event_btnThemPhieuNhap_PhieuNhapActionPerformed
private void btnXoaSanPham_HoaDonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnXoaSanPham_HoaDonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_btnXoaSanPham_HoaDonActionPerformed
private void btnThemHoaDon_HoaDonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnThemHoaDon_HoaDonActionPerformed
// TODO add your handling code here:
ThemLoaiHoaDon form = new ThemLoaiHoaDon();
form.setVisible(true);
}//GEN-LAST:event_btnThemHoaDon_HoaDonActionPerformed
private void btnDanhSachHoaDon_HoaDonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDanhSachHoaDon_HoaDonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_btnDanhSachHoaDon_HoaDonActionPerformed
private void btnHuy_HoaDonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHuy_HoaDonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_btnHuy_HoaDonActionPerformed
private void btnTaoHoaDon_HoaDonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTaoHoaDon_HoaDonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_btnTaoHoaDon_HoaDonActionPerformed
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
QuanLyCuaHang.setSelectedIndex(6); // TODO add your handling code here:
}//GEN-LAST:event_jButton6ActionPerformed
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
QuanLyCuaHang.setSelectedIndex(7); // TODO add your handling code here:
}//GEN-LAST:event_jButton7ActionPerformed
private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
QuanLyCuaHang.setSelectedIndex(12); // TODO add your handling code here:
}//GEN-LAST:event_jButton12ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
QuanLyCuaHang.setSelectedIndex(2); // TODO add your handling code here:
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
QuanLyCuaHang.setSelectedIndex(11); // TODO add your handling code here:
}//GEN-LAST:event_jButton11ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
QuanLyCuaHang.setSelectedIndex(1); // TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
QuanLyCuaHang.setSelectedIndex(10); // TODO add your handling code here:
}//GEN-LAST:event_jButton10ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
QuanLyCuaHang.setSelectedIndex(3); // TODO add your handling code here:
}//GEN-LAST:event_jButton4ActionPerformed
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
QuanLyCuaHang.setSelectedIndex(9); // TODO add your handling code here:
}//GEN-LAST:event_jButton9ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
QuanLyCuaHang.setSelectedIndex(4); // TODO add your handling code here:
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
QuanLyCuaHang.setSelectedIndex(8); // TODO add your handling code here:
}//GEN-LAST:event_jButton8ActionPerformed
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
QuanLyCuaHang.setSelectedIndex(5); // TODO add your handling code here:
}//GEN-LAST:event_jButton5ActionPerformed
private void cboNhomLoaiSanPhamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboNhomLoaiSanPhamActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cboNhomLoaiSanPhamActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Pages.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Pages.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Pages.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Pages.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Pages().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel CuaHang;
public javax.swing.JPanel HoaDon;
private javax.swing.JPanel KhacHang;
private javax.swing.JPanel KhuyenMai;
private javax.swing.JPanel LapPhieuThu;
private javax.swing.JPanel NhanVien;
private javax.swing.JPanel PhieuNhap;
private javax.swing.JTabbedPane QuanLyCuaHang;
private javax.swing.JPanel QuyDinh;
private javax.swing.JPanel SanPham;
private javax.swing.JPanel TaiKhoan;
private javax.swing.JPanel ThongKe;
private javax.swing.JPanel TimHoaDon;
private javax.swing.JPanel TimKiem;
private javax.swing.JPanel TimPhieuNhap;
private javax.swing.JPanel TimSanPham;
private javax.swing.JPanel TrangChu;
private javax.swing.JButton btnDanhSachHoaDon_HoaDon;
private javax.swing.JButton btnDanhSachPhieuNhap_PhieuNhap;
private javax.swing.JButton btnHuy_HoaDon;
private javax.swing.JButton btnHuy_PhieuNhap;
private javax.swing.JButton btnTaoHoaDon_HoaDon;
private javax.swing.JButton btnThemHoaDon_HoaDon;
private javax.swing.JButton btnThemLoaiHoaDon_PhieuNhap;
private javax.swing.JButton btnThemNhaCungCap_PhieuNhap;
private javax.swing.JButton btnThemPhieuNhap_PhieuNhap;
private javax.swing.JButton btnThemTrangThai_HoaDon;
private javax.swing.JButton btnThemTrangThai_PhieuNhap;
private javax.swing.JButton btnTim;
private javax.swing.JButton btnTim_TimKiem1;
private javax.swing.JButton btnXoaSanPham_HoaDon;
private javax.swing.JComboBox cboLoaiHoaDon_HoaDon;
private javax.swing.JComboBox cboLoaiHoaDon_PhieuNhap;
private javax.swing.JComboBox cboNhaCungCap_PhieuNhap;
private javax.swing.JComboBox cboNhaSanXuat_HoaDon;
private javax.swing.JComboBox cboNhomLoaiSanPham;
private javax.swing.JComboBox cboNhomLoaiSanPham_TimKiem1;
private javax.swing.JComboBox cboTrangThai_HoaDon;
private javax.swing.JComboBox cboTrangThai_HoaDon1;
private javax.swing.JComboBox cboTrangThai_PhieuNhap;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton10;
private javax.swing.JButton jButton11;
private javax.swing.JButton jButton12;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JButton jButton9;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel24;
private javax.swing.JLabel jLabel25;
private javax.swing.JLabel jLabel26;
private javax.swing.JLabel jLabel27;
private javax.swing.JLabel jLabel28;
private javax.swing.JLabel jLabel29;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel30;
private javax.swing.JLabel jLabel31;
private javax.swing.JLabel jLabel32;
private javax.swing.JLabel jLabel33;
private javax.swing.JLabel jLabel34;
private javax.swing.JLabel jLabel35;
private javax.swing.JLabel jLabel36;
private javax.swing.JLabel jLabel37;
private javax.swing.JLabel jLabel38;
private javax.swing.JLabel jLabel39;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JList jList1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollBar jScrollBar1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JScrollPane jScrollPane6;
private javax.swing.JScrollPane jScrollPane7;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTable jTable2;
private javax.swing.JSpinner spnNgayChungTu_HoaDon;
private javax.swing.JSpinner spnNgayChungTu_PhieuNhap;
private javax.swing.JSpinner spnNgayNhap_PhieuNhap;
private javax.swing.JSpinner spnNgayTao_HoaDon;
private javax.swing.JSpinner spnNgayTao_PhieuNhap;
private javax.swing.JTabbedPane tabTimKiem;
private javax.swing.JTable tblPhieuNhap_PhieuNhap;
private javax.swing.JTable tblSanPham;
private javax.swing.JTextArea txtDienGiai_HoaDon;
private javax.swing.JTextArea txtDienGiai_PhieuNhap;
private javax.swing.JTextField txtKhachHang_HoaDon;
private javax.swing.JTextField txtKhachHang_HoaDon1;
private javax.swing.JTextField txtMaHoaDon_HoaDon;
private javax.swing.JTextField txtMaPhieu_PhieuNhap;
private javax.swing.JTextField txtSoChungTu_HoaDon;
private javax.swing.JTextField txtSoChungTu_PhieuNhap;
private javax.swing.JTextField txtTenSanPham;
private javax.swing.JTextField txtTenSanPham_TimKiem1;
// End of variables declaration//GEN-END:variables
private void loadTenNhom() {
/*try {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
String hql = "from NhomLoaiSanPham";
Query q = session.createQuery(hql);
List resultList = q.list();//cai' nay chay xong duoc 1 array list, day gia su lay cai dau tien
NhomLoaiSanPham nhomSP = (NhomLoaiSanPham)resultList.get(0);
String tenNhom = nhomSP.getTenNhomSanPham();
session.getTransaction().commit();
this.txtTenNhom.setText(tenNhom);
} catch (HibernateException he) {
he.printStackTrace();
}*/
}
private void loadNhaCungCap() {
try {
List resultList = NhaCungCapDAO.getNhaCungCap();
this.cboNhaCungCap_PhieuNhap.setModel(new DefaultComboBoxModel(resultList.toArray()));
} catch (HibernateException he) {
he.printStackTrace();
}
}
private void loadTrangThai() {
try {
List resultList = TrangThaiDAO.getTrangThai();
this.cboTrangThai_PhieuNhap.setModel(new DefaultComboBoxModel(resultList.toArray()));
} catch (HibernateException he) {
he.printStackTrace();
}
}
private void loadLoaiHoaDon() {
try {
List resultList = LoaiHoaDonDAO.getLoaiHoaDon();
this.cboLoaiHoaDon_PhieuNhap.setModel(new DefaultComboBoxModel(resultList.toArray()));
} catch (HibernateException he) {
he.printStackTrace();
}
}
private void insertPhieuNhap() {
}
private void loadPhieuNhap() {
}
private void loadNhaSanXuat() {
}
private void loadNhomLoaiSanPham() {
try {
List resultList = NhomLoaiSanPhamDAO.getNhomLoaiSanPham();
this.cboNhomLoaiSanPham.setModel(new DefaultComboBoxModel(resultList.toArray()));
} catch (HibernateException he) {
he.printStackTrace();
}
}
private void loadMenu() {
}
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/quanlycuahangcongnghe/Pages.java | Java | oos | 94,670 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package quanlycuahangcongnghe;
import DAO.DonViTinhDAO;
import DAO.NhomLoaiSanPhamDAO;
import DAO.SanPhamDAO;
import DAO.TimSanPhamDAO;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.table.DefaultTableModel;
import org.hibernate.HibernateException;
import qlchcn.entity.DonVi;
import qlchcn.entity.NhomLoaiSanPham;
import qlchcn.entity.SanPham;
import javax.swing.*;
import java.awt.event.*;
/**
*
* @author RUA
*/
public class QuanLySanPham extends javax.swing.JPanel {
/**
* Creates new form SanPham
*/
public QuanLySanPham() {
initComponents();
loadNhomLoaiSanPham();
loadDonViTinh();
enterTxtKeywords();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel6 = new javax.swing.JLabel();
jTextField6 = new javax.swing.JTextField();
tabQuanLySanPham = new javax.swing.JTabbedPane();
pnlThemSanPham = new javax.swing.JPanel();
txtMaSanPham = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtTenSanPham = new javax.swing.JTextField();
txtKichThuoc = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
txtKhoiLuong = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
txtDonGia = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
cboDonViTinh = new javax.swing.JComboBox();
jLabel8 = new javax.swing.JLabel();
cboNhomLoaiSanPham = new javax.swing.JComboBox();
jLabel9 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
txtMoTa = new javax.swing.JTextArea();
btnLuu = new javax.swing.JButton();
btnDanhSach = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
tblSanPham = new javax.swing.JTable();
jLabel10 = new javax.swing.JLabel();
txtMauSac = new javax.swing.JTextField();
pnlLoaiSanPham = new javax.swing.JPanel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
txtMaLoaiSanPham = new javax.swing.JTextField();
txtTenLoaiSanPham = new javax.swing.JTextField();
btnLuuLoaiSanPham = new javax.swing.JButton();
jScrollPane3 = new javax.swing.JScrollPane();
tblNhomLoaiSanPham = new javax.swing.JTable();
pnlXoaSuaSanPham = new javax.swing.JPanel();
btnTim = new javax.swing.JButton();
jScrollPane4 = new javax.swing.JScrollPane();
lisSanPham = new javax.swing.JList();
btnSuaSanPham = new javax.swing.JButton();
btnXoaSanPham = new javax.swing.JButton();
pnlSuaSanPham = new javax.swing.JPanel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
txtSuaTenSanPham = new javax.swing.JTextField();
txtSuaKichThuoc = new javax.swing.JTextField();
txtSuaKhoiLuong = new javax.swing.JTextField();
jLabel16 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
jLabel21 = new javax.swing.JLabel();
txtSuaDonGia = new javax.swing.JTextField();
cboSuaDonViTinh = new javax.swing.JComboBox();
cboSuaNhomLoaiSanPham = new javax.swing.JComboBox();
txtSuaMauSac = new javax.swing.JTextField();
jScrollPane5 = new javax.swing.JScrollPane();
txtSuaMoTa = new javax.swing.JTextArea();
btnLuuSuaSanPham = new javax.swing.JButton();
btnHuySuaSanPham = new javax.swing.JButton();
lblId = new javax.swing.JLabel();
lblNotificationLuu = new javax.swing.JLabel();
lblMaSanPham = new javax.swing.JLabel();
txtTuKhoa = new javax.swing.JTextField();
chbInstant = new javax.swing.JCheckBox();
pnlXoaSanPham = new javax.swing.JPanel();
lblNotificationXoa = new javax.swing.JLabel();
btnDongYXoa = new javax.swing.JButton();
btnHuyXoa = new javax.swing.JButton();
jLabel6.setText("Đơn giá:");
jTextField6.setText("jTextField1");
txtMaSanPham.setEditable(false);
jLabel1.setText("Mã sản phẩm:");
jLabel2.setText("Tên sản phẩm:");
jLabel3.setText("Kích thước:");
txtTenSanPham.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtTenSanPhamActionPerformed(evt);
}
});
txtKichThuoc.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtKichThuocActionPerformed(evt);
}
});
jLabel4.setText("Khối lượng:");
jLabel5.setText("Đơn giá:");
jLabel7.setText("Đơn vị tính:");
cboDonViTinh.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jLabel8.setText("Nhóm sản phẩm:");
cboNhomLoaiSanPham.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jLabel9.setText("Mô tả:");
txtMoTa.setColumns(20);
txtMoTa.setRows(5);
jScrollPane1.setViewportView(txtMoTa);
btnLuu.setText("Lưu sản phẩm");
btnLuu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLuuActionPerformed(evt);
}
});
btnDanhSach.setText("Danh sách");
btnDanhSach.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDanhSachActionPerformed(evt);
}
});
tblSanPham.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
tblSanPham.addInputMethodListener(new java.awt.event.InputMethodListener() {
public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
tblSanPhamCaretPositionChanged(evt);
}
public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
tblSanPhamInputMethodTextChanged(evt);
}
});
tblSanPham.addVetoableChangeListener(new java.beans.VetoableChangeListener() {
public void vetoableChange(java.beans.PropertyChangeEvent evt)throws java.beans.PropertyVetoException {
tblSanPhamVetoableChange(evt);
}
});
jScrollPane2.setViewportView(tblSanPham);
jLabel10.setText("Màu sắc:");
javax.swing.GroupLayout pnlThemSanPhamLayout = new javax.swing.GroupLayout(pnlThemSanPham);
pnlThemSanPham.setLayout(pnlThemSanPhamLayout);
pnlThemSanPhamLayout.setHorizontalGroup(
pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlThemSanPhamLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlThemSanPhamLayout.createSequentialGroup()
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addGap(18, 18, 18)
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlThemSanPhamLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(txtMaSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(35, 35, 35))
.addGroup(pnlThemSanPhamLayout.createSequentialGroup()
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(txtKhoiLuong, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
.addComponent(txtKichThuoc, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtTenSanPham, javax.swing.GroupLayout.Alignment.LEADING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(pnlThemSanPhamLayout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cboDonViTinh, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(pnlThemSanPhamLayout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cboNhomLoaiSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlThemSanPhamLayout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtDonGia, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(pnlThemSanPhamLayout.createSequentialGroup()
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtMauSac, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(40, 40, 40)
.addComponent(jLabel9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(pnlThemSanPhamLayout.createSequentialGroup()
.addComponent(btnLuu, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnDanhSach, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(110, 110, 110))
.addGroup(pnlThemSanPhamLayout.createSequentialGroup()
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 884, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
);
pnlThemSanPhamLayout.setVerticalGroup(
pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlThemSanPhamLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlThemSanPhamLayout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnLuu)
.addComponent(btnDanhSach)))
.addGroup(pnlThemSanPhamLayout.createSequentialGroup()
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtMaSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1)
.addComponent(jLabel7)
.addComponent(cboDonViTinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtTenSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8)
.addComponent(cboNhomLoaiSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtKichThuoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtDonGia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtMauSac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10))
.addGroup(pnlThemSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtKhoiLuong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 366, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
tabQuanLySanPham.addTab("Thêm sản phẩm", pnlThemSanPham);
jLabel11.setText("Mã loại sản phẩm: ");
jLabel12.setText("Tên loại sản phẩm:");
btnLuuLoaiSanPham.setText("Lưu");
btnLuuLoaiSanPham.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLuuLoaiSanPhamActionPerformed(evt);
}
});
tblNhomLoaiSanPham.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
tblNhomLoaiSanPham.setCellSelectionEnabled(true);
tblNhomLoaiSanPham.setEnabled(false);
jScrollPane3.setViewportView(tblNhomLoaiSanPham);
javax.swing.GroupLayout pnlLoaiSanPhamLayout = new javax.swing.GroupLayout(pnlLoaiSanPham);
pnlLoaiSanPham.setLayout(pnlLoaiSanPhamLayout);
pnlLoaiSanPhamLayout.setHorizontalGroup(
pnlLoaiSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlLoaiSanPhamLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlLoaiSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane3)
.addGroup(pnlLoaiSanPhamLayout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtMaLoaiSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtTenLoaiSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnLuuLoaiSanPham)
.addGap(0, 398, Short.MAX_VALUE)))
.addContainerGap())
);
pnlLoaiSanPhamLayout.setVerticalGroup(
pnlLoaiSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlLoaiSanPhamLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlLoaiSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(jLabel12)
.addComponent(txtMaLoaiSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtTenLoaiSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnLuuLoaiSanPham))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 475, Short.MAX_VALUE)
.addContainerGap())
);
tabQuanLySanPham.addTab("Loại sản phẩm", pnlLoaiSanPham);
btnTim.setText("Tìm");
btnTim.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnTimActionPerformed(evt);
}
});
lisSanPham.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
lisSanPham.setToolTipText("");
lisSanPham.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lisSanPhamMouseClicked(evt);
}
});
jScrollPane4.setViewportView(lisSanPham);
btnSuaSanPham.setText("Sửa > ");
btnSuaSanPham.setEnabled(false);
btnSuaSanPham.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSuaSanPhamActionPerformed(evt);
}
});
btnXoaSanPham.setText("Xóa >");
btnXoaSanPham.setEnabled(false);
btnXoaSanPham.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnXoaSanPhamActionPerformed(evt);
}
});
pnlSuaSanPham.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Sửa sản phẩm", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, java.awt.Color.darkGray));
pnlSuaSanPham.setEnabled(false);
jLabel13.setText("Tên sản phẩm:");
jLabel14.setText("Kích thước:");
jLabel15.setText("Khối lượng:");
txtSuaTenSanPham.setEnabled(false);
txtSuaKichThuoc.setEnabled(false);
txtSuaKhoiLuong.setEnabled(false);
jLabel16.setText("Đơn vị tính:");
jLabel17.setText("Màu sắc:");
jLabel18.setText("Nhóm sản phẩm:");
jLabel19.setText("Đơn giá:");
jLabel21.setText("Mô tả:");
txtSuaDonGia.setEnabled(false);
cboSuaDonViTinh.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cboSuaDonViTinh.setEnabled(false);
cboSuaNhomLoaiSanPham.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cboSuaNhomLoaiSanPham.setEnabled(false);
txtSuaMauSac.setEnabled(false);
txtSuaMoTa.setColumns(20);
txtSuaMoTa.setRows(5);
txtSuaMoTa.setEnabled(false);
jScrollPane5.setViewportView(txtSuaMoTa);
btnLuuSuaSanPham.setText("Lưu");
btnLuuSuaSanPham.setEnabled(false);
btnLuuSuaSanPham.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLuuSuaSanPhamActionPerformed(evt);
}
});
btnHuySuaSanPham.setText("Hủy");
btnHuySuaSanPham.setEnabled(false);
lblId.setFont(new java.awt.Font("Tahoma", 0, 3)); // NOI18N
lblId.setForeground(new java.awt.Color(245, 245, 245));
lblId.setText("-");
lblId.setEnabled(false);
lblMaSanPham.setText("-");
lblMaSanPham.setEnabled(false);
javax.swing.GroupLayout pnlSuaSanPhamLayout = new javax.swing.GroupLayout(pnlSuaSanPham);
pnlSuaSanPham.setLayout(pnlSuaSanPhamLayout);
pnlSuaSanPhamLayout.setHorizontalGroup(
pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlSuaSanPhamLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel19)
.addComponent(jLabel21)
.addComponent(jLabel16)
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlSuaSanPhamLayout.createSequentialGroup()
.addComponent(jLabel17)
.addGap(48, 48, 48)
.addComponent(txtSuaMauSac))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlSuaSanPhamLayout.createSequentialGroup()
.addComponent(jLabel18)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cboSuaNhomLoaiSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlSuaSanPhamLayout.createSequentialGroup()
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel13)
.addComponent(jLabel14)
.addComponent(jLabel15))
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlSuaSanPhamLayout.createSequentialGroup()
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlSuaSanPhamLayout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtSuaKichThuoc, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(pnlSuaSanPhamLayout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtSuaDonGia)
.addComponent(txtSuaKhoiLuong)
.addComponent(txtSuaTenSanPham)
.addComponent(cboSuaDonViTinh, 0, 137, Short.MAX_VALUE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblMaSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblId, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(pnlSuaSanPhamLayout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlSuaSanPhamLayout.createSequentialGroup()
.addComponent(btnLuuSuaSanPham)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnHuySuaSanPham)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblNotificationLuu))
.addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 336, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addContainerGap(96, Short.MAX_VALUE))
);
pnlSuaSanPhamLayout.setVerticalGroup(
pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlSuaSanPhamLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel13)
.addComponent(txtSuaTenSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblId)
.addComponent(lblMaSanPham))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14)
.addComponent(txtSuaKichThuoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel15)
.addComponent(txtSuaKhoiLuong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(11, 11, 11)
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel16)
.addComponent(cboSuaDonViTinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel17)
.addComponent(txtSuaMauSac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel18)
.addComponent(cboSuaNhomLoaiSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel19)
.addComponent(txtSuaDonGia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel21)
.addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnHuySuaSanPham)
.addComponent(btnLuuSuaSanPham)
.addComponent(lblNotificationLuu)))
);
chbInstant.setText("Instant");
chbInstant.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chbInstantActionPerformed(evt);
}
});
pnlXoaSanPham.setBorder(javax.swing.BorderFactory.createTitledBorder("Xóa sản phẩm"));
pnlXoaSanPham.setEnabled(false);
lblNotificationXoa.setText("Lưu ý, sản phẩm bị xóa sẽ KHÔNG thể khôi phục lại được, bạn có muốn tiếp tục?");
lblNotificationXoa.setEnabled(false);
btnDongYXoa.setText("Đồng ý");
btnDongYXoa.setEnabled(false);
btnDongYXoa.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDongYXoaActionPerformed(evt);
}
});
btnHuyXoa.setText("Hủy");
btnHuyXoa.setEnabled(false);
btnHuyXoa.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnHuyXoaActionPerformed(evt);
}
});
javax.swing.GroupLayout pnlXoaSanPhamLayout = new javax.swing.GroupLayout(pnlXoaSanPham);
pnlXoaSanPham.setLayout(pnlXoaSanPhamLayout);
pnlXoaSanPhamLayout.setHorizontalGroup(
pnlXoaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlXoaSanPhamLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lblNotificationXoa)
.addGap(8, 8, 8)
.addComponent(btnDongYXoa)
.addGap(3, 3, 3)
.addComponent(btnHuyXoa, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
pnlXoaSanPhamLayout.setVerticalGroup(
pnlXoaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlXoaSanPhamLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlXoaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblNotificationXoa)
.addComponent(btnDongYXoa)
.addComponent(btnHuyXoa))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout pnlXoaSuaSanPhamLayout = new javax.swing.GroupLayout(pnlXoaSuaSanPham);
pnlXoaSuaSanPham.setLayout(pnlXoaSuaSanPhamLayout);
pnlXoaSuaSanPhamLayout.setHorizontalGroup(
pnlXoaSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlXoaSuaSanPhamLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlXoaSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlXoaSuaSanPhamLayout.createSequentialGroup()
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlXoaSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(btnSuaSanPham, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnXoaSanPham, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlXoaSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlXoaSanPham, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlSuaSanPham, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(14, 14, 14))
.addGroup(pnlXoaSuaSanPhamLayout.createSequentialGroup()
.addComponent(txtTuKhoa, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(2, 2, 2)
.addComponent(btnTim)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chbInstant)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
);
pnlXoaSuaSanPhamLayout.setVerticalGroup(
pnlXoaSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlXoaSuaSanPhamLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlXoaSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnTim)
.addComponent(txtTuKhoa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(chbInstant))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlXoaSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(pnlXoaSuaSanPhamLayout.createSequentialGroup()
.addGroup(pnlXoaSuaSanPhamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlXoaSuaSanPhamLayout.createSequentialGroup()
.addComponent(btnSuaSanPham)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnXoaSanPham))
.addComponent(pnlSuaSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(pnlXoaSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane4))
.addContainerGap(31, Short.MAX_VALUE))
);
tabQuanLySanPham.addTab("Xóa/sửa sản phẩm", pnlXoaSuaSanPham);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(tabQuanLySanPham, javax.swing.GroupLayout.PREFERRED_SIZE, 909, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tabQuanLySanPham)
);
}// </editor-fold>//GEN-END:initComponents
private void btnDanhSachActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDanhSachActionPerformed
loadDanhSach();
}//GEN-LAST:event_btnDanhSachActionPerformed
private void btnLuuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLuuActionPerformed
List resultList = SanPhamDAO.getToanBoSanPham();
Integer idLast = 0;
for (Object o : resultList) {
idLast++;
}
SanPham sp = new SanPham();
String txt = Integer.toString(cboNhomLoaiSanPham.getSelectedIndex() + 1) + idLast + txtTenSanPham.getText().substring(0, 3).toUpperCase();
txtMaSanPham.setText(txt);
sp.setMaSanPham(txtMaSanPham.getText());
sp.setTenSanPham(txtTenSanPham.getText());
sp.setKichThuoc(txtKichThuoc.getText());
sp.setKhoiLuong(Float.parseFloat(txtKhoiLuong.getText()));
sp.setDonVi((DonVi) cboDonViTinh.getSelectedItem());
sp.setNhomLoaiSanPham((NhomLoaiSanPham) cboNhomLoaiSanPham.getSelectedItem());
sp.setMoTa(txtMoTa.getText());
sp.setDonGia(Double.parseDouble(txtDonGia.getText()));
sp.setMauSac(txtMauSac.getText());
boolean kq;
kq = SanPhamDAO.themSanPham(sp);
tblSanPham.clearSelection();
loadDanhSach();
}//GEN-LAST:event_btnLuuActionPerformed
private void txtKichThuocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtKichThuocActionPerformed
}//GEN-LAST:event_txtKichThuocActionPerformed
private void txtTenSanPhamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTenSanPhamActionPerformed
}//GEN-LAST:event_txtTenSanPhamActionPerformed
private void btnLuuLoaiSanPhamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLuuLoaiSanPhamActionPerformed
NhomLoaiSanPham nlsp = new NhomLoaiSanPham();
nlsp.setMaNhomSanPham(txtMaLoaiSanPham.getText());
nlsp.setTenNhomSanPham(txtTenLoaiSanPham.getText());
boolean kq;
kq = NhomLoaiSanPhamDAO.themNhomLoaiSanPham(nlsp);
tblNhomLoaiSanPham.clearSelection();
loadNhomLoaiSanPham();
}//GEN-LAST:event_btnLuuLoaiSanPhamActionPerformed
private void tblSanPhamInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_tblSanPhamInputMethodTextChanged
}//GEN-LAST:event_tblSanPhamInputMethodTextChanged
private void tblSanPhamCaretPositionChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_tblSanPhamCaretPositionChanged
// TODO add your handling code here:
}//GEN-LAST:event_tblSanPhamCaretPositionChanged
private void tblSanPhamVetoableChange(java.beans.PropertyChangeEvent evt)throws java.beans.PropertyVetoException {//GEN-FIRST:event_tblSanPhamVetoableChange
// TODO add your handling code here:
}//GEN-LAST:event_tblSanPhamVetoableChange
private void btnTimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTimActionPerformed
loadThongTinSanPham();
}//GEN-LAST:event_btnTimActionPerformed
private void lisSanPhamMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lisSanPhamMouseClicked
lblNotificationXoa.setEnabled(false);
btnDongYXoa.setEnabled(false);
btnHuyXoa.setEnabled(false);
lblNotificationLuu.setText("");
btnXoaSanPham.setEnabled(true);
btnSuaSanPham.setEnabled(true);
txtSuaDonGia.setEnabled(false);
txtSuaKhoiLuong.setEnabled(false);
txtSuaKichThuoc.setEnabled(false);
txtSuaMauSac.setEnabled(false);
txtSuaMoTa.setEnabled(false);
btnLuuSuaSanPham.setEnabled(false);
btnHuySuaSanPham.setEnabled(false);
txtSuaTenSanPham.setEnabled(false);
cboSuaDonViTinh.setEnabled(false);
cboSuaNhomLoaiSanPham.setEnabled(false);
loadChiTietSanPham();
}//GEN-LAST:event_lisSanPhamMouseClicked
private void btnSuaSanPhamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSuaSanPhamActionPerformed
loadChiTietSanPham();
txtSuaDonGia.setEnabled(true);
txtSuaKhoiLuong.setEnabled(true);
txtSuaKichThuoc.setEnabled(true);
txtSuaMauSac.setEnabled(true);
txtSuaMoTa.setEnabled(true);
txtSuaTenSanPham.setEnabled(true);
cboSuaDonViTinh.setEnabled(true);
cboSuaNhomLoaiSanPham.setEnabled(true);
btnLuuSuaSanPham.setEnabled(true);
btnHuySuaSanPham.setEnabled(true);
}//GEN-LAST:event_btnSuaSanPhamActionPerformed
private void chbInstantActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chbInstantActionPerformed
instantTxtKeywords();
}//GEN-LAST:event_chbInstantActionPerformed
private void btnLuuSuaSanPhamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLuuSuaSanPhamActionPerformed
//SanPhamDAO.suaSanPham(Integer.parseInt(lblId.getText()), txtSuaTenSanPham.getText(),txtSuaKichThuoc.getText(),Float.valueOf(txtSuaKhoiLuong.getText().trim()).floatValue(), cboSuaDonViTinh.getSelectedIndex()+1, txtSuaMauSac.getText(), cboSuaNhomLoaiSanPham.getSelectedIndex(), Long.valueOf(txtSuaDonGia.getText().trim()).longValue(), txtSuaMoTa.getText());
SanPham sp = new SanPham();
sp.setId(Integer.parseInt(lblId.getText()));
sp.setTenSanPham(txtSuaTenSanPham.getText());
sp.setKichThuoc(txtSuaKichThuoc.getText());
sp.setKhoiLuong(Float.parseFloat(txtSuaKhoiLuong.getText()));
sp.setDonVi((DonVi) cboSuaDonViTinh.getSelectedItem());
sp.setNhomLoaiSanPham((NhomLoaiSanPham) cboSuaNhomLoaiSanPham.getSelectedItem());
sp.setMoTa(txtSuaMoTa.getText());
sp.setDonGia(Double.parseDouble(txtSuaDonGia.getText()));
sp.setMauSac(txtSuaMauSac.getText());
boolean kq;
kq = SanPhamDAO.suaSanPham(sp);
lisSanPham.clearSelection();
btnTim.doClick();
lblNotificationLuu.setText("Sản phẩm đã được lưu");
}//GEN-LAST:event_btnLuuSuaSanPhamActionPerformed
private void btnXoaSanPhamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnXoaSanPhamActionPerformed
lblNotificationXoa.setEnabled(true);
btnDongYXoa.setEnabled(true);
btnHuyXoa.setEnabled(true);
}//GEN-LAST:event_btnXoaSanPhamActionPerformed
private void btnDongYXoaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDongYXoaActionPerformed
SanPham sp = new SanPham();
sp.setId(Integer.parseInt(lblId.getText()));
sp.setTenSanPham(txtSuaTenSanPham.getText());
sp.setKichThuoc(txtSuaKichThuoc.getText());
sp.setKhoiLuong(Float.parseFloat(txtSuaKhoiLuong.getText()));
sp.setDonVi((DonVi) cboSuaDonViTinh.getSelectedItem());
sp.setNhomLoaiSanPham((NhomLoaiSanPham) cboSuaNhomLoaiSanPham.getSelectedItem());
sp.setMoTa(txtSuaMoTa.getText());
sp.setDonGia(Double.parseDouble(txtSuaDonGia.getText()));
sp.setMauSac(txtSuaMauSac.getText());
boolean kq;
kq = SanPhamDAO.xoaSanPham(sp);
lisSanPham.clearSelection();
btnTim.doClick();
}//GEN-LAST:event_btnDongYXoaActionPerformed
private void btnHuyXoaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHuyXoaActionPerformed
btnDongYXoa.setEnabled(false);
btnHuyXoa.setEnabled(false);
}//GEN-LAST:event_btnHuyXoaActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnDanhSach;
private javax.swing.JButton btnDongYXoa;
private javax.swing.JButton btnHuySuaSanPham;
private javax.swing.JButton btnHuyXoa;
private javax.swing.JButton btnLuu;
private javax.swing.JButton btnLuuLoaiSanPham;
private javax.swing.JButton btnLuuSuaSanPham;
private javax.swing.JButton btnSuaSanPham;
private javax.swing.JButton btnTim;
private javax.swing.JButton btnXoaSanPham;
private javax.swing.JComboBox cboDonViTinh;
private javax.swing.JComboBox cboNhomLoaiSanPham;
private javax.swing.JComboBox cboSuaDonViTinh;
private javax.swing.JComboBox cboSuaNhomLoaiSanPham;
private javax.swing.JCheckBox chbInstant;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JTextField jTextField6;
private javax.swing.JLabel lblId;
private javax.swing.JLabel lblMaSanPham;
private javax.swing.JLabel lblNotificationLuu;
private javax.swing.JLabel lblNotificationXoa;
private javax.swing.JList lisSanPham;
private javax.swing.JPanel pnlLoaiSanPham;
private javax.swing.JPanel pnlSuaSanPham;
private javax.swing.JPanel pnlThemSanPham;
private javax.swing.JPanel pnlXoaSanPham;
private javax.swing.JPanel pnlXoaSuaSanPham;
private javax.swing.JTabbedPane tabQuanLySanPham;
private javax.swing.JTable tblNhomLoaiSanPham;
private javax.swing.JTable tblSanPham;
private javax.swing.JTextField txtDonGia;
private javax.swing.JTextField txtKhoiLuong;
private javax.swing.JTextField txtKichThuoc;
private javax.swing.JTextField txtMaLoaiSanPham;
private javax.swing.JTextField txtMaSanPham;
private javax.swing.JTextField txtMauSac;
private javax.swing.JTextArea txtMoTa;
private javax.swing.JTextField txtSuaDonGia;
private javax.swing.JTextField txtSuaKhoiLuong;
private javax.swing.JTextField txtSuaKichThuoc;
private javax.swing.JTextField txtSuaMauSac;
private javax.swing.JTextArea txtSuaMoTa;
private javax.swing.JTextField txtSuaTenSanPham;
private javax.swing.JTextField txtTenLoaiSanPham;
private javax.swing.JTextField txtTenSanPham;
private javax.swing.JTextField txtTuKhoa;
// End of variables declaration//GEN-END:variables
private void loadNhomLoaiSanPham() {
try {
List resultList = NhomLoaiSanPhamDAO.getNhomLoaiSanPham();
this.cboNhomLoaiSanPham.setModel(new DefaultComboBoxModel(resultList.toArray()));
this.cboSuaNhomLoaiSanPham.setModel(new DefaultComboBoxModel(resultList.toArray()));
} catch (HibernateException he) {
he.printStackTrace();
}
}
private void loadDonViTinh() {
try {
List resultList = DonViTinhDAO.getDonViTinh();
this.cboDonViTinh.setModel(new DefaultComboBoxModel(resultList.toArray()));
this.cboSuaDonViTinh.setModel(new DefaultComboBoxModel(resultList.toArray()));
} catch (HibernateException he) {
he.printStackTrace();
}
}
private void loadDanhSach() {
try {
List resultList = SanPhamDAO.getToanBoSanPham();
Vector<String> tableHeaders = new Vector<String>();
Vector<Object> tableData = new Vector<Object>();
tableHeaders.add("Tên sản phẩm");
tableHeaders.add("Nhóm sản phẩm");
tableHeaders.add("Màu sắc");
tableHeaders.add("Khối lượng");
tableHeaders.add("Kích thước");
tableHeaders.add("Giá");
tableHeaders.add("Mô tả");
for (Object o : resultList) {
Vector oneRow = new Vector();
//Object[] objs = (Object[])o;
//SanPham sp = (SanPham) objs[0];
SanPham sp = (SanPham) o;
oneRow.add(sp.getTenSanPham());
oneRow.add(sp.getNhomLoaiSanPham());
oneRow.add(sp.getMauSac());
oneRow.add(sp.getKhoiLuong());
oneRow.add(sp.getKichThuoc());
DecimalFormat df = new DecimalFormat("#.##");
oneRow.add(df.format(sp.getDonGia()));
oneRow.add(sp.getMoTa());
tableData.add(oneRow);
}
this.tblSanPham.setModel(new DefaultTableModel(tableData, tableHeaders));
} catch (HibernateException he) {
he.printStackTrace();
}
}
private void loadThongTinSanPham() {
try {
List resultList = TimSanPhamDAO.getSanPham(txtTuKhoa.getText());
this.lisSanPham.setModel(new DefaultComboBoxModel(resultList.toArray()));
} catch (HibernateException he) {
he.printStackTrace();
}
}
private void loadChiTietSanPham() {
SanPham a = (SanPham) lisSanPham.getSelectedValue();
txtSuaKhoiLuong.setText(a.getKhoiLuong().toString());
txtSuaTenSanPham.setText(a.getTenSanPham());
txtSuaKichThuoc.setText(a.getKichThuoc());
DecimalFormat df = new DecimalFormat("#.##");
txtSuaDonGia.setText(df.format(a.getDonGia()).toString());
txtSuaMauSac.setText(a.getMauSac());
txtSuaMoTa.setText(a.getMoTa());
lblId.setText(Integer.toString(a.getId()));
lblMaSanPham.setText(a.getMaSanPham());
cboSuaDonViTinh.setSelectedIndex(a.getDonVi().getId() - 1);
cboSuaNhomLoaiSanPham.setSelectedIndex(a.getNhomLoaiSanPham().getId() - 1);
}
private void enterTxtKeywords() {
txtTuKhoa.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_ENTER) {
JTextField textField = (JTextField) e.getSource();
String text = textField.getText();
btnTim.doClick();
}
}
});
}
private void instantTxtKeywords() {
//
txtTuKhoa.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
JTextField textField = (JTextField) e.getSource();
String text = textField.getText();
btnTim.doClick();
}
});
}
public class DialogBoxTutorial {
JFrame frame;
public DialogBoxTutorial() {
frame = new JFrame("Simple Dialog Box Demo");
JButton button = new JButton("Show Dialog");
button.addActionListener(new DialogAction());
frame.add(button);
frame.setSize(500, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public class DialogAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(frame,
"This is warning dialog demo.",
"Warning",
JOptionPane.WARNING_MESSAGE);
}
}
}
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/quanlycuahangcongnghe/QuanLySanPham.java | Java | oos | 56,345 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package quanlycuahangcongnghe;
/**
*
* @author RUA
*/
public class KhuyenMai extends javax.swing.JPanel {
/**
* Creates new form KhuyenMai
*/
public KhuyenMai() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel1.setText("km");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(jLabel1)
.addContainerGap(891, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jLabel1)
.addContainerGap(473, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
// End of variables declaration//GEN-END:variables
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/quanlycuahangcongnghe/KhuyenMai.java | Java | oos | 1,716 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package quanlycuahangcongnghe;
/**
*
* @author RUA
*/
public class KhoHang extends javax.swing.JPanel {
/**
* Creates new form KhoHang
*/
public KhoHang() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel1.setText("jLabel1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(jLabel1)
.addContainerGap(871, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jLabel1)
.addContainerGap(472, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
// End of variables declaration//GEN-END:variables
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/quanlycuahangcongnghe/KhoHang.java | Java | oos | 1,715 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package quanlycuahangcongnghe;
import DAO.NhomLoaiSanPhamDAO;
import DAO.TimSanPhamDAO;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import org.hibernate.HibernateException;
import qlchcn.entity.SanPham;
/**
*
* @author RUA
*/
public class TimKiem extends javax.swing.JPanel {
/**
* Creates new form TimKiem
*/
public TimKiem() {
initComponents();
loadNhomLoaiSanPham();
enterTxtKeywords();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jToolBar3 = new javax.swing.JToolBar();
jToolBar4 = new javax.swing.JToolBar();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
txtTuKhoa = new javax.swing.JTextField();
btnTim = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
tblSanPham = new javax.swing.JTable();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
lbKetQua = new javax.swing.JLabel();
lbTuKhoa = new javax.swing.JLabel();
txtInstant = new javax.swing.JCheckBox();
jToolBar3.setRollover(true);
jToolBar4.setRollover(true);
txtTuKhoa.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtTuKhoaActionPerformed(evt);
}
});
btnTim.setText("Tìm");
btnTim.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnTimActionPerformed(evt);
}
});
tblSanPham.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Tên sản phẩm", "Nhóm sản phẩm", "Giá sản phẩm", "Mô tả"
}
) {
boolean[] canEdit = new boolean [] {
false, false, false, false
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jScrollPane1.setViewportView(tblSanPham);
jLabel1.setText("Tên sản phẩm:");
jLabel2.setFont(new java.awt.Font("Tahoma", 2, 10)); // NOI18N
jLabel2.setText("Bạn có thể nhập Tên sản phẩm, Nhóm sản phẩm hoặc Mô tả để tìm kiếm");
jLabel3.setText("Tìm được:");
jLabel4.setText("kết quả với từ khóa");
lbKetQua.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
lbKetQua.setForeground(new java.awt.Color(0, 204, 204));
lbKetQua.setText("-");
lbTuKhoa.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
lbTuKhoa.setForeground(new java.awt.Color(0, 204, 204));
lbTuKhoa.setText("-");
txtInstant.setText("Instant");
txtInstant.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtInstantActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 902, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(400, 400, 400)
.addComponent(jLabel5))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtTuKhoa, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnTim)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtInstant))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(142, 142, 142)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lbKetQua, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lbTuKhoa, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtTuKhoa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnTim)
.addComponent(jLabel1)
.addComponent(txtInstant))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(lbKetQua)
.addComponent(jLabel4)
.addComponent(lbTuKhoa))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 396, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5)
.addGap(23, 23, 23))
);
jTabbedPane1.addTab("Tìm sản phẩm", jPanel1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1)
);
}// </editor-fold>//GEN-END:initComponents
private void btnTimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTimActionPerformed
try {
List resultList = TimSanPhamDAO.getSanPham(txtTuKhoa.getText());
Vector<String> tableHeaders = new Vector<String>();
Vector<Object> tableData = new Vector<Object>();
tableHeaders.add("Tên sản phẩm");
tableHeaders.add("Nhóm sản phẩm");
tableHeaders.add("Giá");
tableHeaders.add("Mô tả");
for (Object o : resultList) {
Vector oneRow = new Vector();
//Object[] objs = (Object[])o;
//SanPham sp = (SanPham) objs[0];
SanPham sp = (SanPham) o;
oneRow.add(sp.getTenSanPham());
oneRow.add(sp.getNhomLoaiSanPham());
DecimalFormat df = new DecimalFormat("#.##");
oneRow.add(df.format(sp.getDonGia()));
oneRow.add(sp.getMoTa());
tableData.add(oneRow);
}
this.tblSanPham.setModel(new DefaultTableModel(tableData, tableHeaders));
this.lbKetQua.setText(Integer.toString(tblSanPham.getRowCount()));
this.lbTuKhoa.setText(txtTuKhoa.getText());
} catch (HibernateException he) {
he.printStackTrace();
}
}//GEN-LAST:event_btnTimActionPerformed
private void txtTuKhoaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTuKhoaActionPerformed
}//GEN-LAST:event_txtTuKhoaActionPerformed
private void txtInstantActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtInstantActionPerformed
instantTxtKeywords();
txtInstant.setEnabled(false);
}//GEN-LAST:event_txtInstantActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnTim;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JToolBar jToolBar3;
private javax.swing.JToolBar jToolBar4;
private javax.swing.JLabel lbKetQua;
private javax.swing.JLabel lbTuKhoa;
private javax.swing.JTable tblSanPham;
private javax.swing.JCheckBox txtInstant;
private javax.swing.JTextField txtTuKhoa;
// End of variables declaration//GEN-END:variables
private void loadNhomLoaiSanPham() {
/*List resultList = NhomLoaiSanPhamDAO.getNhomLoaiSanPham();
this.cboNhomLoaiSanPham.setModel(new DefaultComboBoxModel(resultList.toArray()));*/
}
private void instantTxtKeywords() {
//
txtTuKhoa.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
JTextField textField = (JTextField) e.getSource();
String text = textField.getText();
btnTim.doClick();
}
});
}
private void enterTxtKeywords() {
txtTuKhoa.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_ENTER) {
JTextField textField = (JTextField) e.getSource();
String text = textField.getText();
btnTim.doClick();
}
}
});
}
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/quanlycuahangcongnghe/TimKiem.java | Java | oos | 12,707 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package quanlycuahangcongnghe;
import DAO.NhanVienDAO;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import org.hibernate.HibernateException;
import qlchcn.entity.NhanVien;
import java.security.*;
/**
*
* @author RUA
*/
public class QuanLyNhanVien extends javax.swing.JPanel {
/**
* Creates new form NhanVien
*/
public QuanLyNhanVien() {
initComponents();
enterTxtKeywords();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
pnlChinhSuaNhanVien = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
txtTuKhoa = new javax.swing.JTextField();
btnTim = new javax.swing.JButton();
chbInstant = new javax.swing.JCheckBox();
jScrollPane4 = new javax.swing.JScrollPane();
lisNhanVien = new javax.swing.JList();
btnSuaNhanVien = new javax.swing.JButton();
btnXoaNhanVien = new javax.swing.JButton();
pnlSuaNhanVien = new javax.swing.JPanel();
txtSuaTenNhanVien = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
txtSuaDiaChi = new javax.swing.JTextField();
txtSuaCMND = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
txtSuaSDT = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
pswSuaMatKhau = new javax.swing.JPasswordField();
jLabel15 = new javax.swing.JLabel();
spnSuaNgaySinh = new javax.swing.JSpinner();
cboSuaGioiTinh = new javax.swing.JComboBox();
btnLuuSuaNhanVien = new javax.swing.JButton();
btnHuySuaNhanVien = new javax.swing.JButton();
lblID = new javax.swing.JLabel();
lblNotificationLuu = new javax.swing.JLabel();
pnlXoaNhanVien = new javax.swing.JPanel();
s = new javax.swing.JLabel();
lblDongY = new javax.swing.JLabel();
btnDongYXoa = new javax.swing.JButton();
btnHuyXoa = new javax.swing.JButton();
lblXoaNhanVien = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
txtTenNhanVien = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
txtMaNhanVien = new javax.swing.JTextField();
txtDiaChi = new javax.swing.JTextField();
txtCMND = new javax.swing.JTextField();
txtSoDienThoai = new javax.swing.JTextField();
pswMatKhau = new javax.swing.JPasswordField();
spnNgaySinh = new javax.swing.JSpinner();
cboGioiTinh = new javax.swing.JComboBox();
jScrollPane1 = new javax.swing.JScrollPane();
tblNhanVien = new javax.swing.JTable();
btnThem = new javax.swing.JButton();
btnDanhSach = new javax.swing.JButton();
btnTim.setText("Tìm");
btnTim.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnTimActionPerformed(evt);
}
});
chbInstant.setText("Instant");
chbInstant.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chbInstantActionPerformed(evt);
}
});
lisNhanVien.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
lisNhanVien.setToolTipText("");
lisNhanVien.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lisNhanVienMouseClicked(evt);
}
});
jScrollPane4.setViewportView(lisNhanVien);
btnSuaNhanVien.setText("Sửa > ");
btnSuaNhanVien.setEnabled(false);
btnSuaNhanVien.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSuaNhanVienActionPerformed(evt);
}
});
btnXoaNhanVien.setText("Xóa >");
btnXoaNhanVien.setEnabled(false);
btnXoaNhanVien.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnXoaNhanVienActionPerformed(evt);
}
});
pnlSuaNhanVien.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Sửa nhân viên", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, java.awt.Color.gray));
txtSuaTenNhanVien.setEnabled(false);
jLabel9.setText("Tên nhân viên:");
jLabel10.setText("Địa chỉ:");
txtSuaDiaChi.setEnabled(false);
txtSuaCMND.setEnabled(false);
jLabel11.setText("CMND:");
jLabel12.setText("Giới tính:");
jLabel13.setText("SĐT:");
txtSuaSDT.setEnabled(false);
jLabel14.setText("Ngày sinh:");
pswSuaMatKhau.setEnabled(false);
jLabel15.setText("Mật khẩu:");
spnSuaNgaySinh.setModel(new javax.swing.SpinnerDateModel());
spnSuaNgaySinh.setEditor(new javax.swing.JSpinner.DateEditor(spnSuaNgaySinh, "d/M/y"));
spnSuaNgaySinh.setEnabled(false);
cboSuaGioiTinh.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Nam", "Nữ", "Chưa xác định" }));
cboSuaGioiTinh.setEnabled(false);
btnLuuSuaNhanVien.setText("Lưu");
btnLuuSuaNhanVien.setEnabled(false);
btnLuuSuaNhanVien.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLuuSuaNhanVienActionPerformed(evt);
}
});
btnHuySuaNhanVien.setText("Hủy");
btnHuySuaNhanVien.setEnabled(false);
lblID.setText("-");
lblID.setEnabled(false);
javax.swing.GroupLayout pnlSuaNhanVienLayout = new javax.swing.GroupLayout(pnlSuaNhanVien);
pnlSuaNhanVien.setLayout(pnlSuaNhanVienLayout);
pnlSuaNhanVienLayout.setHorizontalGroup(
pnlSuaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlSuaNhanVienLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlSuaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9)
.addComponent(jLabel10)
.addComponent(jLabel11)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(pnlSuaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlSuaNhanVienLayout.createSequentialGroup()
.addComponent(btnLuuSuaNhanVien, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnHuySuaNhanVien))
.addComponent(txtSuaSDT)
.addComponent(txtSuaCMND)
.addComponent(txtSuaDiaChi)
.addComponent(txtSuaTenNhanVien)
.addComponent(pswSuaMatKhau)
.addComponent(spnSuaNgaySinh)
.addComponent(cboSuaGioiTinh, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlSuaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblID)
.addComponent(lblNotificationLuu))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pnlSuaNhanVienLayout.setVerticalGroup(
pnlSuaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlSuaNhanVienLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlSuaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtSuaTenNhanVien, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9)
.addComponent(lblID))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlSuaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel10)
.addComponent(txtSuaDiaChi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlSuaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtSuaCMND, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlSuaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(cboSuaGioiTinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlSuaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel13)
.addComponent(txtSuaSDT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlSuaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14)
.addComponent(spnSuaNgaySinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlSuaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(pswSuaMatKhau, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel15))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(pnlSuaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnLuuSuaNhanVien)
.addComponent(btnHuySuaNhanVien)
.addComponent(lblNotificationLuu))
.addContainerGap(17, Short.MAX_VALUE))
);
pnlXoaNhanVien.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Xóa nhân viên", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, java.awt.Color.gray));
s.setText("Chú ý! Xóa nhân viên sẽ ảnh hưởng đến nhiều vấn đề liên quan đến thao tác quản lý. Và KHÔNG thể phục hồi");
lblDongY.setText("Bạn có đồng ý xóa?");
lblDongY.setEnabled(false);
btnDongYXoa.setText("Đồng ý xóa");
btnDongYXoa.setEnabled(false);
btnDongYXoa.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDongYXoaActionPerformed(evt);
}
});
btnHuyXoa.setText("Hủy");
btnHuyXoa.setEnabled(false);
javax.swing.GroupLayout pnlXoaNhanVienLayout = new javax.swing.GroupLayout(pnlXoaNhanVien);
pnlXoaNhanVien.setLayout(pnlXoaNhanVienLayout);
pnlXoaNhanVienLayout.setHorizontalGroup(
pnlXoaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlXoaNhanVienLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlXoaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(s)
.addGroup(pnlXoaNhanVienLayout.createSequentialGroup()
.addComponent(lblDongY)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnDongYXoa)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnHuyXoa)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblXoaNhanVien)))
.addContainerGap(50, Short.MAX_VALUE))
);
pnlXoaNhanVienLayout.setVerticalGroup(
pnlXoaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlXoaNhanVienLayout.createSequentialGroup()
.addContainerGap()
.addComponent(s)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlXoaNhanVienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblDongY)
.addComponent(btnDongYXoa)
.addComponent(btnHuyXoa)
.addComponent(lblXoaNhanVien))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(btnSuaNhanVien, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnXoaNhanVien, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlXoaNhanVien, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlSuaNhanVien, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtTuKhoa, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(2, 2, 2)
.addComponent(btnTim)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chbInstant)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnTim)
.addComponent(txtTuKhoa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(chbInstant))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(btnSuaNhanVien)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnXoaNhanVien))
.addComponent(pnlSuaNhanVien, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlXoaNhanVien, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap())
);
pnlChinhSuaNhanVien.addTab("Chỉnh sửa nhân viên", jPanel1);
jLabel1.setText("Tên nhân viên:");
jLabel2.setText("Mã nhân viên:");
jLabel3.setText("Địa chỉ:");
jLabel4.setText("Giới tính:");
jLabel5.setText("Số điện thoại:");
jLabel6.setText("CMND:");
jLabel7.setText("Ngày sinh:");
jLabel8.setText("Mật khẩu:");
txtMaNhanVien.setEditable(false);
spnNgaySinh.setModel(new javax.swing.SpinnerDateModel());
spnNgaySinh.setEditor(new javax.swing.JSpinner.DateEditor(spnNgaySinh, "d/M/y"));
cboGioiTinh.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Nam", "Nữ", "Chưa xác định" }));
tblNhanVien.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane1.setViewportView(tblNhanVien);
btnThem.setText("Thêm");
btnThem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnThemActionPerformed(evt);
}
});
btnDanhSach.setText("Danh sách");
btnDanhSach.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDanhSachActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jScrollPane1)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtTenNhanVien, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtMaNhanVien, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel3)
.addGap(16, 16, 16)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(txtDiaChi)
.addComponent(cboGioiTinh, 0, 151, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addGap(15, 15, 15)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(btnThem)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnDanhSach))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtSoDienThoai, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
.addComponent(txtCMND))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(jLabel8)
.addGap(10, 10, 10))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel7)
.addGap(7, 7, 7)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(spnNgaySinh, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
.addComponent(pswMatKhau))))))
.addContainerGap(44, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(spnNgaySinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(pswMatKhau, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(txtCMND, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtSoDienThoai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(txtTenNhanVien, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtMaNhanVien, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtDiaChi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(cboGioiTinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnDanhSach)
.addComponent(btnThem))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE)
.addContainerGap())
);
pnlChinhSuaNhanVien.addTab("Thêm nhân viên", jPanel2);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlChinhSuaNhanVien)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlChinhSuaNhanVien)
);
}// </editor-fold>//GEN-END:initComponents
private void btnThemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnThemActionPerformed
List resultList = NhanVienDAO.getToanBoNhanVien();
Integer idLast = 1;
for (Object o : resultList) {
idLast++;
}
NhanVien nv = new NhanVien();
String txt = Integer.toString(idLast);
txtMaNhanVien.setText(txt);
nv.setHoTen(txtTenNhanVien.getText());
nv.setMaNhanVien(txtMaNhanVien.getText());
nv.setSoCmnd(txtCMND.getText());
nv.setGioiTinh(cboGioiTinh.getSelectedItem().toString());
nv.setDiaChi(txtDiaChi.getText());
nv.setSoDienThoai(txtSoDienThoai.getText());
nv.setNgaySinh((Date) spnNgaySinh.getModel().getValue());
nv.setMatKhau(MD5Covert(pswMatKhau.getPassword().toString()));
boolean kq;
kq = NhanVienDAO.themNhanVien(nv);
tblNhanVien.clearSelection();
loadNhanVien();
}//GEN-LAST:event_btnThemActionPerformed
private void btnDanhSachActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDanhSachActionPerformed
loadNhanVien();
}//GEN-LAST:event_btnDanhSachActionPerformed
private void btnTimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTimActionPerformed
loadThongTinNhanVien();
}//GEN-LAST:event_btnTimActionPerformed
private void chbInstantActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chbInstantActionPerformed
instantTxtKeywords();
chbInstant.setEnabled(false);
}//GEN-LAST:event_chbInstantActionPerformed
private void lisNhanVienMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lisNhanVienMouseClicked
btnSuaNhanVien.setEnabled(true);
txtSuaCMND.setEnabled(false);
txtSuaSDT.setEnabled(false);
txtSuaDiaChi.setEnabled(false);
cboSuaGioiTinh.setEnabled(false);
pswSuaMatKhau.setEnabled(false);
spnSuaNgaySinh.setEnabled(false);
txtSuaTenNhanVien.setEnabled(false);
btnLuuSuaNhanVien.setEnabled(false);
btnHuySuaNhanVien.setEnabled(false);
lblDongY.setEnabled(false);
btnDongYXoa.setEnabled(false);
btnHuyXoa.setEnabled(false);
lblXoaNhanVien.setText(" ");
lblNotificationLuu.setText(" ");
btnXoaNhanVien.setEnabled(true);
loadChiTietNhanVien();
}//GEN-LAST:event_lisNhanVienMouseClicked
private void btnSuaNhanVienActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSuaNhanVienActionPerformed
txtSuaCMND.setEnabled(true);
txtSuaSDT.setEnabled(true);
txtSuaDiaChi.setEnabled(true);
cboSuaGioiTinh.setEnabled(true);
pswSuaMatKhau.setEnabled(true);
spnSuaNgaySinh.setEnabled(true);
txtSuaTenNhanVien.setEnabled(true);
btnLuuSuaNhanVien.setEnabled(true);
btnHuySuaNhanVien.setEnabled(true);
}//GEN-LAST:event_btnSuaNhanVienActionPerformed
private void btnXoaNhanVienActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnXoaNhanVienActionPerformed
lblDongY.setEnabled(true);
btnDongYXoa.setEnabled(true);
btnHuyXoa.setEnabled(true);
}//GEN-LAST:event_btnXoaNhanVienActionPerformed
private void btnLuuSuaNhanVienActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLuuSuaNhanVienActionPerformed
NhanVien nv = new NhanVien();
nv.setDiaChi(txtSuaDiaChi.getText());
nv.setGioiTinh(cboSuaGioiTinh.getSelectedItem().toString());
nv.setNgaySinh((Date) spnSuaNgaySinh.getModel().getValue());
nv.setHoTen(txtSuaTenNhanVien.getText());
nv.setId(Integer.parseInt(lblID.getText()));
nv.setMatKhau(MD5Covert(pswSuaMatKhau.getPassword().toString()));
nv.setSoDienThoai(txtSuaSDT.getText());
nv.setSoCmnd(txtSuaCMND.getText());
nv.setMaNhanVien(lblID.getText());
boolean kq;
kq = NhanVienDAO.suaNhanVien(nv);
lisNhanVien.clearSelection();
btnTim.doClick();
lblNotificationLuu.setText("Nhân viên đã được lưu");
}//GEN-LAST:event_btnLuuSuaNhanVienActionPerformed
private void btnDongYXoaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDongYXoaActionPerformed
NhanVien nv = new NhanVien();
nv.setId(Integer.parseInt(lblID.getText()));
boolean kq;
kq = NhanVienDAO.xoaNhanVien(nv);
lisNhanVien.clearSelection();
btnTim.doClick();
lblXoaNhanVien.setText("Bạn đã vừa cho ra đi một nhân viên");
}//GEN-LAST:event_btnDongYXoaActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnDanhSach;
private javax.swing.JButton btnDongYXoa;
private javax.swing.JButton btnHuySuaNhanVien;
private javax.swing.JButton btnHuyXoa;
private javax.swing.JButton btnLuuSuaNhanVien;
private javax.swing.JButton btnSuaNhanVien;
private javax.swing.JButton btnThem;
private javax.swing.JButton btnTim;
private javax.swing.JButton btnXoaNhanVien;
private javax.swing.JComboBox cboGioiTinh;
private javax.swing.JComboBox cboSuaGioiTinh;
private javax.swing.JCheckBox chbInstant;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JLabel lblDongY;
private javax.swing.JLabel lblID;
private javax.swing.JLabel lblNotificationLuu;
private javax.swing.JLabel lblXoaNhanVien;
private javax.swing.JList lisNhanVien;
private javax.swing.JTabbedPane pnlChinhSuaNhanVien;
private javax.swing.JPanel pnlSuaNhanVien;
private javax.swing.JPanel pnlXoaNhanVien;
private javax.swing.JPasswordField pswMatKhau;
private javax.swing.JPasswordField pswSuaMatKhau;
private javax.swing.JLabel s;
private javax.swing.JSpinner spnNgaySinh;
private javax.swing.JSpinner spnSuaNgaySinh;
private javax.swing.JTable tblNhanVien;
private javax.swing.JTextField txtCMND;
private javax.swing.JTextField txtDiaChi;
private javax.swing.JTextField txtMaNhanVien;
private javax.swing.JTextField txtSoDienThoai;
private javax.swing.JTextField txtSuaCMND;
private javax.swing.JTextField txtSuaDiaChi;
private javax.swing.JTextField txtSuaSDT;
private javax.swing.JTextField txtSuaTenNhanVien;
private javax.swing.JTextField txtTenNhanVien;
private javax.swing.JTextField txtTuKhoa;
// End of variables declaration//GEN-END:variables
private void loadNhanVien() {
try {
List resultList = NhanVienDAO.getToanBoNhanVien();
Vector<String> tableHeaders = new Vector<String>();
Vector<Object> tableData = new Vector<Object>();
tableHeaders.add("Mã đăng nhập");
tableHeaders.add("Tên nhân viên");
tableHeaders.add("Địa chỉ");
tableHeaders.add("SĐT");
tableHeaders.add("CMND");
tableHeaders.add("Giới tính");
tableHeaders.add("Ngày sinh");
for (Object o : resultList) {
Vector oneRow = new Vector();
NhanVien nv = (NhanVien) o;
oneRow.add(nv.getMaNhanVien());
oneRow.add(nv.getHoTen());
oneRow.add(nv.getDiaChi());
oneRow.add(nv.getSoDienThoai());
oneRow.add(nv.getSoCmnd());
oneRow.add(nv.getGioiTinh());
oneRow.add(nv.getNgaySinh());
tableData.add(oneRow);
}
this.tblNhanVien.setModel(new DefaultTableModel(tableData, tableHeaders));
} catch (HibernateException he) {
he.printStackTrace();
}
}
private void enterTxtKeywords() {
txtTuKhoa.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_ENTER) {
JTextField textField = (JTextField) e.getSource();
String text = textField.getText();
btnTim.doClick();
}
}
});
}
private void loadThongTinNhanVien() {
try {
List resultList = NhanVienDAO.getNhanVien(txtTuKhoa.getText());
lisNhanVien.setModel(new DefaultComboBoxModel(resultList.toArray()));
} catch (HibernateException he) {
he.printStackTrace();
}
}
private void instantTxtKeywords() {
//
txtTuKhoa.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
JTextField textField = (JTextField) e.getSource();
String text = textField.getText();
btnTim.doClick();
}
});
}
private void loadChiTietNhanVien() {
NhanVien nv = (NhanVien) lisNhanVien.getSelectedValue();
txtSuaTenNhanVien.setText(nv.getHoTen());
txtSuaDiaChi.setText(nv.getDiaChi());
txtSuaSDT.setText(nv.getSoDienThoai());
cboSuaGioiTinh.setSelectedItem(nv.getGioiTinh());
spnSuaNgaySinh.setValue((Date) nv.getNgaySinh());
txtSuaCMND.setText(nv.getSoCmnd());
lblID.setText(Integer.toString(nv.getId()));
}
private static String MD5Covert(String md5) {
String res = "";
try {
MessageDigest algorithm = MessageDigest.getInstance("MD5");
algorithm.reset();
algorithm.update(md5.getBytes());
byte[] MD5Covert = algorithm.digest();
String tmp = "";
for (int i = 0; i < MD5Covert.length; i++) {
tmp = (Integer.toHexString(0xFF & MD5Covert[i]));
if (tmp.length() == 1) {
res += "0" + tmp;
} else {
res += tmp;
}
}
} catch (NoSuchAlgorithmException ex) {
}
return res;
}
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/quanlycuahangcongnghe/QuanLyNhanVien.java | Java | oos | 41,771 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package quanlycuahangcongnghe;
/**
*
* @author RUA
*/
public class KhachHang extends javax.swing.JPanel {
/**
* Creates new form KhachHang
*/
public KhachHang() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel1.setText("jLabel1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(jLabel1)
.addContainerGap(871, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jLabel1)
.addContainerGap(473, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
// End of variables declaration//GEN-END:variables
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/quanlycuahangcongnghe/KhachHang.java | Java | oos | 1,721 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package qlchcn.util;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.SessionFactory;
/**
* Hibernate Utility class with a convenient method to get Session Factory
* object.
*
* @author RUA
*/
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from standard (hibernate.cfg.xml)
// config file.
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Log the exception.
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/qlchcn/util/HibernateUtil.java | Java | oos | 991 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package DAO;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import qlchcn.entity.NhaCungCap;
import qlchcn.util.HibernateUtil;
/**
*
* @author RUA
*/
public class NhaCungCapDAO {
public static List getNhaCungCap() {
try {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
String hql = "from NhaCungCap";
Query q = session.createQuery(hql);
List resultList = q.list();
session.getTransaction().commit();
return resultList;
} catch (HibernateException he) {
he.printStackTrace();
}
return null;
}
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/DAO/NhaCungCapDAO.java | Java | oos | 888 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package DAO;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.transform.DistinctRootEntityResultTransformer;
import org.hibernate.transform.ResultTransformer;
import qlchcn.entity.SanPham;
import qlchcn.util.HibernateUtil;
/**
*
* @author RUA
*/
public class SanPhamDAO {
public static List getToanBoSanPham() {
try {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
String hql = "from SanPham";
Query q = session.createQuery(hql);
List resultList = q.list();
session.getTransaction().commit();
return resultList;
} catch (HibernateException he) {
he.printStackTrace();
}
return null;
}
public static List getSanPham(String keyWords) {
try {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
String hql = "select distinct sp from SanPham sp, NhomLoaiSanPham nlsp where upper(sp.moTa) like :keyWords or upper(sp.tenSanPham) like :keyWords or upper(nlsp.tenNhomSanPham) like :keyWords group by sp.id";
Query q = session.createQuery(hql);
//q.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);// select distinct
q.setString("keyWords", "%" + keyWords.toUpperCase() + "%");
//q.setInteger("nhomSanPham", nhomSanPham);
//q.setInteger("nhomSanPham", giaSanPham);
final ResultTransformer trans = new DistinctRootEntityResultTransformer();
q.setResultTransformer(trans);
List resultList = q.list();
session.getTransaction().commit();
return resultList;
} catch (HibernateException he) {
he.printStackTrace();
}
return null;
}
public static boolean themSanPham(SanPham sanPham) {
Session session = HibernateUtil.getSessionFactory().openSession();
boolean kq = true;
Transaction transaction = null;
try {
transaction = session.beginTransaction();
session.save(sanPham);
transaction.commit();
} catch (HibernateException ex) {
transaction.rollback();
System.err.println(ex);
kq = false;
} finally {
session.close();
}
return kq;
}
public static boolean suaSanPham(SanPham sanPham) {
Session session = HibernateUtil.getSessionFactory().openSession();
boolean kq = true;
Transaction transaction = null;
try {
transaction = session.beginTransaction();
session.update(sanPham);
transaction.commit();
} catch (HibernateException ex) {
transaction.rollback();
System.err.println(ex);
kq = false;
} finally {
session.close();
}
return kq;
}
public static boolean xoaSanPham(SanPham sanPham) {
Session session = HibernateUtil.getSessionFactory().openSession();
boolean kq = true;
Transaction transaction = null;
transaction = session.beginTransaction();
try {
session.delete(sanPham);
transaction.commit();
} catch (Exception e) {
transaction.rollback();
System.err.println(e);
kq = false;
}
session.close();
return kq;
}
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/DAO/SanPhamDAO.java | Java | oos | 3,861 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package DAO;
import java.sql.Date;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import qlchcn.entity.PhieuNhap;
import qlchcn.util.HibernateUtil;
/**
*
* @author RUA
*/
public class PhieuNhapDAO {
public static List getPhieuNhap() {
try {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
String hql = "from PhieuNhap";
Query q = session.createQuery(hql);
List resultList = q.list();
session.getTransaction().commit();
return resultList;
} catch (HibernateException he) {
he.printStackTrace();
}
return null;
}
public static boolean themPhieuNhap(PhieuNhap phieunhap) {
Session session = HibernateUtil.getSessionFactory().openSession();
boolean kq = true;
Transaction transaction = null;
try {
transaction = session.beginTransaction();
session.save(phieunhap);
transaction.commit();
} catch (HibernateException ex) {
transaction.rollback();
System.err.println(ex);
kq = false;
} finally {
session.close();
}
return kq;
}
} | 1142041-1142056-quanlycuahangcongnghe | trunk/src/DAO/PhieuNhapDAO.java | Java | oos | 1,530 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package DAO;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import qlchcn.util.HibernateUtil;
/**
*
* @author RUA
*/
public class DonViTinhDAO {
public static List getDonViTinh() {
try {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
String hql = "from DonVi";
Query q = session.createQuery(hql);
List resultList = q.list();
session.getTransaction().commit();
return resultList;
} catch (HibernateException he) {
he.printStackTrace();
}
return null;
}
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/DAO/DonViTinhDAO.java | Java | oos | 851 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package DAO;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import qlchcn.entity.TrangThai;
import qlchcn.util.HibernateUtil;
/**
*
* @author RUA
*/
public class TrangThaiDAO {
public static List getTrangThai() {
try {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
String hql = "from TrangThai";
Query q = session.createQuery(hql);
List resultList = q.list();
session.getTransaction().commit();
return resultList;
} catch (HibernateException he) {
he.printStackTrace();
}
return null;
}
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/DAO/TrangThaiDAO.java | Java | oos | 884 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package DAO;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.transform.DistinctRootEntityResultTransformer;
import org.hibernate.transform.ResultTransformer;
import qlchcn.entity.NhanVien;
import qlchcn.util.HibernateUtil;
/**
*
* @author RUA
*/
public class NhanVienDAO {
public static boolean themNhanVien(NhanVien nhanVien) {
Session session = HibernateUtil.getSessionFactory().openSession();
boolean kq = true;
Transaction transaction = null;
try {
transaction = session.beginTransaction();
session.save(nhanVien);
transaction.commit();
} catch (HibernateException ex) {
transaction.rollback();
System.err.println(ex);
kq = false;
} finally {
session.close();
}
return kq;
}
public static List getToanBoNhanVien() {
try {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
String hql = "from NhanVien";
Query q = session.createQuery(hql);
List resultList = q.list();
session.getTransaction().commit();
return resultList;
} catch (HibernateException he) {
he.printStackTrace();
}
return null;
}
public static List getNhanVien(String keyWords) {
try {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
String hql = "select distinct nv from NhanVien nv where upper(nv.hoTen) like :keyWords";
Query q = session.createQuery(hql);
q.setParameter("keyWords", "%" + keyWords.toUpperCase() + "%");
final ResultTransformer trans = new DistinctRootEntityResultTransformer();
q.setResultTransformer(trans);
List resultList = q.list();
session.getTransaction().commit();
return resultList;
} catch (HibernateException he) {
he.printStackTrace();
}
return null;
}
public static boolean suaNhanVien(NhanVien nhanVien) {
Session session = HibernateUtil.getSessionFactory().openSession();
boolean kq = true;
Transaction transaction = null;
try {
transaction = session.beginTransaction();
session.update(nhanVien);
transaction.commit();
} catch (HibernateException ex) {
transaction.rollback();
System.err.println(ex);
kq = false;
} finally {
session.close();
}
return kq;
}
public static boolean xoaNhanVien(NhanVien nhanVien) {
Session session = HibernateUtil.getSessionFactory().openSession();
boolean kq = true;
Transaction transaction = null;
transaction = session.beginTransaction();
try {
session.delete(nhanVien);
transaction.commit();
} catch (Exception e) {
transaction.rollback();
System.err.println(e);
kq = false;
}
session.close();
return kq;
}
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/DAO/NhanVienDAO.java | Java | oos | 3,547 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package DAO;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import qlchcn.entity.LoaiHoaDon;
import qlchcn.util.HibernateUtil;
/**
*
* @author RUA
*/
public class LoaiHoaDonDAO {
public static List getLoaiHoaDon() {
try {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
String hql = "from LoaiHoaDon";
Query q = session.createQuery(hql);
List resultList = q.list();
session.getTransaction().commit();
return resultList;
} catch (HibernateException he) {
he.printStackTrace();
}
return null;
}
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/DAO/LoaiHoaDonDAO.java | Java | oos | 893 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package DAO;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import qlchcn.entity.NhomLoaiSanPham;
import qlchcn.util.HibernateUtil;
/**
*
* @author RUA
*/
public class NhomLoaiSanPhamDAO {
public static List getNhomLoaiSanPham() {
try {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
String hql = "from NhomLoaiSanPham";
Query q = session.createQuery(hql);
List resultList = q.list();
session.getTransaction().commit();
return resultList;
} catch (HibernateException he) {
he.printStackTrace();
}
return null;
}
public static boolean themNhomLoaiSanPham(NhomLoaiSanPham nlsp) {
Session session = HibernateUtil.getSessionFactory().openSession();
boolean kq = true;
Transaction transaction = null;
try {
transaction = session.beginTransaction();
session.save(nlsp);
transaction.commit();
} catch (HibernateException ex) {
transaction.rollback();
System.err.println(ex);
kq = false;
} finally {
session.close();
}
return kq;
}
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/DAO/NhomLoaiSanPhamDAO.java | Java | oos | 1,533 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package DAO;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Projections;
import org.hibernate.transform.DistinctRootEntityResultTransformer;
import org.hibernate.transform.ResultTransformer;
import qlchcn.entity.SanPham;
import qlchcn.entity.NhomLoaiSanPham;
import qlchcn.util.HibernateUtil;
/**
*
* @author RUA
*/
public class TimSanPhamDAO {
public static List getSanPham(String keyWords) {
try {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
String hql = "select distinct sp from SanPham sp, NhomLoaiSanPham nlsp where upper(sp.moTa) like :keyWords or upper(sp.tenSanPham) like :keyWords or upper(nlsp.tenNhomSanPham) like :keyWords group by sp.id";
Query q = session.createQuery(hql);
//q.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);// select distinct
q.setString("keyWords", "%" + keyWords.toUpperCase() + "%");
//q.setInteger("nhomSanPham", nhomSanPham);
//q.setInteger("nhomSanPham", giaSanPham);
final ResultTransformer trans = new DistinctRootEntityResultTransformer();
q.setResultTransformer(trans);
List resultList = q.list();
session.getTransaction().commit();
return resultList;
} catch (HibernateException he) {
he.printStackTrace();
}
return null;
}
}
| 1142041-1142056-quanlycuahangcongnghe | trunk/src/DAO/TimSanPhamDAO.java | Java | oos | 1,753 |
#include "LutController.h"
#include "MainWindow.h"
#include <QtDebug>
LutController *LutController::instance = 0;
LutController::LutController()
{
users = new UserList(this);
window = new MainWindow();
}
LutController* LutController::getInstance()
{
if(!instance)
instance = new LutController();
;
return instance;
}
void LutController::startApp()
{
window->initMainWindow();
window->show();
}
bool LutController::getShowTime()
{
return window->getShowTime();
}
int LutController::myId()
{
return window->myId();
}
QString LutController::getNameFromId(int id)
{
return users->getNameById(id);
}
void LutController::sendMsg(QString str)
{
window->sendMsg(str);
}
void LutController::sendPrivateMsg(int to, QString str)
{
window->sendPrivateMsg(to, str);
}
void LutController::onQuitReq()
{
emit quitMe();
}
UserList* LutController::getUsers()
{
return users;
}
| 01lut | branches/test2/src/ClientQt/LutController.cpp | C++ | gpl3 | 886 |
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QtNetwork>
#include <QSystemTrayIcon>
#include <QSettings>
#include <QListWidgetItem>
#include "LutController.h"
#include "User.h"
class DiscussPane;
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void sendMsg(QString str);
void sendPrivateMsg(int to, QString str);
int myId();
void initMainWindow();
bool getShowTime();
private:
Ui::MainWindow *ui;
QTcpSocket *sock;
QString nickname;
int id;
QSystemTrayIcon *trayIcon;
QIcon *icon;
QIcon *iconWarn;
bool event ( QEvent * event );
DiscussPane *findPaneById(int id);
void majUserList(QStringList list);
void majUser(QString data);
bool notifications;
bool showTime;
QSettings settings;
DiscussPane *mainPane;
QList<DiscussPane*> *privatePanes;
QString serverIP;
int serverPort;
QAction *exitAct;
QMenu *menuTray;
private slots:
void on_actionClear_triggered();
void on_actionShow_time_toggled(bool v);
void on_actionShow_time_triggered();
void on_actionClose_current_tab_triggered();
void on_actionNotifications_toggled(bool v);
void on_actionChange_server_triggered();
void on_actionChange_nickname_triggered();
void onExitAct();
void onTrayClicked(QSystemTrayIcon::ActivationReason r);
void errorReceived(QAbstractSocket::SocketError socketError);
void onConnected();
void dataHandler();
void onItemDoubleClicked(QModelIndex index);
void onTabChanged(int id);
void onToRead(DiscussPane *p);
};
#endif // MAINWINDOW_H
| 01lut | branches/test2/src/ClientQt/MainWindow.h | C++ | gpl3 | 1,620 |
#ifndef USERLIST_H
#define USERLIST_H
#include <QAbstractListModel>
#include "User.h"
class UserList : public QAbstractListModel
{
Q_OBJECT
public:
explicit UserList(QObject *parent = 0);
QVariant data(const QModelIndex &index, int role) const;
int rowCount(const QModelIndex &parent) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::EditRole);
bool insertRow(int row, const QModelIndex &parent);
bool removeRow(int row, const QModelIndex &parent);
// usermade :)
void addOrReplace(User *u);
QString getNameById(int id);
void removeRowById(int id);
void clear();
private:
QList<User *> *users;
signals:
public slots:
};
#endif // USERLIST_H
| 01lut | branches/test2/src/ClientQt/UserList.h | C++ | gpl3 | 766 |
#-------------------------------------------------
#
# Project created by QtCreator 2010-11-17T19:24:13
#
#-------------------------------------------------
QT += core gui network
TARGET = ClientQt
TEMPLATE = app
SOURCES += main.cpp\
MainWindow.cpp \
User.cpp \
DiscussPane.cpp \
LutController.cpp \
UserList.cpp
HEADERS += MainWindow.h \
User.h \
DiscussPane.h \
LutController.h \
UserList.h
FORMS += MainWindow.ui \
DiscussPane.ui
RESOURCES += \
resources.qrc
| 01lut | branches/test2/src/ClientQt/ClientQt.pro | QMake | gpl3 | 518 |
#include "User.h"
User::User(int id, QString name) :
id(id),
name(name)
{
}
User::User(QString data)
{
QStringList infos = data.split(" ");
id = infos.at(0).toInt();
name = infos.at(1);
}
int User::getId()
{
return id;
}
QString User::getName()
{
return name;
}
void User::setId(int val)
{
id = val;
}
void User::setName(QString n)
{
this->name = n;
}
| 01lut | branches/test2/src/ClientQt/User.cpp | C++ | gpl3 | 369 |
#include <QtGui/QApplication>
#include "LutController.h"
int main(int argc, char *argv[])
{
QApplication *a = new QApplication(argc, argv);
a->setQuitOnLastWindowClosed(false);
LutController *ctrl = LutController::getInstance();
QApplication::connect(ctrl, SIGNAL(quitMe()), a, SLOT(quit()));
ctrl->startApp();
return a->exec();
}
| 01lut | branches/test2/src/ClientQt/main.cpp | C++ | gpl3 | 344 |
#include "UserList.h"
#include "LutController.h"
UserList::UserList(QObject *parent) :
QAbstractListModel(parent)
{
users = new QList<User*>();
}
QVariant UserList::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (index.row() >= users->size())
return QVariant();
if (role == Qt::DisplayRole || role == Qt::EditRole)
return users->at(index.row())->getName();
if (role == Qt::UserRole)
return users->at(index.row())->getId();
if (role == Qt::ForegroundRole)
{
if(LutController::getInstance()->myId() == users->at(index.row())->getId())
return Qt::darkRed;
return Qt::darkBlue;
}
else
return QVariant();
}
int UserList::rowCount(const QModelIndex &) const
{
return users->size();
}
Qt::ItemFlags UserList::flags(const QModelIndex &index) const
{
if (!index.isValid())
return Qt::ItemIsEnabled;
return QAbstractListModel::flags(index);
}
bool UserList::insertRow(int row, const QModelIndex &parent)
{
beginInsertRows(parent, row, row);
users->insert(row, new User(-1, ""));
endInsertRows();
return true;
}
bool UserList::removeRow(int row, const QModelIndex &parent)
{
beginRemoveRows(parent, row, row);
users->removeAt(row);
endRemoveRows();
return true;
}
bool UserList::setData(const QModelIndex &index, const QVariant &value, int role)
{
if(index.isValid() && role == Qt::EditRole)
{
users->at(index.row())->setName(value.toString());
emit dataChanged(index, index);
return true;
}
else if(index.isValid() && role == Qt::UserRole)
{
users->at(index.row())->setId(value.toInt());
emit dataChanged(index, index);
return true;
}
else return false;
}
void UserList::addOrReplace(User *u)
{
User *existing = 0;
int i = 0;
while(i<users->size() && !existing)
{
if(users->at(i)->getId() == u->getId())
{
existing = users->at(i);
existing->setName(u->getName());
emit dataChanged(index(0, 0), index(users->size()-1, 0));
}
i++;
}
if(!existing)
{
insertRow(users->size(), QModelIndex());
setData(index(users->size()-1, 0), u->getId(), Qt::UserRole);
setData(index(users->size()-1, 0), u->getName(), Qt::EditRole);
}
}
void UserList::clear()
{
users->clear();
emit dataChanged(index(0, 0), index(users->size()-1, 0));
}
void UserList::removeRowById(int id)
{
int i = 0;
while(i<users->size())
{
if(users->at(i)->getId() == id)
{
users->removeAt(i);
emit dataChanged(index(0, 0), index(users->size()-1, 0));
}
i++;
}
}
QString UserList::getNameById(int id)
{
int i = 0;
while(i<users->size())
{
if(users->at(i)->getId() == id)
return users->at(i)->getName();
i++;
}
return "";
}
| 01lut | branches/test2/src/ClientQt/UserList.cpp | C++ | gpl3 | 2,654 |