frmCheckItem.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. using Pur.Entity;
  11. using System.Collections;
  12. using Core.Mes.Client.Comm.Tool;
  13. using Pur.Entity.configureEntity;
  14. using Core.Mes.Client.Comm.Control;
  15. using com.hnshituo.pur.vo;
  16. using Pur.Entity.ck;
  17. using Infragistics.Win;
  18. using Pur.require_plan;
  19. namespace Pur.ck
  20. {
  21. public partial class frmCheckItem : FrmPmsBase
  22. {
  23. public frmCheckItem()
  24. {
  25. InitializeComponent();
  26. }
  27. //菜单按钮事件
  28. public override void ToolBar_Click(object sender, string ToolbarKey)
  29. {
  30. switch (ToolbarKey)
  31. {
  32. case "Query":
  33. GetCkInBill();
  34. break;
  35. case "RecReceiveAll"://全部接收
  36. RecReceiveAll();
  37. break;
  38. case "RecReceivePortion"://部分接收
  39. RecReceivePortion();
  40. break;
  41. case "RecReceiveBack"://让步接收
  42. RecReceiveBack();
  43. break;
  44. case "RecReturn"://拒收
  45. RecReturn();
  46. break;
  47. }
  48. }
  49. /// <summary>
  50. /// 全部接收
  51. /// </summary>
  52. private void RecReceiveAll()
  53. { checkRec("1"); }
  54. /// <summary>
  55. /// 部分接收
  56. /// </summary>
  57. private void RecReceivePortion()
  58. { checkRec("2"); }
  59. /// <summary>
  60. /// 让步接收
  61. /// </summary>
  62. private void RecReceiveBack()
  63. { checkRec("3"); }
  64. /// <summary>
  65. /// 拒收
  66. /// </summary>
  67. private void RecReturn()
  68. { checkRec("4"); }
  69. /// <summary>
  70. /// 查询
  71. /// </summary>
  72. private void GetCkInBill()
  73. {
  74. PurCkRecBillEntity pcibEntity = new PurCkRecBillEntity();
  75. pcibEntity.Status = "2";//只查询已初检的收货单
  76. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkRecBillService", "GetCkRecBill", new object[] { pcibEntity });
  77. //按创建时间降序
  78. if (dt.Rows.Count != 0)
  79. {
  80. dt.DefaultView.Sort = "CREATETIME DESC";
  81. dt = dt.DefaultView.ToTable();
  82. }
  83. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  84. }
  85. /// <summary>
  86. /// 查询
  87. /// </summary>
  88. private void GetPUR_CK_STORAGE()
  89. {
  90. CkStorage CkSto = new CkStorage();
  91. CkSto.OrderId = txt_ORDER_ID.Text;
  92. CkSto.RefeId = txt_RefeId.Text;
  93. CkSto.RefType = "3";
  94. if (!string.IsNullOrEmpty(txt_createTimeS.Text) && !string.IsNullOrEmpty(txt_createTimeE.Text))
  95. {
  96. CkSto.CreateTime = Convert.ToDateTime(txt_createTimeS.Text);
  97. CkSto.UpdateTime = Convert.ToDateTime(txt_createTimeE.Text).AddDays(1);
  98. }
  99. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageService", "find_Storage", new object[] { CkSto });
  100. GridHelper.CopyDataToDatatable(dt, dataTable7, true);
  101. }
  102. /// <summary>
  103. /// 获取质检头信息
  104. /// </summary>
  105. private void getCkLimsM()
  106. {
  107. PurCkLimsMEntity CkLimsMEntity = new PurCkLimsMEntity();
  108. CkLimsMEntity.InspectCode = txt_INSPECT_CODE_Query.Text;
  109. CkLimsMEntity.BatchNo = txt_BATCH_NO_Query.Text;
  110. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkLimsMService", "getCkLimsM", new object[] { CkLimsMEntity});
  111. GridHelper.CopyDataToDatatable(dt, dataTable8, true);
  112. }
  113. /// <summary>
  114. /// 获取质检行信息
  115. /// </summary>
  116. private void getCkLimsC(string strInspectCode)
  117. {
  118. PurCkLimsCEntity CkLimsCEntity = new PurCkLimsCEntity();
  119. CkLimsCEntity.InspectCode = strInspectCode;
  120. CkLimsCEntity.Validflag = "1";
  121. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkLimsCService", "find", new object[] { CkLimsCEntity, 0, 0 });
  122. GridHelper.CopyDataToDatatable(dt, dataTable3, true);
  123. }
  124. /// <summary>
  125. /// 开始初检
  126. /// </summary>
  127. private void checkRec(string strRecieveMode)
  128. {
  129. //ultraGrid1.UpdateData();
  130. ArrayList alCkRecBillEntity = new ArrayList();
  131. // for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  132. //{
  133. PurCkRecBillEntity CkRecBillEntity = new PurCkRecBillEntity();
  134. //CkRecBillEntity.RecId = ultraGrid1.Rows[i].Cells["RecId"].Value.ToString();
  135. CkRecBillEntity.RecCls = strRecieveMode;//接收方式
  136. CkRecBillEntity.Status = "3";
  137. alCkRecBillEntity.Add(CkRecBillEntity);
  138. // }
  139. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkRecBillService", "checkRec", new object[] { alCkRecBillEntity });
  140. if (crt.Resultcode != 0)
  141. {
  142. MessageUtil.ShowTips("操作失败 " + crt.Resultmsg);
  143. return;
  144. }
  145. MessageUtil.ShowTips("操作成功");
  146. }
  147. /// <summary>
  148. /// 生成检验委托单
  149. /// </summary>
  150. private void AddCheckDelegateId()
  151. {
  152. if (ultraGrid6.ActiveRow == null)
  153. { return; }
  154. try
  155. {
  156. DateTime? dtnull = null;
  157. PurCkLimsMEntity CkLimsMEntity = new PurCkLimsMEntity();
  158. String strInspectCode = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getOddNumber_yymm", new object[] { "PUR_CK_LIMS_M", "INSPECT_CODE", "ZJDH-", "3" });
  159. String strBatchNo = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getOddNumber_yymm", new object[] { "PUR_CK_LIMS_M", "INSPECT_SNQ", "JYP-", "3" });
  160. CkLimsMEntity.InspectCode = strInspectCode;//质检单号
  161. CkLimsMEntity.RecId = ultraGrid6.ActiveRow.Cells["INSTOCKNO"].Value.ToString();//收货单号
  162. CkLimsMEntity.BatchNo = ultraGrid6.ActiveRow.Cells["BATCHNO"].Value.ToString();//入场批号
  163. CkLimsMEntity.InspectSnq = strBatchNo;//检验批号
  164. CkLimsMEntity.InspectDate = txt_INSPECT_DATE.Value == null ? dtnull : (DateTime)txt_INSPECT_DATE.Value;//检验日期(判定日期)
  165. CkLimsMEntity.Remark = txt_REMARK.Text;//备注
  166. CkLimsMEntity.Paihao = txt_PAIHAO.Text;//牌号
  167. CkLimsMEntity.InspectUserName = txt_INSPECT_USER_NAME.Text;//质检人姓名
  168. CkLimsMEntity.OrderLineSqe = txt_ORDER_LINE_SQE.Text;//合同行号
  169. CkLimsMEntity.Qty = txt_QTY.Text.Trim() == "" ? 0 : double.Parse(txt_QTY.Text);//验收量
  170. CkLimsMEntity.InspectStandCode = txt_INSPECT_STAND_CODE.Text;//质检标准编号
  171. CkLimsMEntity.ItemName = txt_ITEM_NAME.Text;//物料名称
  172. CkLimsMEntity.ItemCode = ultraGrid6.ActiveRow.Cells["ITEMCODE"].Value.ToString();//物料编码
  173. CkLimsMEntity.ItemStandardsCode = txt_ITEM_STANDARDS_CODE.Text;//标准编号
  174. CkLimsMEntity.CheckItems = txt_CHECK_ITEMS.Text;// 检测项目
  175. CkLimsMEntity.Validflag = "1";
  176. CkLimsMEntity.CreateName = UserInfo.GetUserName();
  177. CkLimsMEntity.CreateUserid = UserInfo.GetUserID();
  178. CkLimsMEntity.CreateTime = System.DateTime.Now;
  179. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkLimsMService", "doInsert", new object[] { CkLimsMEntity });//添加操作
  180. CkStorage CkSto = new CkStorage();
  181. CkSto.InvId = ultraGrid6.ActiveRow.Cells["InvId"].Value.ToString();
  182. CkSto.BatchNo = strBatchNo;
  183. CoreResult crt1 = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "doUpdate", new object[] { CkSto });//修改库存检验批号
  184. if (crt.Resultcode != 0 || crt1.Resultcode != 0)
  185. {
  186. MessageUtil.ShowTips("生成失败: " + crt.Resultmsg);
  187. return;
  188. }
  189. MessageUtil.ShowTips("成功生成检验委托单:" + strBatchNo);
  190. getCkLimsM();
  191. comm.doActiveSelRow(ultraGrid1, "INSPECTCODE", strInspectCode);
  192. GetPUR_CK_STORAGE();
  193. comm.doActiveSelRow(ultraGrid6, "INSTOCKNO", CkLimsMEntity.RecId);
  194. }
  195. catch (Exception e){
  196. MessageUtil.ShowTips("生成失败: " + e.Message);
  197. return;
  198. }
  199. }
  200. /// <summary>
  201. /// 增加质检行信息
  202. /// </summary>
  203. private void AddCkLims()
  204. {
  205. if (ultraGrid1.ActiveRow == null)
  206. {
  207. MessageUtil.ShowTips("请选择质检委托单");
  208. return;
  209. }
  210. ultraGrid5.UpdateData();
  211. //更新检验单检验结果
  212. PurCkLimsMEntity CkLimsMEntity = new PurCkLimsMEntity();
  213. CkLimsMEntity.InspectCode = ultraGrid1.ActiveRow.Cells["InspectCode"].Value.ToString();
  214. CkLimsMEntity.Result = cmbCheck.Value.ToString();
  215. CkLimsMEntity.Remark = txt_REMARK1.Text;
  216. if (txt_ITEM_UOM_CONEFFICIENT.Text != "")
  217. {
  218. CkLimsMEntity.ItemUomConefficient = double.Parse(txt_ITEM_UOM_CONEFFICIENT.Text);
  219. }
  220. //插入检验详细信息
  221. ArrayList alCkLims = new ArrayList();
  222. for (int i = 0; i < ultraGrid5.Rows.Count; i++)
  223. {
  224. PurCkLimsCEntity CkLimsCEntity = new PurCkLimsCEntity();
  225. CkLimsCEntity.InspectCode = ultraGrid1.ActiveRow.Cells["InspectCode"].Value.ToString();
  226. CkLimsCEntity.ChemCode = ultraGrid5.Rows[i].Cells["ChemCode"].Value.ToString();//质检项
  227. CkLimsCEntity.ChemValue1 = ultraGrid5.Rows[i].Cells["ChemValue1"].Value.ToString();//质检结果
  228. CkLimsCEntity.ChemValue2 = ultraGrid5.Rows[i].Cells["ChemValue2"].Value.ToString();//单位
  229. CkLimsCEntity.SeqNo = i;
  230. CkLimsCEntity.Validflag = "1";
  231. CkLimsCEntity.CreateName = UserInfo.GetUserName();
  232. CkLimsCEntity.CreateUserid = UserInfo.GetUserID();
  233. CkLimsCEntity.CreateTime = System.DateTime.Now;
  234. alCkLims.Add(CkLimsCEntity);
  235. }
  236. //更新库存收货单的状态
  237. CkStorage ckEntity =new CkStorage();
  238. ckEntity.InStockNo = ultraGrid1.ActiveRow.Cells["RECID"].Value.ToString();
  239. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkLimsCService", "AddCkLims", new object[] { alCkLims, CkLimsMEntity, ckEntity });//添加操作
  240. if (crt.Resultcode != 0)
  241. {
  242. MessageUtil.ShowTips("判定结果失败");
  243. return;
  244. }
  245. MessageUtil.ShowTips("已生成判定结果:"+cmbCheck.Text);
  246. getCkLimsM();
  247. comm.doActiveSelRow(ultraGrid1, "INSPECTCODE", CkLimsMEntity.InspectCode);
  248. string strINSTOCKNO = ultraGrid6.ActiveRow.Cells["INSTOCKNO"].Value.ToString();
  249. GetPUR_CK_STORAGE();
  250. comm.doActiveSelRow(ultraGrid6, "INSTOCKNO", strINSTOCKNO);
  251. }
  252. /// <summary>
  253. /// 获取检验委托信息
  254. /// </summary>
  255. private void getCheckDelegate()
  256. {
  257. txt_ORDER_LINE_SQE.Text = ultraGrid6.ActiveRow.Cells["ORDERLINESQE"].Value.ToString();//合同行号
  258. txt_SUPP_NAME.Text = ultraGrid6.ActiveRow.Cells["SUPPNAME"].Value.ToString();//供应商名称
  259. txt_CHK_BATCH_NO.Text = ultraGrid6.ActiveRow.Cells["CHKBATCHNO"].Value.ToString();//检验批
  260. txt_ITEM_NAME.Text = ultraGrid6.ActiveRow.Cells["ITEMNAME"].Value.ToString();//物料名称
  261. txt_ITEM_STANDARDS_CODE.Text = ultraGrid6.ActiveRow.Cells["ITEMSTANDARDSCODE"].Value.ToString();//标准编号
  262. txt_RECQTY.Text = ultraGrid6.ActiveRow.Cells["INVQTY"].Value.ToString();//收货数量、供货数量
  263. }
  264. /// <summary>
  265. /// 激活收货单号,查询 相应的质检信息
  266. /// </summary>
  267. /// <param name="sender"></param>
  268. /// <param name="e"></param>
  269. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  270. {
  271. getCkLimsC(ultraGrid1.ActiveRow.Cells["INSPECTCODE"].Value.ToString());
  272. if (ultraGrid1.ActiveRow.Cells["RESULT"].Value.ToString() == "合格")
  273. {
  274. cmbCheck.Value = 1;
  275. }
  276. else
  277. {
  278. cmbCheck.Value = 0;
  279. }
  280. txt_ITEM_UOM_CONEFFICIENT.Text = ultraGrid1.ActiveRow.Cells["ITEMUOMCONEFFICIENT"].Value.ToString();
  281. }
  282. /// <summary>
  283. /// 质检信息激活事件,查询质检明细单
  284. /// </summary>
  285. /// <param name="sender"></param>
  286. /// <param name="e"></param>
  287. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  288. {
  289. PurCkLimsCEntity CkLimsCEntity = new PurCkLimsCEntity();
  290. //CkLimsCEntity.InspectCode = ultraGrid2.ActiveRow.Cells["INSPECTCODE"].Value.ToString();
  291. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkLimsCService", "find", new object[] { CkLimsCEntity, 0, 0 });
  292. GridHelper.CopyDataToDatatable(dt, dataTable3, true);
  293. }
  294. /// <summary>
  295. /// 生成检验委托单
  296. /// </summary>
  297. /// <param name="sender"></param>
  298. /// <param name="e"></param>
  299. private void btnChkDelegate_Click(object sender, EventArgs e)
  300. {
  301. AddCheckDelegateId();
  302. }
  303. /// <summary>
  304. /// 查询库存
  305. /// </summary>
  306. /// <param name="sender"></param>
  307. /// <param name="e"></param>
  308. private void btnQuery_Click(object sender, EventArgs e)
  309. {
  310. GetPUR_CK_STORAGE();
  311. }
  312. /// <summary>
  313. /// 查询质检头信息
  314. /// </summary>
  315. /// <param name="sender"></param>
  316. /// <param name="e"></param>
  317. private void btnQueryCLM_Click(object sender, EventArgs e)
  318. {
  319. getCkLimsM();
  320. }
  321. /// <summary>
  322. /// 确定质检判定结果信息
  323. /// </summary>
  324. /// <param name="sender"></param>
  325. /// <param name="e"></param>
  326. private void btnConform_Click(object sender, EventArgs e)
  327. {
  328. AddCkLims();
  329. }
  330. private void ultraGrid6_AfterRowActivate(object sender, EventArgs e)
  331. {
  332. getCheckDelegate();
  333. }
  334. /// <summary>
  335. /// 界面加载
  336. /// </summary>
  337. /// <param name="sender"></param>
  338. /// <param name="e"></param>
  339. private void frmCheckItem_Load(object sender, EventArgs e)
  340. {
  341. cmbCheck.SelectedIndex = 0;
  342. txt_createTimeS.Value = DateTime.Now.AddMonths(-1);
  343. }
  344. }
  345. }