Bez popisu

WorkTimeOverSet.aspx.cs 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data;
  8. using System.Text;
  9. using System.IO;
  10. using XYFDRQ.Common;
  11. public partial class Business_WorkTimeOverSet : BasePage
  12. {
  13. XYFDRQ.BLL.T_Sys_UserAccount bll_T_Sys_UserAccount = new XYFDRQ.BLL.T_Sys_UserAccount();
  14. XYFDRQ.BLL.T_Sys_DictionaryValue bll_T_Sys_DictionaryValue = new XYFDRQ.BLL.T_Sys_DictionaryValue();
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. AjaxPro.Utility.RegisterTypeForAjax(typeof(Business_WorkTimeOverSet));
  18. if (!IsPostBack)
  19. {
  20. InitData();
  21. }
  22. }
  23. //提取信息 绑定信息
  24. [AjaxPro.AjaxMethod]
  25. public string LoadingData(AjaxPro.JavaScriptArray searchItems)
  26. {
  27. //searchItems0页码,1条数2类型3级别4状态
  28. string[] _operations = GetSearchItems(searchItems);
  29. string strSql =string.Empty;
  30. if (!string.IsNullOrEmpty(_operations[2]))
  31. {
  32. strSql += " and BusinessType=" + _operations[2];
  33. }
  34. if (!string.IsNullOrEmpty(_operations[3]))
  35. {
  36. strSql += " and InfoBigType=" + _operations[3];
  37. }
  38. if (!string.IsNullOrEmpty(_operations[4]))
  39. {
  40. strSql += " and State=" + _operations[4];
  41. }
  42. string ctrl = "~/Business/_controls/ctl_WorkTimeOverSet.ascx";
  43. Control uc_rep = LoadControl(ctrl);
  44. Repeater rptItems = (Repeater)uc_rep.FindControl("rptItems");
  45. XYFDRQ.DBUtility.Pagination pagination = new XYFDRQ.DBUtility.Pagination();//分页的类
  46. if (!string.IsNullOrEmpty(_operations[0]))
  47. pagination.Sequence = Convert.ToInt32(_operations[0]);
  48. else
  49. pagination.Sequence = 1;
  50. if (!string.IsNullOrEmpty(_operations[1]))
  51. pagination.PageSize = Convert.ToInt32(_operations[1]);
  52. else
  53. pagination.PageSize = 20;
  54. pagination.ItemUnit = "条记录";
  55. pagination.SortSentence = "ORDER BY T_Bus_TimeOver.Id DESC";
  56. pagination.Primarykey = "T_Bus_TimeOver.Id";
  57. pagination.SearchField = "*";
  58. pagination.TableName = "T_Bus_TimeOver";
  59. pagination.UrlStr = "";
  60. pagination.SearchSentence = strSql;
  61. pagination.ImagesPath = "../_grid/imgs/";
  62. try
  63. {
  64. rptItems.DataSource = pagination.GetDataTable();
  65. rptItems.DataBind();
  66. StringBuilder strb = new StringBuilder();
  67. StringWriter sw = new StringWriter(strb);
  68. HtmlTextWriter htw = new HtmlTextWriter(sw);
  69. pagination.GoPageBarStyle1();
  70. uc_rep.GetType().GetProperty("PaginationBar").SetValue(uc_rep, pagination.PageBar, null);
  71. rptItems.RenderControl(htw);
  72. return strb.ToString();
  73. }
  74. catch (Exception err) { return err.ToString(); }
  75. }
  76. /// <summary>
  77. /// 转化为数组
  78. /// </summary>
  79. /// <param name="searchItems"></param>
  80. /// <returns></returns>
  81. private string[] GetSearchItems(AjaxPro.JavaScriptArray searchItems)
  82. {
  83. int c = 0;
  84. if (searchItems != null)
  85. c = searchItems.Count;
  86. string[] operations = new string[c];
  87. int i = 0;
  88. foreach (Object obj in searchItems)
  89. {
  90. operations[i] = obj.ToString();
  91. i++;
  92. }
  93. return operations;
  94. }
  95. //绑定查询信息
  96. protected void InitData()
  97. {
  98. //绑定下拉列表
  99. BindDropList(this.ddlInfoType, "0");
  100. //绑定状态
  101. BindFromDictionary(this.ddlState, "GDZT");
  102. ////绑定业务等级
  103. //BindFromDictionary(this.ddlLevel, "GZDJ");
  104. }
  105. #region 绑定下拉列表
  106. private void BindDropList(DropDownList ddl,string parentType)
  107. {
  108. DataTable dt = new DataTable();
  109. try
  110. {
  111. ddl.Items.Clear();
  112. dt = new XYFDRQ.BLL.T_Bus_WorkType().GetList("ParentTypeId=" + parentType + " and IsDelete=0 order by Sort").Tables[0];
  113. foreach (DataRow dr in dt.Rows)
  114. {
  115. ddl.Items.Add(new ListItem(dr["TypeName"].ToString(), dr["TypeId"].ToString()));
  116. }
  117. ddl.Items.Insert(0, new ListItem("--全部--", ""));
  118. }
  119. catch (Exception ex)
  120. {
  121. SysLog.WriteLog(ex);
  122. }
  123. finally
  124. {
  125. dt.Clear();
  126. dt.Dispose();
  127. }
  128. }
  129. /// <summary>
  130. /// Ajax绑定业务类型
  131. /// </summary>
  132. /// <param name="ParentTypeId"></param>
  133. /// <returns></returns>
  134. [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
  135. public DataTable BindInfoType(string ParentTypeId)
  136. {
  137. DataTable dt = new DataTable();
  138. if (!string.IsNullOrEmpty(ParentTypeId))
  139. {
  140. dt = new XYFDRQ.BLL.T_Bus_WorkType().GetList("ParentTypeId=" + ParentTypeId + " and IsDelete=0 order by Sort").Tables[0];
  141. }
  142. return dt;
  143. }
  144. #endregion
  145. /// <summary>
  146. /// 从数据字典读取值
  147. /// </summary>
  148. /// <param name="ddl"></param>
  149. /// <param name="p_Condition"></param>
  150. private void BindFromDictionary(DropDownList ddl, string p_DictionaryFlag)
  151. {
  152. ddl.DataSource = bll_T_Sys_DictionaryValue.GetList("F_DictionaryFlag='" + p_DictionaryFlag + "' order by F_Sort");
  153. ddl.DataValueField = "F_ValueCode";
  154. ddl.DataTextField = "F_Name";
  155. ddl.DataBind();
  156. ddl.Items.Insert(0, new ListItem("--全部--", ""));
  157. }
  158. #region 删除操作
  159. [AjaxPro.AjaxMethod()]
  160. public string DeleteOpt(AjaxPro.JavaScriptArray arrItems)
  161. {
  162. string res = "error";
  163. try
  164. {
  165. string[] _operations = GetSearchItems(arrItems);
  166. string arrid = "";
  167. foreach (string oid in _operations)
  168. {
  169. arrid += "'" + oid + "',";
  170. }
  171. arrid += "#@!";
  172. arrid = arrid.Replace(",#@!", "").Replace("#@!", "");
  173. bool r = new XYFDRQ.BLL.T_Bus_TimeOver().DeleteList(arrid);
  174. if (r)
  175. {
  176. res = "success";
  177. }
  178. }
  179. catch (Exception ex)
  180. {
  181. XYFDRQ.Common.SysLog.WriteLog(ex);
  182. res = "error";
  183. }
  184. return res;
  185. }
  186. #endregion
  187. }