地铁二期项目正式开始

T_SMS_SentSMS.cs 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. using System;
  2. using System.Data;
  3. using System.Text;
  4. using System.Data.SqlClient;
  5. using YTSoft.DBUtility;//Please add references
  6. namespace YTSoft.BaseCallCenter.DAL
  7. {
  8. /// <summary>
  9. /// 数据访问类:T_SMS_SentSMS
  10. /// </summary>
  11. public partial class T_SMS_SentSMS
  12. {
  13. public T_SMS_SentSMS()
  14. {}
  15. #region Method
  16. /// <summary>
  17. /// 得到最大ID
  18. /// </summary>
  19. public int GetMaxId()
  20. {
  21. return DbHelperSQL.GetMaxID("SMSID", "T_SMS_SentSMS");
  22. }
  23. /// <summary>
  24. /// 是否存在该记录
  25. /// </summary>
  26. public bool Exists(int SMSID)
  27. {
  28. StringBuilder strSql=new StringBuilder();
  29. strSql.Append("select count(1) from T_SMS_SentSMS");
  30. strSql.Append(" where SMSID=@SMSID ");
  31. SqlParameter[] parameters = {
  32. new SqlParameter("@SMSID", SqlDbType.Int,4)};
  33. parameters[0].Value = SMSID;
  34. return DbHelperSQL.Exists(strSql.ToString(),parameters);
  35. }
  36. /// <summary>
  37. /// 增加一条数据
  38. /// </summary>
  39. public bool Add(YTSoft.BaseCallCenter.Model.T_SMS_SentSMS model)
  40. {
  41. StringBuilder strSql=new StringBuilder();
  42. strSql.Append("insert into T_SMS_SentSMS(");
  43. strSql.Append("TelNum,Content,CommitTime,State,SendTime,LastSentTime,MaxSendCount,CurSentCount,Info,SendModemIMEI,F_UserID,F_CustomerID,F_Name)");
  44. strSql.Append(" values (");
  45. strSql.Append("@TelNum,@Content,@CommitTime,@State,@SendTime,@LastSentTime,@MaxSendCount,@CurSentCount,@Info,@SendModemIMEI,@F_UserID,@F_CustomerID,@F_Name)");
  46. strSql.Append(";select @@IDENTITY");
  47. SqlParameter[] parameters = {
  48. new SqlParameter("@TelNum", SqlDbType.VarChar,20),
  49. new SqlParameter("@Content", SqlDbType.NVarChar,100),
  50. new SqlParameter("@CommitTime", SqlDbType.DateTime),
  51. new SqlParameter("@State", SqlDbType.Int,4),
  52. new SqlParameter("@SendTime", SqlDbType.DateTime),
  53. new SqlParameter("@LastSentTime", SqlDbType.DateTime),
  54. new SqlParameter("@MaxSendCount", SqlDbType.Int,4),
  55. new SqlParameter("@CurSentCount", SqlDbType.Int,4),
  56. new SqlParameter("@Info", SqlDbType.NVarChar,50),
  57. new SqlParameter("@SendModemIMEI", SqlDbType.VarChar,20),
  58. new SqlParameter("@F_UserID", SqlDbType.Int,4),
  59. new SqlParameter("@F_CustomerID", SqlDbType.Int,4),
  60. new SqlParameter("@F_Name", SqlDbType.NVarChar,50)};
  61. parameters[0].Value = model.TelNum;
  62. parameters[1].Value = model.Content;
  63. parameters[2].Value = model.CommitTime;
  64. parameters[3].Value = model.State;
  65. parameters[4].Value = model.SendTime;
  66. parameters[5].Value = model.LastSentTime;
  67. parameters[6].Value = model.MaxSendCount;
  68. parameters[7].Value = model.CurSentCount;
  69. parameters[8].Value = model.Info;
  70. parameters[9].Value = model.SendModemIMEI;
  71. parameters[10].Value = model.F_UserID;
  72. parameters[11].Value = model.F_CustomerID;
  73. parameters[12].Value = model.F_Name;
  74. int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
  75. if (rows > 0)
  76. {
  77. return true;
  78. }
  79. else {
  80. return false;
  81. }
  82. }
  83. /// <summary>
  84. /// 更新一条数据
  85. /// </summary>
  86. public bool Update(YTSoft.BaseCallCenter.Model.T_SMS_SentSMS model)
  87. {
  88. StringBuilder strSql=new StringBuilder();
  89. strSql.Append("update T_SMS_SentSMS set ");
  90. strSql.Append("TelNum=@TelNum,");
  91. strSql.Append("Content=@Content,");
  92. strSql.Append("CommitTime=@CommitTime,");
  93. strSql.Append("State=@State,");
  94. strSql.Append("SendTime=@SendTime,");
  95. strSql.Append("LastSentTime=@LastSentTime,");
  96. strSql.Append("MaxSendCount=@MaxSendCount,");
  97. strSql.Append("CurSentCount=@CurSentCount,");
  98. strSql.Append("Info=@Info,");
  99. strSql.Append("SendModemIMEI=@SendModemIMEI,");
  100. strSql.Append("F_UserID=@F_UserID,");
  101. strSql.Append("F_CustomerID=@F_CustomerID,");
  102. strSql.Append("F_Name=@F_Name");
  103. strSql.Append(" where SMSID=@SMSID ");
  104. SqlParameter[] parameters = {
  105. new SqlParameter("@TelNum", SqlDbType.VarChar,20),
  106. new SqlParameter("@Content", SqlDbType.NVarChar,100),
  107. new SqlParameter("@CommitTime", SqlDbType.DateTime),
  108. new SqlParameter("@State", SqlDbType.Int,4),
  109. new SqlParameter("@SendTime", SqlDbType.DateTime),
  110. new SqlParameter("@LastSentTime", SqlDbType.DateTime),
  111. new SqlParameter("@MaxSendCount", SqlDbType.Int,4),
  112. new SqlParameter("@CurSentCount", SqlDbType.Int,4),
  113. new SqlParameter("@Info", SqlDbType.NVarChar,50),
  114. new SqlParameter("@SendModemIMEI", SqlDbType.VarChar,20),
  115. new SqlParameter("@F_UserID", SqlDbType.Int,4),
  116. new SqlParameter("@F_CustomerID", SqlDbType.Int,4),
  117. new SqlParameter("@F_Name", SqlDbType.NVarChar,50),
  118. new SqlParameter("@SMSID", SqlDbType.Int,4)};
  119. parameters[0].Value = model.TelNum;
  120. parameters[1].Value = model.Content;
  121. parameters[2].Value = model.CommitTime;
  122. parameters[3].Value = model.State;
  123. parameters[4].Value = model.SendTime;
  124. parameters[5].Value = model.LastSentTime;
  125. parameters[6].Value = model.MaxSendCount;
  126. parameters[7].Value = model.CurSentCount;
  127. parameters[8].Value = model.Info;
  128. parameters[9].Value = model.SendModemIMEI;
  129. parameters[10].Value = model.F_UserID;
  130. parameters[11].Value = model.F_CustomerID;
  131. parameters[12].Value = model.F_Name;
  132. parameters[13].Value = model.SMSID;
  133. int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
  134. if (rows > 0)
  135. {
  136. return true;
  137. }
  138. else
  139. {
  140. return false;
  141. }
  142. }
  143. /// <summary>
  144. /// 删除一条数据
  145. /// </summary>
  146. public bool Delete(int SMSID)
  147. {
  148. StringBuilder strSql=new StringBuilder();
  149. strSql.Append("delete from T_SMS_SentSMS ");
  150. strSql.Append(" where SMSID=@SMSID ");
  151. SqlParameter[] parameters = {
  152. new SqlParameter("@SMSID", SqlDbType.Int,4)};
  153. parameters[0].Value = SMSID;
  154. int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
  155. if (rows > 0)
  156. {
  157. return true;
  158. }
  159. else
  160. {
  161. return false;
  162. }
  163. }
  164. /// <summary>
  165. /// 删除一条数据
  166. /// </summary>
  167. public bool DeleteList(string SMSIDlist )
  168. {
  169. StringBuilder strSql=new StringBuilder();
  170. strSql.Append("delete from T_SMS_SentSMS ");
  171. strSql.Append(" where SMSID in ("+SMSIDlist + ") ");
  172. int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
  173. if (rows > 0)
  174. {
  175. return true;
  176. }
  177. else
  178. {
  179. return false;
  180. }
  181. }
  182. /// <summary>
  183. /// 得到一个对象实体
  184. /// </summary>
  185. public YTSoft.BaseCallCenter.Model.T_SMS_SentSMS GetModel(int SMSID)
  186. {
  187. StringBuilder strSql=new StringBuilder();
  188. strSql.Append("select top 1 SMSID,TelNum,Content,CommitTime,State,SendTime,LastSentTime,MaxSendCount,CurSentCount,Info,SendModemIMEI,F_UserID,F_CustomerID,F_Name from T_SMS_SentSMS ");
  189. strSql.Append(" where SMSID=@SMSID ");
  190. SqlParameter[] parameters = {
  191. new SqlParameter("@SMSID", SqlDbType.Int,4)};
  192. parameters[0].Value = SMSID;
  193. YTSoft.BaseCallCenter.Model.T_SMS_SentSMS model=new YTSoft.BaseCallCenter.Model.T_SMS_SentSMS();
  194. DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
  195. if(ds.Tables[0].Rows.Count>0)
  196. {
  197. if(ds.Tables[0].Rows[0]["SMSID"]!=null && ds.Tables[0].Rows[0]["SMSID"].ToString()!="")
  198. {
  199. model.SMSID=int.Parse(ds.Tables[0].Rows[0]["SMSID"].ToString());
  200. }
  201. if(ds.Tables[0].Rows[0]["TelNum"]!=null && ds.Tables[0].Rows[0]["TelNum"].ToString()!="")
  202. {
  203. model.TelNum=ds.Tables[0].Rows[0]["TelNum"].ToString();
  204. }
  205. if(ds.Tables[0].Rows[0]["Content"]!=null && ds.Tables[0].Rows[0]["Content"].ToString()!="")
  206. {
  207. model.Content=ds.Tables[0].Rows[0]["Content"].ToString();
  208. }
  209. if(ds.Tables[0].Rows[0]["CommitTime"]!=null && ds.Tables[0].Rows[0]["CommitTime"].ToString()!="")
  210. {
  211. model.CommitTime=DateTime.Parse(ds.Tables[0].Rows[0]["CommitTime"].ToString());
  212. }
  213. if(ds.Tables[0].Rows[0]["State"]!=null && ds.Tables[0].Rows[0]["State"].ToString()!="")
  214. {
  215. model.State=int.Parse(ds.Tables[0].Rows[0]["State"].ToString());
  216. }
  217. if(ds.Tables[0].Rows[0]["SendTime"]!=null && ds.Tables[0].Rows[0]["SendTime"].ToString()!="")
  218. {
  219. model.SendTime=DateTime.Parse(ds.Tables[0].Rows[0]["SendTime"].ToString());
  220. }
  221. if(ds.Tables[0].Rows[0]["LastSentTime"]!=null && ds.Tables[0].Rows[0]["LastSentTime"].ToString()!="")
  222. {
  223. model.LastSentTime=DateTime.Parse(ds.Tables[0].Rows[0]["LastSentTime"].ToString());
  224. }
  225. if(ds.Tables[0].Rows[0]["MaxSendCount"]!=null && ds.Tables[0].Rows[0]["MaxSendCount"].ToString()!="")
  226. {
  227. model.MaxSendCount=int.Parse(ds.Tables[0].Rows[0]["MaxSendCount"].ToString());
  228. }
  229. if(ds.Tables[0].Rows[0]["CurSentCount"]!=null && ds.Tables[0].Rows[0]["CurSentCount"].ToString()!="")
  230. {
  231. model.CurSentCount=int.Parse(ds.Tables[0].Rows[0]["CurSentCount"].ToString());
  232. }
  233. if(ds.Tables[0].Rows[0]["Info"]!=null && ds.Tables[0].Rows[0]["Info"].ToString()!="")
  234. {
  235. model.Info=ds.Tables[0].Rows[0]["Info"].ToString();
  236. }
  237. if(ds.Tables[0].Rows[0]["SendModemIMEI"]!=null && ds.Tables[0].Rows[0]["SendModemIMEI"].ToString()!="")
  238. {
  239. model.SendModemIMEI=ds.Tables[0].Rows[0]["SendModemIMEI"].ToString();
  240. }
  241. if(ds.Tables[0].Rows[0]["F_UserID"]!=null && ds.Tables[0].Rows[0]["F_UserID"].ToString()!="")
  242. {
  243. model.F_UserID=int.Parse(ds.Tables[0].Rows[0]["F_UserID"].ToString());
  244. }
  245. if(ds.Tables[0].Rows[0]["F_CustomerID"]!=null && ds.Tables[0].Rows[0]["F_CustomerID"].ToString()!="")
  246. {
  247. model.F_CustomerID=int.Parse(ds.Tables[0].Rows[0]["F_CustomerID"].ToString());
  248. }
  249. if(ds.Tables[0].Rows[0]["F_Name"]!=null && ds.Tables[0].Rows[0]["F_Name"].ToString()!="")
  250. {
  251. model.F_Name=ds.Tables[0].Rows[0]["F_Name"].ToString();
  252. }
  253. return model;
  254. }
  255. else
  256. {
  257. return null;
  258. }
  259. }
  260. /// <summary>
  261. /// 获得数据列表
  262. /// </summary>
  263. public DataSet GetList(string strWhere)
  264. {
  265. StringBuilder strSql=new StringBuilder();
  266. strSql.Append("select SMSID,TelNum,Content,CommitTime,State,SendTime,LastSentTime,MaxSendCount,CurSentCount,Info,SendModemIMEI,F_UserID,F_CustomerID,F_Name ");
  267. strSql.Append(" FROM T_SMS_SentSMS ");
  268. if(strWhere.Trim()!="")
  269. {
  270. strSql.Append(" where "+strWhere);
  271. }
  272. return DbHelperSQL.Query(strSql.ToString());
  273. }
  274. /// <summary>
  275. /// 获得前几行数据
  276. /// </summary>
  277. public DataSet GetList(int Top,string strWhere,string filedOrder)
  278. {
  279. StringBuilder strSql=new StringBuilder();
  280. strSql.Append("select ");
  281. if(Top>0)
  282. {
  283. strSql.Append(" top "+Top.ToString());
  284. }
  285. strSql.Append(" SMSID,TelNum,Content,CommitTime,State,SendTime,LastSentTime,MaxSendCount,CurSentCount,Info,SendModemIMEI,F_UserID,F_CustomerID,F_Name ");
  286. strSql.Append(" FROM T_SMS_SentSMS ");
  287. if(strWhere.Trim()!="")
  288. {
  289. strSql.Append(" where "+strWhere);
  290. }
  291. strSql.Append(" order by " + filedOrder);
  292. return DbHelperSQL.Query(strSql.ToString());
  293. }
  294. /*
  295. /// <summary>
  296. /// 分页获取数据列表
  297. /// </summary>
  298. public DataSet GetList(int PageSize,int PageIndex,string strWhere)
  299. {
  300. SqlParameter[] parameters = {
  301. new SqlParameter("@tblName", SqlDbType.VarChar, 255),
  302. new SqlParameter("@fldName", SqlDbType.VarChar, 255),
  303. new SqlParameter("@PageSize", SqlDbType.Int),
  304. new SqlParameter("@PageIndex", SqlDbType.Int),
  305. new SqlParameter("@IsReCount", SqlDbType.Bit),
  306. new SqlParameter("@OrderType", SqlDbType.Bit),
  307. new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
  308. };
  309. parameters[0].Value = "T_SMS_SentSMS";
  310. parameters[1].Value = "SMSID";
  311. parameters[2].Value = PageSize;
  312. parameters[3].Value = PageIndex;
  313. parameters[4].Value = 0;
  314. parameters[5].Value = 0;
  315. parameters[6].Value = strWhere;
  316. return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
  317. }*/
  318. #endregion Method
  319. }
  320. }