FrmScrapApplyFrim.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Format;
  3. using Core.Mes.Client.Comm.Server;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.YdmBcPipeManage.Entity;
  6. using CoreFS.CA06;
  7. using Infragistics.Win.UltraWinGrid;
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Windows.Forms;
  17. namespace Core.StlMes.Client.YdmBcPipeManage
  18. {
  19. public partial class FrmScrapApplyFrim : FrmBase
  20. {
  21. public FrmScrapApplyFrim()
  22. {
  23. InitializeComponent();
  24. }
  25. private void FrmScrapApplyFrim_Load(object sender, EventArgs e)
  26. {
  27. DateTime d1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
  28. this.StartTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM"));
  29. DateTime now = DateTime.Now;
  30. DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
  31. DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
  32. this.RegStartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
  33. this.RegEndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
  34. EntityHelper.ShowGridCaption<YdmBcScrapfrimEntity>(ultraGrid2.DisplayLayout.Bands[0]);
  35. initDepartMent();
  36. }
  37. /// <summary>
  38. /// 所属权
  39. /// </summary>
  40. private void initDepartMent()
  41. {
  42. DataTable ds = ServerHelper.GetData("com.steering.ydm.bc.FrmDeleteMatBcM.doQueryDepartM", new object[] { }, ob);
  43. if (ds.Rows.Count > 0)
  44. {
  45. this.cmbDepartMent.DataSource = ds;
  46. cmbDepartMent.DisplayMember = "DEPARTMENT_NAME_P";
  47. cmbDepartMent.ValueMember = "DEPARTMENT_CODE_P";
  48. }
  49. }
  50. /// <summary>
  51. /// 重写基类方法
  52. /// </summary>
  53. /// <param name="sender"></param>
  54. /// <param name="ToolbarKey"></param>
  55. public override void ToolBar_Click(object sender, string ToolbarKey)
  56. {
  57. switch (ToolbarKey)
  58. {
  59. case "DoQuery":
  60. doQuery();
  61. break;
  62. case "FrimScarpApply":
  63. frimScarpApply();
  64. break;
  65. case "FrimScarpApplyNot":
  66. frimScarpApplyNot();
  67. break;
  68. case "CancelFrimScarpApply":
  69. cancelFrimScrapApply();
  70. break;
  71. case "Export":
  72. exportData();
  73. break;
  74. case "Close":
  75. this.Close();
  76. break;
  77. }
  78. }
  79. /// <summary>
  80. /// 查询
  81. /// </summary>
  82. private void doQuery()
  83. {
  84. string bathYear = "";
  85. string txtJudgeNo = "";
  86. string startTime = "";
  87. string endTim = "";
  88. if (this.chkTim.Checked)
  89. {
  90. bathYear = this.StartTime.Value.ToString("yyyyMM");
  91. }
  92. if (this.chkJugeHeatNo.Checked && this.txtJugeNo.Text.Trim() != "")
  93. {
  94. txtJudgeNo = this.txtJugeNo.Text.Trim();
  95. }
  96. if (this.chkRegTime.Checked)
  97. {
  98. startTime = this.RegStartTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  99. endTim = this.RegEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  100. }
  101. ArrayList parmList = new ArrayList();
  102. parmList.Add(bathYear);
  103. parmList.Add(txtJudgeNo);
  104. parmList.Add(startTime);
  105. parmList.Add(endTim);
  106. List<YdmBcScrapfrimEntity> listSource = EntityHelper.GetData<YdmBcScrapfrimEntity>(
  107. "com.steering.ydm.bc.FrmScrapApplyFrim.doQueryApply", new object[] { parmList, ultraOptionSet1.CheckedItem.DataValue.ToString(), this.CustomInfo, this.ValidDataPurviewIds }, this.ob);
  108. foreach(YdmBcScrapfrimEntity YdmBcScrapfrimEntity in listSource)
  109. {
  110. if (String.IsNullOrWhiteSpace(YdmBcScrapfrimEntity.FrimTime))
  111. {
  112. YdmBcScrapfrimEntity.TimeDiffe = "0.0天";
  113. }
  114. else {
  115. TimeSpan ts1 = new TimeSpan(DateTime.ParseExact(YdmBcScrapfrimEntity.FrimTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture).Ticks);
  116. TimeSpan ts2 = new TimeSpan(DateTime.ParseExact(YdmBcScrapfrimEntity.CreateTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture).Ticks);
  117. YdmBcScrapfrimEntity.TimeDiffe = ts1.Subtract(ts2).TotalDays.ToString("0.0") + "天";
  118. }
  119. }
  120. ydmBcScrapfrimEntityBindingSource.DataSource = listSource;
  121. }
  122. /// <summary>
  123. /// 审核
  124. /// </summary>
  125. private void frimScarpApply()
  126. {
  127. this.ultraGrid2.UpdateData();
  128. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  129. if (checkMagRows.Count() == 0)
  130. {
  131. MessageUtil.ShowTips("请选择需要审核的信息!");
  132. return;
  133. }
  134. ArrayList parmList = new ArrayList();
  135. foreach (UltraGridRow row in checkMagRows)
  136. {
  137. YdmBcScrapfrimEntity matBcEntity = (YdmBcScrapfrimEntity)row.ListObject;
  138. matBcEntity.BelongCodeResponse = row.Cells["BelongCodeResponse"].Value.ToString();
  139. matBcEntity.BelongNameResponse = row.Cells["BelongCodeResponse"].Text;
  140. matBcEntity.FrimName = UserInfo.GetUserName();
  141. if (matBcEntity.BelongCodeResponse == "")
  142. {
  143. MessageUtil.ShowTips("审核时请确定责任单位!");
  144. return;
  145. }
  146. string ydmFrimEntity = JSONFormat.Format(matBcEntity);
  147. parmList.Add(ydmFrimEntity);
  148. }
  149. CoreClientParam ccp = new CoreClientParam();
  150. ccp.ServerName = "com.steering.ydm.bc.FrmScrapApplyFrim";
  151. ccp.MethodName = "frimScarpApply";
  152. ccp.ServerParams = new object[] { parmList };
  153. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  154. if (ccp.ReturnCode != -1)
  155. {
  156. if (ccp.ReturnInfo.Equals("审核成功!"))
  157. {
  158. doQuery();
  159. MessageUtil.ShowTips(ccp.ReturnInfo);
  160. }
  161. else
  162. {
  163. MessageUtil.ShowTips(ccp.ReturnInfo);
  164. }
  165. }
  166. }
  167. /// <summary>
  168. /// 审核不通过
  169. /// </summary>
  170. private void frimScarpApplyNot()
  171. {
  172. this.ultraGrid2.UpdateData();
  173. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  174. if (checkMagRows.Count() == 0)
  175. {
  176. MessageUtil.ShowTips("请选择需要审核的信息!");
  177. return;
  178. }
  179. ArrayList parmList = new ArrayList();
  180. foreach (UltraGridRow row in checkMagRows)
  181. {
  182. YdmBcScrapfrimEntity matBcEntity = (YdmBcScrapfrimEntity)row.ListObject;
  183. matBcEntity.FrimName = UserInfo.GetUserName();
  184. string ydmFrimEntity = JSONFormat.Format(matBcEntity);
  185. parmList.Add(ydmFrimEntity);
  186. }
  187. CoreClientParam ccp = new CoreClientParam();
  188. ccp.ServerName = "com.steering.ydm.bc.FrmScrapApplyFrim";
  189. ccp.MethodName = "frimScarpApplyNot";
  190. ccp.ServerParams = new object[] { parmList };
  191. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  192. if (ccp.ReturnCode != -1)
  193. {
  194. if (ccp.ReturnInfo.Equals("审核成功!"))
  195. {
  196. doQuery();
  197. MessageUtil.ShowTips(ccp.ReturnInfo);
  198. }
  199. else
  200. {
  201. MessageUtil.ShowTips(ccp.ReturnInfo);
  202. }
  203. }
  204. }
  205. /// <summary>
  206. /// 撤销废品的审核
  207. /// </summary>
  208. private void cancelFrimScrapApply()
  209. {
  210. this.ultraGrid2.UpdateData();
  211. string date = DateTime.Now.ToString("yyyyMM");
  212. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  213. if (checkMagRows.Count() == 0)
  214. {
  215. MessageUtil.ShowTips("请选择需要撤销审核的信息!");
  216. return;
  217. }
  218. ArrayList parmList = new ArrayList();
  219. foreach (UltraGridRow row in checkMagRows)
  220. {
  221. YdmBcScrapfrimEntity matBcEntity = (YdmBcScrapfrimEntity)row.ListObject;
  222. string ydmFrimEntity = JSONFormat.Format(matBcEntity);
  223. parmList.Add(ydmFrimEntity);
  224. }
  225. CoreClientParam ccp = new CoreClientParam();
  226. ccp.ServerName = "com.steering.ydm.bc.FrmScrapApplyFrim";
  227. ccp.MethodName = "cancelFrimScrapApply";
  228. ccp.ServerParams = new object[] { parmList, date };
  229. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  230. if (ccp.ReturnCode != -1)
  231. {
  232. if (ccp.ReturnInfo.Equals("撤销成功!"))
  233. {
  234. doQuery();
  235. MessageUtil.ShowTips(ccp.ReturnInfo);
  236. }
  237. else
  238. {
  239. MessageUtil.ShowTips(ccp.ReturnInfo);
  240. }
  241. }
  242. }
  243. /// <summary>
  244. /// 导出
  245. /// </summary>
  246. private void exportData()
  247. {
  248. GridHelper.ulGridToExcel(ultraGrid2, "已审核废品数据汇总");
  249. }
  250. private void chkJugeHeatNo_CheckedChanged(object sender, EventArgs e)
  251. {
  252. this.txtJugeNo.Enabled = this.chkJugeHeatNo.Checked;
  253. }
  254. private void chkRegTime_CheckedChanged(object sender, EventArgs e)
  255. {
  256. this.RegStartTime.Enabled = this.RegEndTime.Enabled = this.chkRegTime.Checked;
  257. }
  258. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  259. {
  260. UltraGridRow uRow = this.ultraGrid2.ActiveRow;
  261. if (uRow.Cells["CraftNo"].Text.Trim() == "" || uRow.Cells["CraftPath"].Text.Trim() == "")
  262. {
  263. return;
  264. }
  265. BaseMethod.ViewCarft_No(uRow.Cells["CraftPath"].Text.Trim());
  266. }
  267. }
  268. }