FrmSubContractResult.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. using Core.Mes.Client.Comm.Format;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.YdmStuffManage.Entity;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using System.ComponentModel;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Windows.Forms;
  16. namespace Core.StlMes.Client.YdmStuffManage
  17. {
  18. public partial class FrmSubContractResult : FrmBase
  19. {
  20. public FrmSubContractResult()
  21. {
  22. InitializeComponent();
  23. }
  24. private string[] arr = null;
  25. private void FrmSubContractResult_Load(object sender, EventArgs e)
  26. {
  27. DateTime now = DateTime.Now;
  28. DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
  29. DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
  30. this.StartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
  31. this.EndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
  32. EntityHelper.ShowGridCaption<FrgEntrustedBillEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  33. EntityHelper.ShowGridCaption<FrgEntrustedBillResultEntity>(ultraGrid2.DisplayLayout.Bands[0]);
  34. arr = BaseMethod.InitLgPermissions(this.ValidDataPurviewIds, "C", this.ob);
  35. }
  36. /// <summary>
  37. /// 重写基类方法
  38. /// </summary>
  39. /// <param name="sender"></param>
  40. /// <param name="ToolbarKey"></param>
  41. public override void ToolBar_Click(object sender, string ToolbarKey)
  42. {
  43. switch (ToolbarKey)
  44. {
  45. case "Query":
  46. doQueryEntrust();
  47. break;
  48. case "SubContractComplete":
  49. subContractComplete();
  50. break;
  51. case "CancelSubContractComplete":
  52. cancelSubContractComplete();
  53. break;
  54. case "Close":
  55. this.Close();
  56. break;
  57. }
  58. }
  59. /// <summary>
  60. /// 数据验证
  61. /// </summary>
  62. /// <returns></returns>
  63. private bool CheckQuery()
  64. {
  65. if (this.chkSubContractNo.Checked && string.IsNullOrEmpty(this.txtSubContractNo.Text.Trim()))
  66. {
  67. MessageUtil.ShowWarning("请输入委托单号!");
  68. return false;
  69. }
  70. if (this.chkSubContractLog.Checked && string.IsNullOrEmpty(this.cmbSubContractLog.Text.Trim()))
  71. {
  72. MessageUtil.ShowTips("请选择委托单状态!");
  73. return false;
  74. }
  75. return true;
  76. }
  77. /// <summary>
  78. /// 查询委托信息
  79. /// </summary>
  80. private void doQueryEntrust()
  81. {
  82. string subContractNo = "";
  83. string subContractLog = "";
  84. string startTim = "";
  85. string endTim = "";
  86. if (!CheckQuery())
  87. {
  88. return;
  89. }
  90. if (this.chkTim.Checked)
  91. {
  92. startTim = this.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  93. endTim = this.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  94. }
  95. if (this.chkSubContractNo.Checked)
  96. {
  97. subContractNo = this.txtSubContractNo.Text.Trim();
  98. }
  99. if (this.chkSubContractLog.Checked)
  100. {
  101. subContractLog = this.cmbSubContractLog.Value.ToString();
  102. }
  103. ArrayList parmList = new ArrayList();
  104. parmList.Add(subContractNo);
  105. parmList.Add(subContractLog);
  106. List<FrgEntrustedBillEntity> listSource = EntityHelper.GetData<FrgEntrustedBillEntity>(
  107. "Core.LgMes.Server.Stuffmanage.FrmSubContractResult.doQueryEntrustDz", new object[] { parmList, startTim, endTim, arr }, this.ob);
  108. FrgEntrustedBillEntitybindingSource.DataSource = listSource;
  109. }
  110. /// <summary>
  111. /// 委托回报完成
  112. /// </summary>
  113. private void subContractComplete()
  114. {
  115. this.ultraGrid2.UpdateData();
  116. string storeNo = "";
  117. string strInBound = "800701";
  118. string departId = ClsLoad.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob);
  119. string departMent = ClsLoad.GetDepartBySectionId(this.UserInfo.GetDeptid(), this.ob);
  120. string[] storeType = new string[4];
  121. UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  122. if (uRow == null)
  123. {
  124. MessageUtil.ShowTips("请选择需要回报实绩的委托信息!");
  125. return;
  126. }
  127. IQueryable<UltraGridRow> checkMags = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  128. if (checkMags.Count() == 0)
  129. {
  130. MessageUtil.ShowTips("请勾选需要回报的实绩信息!");
  131. return;
  132. }
  133. if (uRow.Cells["PlineCode"].Text.Equals("C005"))
  134. {
  135. storeNo = "XED1";
  136. }
  137. else
  138. {
  139. MessageUtil.ShowTips("未获取到所在科室,无法交库!");
  140. return;
  141. }
  142. storeType = getStoreType(storeNo);
  143. ArrayList parmList = new ArrayList();
  144. int chCount = 0;
  145. int trCount = 0;
  146. foreach (UltraGridRow row in checkMags)
  147. {
  148. FrgEntrustedBillResultEntity frgEntity = (FrgEntrustedBillResultEntity)row.ListObject;
  149. if (!checkResult(frgEntity))
  150. {
  151. return;
  152. }
  153. chCount = chCount + int.Parse(frgEntity.ActCount.ToString()) * int.Parse(frgEntity.OutnumCut.ToString());
  154. string frgEntrustResultTity = JSONFormat.Format(frgEntity);
  155. parmList.Add(frgEntrustResultTity);
  156. }
  157. FrgEntrustedBillEntity frgBillTity = (FrgEntrustedBillEntity)uRow.ListObject;
  158. trCount = int.Parse(frgBillTity.SubcontractNum.ToString()) * int.Parse(frgBillTity.InnumCut.ToString());
  159. string frgEntrsutBillTity = JSONFormat.Format(frgBillTity);
  160. //if (chCount > trCount)
  161. //{
  162. // MessageUtil.ShowTips("回报的产出单倍坯支数大于委托的单倍坯支数,请核实!");
  163. // return;
  164. //}
  165. CoreClientParam ccp = new CoreClientParam();
  166. ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmSubContractResult";
  167. ccp.MethodName = "subContractComplete";
  168. ccp.ServerParams = new object[] { frgEntrsutBillTity, parmList, UserInfo.GetUserName(), storeNo, strInBound, storeType, this.UserInfo.GetDeptid(), this.UserInfo.GetDepartment(), departId, departMent };
  169. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  170. if (ccp.ReturnCode != -1)
  171. {
  172. if (ccp.ReturnInfo.Equals("回报成功!"))
  173. {
  174. doQueryEntrust();
  175. MessageUtil.ShowTips(ccp.ReturnInfo);
  176. }
  177. else
  178. {
  179. MessageUtil.ShowTips(ccp.ReturnInfo);
  180. }
  181. }
  182. }
  183. /// <summary>
  184. /// 查询仓库类型
  185. /// </summary>
  186. /// <param name="storeNo"></param>
  187. /// <returns></returns>
  188. private string[] getStoreType(string storeNo)
  189. {
  190. string[] storeType = new string[4];
  191. DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffInputStore.getStoreType", new object[] { storeNo }, ob);
  192. if (dt.Rows.Count > 0)
  193. {
  194. storeType[0] = dt.Rows[0]["STORAGE_ATTR"].ToString();
  195. storeType[1] = dt.Rows[0]["STORAGE_ATTR_NAME"].ToString();
  196. storeType[2] = dt.Rows[0]["STORAGE_TYPE_NO"].ToString();
  197. storeType[3] = dt.Rows[0]["STORAGE_TYPE_NAME"].ToString();
  198. }
  199. return storeType;
  200. }
  201. /// <summary>
  202. /// 验证实绩信息
  203. /// </summary>
  204. /// <returns></returns>
  205. private bool checkResult(FrgEntrustedBillResultEntity frgResultTity)
  206. {
  207. if (frgResultTity.JudgeStoveNo.ToString() == "")
  208. {
  209. MessageUtil.ShowTips("实绩回报时判定炉号不能为空!");
  210. return false;
  211. }
  212. if (frgResultTity.DimaterOut.ToString() == ""|| !StringUtil.IsInt(frgResultTity.DimaterOut.ToString3()))
  213. {
  214. MessageUtil.ShowTips("实绩回报的产出直径需为正整数!");
  215. return false;
  216. }
  217. if (frgResultTity.LenGpSingle.ToString() == "" || !StringUtil.IsInt(frgResultTity.LenGpSingle.ToString3()))
  218. {
  219. MessageUtil.ShowTips("实绩回报的单倍长度需为正整数!");
  220. return false;
  221. }
  222. if (frgResultTity.OutnumCut.ToString() == "" || !StringUtil.IsInt(frgResultTity.OutnumCut.ToString3()))
  223. {
  224. MessageUtil.ShowTips("实绩回报的倍尺数需为正整数!");
  225. return false;
  226. }
  227. if (frgResultTity.LengthOut.ToString() == "" || !StringUtil.IsInt(frgResultTity.LengthOut.ToString3()))
  228. {
  229. MessageUtil.ShowTips("实绩回报的坯料长度需为正整数!");
  230. return false;
  231. }
  232. if (frgResultTity.ActCount.ToString() == "" || !StringUtil.IsInt(frgResultTity.ActCount.ToString3()))
  233. {
  234. MessageUtil.ShowTips("实绩回报的合格支数需为正整数!");
  235. return false;
  236. }
  237. if (frgResultTity.ActWeight.ToString() == "" || !StringUtil.IsDouble(frgResultTity.ActCount.ToString3()))
  238. {
  239. MessageUtil.ShowTips("实绩回报的合格重量需为正浮点数!");
  240. return false;
  241. }
  242. return true;
  243. }
  244. /// <summary>
  245. /// 撤销委托完成
  246. /// </summary>
  247. private void cancelSubContractComplete()
  248. {
  249. this.ultraGrid1.UpdateData();
  250. UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  251. if (uRow == null)
  252. {
  253. MessageUtil.ShowTips("请选择需要撤销委外实绩的委托信息");
  254. return;
  255. }
  256. FrgEntrustedBillEntity frgEntrustTity = (FrgEntrustedBillEntity)uRow.ListObject;
  257. string frgEntrustEntity = JSONFormat.Format(frgEntrustTity);
  258. CoreClientParam ccp = new CoreClientParam();
  259. ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmSubContractResult";
  260. ccp.MethodName = "cancelSubContractComplete";
  261. ccp.ServerParams = new object[] { frgEntrustEntity };
  262. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  263. if (ccp.ReturnCode != -1)
  264. {
  265. if (ccp.ReturnInfo.Equals("撤销成功!"))
  266. {
  267. doQueryEntrust();
  268. MessageUtil.ShowTips(ccp.ReturnInfo);
  269. }
  270. else
  271. {
  272. MessageUtil.ShowTips(ccp.ReturnInfo);
  273. }
  274. }
  275. }
  276. private void chkTim_CheckedChanged(object sender, EventArgs e)
  277. {
  278. this.StartTime.Enabled = this.EndTime.Enabled = this.chkTim.Checked;
  279. }
  280. private void chkSubContractNo_CheckedChanged(object sender, EventArgs e)
  281. {
  282. this.txtSubContractNo.Enabled = this.chkSubContractNo.Checked;
  283. }
  284. private void chkSubContractLog_CheckedChanged(object sender, EventArgs e)
  285. {
  286. this.cmbSubContractLog.Enabled = this.chkSubContractLog.Checked;
  287. }
  288. private void ultraGrid2_CellChange(object sender, CellEventArgs e)
  289. {
  290. UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  291. UltraGridRow row = this.ultraGrid2.ActiveRow;
  292. if(uRow == null)return;
  293. //米单重
  294. double mSingleWeight = (7.8 * 3.1415926 / 4 * int.Parse(row.Cells["DimaterOut"].Text.ToString3()) * int.Parse(row.Cells["DimaterOut"].Text.ToString3())) / 1000 / 1000;// 米单重
  295. // 倍尺坯单支重=坯米单重*倍尺坯长/1000
  296. double weightM = mSingleWeight * (int.Parse(row.Cells["LengthOut"].Text.ToString3()) / 1000d);
  297. if(e.Cell.Column.Key == "CHK")
  298. {
  299. e.Cell.Row.Cells["LenGpSingle"].Value = uRow.Cells["LenGpSingleOut"].Text.ToString();
  300. e.Cell.Row.Cells["DimaterOut"].Value = uRow.Cells["DiameterOut"].Text.ToString();
  301. }
  302. if (e.Cell.Column.Key == "OutnumCut")
  303. {
  304. e.Cell.Row.Cells["LengthOut"].Value = (int.Parse(row.Cells["LenGpSingle"].Text.ToString3()) * int.Parse(row.Cells["OutnumCut"].Text.Trim().ToString3())).ToString();
  305. }
  306. if (e.Cell.Column.Key == "ActCount")
  307. {
  308. e.Cell.Row.Cells["ActWeight"].Value = Math.Round(int.Parse(row.Cells["ActCount"].Text) * weightM,3).ToString();
  309. }
  310. if (e.Cell.Column.Key == "LenGpSingle")
  311. {
  312. e.Cell.Row.Cells["LengthOut"].Value = (int.Parse(row.Cells["LenGpSingle"].Text.ToString3()) * int.Parse(row.Cells["OutnumCut"].Text.Trim().ToString3())).ToString();
  313. }
  314. }
  315. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  316. {
  317. UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  318. if (uRow == null) return;
  319. List<FrgEntrustedBillResultEntity> listSource = EntityHelper.GetData<FrgEntrustedBillResultEntity>(
  320. "Core.LgMes.Server.Stuffmanage.FrmSubContractResult.doQueryEntrustBillResult", new object[] { uRow.Cells["subcontractNo"].Text, uRow.Cells["subcontractNoSeq"].Text }, this.ob);
  321. FrgEntrustedBillResultEntitybindingSource.DataSource = listSource;
  322. }
  323. private void txtDimter_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  324. {
  325. this.ultraGrid2.UpdateData();
  326. DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.doQueryDimaterAll",
  327. new object[] { }, ob);
  328. dt.Columns["SPEC_NAME"].Caption = "直径";
  329. BaseInfoPopup baseInfo = new BaseInfoPopup(dt, "SPEC_NAME", "SPEC_CODE");
  330. baseInfo.Shown += new EventHandler((a, b) =>
  331. {
  332. var actRow = baseInfo.UltraGrid1.Rows.AsQueryable().Where(
  333. c => c.GetValue("SPEC_CODE") == this.txtDimter.Tag.ToString2()).FirstOrDefault();
  334. if (actRow != null) actRow.Activate();
  335. });
  336. if (baseInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  337. {
  338. //cmbLocationNo.Tag = baseInfo.ChoicedRow.GetValue("LOCATION_NO");
  339. //cmbLocationNo.Text = baseInfo.ChoicedRow.GetValue("LOCATION_NAME");
  340. this.ultraGrid2.ActiveCell.Value = baseInfo.ChoicedRow.GetValue("SPEC_NAME");
  341. this.ultraGrid2.ActiveCell.Row.Cells["DimaterOut"].Value = baseInfo.ChoicedRow.GetValue("SPEC_NAME").Replace(".00","");
  342. }
  343. }
  344. }
  345. }