Geen omschrijving

T_SMS_SentSMS.cs 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. using System;
  2. using System.Data;
  3. using System.Text;
  4. using System.Data.SqlClient;
  5. using CallCenterApi.DB;
  6. namespace CallCenterApi.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 int Add(CallCenterApi.Model.T_SMS_SentSMS model)
  40. {
  41. StringBuilder strSql = new StringBuilder();
  42. strSql.Append("insert into T_SMS_SentSMS(");
  43. strSql.Append("SMSID,TelNum,Content,CommitTime,State,SendTime,LastSentTime,MaxSendCount,CurSentCount,Info,SendModemIMEI,F_UserID,F_CustomerID,F_Name)");
  44. strSql.Append(" values (");
  45. strSql.Append("@SMSID,@TelNum,@Content,@CommitTime,@State,@SendTime,@LastSentTime,@MaxSendCount,@CurSentCount,@Info,@SendModemIMEI,@F_UserID,@F_CustomerID,@F_Name)");
  46. SqlParameter[] parameters = {
  47. new SqlParameter("@SMSID", SqlDbType.Int,4),
  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.SMSID;
  62. parameters[1].Value = model.TelNum;
  63. parameters[2].Value = model.Content;
  64. parameters[3].Value = model.CommitTime;
  65. parameters[4].Value = model.State;
  66. parameters[5].Value = model.SendTime;
  67. parameters[6].Value = model.LastSentTime;
  68. parameters[7].Value = model.MaxSendCount;
  69. parameters[8].Value = model.CurSentCount;
  70. parameters[9].Value = model.Info;
  71. parameters[10].Value = model.SendModemIMEI;
  72. parameters[11].Value = model.F_UserID;
  73. parameters[12].Value = model.F_CustomerID;
  74. parameters[13].Value = model.F_Name;
  75. return DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  76. }
  77. /// <summary>
  78. /// 更新一条数据
  79. /// </summary>
  80. public bool Update(CallCenterApi.Model.T_SMS_SentSMS model)
  81. {
  82. StringBuilder strSql = new StringBuilder();
  83. strSql.Append("update T_SMS_SentSMS set ");
  84. strSql.Append("TelNum=@TelNum,");
  85. strSql.Append("Content=@Content,");
  86. strSql.Append("CommitTime=@CommitTime,");
  87. strSql.Append("State=@State,");
  88. strSql.Append("SendTime=@SendTime,");
  89. strSql.Append("LastSentTime=@LastSentTime,");
  90. strSql.Append("MaxSendCount=@MaxSendCount,");
  91. strSql.Append("CurSentCount=@CurSentCount,");
  92. strSql.Append("Info=@Info,");
  93. strSql.Append("SendModemIMEI=@SendModemIMEI,");
  94. strSql.Append("F_UserID=@F_UserID,");
  95. strSql.Append("F_CustomerID=@F_CustomerID,");
  96. strSql.Append("F_Name=@F_Name");
  97. strSql.Append(" where SMSID=@SMSID ");
  98. SqlParameter[] parameters = {
  99. new SqlParameter("@TelNum", SqlDbType.VarChar,20),
  100. new SqlParameter("@Content", SqlDbType.NVarChar,100),
  101. new SqlParameter("@CommitTime", SqlDbType.DateTime),
  102. new SqlParameter("@State", SqlDbType.Int,4),
  103. new SqlParameter("@SendTime", SqlDbType.DateTime),
  104. new SqlParameter("@LastSentTime", SqlDbType.DateTime),
  105. new SqlParameter("@MaxSendCount", SqlDbType.Int,4),
  106. new SqlParameter("@CurSentCount", SqlDbType.Int,4),
  107. new SqlParameter("@Info", SqlDbType.NVarChar,50),
  108. new SqlParameter("@SendModemIMEI", SqlDbType.VarChar,20),
  109. new SqlParameter("@F_UserID", SqlDbType.Int,4),
  110. new SqlParameter("@F_CustomerID", SqlDbType.Int,4),
  111. new SqlParameter("@F_Name", SqlDbType.NVarChar,50),
  112. new SqlParameter("@SMSID", SqlDbType.Int,4)};
  113. parameters[0].Value = model.TelNum;
  114. parameters[1].Value = model.Content;
  115. parameters[2].Value = model.CommitTime;
  116. parameters[3].Value = model.State;
  117. parameters[4].Value = model.SendTime;
  118. parameters[5].Value = model.LastSentTime;
  119. parameters[6].Value = model.MaxSendCount;
  120. parameters[7].Value = model.CurSentCount;
  121. parameters[8].Value = model.Info;
  122. parameters[9].Value = model.SendModemIMEI;
  123. parameters[10].Value = model.F_UserID;
  124. parameters[11].Value = model.F_CustomerID;
  125. parameters[12].Value = model.F_Name;
  126. parameters[13].Value = model.SMSID;
  127. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  128. if (rows > 0)
  129. {
  130. return true;
  131. }
  132. else
  133. {
  134. return false;
  135. }
  136. }
  137. /// <summary>
  138. /// 删除一条数据
  139. /// </summary>
  140. public bool Delete(int SMSID)
  141. {
  142. StringBuilder strSql = new StringBuilder();
  143. strSql.Append("delete from T_SMS_SentSMS ");
  144. strSql.Append(" where SMSID=@SMSID ");
  145. SqlParameter[] parameters = {
  146. new SqlParameter("@SMSID", SqlDbType.Int,4)};
  147. parameters[0].Value = SMSID;
  148. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  149. if (rows > 0)
  150. {
  151. return true;
  152. }
  153. else
  154. {
  155. return false;
  156. }
  157. }
  158. public bool Delete(string arrSMSID)
  159. {
  160. StringBuilder strSql = new StringBuilder();
  161. strSql.Append("delete from T_SMS_SentSMS ");
  162. strSql.Append(" where SMSID in (" + arrSMSID + ") ");
  163. int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
  164. if (rows > 0)
  165. {
  166. return true;
  167. }
  168. else
  169. {
  170. return false;
  171. }
  172. }
  173. public int ReSend(string arrSMSID)
  174. {
  175. StringBuilder strSql = new StringBuilder();
  176. strSql.Append("insert into T_SMS_SendSMSTask(");
  177. strSql.Append("TelNum,Content,CommitTime,State,SendTime,LastSentTime,CurSentCount,MaxSendCount,Info,F_UserID,F_CustomerID,F_Name)");
  178. strSql.Append(" select TelNum,Content,getdate(),0,getdate(),null,0,MaxSendCount,'',F_UserID,F_CustomerID,F_Name ");
  179. strSql.Append(" from T_SMS_SentSMS ");
  180. strSql.Append(" where SMSID in (" + arrSMSID + ") ");
  181. return DbHelperSQL.ExecuteSql(strSql.ToString());
  182. }
  183. /// <summary>
  184. /// 批量删除数据
  185. /// </summary>
  186. public bool DeleteList(string SMSIDlist)
  187. {
  188. StringBuilder strSql = new StringBuilder();
  189. strSql.Append("delete from T_SMS_SentSMS ");
  190. strSql.Append(" where SMSID in (" + SMSIDlist + ") ");
  191. int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
  192. if (rows > 0)
  193. {
  194. return true;
  195. }
  196. else
  197. {
  198. return false;
  199. }
  200. }
  201. /// <summary>
  202. /// 得到一个对象实体
  203. /// </summary>
  204. public CallCenterApi.Model.T_SMS_SentSMS GetModel(int SMSID)
  205. {
  206. StringBuilder strSql = new StringBuilder();
  207. 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 ");
  208. strSql.Append(" where SMSID=@SMSID ");
  209. SqlParameter[] parameters = {
  210. new SqlParameter("@SMSID", SqlDbType.Int,4)};
  211. parameters[0].Value = SMSID;
  212. CallCenterApi.Model.T_SMS_SentSMS model = new CallCenterApi.Model.T_SMS_SentSMS();
  213. DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
  214. if (ds.Tables[0].Rows.Count > 0)
  215. {
  216. if (ds.Tables[0].Rows[0]["SMSID"] != null && ds.Tables[0].Rows[0]["SMSID"].ToString() != "")
  217. {
  218. model.SMSID = int.Parse(ds.Tables[0].Rows[0]["SMSID"].ToString());
  219. }
  220. if (ds.Tables[0].Rows[0]["TelNum"] != null && ds.Tables[0].Rows[0]["TelNum"].ToString() != "")
  221. {
  222. model.TelNum = ds.Tables[0].Rows[0]["TelNum"].ToString();
  223. }
  224. if (ds.Tables[0].Rows[0]["Content"] != null && ds.Tables[0].Rows[0]["Content"].ToString() != "")
  225. {
  226. model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
  227. }
  228. if (ds.Tables[0].Rows[0]["CommitTime"] != null && ds.Tables[0].Rows[0]["CommitTime"].ToString() != "")
  229. {
  230. model.CommitTime = DateTime.Parse(ds.Tables[0].Rows[0]["CommitTime"].ToString());
  231. }
  232. if (ds.Tables[0].Rows[0]["State"] != null && ds.Tables[0].Rows[0]["State"].ToString() != "")
  233. {
  234. model.State = int.Parse(ds.Tables[0].Rows[0]["State"].ToString());
  235. }
  236. if (ds.Tables[0].Rows[0]["SendTime"] != null && ds.Tables[0].Rows[0]["SendTime"].ToString() != "")
  237. {
  238. model.SendTime = DateTime.Parse(ds.Tables[0].Rows[0]["SendTime"].ToString());
  239. }
  240. if (ds.Tables[0].Rows[0]["LastSentTime"] != null && ds.Tables[0].Rows[0]["LastSentTime"].ToString() != "")
  241. {
  242. model.LastSentTime = DateTime.Parse(ds.Tables[0].Rows[0]["LastSentTime"].ToString());
  243. }
  244. if (ds.Tables[0].Rows[0]["MaxSendCount"] != null && ds.Tables[0].Rows[0]["MaxSendCount"].ToString() != "")
  245. {
  246. model.MaxSendCount = int.Parse(ds.Tables[0].Rows[0]["MaxSendCount"].ToString());
  247. }
  248. if (ds.Tables[0].Rows[0]["CurSentCount"] != null && ds.Tables[0].Rows[0]["CurSentCount"].ToString() != "")
  249. {
  250. model.CurSentCount = int.Parse(ds.Tables[0].Rows[0]["CurSentCount"].ToString());
  251. }
  252. if (ds.Tables[0].Rows[0]["Info"] != null && ds.Tables[0].Rows[0]["Info"].ToString() != "")
  253. {
  254. model.Info = ds.Tables[0].Rows[0]["Info"].ToString();
  255. }
  256. if (ds.Tables[0].Rows[0]["SendModemIMEI"] != null && ds.Tables[0].Rows[0]["SendModemIMEI"].ToString() != "")
  257. {
  258. model.SendModemIMEI = ds.Tables[0].Rows[0]["SendModemIMEI"].ToString();
  259. }
  260. if (ds.Tables[0].Rows[0]["F_UserID"] != null && ds.Tables[0].Rows[0]["F_UserID"].ToString() != "")
  261. {
  262. model.F_UserID = int.Parse(ds.Tables[0].Rows[0]["F_UserID"].ToString());
  263. }
  264. if (ds.Tables[0].Rows[0]["F_CustomerID"] != null && ds.Tables[0].Rows[0]["F_CustomerID"].ToString() != "")
  265. {
  266. model.F_CustomerID = int.Parse(ds.Tables[0].Rows[0]["F_CustomerID"].ToString());
  267. }
  268. if (ds.Tables[0].Rows[0]["F_Name"] != null && ds.Tables[0].Rows[0]["F_Name"].ToString() != "")
  269. {
  270. model.F_Name = ds.Tables[0].Rows[0]["F_Name"].ToString();
  271. }
  272. return model;
  273. }
  274. else
  275. {
  276. return null;
  277. }
  278. }
  279. /// <summary>
  280. /// 获得数据列表
  281. /// </summary>
  282. public DataSet GetList(string strWhere)
  283. {
  284. StringBuilder strSql = new StringBuilder();
  285. strSql.Append("select 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. return DbHelperSQL.Query(strSql.ToString());
  292. }
  293. /// <summary>
  294. /// 获得前几行数据
  295. /// </summary>
  296. public DataSet GetList(int Top, string strWhere, string filedOrder)
  297. {
  298. StringBuilder strSql = new StringBuilder();
  299. strSql.Append("select ");
  300. if (Top > 0)
  301. {
  302. strSql.Append(" top " + Top.ToString());
  303. }
  304. strSql.Append(" SMSID,TelNum,Content,CommitTime,State,SendTime,LastSentTime,MaxSendCount,CurSentCount,Info,SendModemIMEI,F_UserID,F_CustomerID,F_Name ");
  305. strSql.Append(" FROM T_SMS_SentSMS ");
  306. if (strWhere.Trim() != "")
  307. {
  308. strSql.Append(" where " + strWhere);
  309. }
  310. strSql.Append(" order by " + filedOrder);
  311. return DbHelperSQL.Query(strSql.ToString());
  312. }
  313. /*
  314. /// <summary>
  315. /// 分页获取数据列表
  316. /// </summary>
  317. public DataSet GetList(int PageSize,int PageIndex,string strWhere)
  318. {
  319. SqlParameter[] parameters = {
  320. new SqlParameter("@tblName", SqlDbType.VarChar, 255),
  321. new SqlParameter("@fldName", SqlDbType.VarChar, 255),
  322. new SqlParameter("@PageSize", SqlDbType.Int),
  323. new SqlParameter("@PageIndex", SqlDbType.Int),
  324. new SqlParameter("@IsReCount", SqlDbType.Bit),
  325. new SqlParameter("@OrderType", SqlDbType.Bit),
  326. new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
  327. };
  328. parameters[0].Value = "T_SMS_SentSMS";
  329. parameters[1].Value = "SMSID";
  330. parameters[2].Value = PageSize;
  331. parameters[3].Value = PageIndex;
  332. parameters[4].Value = 0;
  333. parameters[5].Value = 0;
  334. parameters[6].Value = strWhere;
  335. return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
  336. }*/
  337. #endregion Method
  338. }
  339. }