frmPopReqDReport.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using Core.Mes.Client.Comm.Control;
  11. using Core.Mes.Client.Comm.Server;
  12. using Core.Mes.Client.Comm.Tool;
  13. using CoreFS.SA06;
  14. using Infragistics.Win;
  15. using Pur.Entity;
  16. using Pur.Entity.require_planEntiy;
  17. using Pur.require_plan;
  18. namespace Pur.require_plan
  19. {
  20. public partial class frmPopReqDReport : FrmPmsBase
  21. {
  22. public frmPopReqDReport()
  23. {
  24. InitializeComponent();
  25. this.IsLoadUserView = true;
  26. }
  27. //load
  28. private void frmPopReqDReport_Load(object sender, EventArgs e)//load
  29. {
  30. CK_Ctime.Checked = true;
  31. CK_ptime.Checked = true;
  32. checkBox1.Checked = true;
  33. txtMrPeriodStart.Value =DateTime.Now.AddMonths(-2);
  34. txtMrPeriodEnd.Value = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Now.AddMonths(-1) : DateTime.Now;
  35. txt_createTimeStart.Value = DateTime.Now.AddMonths(-1).ToString();
  36. txt_createTimeEnd.Value = DateTime.Now.AddDays(7).ToString();
  37. String strYear = DateTime.Now.Year + "";
  38. String strMouth = DateTime.Now.Month + "";
  39. String strStart = strYear + "-" + strMouth + "-" + "20 00:00:00";
  40. String strEnd = strYear + "-" + strMouth + "-" + "26 00:00:00";
  41. txtAuditedStart.Value = Convert.ToDateTime(strStart);
  42. txtAuditedEnd.Value = Convert.ToDateTime(strEnd);
  43. if (this.CustomInfo == "1")//生产厂
  44. {
  45. txt_Mstatus.ReadOnly = false;
  46. txt_Mstatus.SelectedIndex = 0;//默认全部
  47. }
  48. else
  49. {
  50. txt_Mstatus.ReadOnly = true;
  51. txt_Mstatus.SelectedIndex = 6;//默认全部
  52. }
  53. txt_style.SelectedIndex = 1;//默认有效
  54. txt_Dstatus.SelectedIndex = 0;//默认全部
  55. Init();
  56. //GetPUR_REQUIRE_PLAND();
  57. GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] { });
  58. }
  59. //初始化
  60. private void Init()//初始化
  61. {
  62. //初始化业务角色选择Combo
  63. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatService", "get_UsedPlanner", new object[] { });
  64. //DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1221" }, this.ob);
  65. comm.FilComboboxAdd(txt_businessName, dt1, "PLANNERROLEID", "plannerrolename", null, true, "全部", "");
  66. txt_businessName.SelectedIndex = 0;//默认全部
  67. //初始化业务人员选择Combo
  68. DataTable dt2 = this.execute<DataTable>("com.hnshituo.core.service.AppUserRoleService", "getMatUser", new object[] { });
  69. //DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1221" }, this.ob);
  70. comm.FilComboboxAdd(txt_businessUser, dt2, "userid", "roleid", null, true, "全部", "");
  71. txt_businessUser.SelectedIndex = 0;//默认全部
  72. }
  73. //菜单按钮
  74. public override void ToolBar_Click(object sender, string ToolbarKey)//菜单按钮
  75. {
  76. switch (ToolbarKey)
  77. {
  78. case "Query"://刷新数据
  79. GetPUR_REQUIRE_PLAND();
  80. break;
  81. case "doReport"://导出Excel
  82. ReportPUR_REQUIRE_PLAND();
  83. break;
  84. case "doClose"://关闭
  85. this.Close();
  86. break;
  87. }
  88. }
  89. private void ReportPUR_REQUIRE_PLAND()
  90. {
  91. try
  92. {
  93. this.Cursor = Cursors.WaitCursor;
  94. //获取导出的采购计划行表
  95. ArrayList alUltraGrid = new ArrayList();
  96. alUltraGrid.Add(ultraGrid1);
  97. ArrayList alSheeft = new ArrayList();
  98. alSheeft.Add("需求计划行表");
  99. if (ultraGrid1.Rows.Count > 0)
  100. {
  101. GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "需求计划行汇总表");//导出excel
  102. }
  103. //MessageUtil.ShowTips("导出成功");
  104. }
  105. catch (Exception e)
  106. {
  107. MessageUtil.ShowTips("导出失败" + e.Message);
  108. }
  109. finally
  110. {
  111. this.Cursor = Cursors.Default;
  112. }
  113. }
  114. /// <summary>
  115. /// 查询
  116. /// </summary>
  117. private void GetPUR_REQUIRE_PLAND()
  118. {
  119. dataTable2.Clear();
  120. try
  121. {
  122. this.Cursor = Cursors.WaitCursor;
  123. string adm = CoreUserInfo.UserInfo.GetUserID();
  124. Dictionary<string, object> ReqPnew = new Dictionary<string, object>();
  125. //创建时间
  126. if (CK_Ctime.Checked == true)
  127. {
  128. if (txt_createTimeStart.Text != "")
  129. {
  130. DateTime Start = Convert.ToDateTime(txt_createTimeStart.Value);
  131. ReqPnew.Add("createTimeStart", Start);
  132. }
  133. if (txt_createTimeEnd.Text != "")
  134. {
  135. DateTime End = Convert.ToDateTime(txt_createTimeEnd.Value);
  136. ReqPnew.Add("createTimeEnd", End);
  137. }
  138. }
  139. //计划时间
  140. if (CK_ptime.Checked == true)
  141. {
  142. if (txtMrPeriodStart.Text != "")
  143. {
  144. DateTime Start1 = DateTime.Parse(Convert.ToDateTime(txtMrPeriodStart.Value).ToString("yyyy/MM"));
  145. ReqPnew.Add("mrPeriodStart", Start1);
  146. }
  147. if (txtMrPeriodEnd.Text != "")
  148. {
  149. DateTime End1 = DateTime.Parse(Convert.ToDateTime(txtMrPeriodEnd.Value).ToString("yyyy/MM"));
  150. ReqPnew.Add("mrPeriodEnd", End1);
  151. }
  152. }
  153. //审批时间
  154. if (checkBox1.Checked)
  155. {
  156. if (txtAuditedStart.Text != "")
  157. {
  158. DateTime Start2 = Convert.ToDateTime(txtAuditedStart.Value);
  159. ReqPnew.Add("auditedTimeStart", Start2);
  160. }
  161. if (txtAuditedEnd.Text != "")
  162. {
  163. DateTime End2 = Convert.ToDateTime(txtAuditedEnd.Value);
  164. ReqPnew.Add("auditedTimeEnd", End2);
  165. }
  166. }
  167. //导出类型
  168. if (txt_style.SelectedIndex != -1)
  169. {
  170. ReqPnew.Add("style", txt_style.Value.ToString().Trim());
  171. }
  172. //角色
  173. if (txt_businessName.SelectedIndex != -1)
  174. {
  175. ReqPnew.Add("roleId", txt_businessName.Value.ToString().Trim());
  176. }
  177. //计划员
  178. if (txt_businessUser.SelectedIndex != -1)
  179. {
  180. ReqPnew.Add("buyerName", txt_businessUser.Value.ToString().Trim());
  181. }
  182. //头状态
  183. if (txt_Mstatus.SelectedIndex != -1)
  184. {
  185. ReqPnew.Add("mStatus", txt_Mstatus.Value.ToString().Trim());
  186. }
  187. //行状态
  188. if (txt_Dstatus.SelectedIndex != -1)
  189. {
  190. ReqPnew.Add("dStatus", txt_Dstatus.Value.ToString().Trim());
  191. }
  192. ReqPnew.Add("itemName", txt_itemName.Text.Trim());
  193. ReqPnew.Add("itemCode", txt_itemCode.Text.Trim());
  194. DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RePDM", new object[] { ReqPnew });
  195. foreach (DataRow row in dt2.Rows)
  196. {
  197. row["itemDescE"] = Convert.ToDateTime(row["itemDescE"]).ToString("yyyy/MM");
  198. }
  199. GridHelper.CopyDataToDatatable(dt2, dataTable2, true);
  200. GridHelper.RefreshAndAutoSize(ultraGrid1);
  201. }
  202. catch (Exception ex)
  203. {
  204. MessageUtil.ShowTips("加载数据失败:" + ex);
  205. }
  206. finally
  207. {
  208. this.Cursor = Cursors.Default;
  209. }
  210. }
  211. /// <summary>
  212. /// 计划时间处理
  213. /// </summary>
  214. /// <param name="sender"></param>
  215. /// <param name="e"></param>
  216. private void CK_ptime_CheckedChanged(object sender, EventArgs e)// 计划时间处理
  217. {
  218. if (CK_ptime.Checked == false)
  219. {
  220. txtMrPeriodStart.Enabled = false;
  221. txtMrPeriodEnd.Enabled = false;
  222. }
  223. else
  224. {
  225. txtMrPeriodStart.Enabled = true;
  226. txtMrPeriodEnd.Enabled = true;
  227. }
  228. }
  229. /// <summary>
  230. /// 创建时间处理
  231. /// </summary>
  232. /// <param name="sender"></param>
  233. /// <param name="e"></param>
  234. private void CK_Ctime_CheckedChanged(object sender, EventArgs e)// 创建时间处理
  235. {
  236. if (CK_Ctime.Checked == false)
  237. {
  238. txt_createTimeEnd.Enabled = false;
  239. txt_createTimeStart.Enabled = false;
  240. }
  241. else
  242. {
  243. txt_createTimeEnd.Enabled = true;
  244. txt_createTimeStart.Enabled = true;
  245. }
  246. }
  247. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  248. {
  249. txtAuditedStart.Enabled = checkBox1.Checked;
  250. txtAuditedEnd.Enabled = checkBox1.Checked;
  251. // txtMrPeriodEnd.Enabled = checkBox1.Checked;
  252. }
  253. }
  254. }