invitationOfficialActivities.aspx.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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 DAL;
  8. using Models;
  9. using OA2014.publicCode;
  10. using System.Transactions;
  11. namespace OA2014.groups
  12. {
  13. public partial class invitationOfficialActivities : SessionCode
  14. {
  15. //分页设置
  16. int sumPage = 0;
  17. int totalRecord = 0;
  18. string url = "../groups/invitationOfficialActivities.aspx";
  19. /// <summary>
  20. /// 加载事件
  21. /// </summary>
  22. /// <param name="sender"></param>
  23. /// <param name="e"></param>
  24. protected void Page_Load(object sender, EventArgs e)
  25. {
  26. if (!IsPostBack)
  27. {
  28. string arrayUsersId = null;
  29. string arrayTourCodeId = null;
  30. GroupsTaskAssignmentService gtas = new GroupsTaskAssignmentService();
  31. List<GroupsTaskAssignment> gtaUIdList = gtas.GetAllByUIdAndCTId(UserId.ToString(), "81");
  32. foreach (GroupsTaskAssignment gta in gtaUIdList)
  33. arrayTourCodeId += gta.DIId + ",";
  34. bindDDL(arrayTourCodeId);
  35. List<GroupsTaskAssignment> gtaList = gtas.GetAll(ddlTourCode.SelectedValue, "81");
  36. foreach (GroupsTaskAssignment gta in gtaList)
  37. arrayUsersId += gta.UId + ",";
  38. bind(arrayUsersId);
  39. bindContent();
  40. }
  41. }
  42. /// <summary>
  43. /// 绑定下拉列表
  44. /// </summary>
  45. void bindDDL(string arrayTourCodeId)
  46. {
  47. DelegationInfoService dis = new DelegationInfoService();
  48. if (!string.IsNullOrEmpty(arrayTourCodeId))
  49. arrayTourCodeId = arrayTourCodeId.TrimEnd(',');
  50. ddlTourCode.DataSource = dis.GetAllByTourCodeInId(arrayTourCodeId);
  51. ddlTourCode.DataTextField = "TeamName";
  52. ddlTourCode.DataValueField = "Id";
  53. ddlTourCode.DataBind();
  54. if (Request.QueryString["tourCode"] != null && !string.IsNullOrEmpty(Request.QueryString["tourCode"].ToString()))
  55. ddlTourCode.Items.FindByValue(Request.QueryString["tourCode"].ToString()).Selected = true;
  56. if (Request.QueryString["inviter"] != null && !string.IsNullOrEmpty(Request.QueryString["inviter"].ToString()))
  57. txtInviter.Text = Request.QueryString["inviter"].ToString();
  58. if (Request.QueryString["startTime"] != null && !string.IsNullOrEmpty(Request.QueryString["startTime"].ToString()))
  59. txtStartTime.Text = Request.QueryString["startTime"].ToString();
  60. if (Request.QueryString["endTime"] != null && !string.IsNullOrEmpty(Request.QueryString["endTime"].ToString()))
  61. txtEndTime.Text = Request.QueryString["endTime"].ToString();
  62. }
  63. /// <summary>
  64. /// 根据团号下拉列表绑定数据
  65. /// </summary>
  66. void bindContent()
  67. {
  68. DelegationInfoService dis = new DelegationInfoService();
  69. if (ddlTourCode.SelectedValue != "0")
  70. {
  71. DelegationInfo di = dis.GetDelegationInfoByID(Convert.ToInt32(ddlTourCode.SelectedValue));
  72. lblTeamName.Text = di.TourCode;
  73. lblClientName.Text = di.ClientName;
  74. lblVisitCountry.Text = di.VisitCountry;
  75. lblStartTime.Text = di.VisitStartDate;
  76. lblEndTime.Text = di.VisitEndDate;
  77. lblVisitDays.Text = di.VisitDays.ToString();
  78. lblPNumber.Text = di.VisitPNumber.ToString();
  79. }
  80. else
  81. {
  82. PublicCode.GetAlertMsg(this, GetType(), "请联系操作部经理分配任务!");
  83. }
  84. }
  85. /// <summary>
  86. /// 绑定事件
  87. /// </summary>
  88. void bind(string arrayUsersId)
  89. {
  90. try
  91. {
  92. InvitationOfficialActivitiesService ioas = new InvitationOfficialActivitiesService();
  93. //url传递参数设置
  94. pageControl.Params = "&tourCode=" + ddlTourCode.SelectedValue + "&inviter=" + txtInviter.Text + "&startTime=" + txtStartTime.Text + "&endTime=" + txtEndTime.Text;
  95. //分页设置
  96. int pageIndex = pageControl.getPageIndex();
  97. if (!string.IsNullOrEmpty(arrayUsersId))
  98. arrayUsersId = arrayUsersId.TrimEnd(',');
  99. rpData.DataSource = ioas.GetInvitationOfficialActivities(pageIndex, out sumPage, out totalRecord, ddlTourCode.SelectedValue, txtInviter.Text, txtStartTime.Text, txtEndTime.Text, arrayUsersId);
  100. rpData.DataBind();
  101. //绑定分页用户控件
  102. pageControl.bind(pageIndex, sumPage, totalRecord, url);
  103. }
  104. catch
  105. {
  106. PublicCode.GetAlertMsg(this, GetType(), "请联系操作部经理分配任务!");
  107. }
  108. }
  109. /// <summary>
  110. /// 查询事件
  111. /// </summary>
  112. /// <param name="sender"></param>
  113. /// <param name="e"></param>
  114. protected void btnSelect_Click(object sender, EventArgs e)
  115. {
  116. Response.Redirect("invitationOfficialActivities.aspx?Page=1&tourCode=" + ddlTourCode.SelectedValue + "&inviter=" + txtInviter.Text + "&startTime=" + txtStartTime.Text + "&endTime=" + txtEndTime.Text);
  117. }
  118. /// <summary>
  119. /// 新增事件
  120. /// </summary>
  121. /// <param name="sender"></param>
  122. /// <param name="e"></param>
  123. protected void btnAdd_Click(object sender, EventArgs e)
  124. {
  125. Response.Redirect("addInvitationOfficialActivities.aspx?tourCode=" + ddlTourCode.SelectedValue);
  126. }
  127. /// <summary>
  128. /// 团号下拉列表值改变时触发的事件
  129. /// </summary>
  130. /// <param name="sender"></param>
  131. /// <param name="e"></param>
  132. protected void ddlTourCode_TextChanged(object sender, EventArgs e)
  133. {
  134. Response.Redirect("invitationOfficialActivities.aspx?Page=1&tourCode=" + ddlTourCode.SelectedValue + "&inviter=" + txtInviter.Text + "&startTime=" + txtStartTime.Text + "&endTime=" + txtEndTime.Text);
  135. }
  136. /// <summary>
  137. /// 行数据绑定后激发的事件
  138. /// </summary>
  139. /// <param name="sender"></param>
  140. /// <param name="e"></param>
  141. protected void rpData_ItemDataBound(object sender, RepeaterItemEventArgs e)
  142. {
  143. int currencyVal = Convert.ToInt32((e.Item.FindControl("lblCurrencyVal") as Label).Text);
  144. SetDataService sds = new SetDataService();
  145. SetData sd = sds.GetSetDataByID(currencyVal);
  146. if (sd != null)
  147. (e.Item.FindControl("lblCurrency") as Label).Text = sd.Name;
  148. else (e.Item.FindControl("lblCurrency") as Label).Text = "CNY";
  149. int SendCurrencyVal = Convert.ToInt32((e.Item.FindControl("SendCurrencyVal") as Label).Text);
  150. SetData sd1 = sds.GetSetDataByID(SendCurrencyVal);
  151. if (sd1 != null)
  152. (e.Item.FindControl("lblSendCurrency") as Label).Text = sd1.Name;
  153. else (e.Item.FindControl("lblSendCurrency") as Label).Text = "CNY";
  154. int EventsCurrencyVal = Convert.ToInt32((e.Item.FindControl("EventsCurrencyVal") as Label).Text);
  155. SetData sd2 = sds.GetSetDataByID(EventsCurrencyVal);
  156. if (sd2 != null)
  157. (e.Item.FindControl("lblEventsCurrency") as Label).Text = sd2.Name;
  158. else (e.Item.FindControl("lblEventsCurrency") as Label).Text = "CNY";
  159. int TranslateCurrencyVal = Convert.ToInt32((e.Item.FindControl("TranslateCurrencyVal") as Label).Text);
  160. SetData sd3 = sds.GetSetDataByID(TranslateCurrencyVal);
  161. if (sd3 != null)
  162. (e.Item.FindControl("lblTranslateCurrency") as Label).Text = sd3.Name;
  163. else (e.Item.FindControl("lblTranslateCurrency") as Label).Text = "CNY";
  164. CreditCardPaymentService ccps = new CreditCardPaymentService();
  165. CreditCardPayment C = ccps.GetCreditCardPaymentByCIDAndDIIDAndCTable
  166. (Convert.ToInt32((e.Item.FindControl("lbtnEdit") as LinkButton).CommandArgument), Convert.ToInt32(ddlTourCode.SelectedValue), 81);
  167. if (C != null)
  168. {
  169. (e.Item.FindControl("isAudit") as Label).Text = C.IsAuditGM == 1 ? "已审核" : "未审核";
  170. }
  171. else
  172. {
  173. (e.Item.FindControl("lblOperators") as Label).Text = "未审核";
  174. }
  175. }
  176. /// <summary>
  177. /// 编辑
  178. /// </summary>
  179. /// <param name="sender"></param>
  180. /// <param name="e"></param>
  181. protected void lbtnEdit_Click(object sender, EventArgs e)
  182. {
  183. Response.Redirect("editInvitationOfficialActivities.aspx?id=" + (sender as LinkButton).CommandArgument);
  184. }
  185. /// <summary>
  186. /// 删除事件
  187. /// </summary>
  188. /// <param name="sender"></param>
  189. /// <param name="e"></param>
  190. protected void lbtnDel_Click(object sender, EventArgs e)
  191. {
  192. CreditCardPayment ccp = new CreditCardPayment();
  193. CreditCardPaymentService ccps = new CreditCardPaymentService();
  194. ccp = ccps.GetCreditCardPaymentByCIDAndDIIDAndCTable(Convert.ToInt32((sender as LinkButton).CommandArgument), Convert.ToInt32(ddlTourCode.SelectedValue), 81);
  195. //已经审核的记录不能被修改
  196. if (ccp != null)
  197. {
  198. if (ccp.IsAuditGM == 1 || ccp.IsAuditMF == 1)
  199. {
  200. PublicCode.GetAlertMsg(this, GetType(), "删除失败,该记录总经理已经审核完成不可再删除!");
  201. return;
  202. }
  203. }
  204. int id = Convert.ToInt32((sender as LinkButton).CommandArgument);
  205. InvitationOfficialActivitiesService ioas = new InvitationOfficialActivitiesService();
  206. using (TransactionScope ts = new TransactionScope())
  207. {
  208. if (ioas.DelInvitationOfficialActivities(id))
  209. {
  210. if (ccps.GetCreditCardPaymentByCIDAndDIIDAndCTable(id, Convert.ToInt32(ddlTourCode.SelectedValue), 81) != null)
  211. {
  212. if (ccps.DelCreditCardPayment(id, Convert.ToInt32(ddlTourCode.SelectedValue)))
  213. {
  214. ts.Complete();
  215. Response.Write("<script>alert('温馨提示:" + PublicCode.AlertMsgTrue + "');location.href='invitationOfficialActivities.aspx?Page=1&tourCode=" + ddlTourCode.SelectedValue + "&inviter=" + txtInviter.Text + "&startTime=" + txtStartTime.Text + "&endTime=" + txtEndTime.Text + "';</script>");
  216. }
  217. else
  218. {
  219. PublicCode.GetAlertMsg(this, GetType(), PublicCode.AlertMsgFalse);
  220. return;
  221. }
  222. }
  223. else
  224. {
  225. ts.Complete();
  226. Response.Write("<script>alert('温馨提示:" + PublicCode.AlertMsgTrue + "');location.href='invitationOfficialActivities.aspx?Page=1&tourCode=" + ddlTourCode.SelectedValue + "&inviter=" + txtInviter.Text + "&startTime=" + txtStartTime.Text + "&endTime=" + txtEndTime.Text + "';</script>");
  227. }
  228. }
  229. }
  230. }
  231. /// <summary>
  232. /// 附件下载
  233. /// </summary>
  234. /// <param name="sender"></param>
  235. /// <param name="e"></param>
  236. protected void lbtnDown_Click(object sender, EventArgs e)
  237. {
  238. string vals = (sender as LinkButton).CommandArgument;
  239. if (!string.IsNullOrEmpty(vals))
  240. {
  241. string attStr = (sender as LinkButton).CommandArgument;
  242. string filePath = AppDomain.CurrentDomain.BaseDirectory + @"UploadFile\";//路径
  243. string fileName = DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss") + ".zip";
  244. if (!string.IsNullOrEmpty(attStr))
  245. {
  246. PublicCode.ZipFileMain(attStr.Split(','), fileName, filePath, 0);
  247. PublicCode.DownloadFile(Response, fileName, filePath);
  248. }
  249. }
  250. else
  251. {
  252. PublicCode.GetAlertMsg(this, GetType(), "未发现附件!");
  253. }
  254. }
  255. }
  256. }