锐腾搅拌上料功能
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1275 lines
62 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Windows.Forms;
  5. using DevExpress.XtraEditors;
  6. using ICSSoft.Base.Config.AppConfig;
  7. using ICSSoft.Base.Config.DBHelper;
  8. using ICSSoft.Base.ReferForm.AppReferForm;
  9. using ICSSoft.Frame.Data.Entity;
  10. using ICSSoft.Frame.Data.BLL;
  11. namespace ICSSoft.Frame.APP
  12. {
  13. public partial class FormICSPickingEditAdd : DevExpress.XtraEditors.XtraForm
  14. {
  15. string VRow = "";
  16. String guid = "";
  17. FormICSPickingModel entity = new FormICSPickingModel();
  18. #region 构造函数
  19. public FormICSPickingEditAdd()
  20. {
  21. InitializeComponent();
  22. this.txtWeight.Properties.ReadOnly = true;
  23. if (this.cboIsMROItem.Checked == true)
  24. {
  25. this.txtMOCode.Properties.ReadOnly = true;
  26. this.txtMORow.Properties.ReadOnly = true;
  27. txtMOCode.Enabled = false;
  28. txtMO.Enabled = false;
  29. }
  30. else
  31. {
  32. this.txtOutCategory.Properties.ReadOnly = true;
  33. //20200407新增
  34. this.txtMROBatch.Enabled = false;
  35. this.txtMROBatch.Properties.ReadOnly = true;
  36. txtMO.Enabled = true;
  37. }
  38. }
  39. public FormICSPickingEditAdd(String id)
  40. {
  41. InitializeComponent();
  42. guid = id;
  43. this.txtWeight.Properties.ReadOnly = true;
  44. if (cboIsMROItem.Checked == true)//是否MRO物料选中
  45. {
  46. txtMO.Enabled = false;
  47. txtMOCode.Properties.ReadOnly = true;
  48. txtMORow.Properties.ReadOnly = true;
  49. }
  50. else
  51. {
  52. txtOutCategory.Properties.ReadOnly = true;
  53. //20200407新增
  54. this.txtMROBatch.Enabled = false;
  55. this.txtMROBatch.Properties.ReadOnly = true;
  56. txtMO.Enabled = true;
  57. }
  58. }
  59. #endregion
  60. #region 关闭 退出
  61. private void btnClose_Click(object sender, EventArgs e)
  62. {
  63. this.Close();
  64. }
  65. #endregion
  66. #region 移动窗体
  67. private const int WM_NCHITTEST = 0x84;
  68. private const int HTCLIENT = 0x1;
  69. private const int HTCAPTION = 0x2;
  70. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  71. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  72. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  73. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  74. //重写窗体,使窗体可以不通过自带标题栏实现移动
  75. protected override void WndProc(ref Message m)
  76. {
  77. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  78. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  79. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  80. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  81. switch (m.Msg)
  82. {
  83. case WM_NCHITTEST:
  84. base.WndProc(ref m);
  85. if ((int)m.Result == HTCLIENT)
  86. m.Result = (IntPtr)HTCAPTION;
  87. return;
  88. }
  89. //拦截双击标题栏、移动窗体的系统消息
  90. if (m.Msg != 0xA3)
  91. {
  92. base.WndProc(ref m);
  93. }
  94. }
  95. #endregion
  96. #region 新增 修改
  97. private void save_Click(object sender, EventArgs e)
  98. {
  99. //if (txtPickingNO.Text.Trim() == "" || txtWHCode.Text.Trim() == "" || txtCode.Text.Trim() == "" || txtiQuantity.Text.Trim() == "" )
  100. //if (txtPickingNO.Text.Trim() == "" || txtWHCode.Text.Trim() == "" || txtOutCategory.Text.Trim() == "")
  101. //{
  102. // ICSBaseSimpleCode.AppshowMessageBox("请输入退料单号、仓库、出库类别内容!");
  103. // return;
  104. //}
  105. for (int i = 0; i < grdDetail.RowCount; i++)
  106. {
  107. string PickingNO = string.Empty;
  108. PickingNO = grdDetail.GetRowCellValue(i, colPickingNO).ToString();
  109. if (string.IsNullOrWhiteSpace(PickingNO))
  110. {
  111. ICSBaseSimpleCode.AppshowMessageBox("请添加字表行信息!");
  112. return;
  113. }
  114. }
  115. entity.ID = guid;
  116. entity.VouchCode = txtPickingNO.Text.Trim();
  117. entity.MUSER = AppConfig.UserCode;
  118. entity.MUSERName = AppConfig.UserName;
  119. entity.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  120. entity.WorkPoint = AppConfig.WorkPointCode;
  121. entity.EATTRIBUTE1 = null;
  122. entity.CreateTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  123. entity.CreateUSER = AppConfig.UserName;
  124. entity.IsPickingOrBack = 3;
  125. entity.IsMROItem = this.cboIsMROItem.Checked; //是否MRO物料
  126. entity.WHCode = txtWHCode.Text.Trim(); //仓库
  127. entity.OutCategory = txtOutCategory.Text.Trim();//出库类别
  128. try
  129. {
  130. guid = ICSPickingBLL.Add(entity, AppConfig.AppConnectString);
  131. this.Close();
  132. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  133. }
  134. catch (Exception ex)
  135. {
  136. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  137. }
  138. }
  139. #endregion
  140. #region 取消
  141. private void can_Click(object sender, EventArgs e)
  142. {
  143. this.Close();
  144. }
  145. #endregion
  146. #region 页面加载
  147. private void FormICSINVENTORYEditAdd_Load(object sender, EventArgs e)
  148. {
  149. if (guid != "")
  150. {
  151. lblTitle.Text = "退料单维护";
  152. txtPickingNO.Properties.ReadOnly = true;
  153. txtWHCode.Properties.ReadOnly = true;
  154. entity = ICSPickingBLL.SearchInfoByID(guid, AppConfig.AppConnectString);
  155. txtPickingNO.Text = entity.VouchCode;
  156. txtWHCode.Text = entity.WHCode;
  157. txtMUSERName.Text = AppConfig.UserName;
  158. txtMTIME.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  159. txtOutCategory.Text = entity.OutCategory;
  160. cboIsMROItem.Checked = entity.IsMROItem;
  161. txtOutCategory.Properties.ReadOnly = true;
  162. cboIsMROItem.Enabled = false;
  163. //cboIsMROItem
  164. txtMOCode.Properties.ReadOnly = true;
  165. txtMORow.Properties.ReadOnly = true;
  166. DataTable body = ICSPickingBLL.GetDetailList(entity.VouchCode);
  167. grvDetail.DataSource = body;
  168. grdDetail.BestFitColumns();
  169. txtMOCode.Text = "";
  170. txtMORow.Text = "";
  171. txtMoverCode.Text = "";
  172. txtDDNo.Text = "";
  173. txtCode.Text = "";
  174. txtcInvName.Text = "";
  175. txtiQuantity.Text = "";
  176. txtcInvStd.Text = "";
  177. txtINVUOM.Text = "";
  178. txtWeight.Text = "";
  179. txtDetailId.Text = "0";
  180. txtRemarks.Text = "";
  181. txtAllWeight.Text = "";
  182. }
  183. else
  184. {
  185. lblTitle.Text = "退料单维护";
  186. txtPickingNO.Properties.ReadOnly = true;
  187. txtPickingNO.Text = ICSPickingBLL.GetOutInNo(AppConfig.AppConnectString);
  188. txtMUSERName.Text = AppConfig.UserName;
  189. txtMTIME.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  190. string sqlYTMoverCode = @"SELECT '' as [零件号] ";
  191. DataTable _dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlYTMoverCode).Tables[0];
  192. txtMoverCode.Properties.ValueMember = "零件号";
  193. txtMoverCode.Properties.DisplayMember = "零件号";
  194. txtMoverCode.Properties.DataSource = _dt;
  195. txtMoverCode.Properties.NullText = "";//空时的值
  196. txtMoverCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  197. txtMoverCode.Properties.ValidateOnEnterKey = true;//回车确认
  198. txtMoverCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  199. txtMoverCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  200. //自适应宽度
  201. txtMoverCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  202. string sqlYTLineNo = @"SELECT '' as [生产订单行号号] ";
  203. DataTable _dt_ = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlYTLineNo).Tables[0];
  204. txtMORow.Properties.ValueMember = "生产订单行号号";
  205. txtMORow.Properties.DisplayMember = "生产订单行号号";
  206. txtMORow.Properties.DataSource = _dt;
  207. txtMORow.Properties.NullText = "";//空时的值
  208. txtMORow.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  209. txtMORow.Properties.ValidateOnEnterKey = true;//回车确认
  210. txtMORow.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  211. txtMORow.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  212. //自适应宽度
  213. txtMORow.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  214. #region
  215. //4.1. 当勾选‘是否MRO物料’后,系统判定:工单号,工号行号为灰色,不可选取;
  216. //4.2. 当勾选取消时,系统判定:出库类别,为灰色,不可选取;
  217. //if (cboIsMROItem.Checked == true)//是否MRO物料选中
  218. //{
  219. // txtMOCode.Properties.ReadOnly = true;
  220. // txtMORow.Properties.ReadOnly = true;
  221. //}
  222. //else
  223. //{
  224. // txtOutCategory.Properties.ReadOnly = true;
  225. //}
  226. #endregion
  227. }
  228. init();
  229. }
  230. #endregion
  231. #region 初始化查询条件
  232. private void init()
  233. {
  234. #region 存货编码
  235. string sql = "SELECT DISTINCT INVCODE AS [存货编码] ,INVNAME AS [存货名称] ,INVSTD AS [规格型号] FROM ICSINVENTORY WHERE WorkPoint='{0}' ORDER BY INVCODE ";
  236. sql = string.Format(sql, AppConfig.WorkPointCode);
  237. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  238. txtCode.Properties.ValueMember = "存货编码";
  239. txtCode.Properties.DisplayMember = "存货编码";
  240. txtCode.Properties.DataSource = dt;
  241. txtCode.Properties.NullText = "";//空时的值
  242. txtCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  243. txtCode.Properties.ValidateOnEnterKey = true;//回车确认
  244. txtCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  245. txtCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  246. //自适应宽度
  247. txtCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  248. #endregion
  249. #region 仓库
  250. string sql1 = "SELECT DISTINCT StorageCode AS [仓库编号] ,StorageName AS[仓库名称] FROM ICSStorage WHERE WorkPoint='{0}' ORDER BY StorageCode";
  251. sql1 = string.Format(sql1, AppConfig.WorkPointCode);
  252. DataTable dt1 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql1).Tables[0];
  253. txtWHCode.Properties.ValueMember = "仓库编号";
  254. txtWHCode.Properties.DisplayMember = "仓库编号";
  255. txtWHCode.Properties.DataSource = dt1;
  256. txtWHCode.Properties.NullText = "";//空时的值
  257. txtWHCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  258. txtWHCode.Properties.ValidateOnEnterKey = true;//回车确认
  259. txtWHCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  260. txtWHCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  261. //自适应宽度
  262. txtWHCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  263. #endregion
  264. #region 出库类型
  265. string sql2 = "SELECT DISTINCT cRdCode AS [出库类型编号],cRdName AS [出库类型名称] FROM ICSRdStyle WHERE WorkPoint = '{0}' AND bRdFlag=0 AND bRdEnd=1 ORDER BY cRdCode";
  266. sql2 = string.Format(sql2, AppConfig.WorkPointCode);
  267. DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0];
  268. txtOutCategory.Properties.ValueMember = "出库类型编号";
  269. txtOutCategory.Properties.DisplayMember = "出库类型编号";
  270. txtOutCategory.Properties.DataSource = dt2;
  271. txtOutCategory.Properties.NullText = "";//空时的值
  272. txtOutCategory.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  273. txtOutCategory.Properties.ValidateOnEnterKey = true;//回车确认
  274. txtOutCategory.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  275. txtOutCategory.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  276. //自适应宽度
  277. txtOutCategory.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  278. #endregion
  279. #region 工单号
  280. string sql3 = @"SELECT DISTINCT MOCODE 生产工单号, MOSEQ 行号, CUSNAME 订单类型, ITEMCODE 存货编码, INVNAME 存货名称, INVSTD 规格型号, MOVER 订单总批号
  281. FROM ICSMO A INNER JOIN ICSINVENTORY B ON A.ITEMCODE = B.INVCODE WHERE 1=1 ORDER BY MOCODE";
  282. sql2 = string.Format(sql3, AppConfig.WorkPointCode);
  283. DataTable dt3 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  284. txtMO.Properties.ValueMember = "生产工单号";
  285. txtMO.Properties.DisplayMember = "生产工单号";
  286. txtMO.Properties.DataSource = dt3;
  287. txtMO.Properties.NullText = "";//空时的值
  288. txtMO.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  289. txtMO.Properties.ValidateOnEnterKey = true;//回车确认
  290. txtMO.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  291. txtMO.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  292. //自适应宽度
  293. txtMO.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  294. #endregion
  295. #region 部门
  296. string sql4 = "SELECT DISTINCT cDepCode AS [部门编号],cDepName AS [部门名称] FROM ICSDepartment WHERE WorkPoint = '{0}' AND bDepEnd = 1 ORDER BY cDepCode";
  297. sql4 = string.Format(sql4, AppConfig.WorkPointCode);
  298. DataTable dt4 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql4).Tables[0];
  299. txtDept.Properties.ValueMember = "部门编号";
  300. txtDept.Properties.DisplayMember = "部门编号";
  301. txtDept.Properties.DataSource = dt4;
  302. txtDept.Properties.NullText = "";//空时的值
  303. txtDept.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  304. txtDept.Properties.ValidateOnEnterKey = true;//回车确认
  305. txtDept.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  306. txtDept.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  307. //自适应宽度
  308. txtDept.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  309. #endregion
  310. }
  311. #endregion
  312. #region 零件号
  313. // //txtMoverCode txtMOCode工单号 20191111新增 历史数据中零件号进行对比
  314. private void initMoverCode(string mocode)
  315. {
  316. //string sqlYTMoverCode = @"select distinct a.venderlotno as [零件号] from icsitemlot a where a.transno='{0}' ";
  317. //sqlYTMoverCode = string.Format(sqlYTMoverCode, mocode);
  318. //20200407新增
  319. string sqlYTMoverCode = @"SELECT DISTINCT b.VenderLotNO as [零件号]
  320. from ICSWareHouseLotInfoLog a
  321. left JOIN ICSITEMLot b on b.lotno=a.LotNO
  322. where a.TransNO='{0}' and a.TransLine='{1}' ";
  323. sqlYTMoverCode = string.Format(sqlYTMoverCode, mocode, txtMORow.Text);
  324. DataTable _dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlYTMoverCode).Tables[0];
  325. txtMoverCode.Properties.ValueMember = "零件号";
  326. txtMoverCode.Properties.DisplayMember = "零件号";
  327. txtMoverCode.Properties.DataSource = _dt;
  328. txtMoverCode.Properties.NullText = "";//空时的值
  329. txtMoverCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  330. txtMoverCode.Properties.ValidateOnEnterKey = true;//回车确认
  331. txtMoverCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  332. txtMoverCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  333. //自适应宽度
  334. txtMoverCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  335. txtMoverCode.EditValue = "";
  336. txtMoverCode.Text = "";
  337. //if (txtMOCode.Text == "")
  338. //{
  339. //}
  340. if (mocode == "")
  341. {
  342. }
  343. if (_dt.Rows.Count > 0)
  344. {
  345. //默认选择第一项
  346. txtMoverCode.EditValue = _dt.Rows[0][0].ToString().Trim();
  347. }
  348. }
  349. #endregion
  350. #region 工单号
  351. private void txtMOCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  352. {
  353. string sql = @" SELECT DISTINCT MOCODE AS [工单号],MOSEQ AS [生产订单行号],ITEMCODE AS [料品编码] FROM ICSMO ";
  354. DataTable data = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql).Tables[0];
  355. FormDataRefer reForm = new FormDataRefer();
  356. reForm.FormTitle = "工单信息";
  357. reForm.DataSource = data;
  358. reForm.MSelectFlag = false;
  359. reForm.RowIndexWidth = 35;
  360. reForm.Width = 600;
  361. reForm.FormHeight = 900;
  362. if (reForm.ShowDialog() == DialogResult.OK)
  363. {
  364. foreach (DataRow dr in reForm.ReturnData.Rows)
  365. {
  366. txtMOCode.Text = dr["生产订单号"].ToString();
  367. }
  368. }
  369. //if (data != null&&data.Rows.Count>0) {
  370. // txtMORow.Text = data.Rows[0]["生产订单行号"].ToString();
  371. // txtMoverCode.Text = data.Rows[0]["苏船工号"].ToString();
  372. //}
  373. initMoverCode(txtMOCode.Text);
  374. }
  375. #endregion
  376. //#region 库房
  377. //private void txtWHCode_EditValueChanged(object sender, EventArgs e)
  378. //{
  379. // string sql = "SELECT DISTINCT StorageCode AS [仓库编号] FROM ICSStorage WHERE WorkPoint='{0}' ORDER BY StorageCode";
  380. // sql = string.Format(sql, AppConfig.WorkPointCode);
  381. // DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  382. // txtWHCode.Properties.ValueMember = "行号";
  383. // txtWHCode.Properties.DisplayMember = "行号";
  384. // txtWHCode.Properties.DataSource = dt;
  385. // txtWHCode.Properties.NullText = "";//空时的值
  386. // txtWHCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  387. // txtWHCode.Properties.ValidateOnEnterKey = true;//回车确认
  388. // txtWHCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  389. // txtWHCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  390. // //自适应宽度
  391. // txtWHCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  392. //}
  393. //#endregion
  394. #region 行号
  395. private void txtMORow_EditValueChanged(object sender, EventArgs e)
  396. {
  397. string MOCODE = txtMOCode.EditValue.ToString();
  398. //string sql = "SELECT DISTINCT MOSEQ AS [行号] FROM ICSMO WHERE MOCODE='{0}' ORDER BY MOSEQ";
  399. string sql = "SELECT MOSEQ AS [行号] FROM ICSMO WHERE MOCODE = '{0}' ORDER BY CAST (MOSEQ AS INT)";
  400. sql = string.Format(sql, MOCODE);
  401. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  402. txtMORow.Properties.ValueMember = "行号";
  403. txtMORow.Properties.DisplayMember = "行号";
  404. txtMORow.Properties.DataSource = dt;
  405. txtMORow.Properties.NullText = "";//空时的值
  406. txtMORow.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  407. txtMORow.Properties.ValidateOnEnterKey = true;//回车确认
  408. txtMORow.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  409. txtMORow.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  410. //自适应宽度
  411. txtMORow.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  412. txtMORow.EditValue = "";
  413. txtMoverCode.Text = "";
  414. if (MOCODE == "")
  415. {
  416. //txtMoverCode.Properties.ReadOnly = false;
  417. }
  418. else
  419. {
  420. //txtMoverCode.Properties.ReadOnly = true;
  421. }
  422. //DataTable dt_temp = (DataTable)glue.Properties.DataSource;
  423. //if (dt_temp.Rows.Count > 0)
  424. if (dt.Rows.Count > 0)
  425. {
  426. //默认选择第一项
  427. txtMORow.EditValue = dt.Rows[0][0].ToString().Trim();
  428. }
  429. }
  430. #endregion
  431. /// <summary>
  432. /// 退料单保存
  433. /// </summary>
  434. /// <param name="sender"></param>
  435. /// <param name="e"></param>
  436. private void btnSaveDetail_Click(object sender, EventArgs e)
  437. {
  438. try
  439. {
  440. //20190911新增一个单据只能保存一个是否MRO物料
  441. string sqlIsMRO = @" SELECT
  442. j.IsMROItem,
  443. a.MoveType
  444. FROM
  445. ICSMaterialPick a
  446. LEFT JOIN ICSMaterial j ON a.VouchCode = j.VouchCode
  447. WHERE
  448. a.VouchCode = '{0}'
  449. AND a.WorkPoint = '" + AppConfig.WorkPointCode + "' ";
  450. sqlIsMRO = string.Format(sqlIsMRO, this.txtPickingNO.Text);
  451. DataTable dtIsMRO = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqlIsMRO).Tables[0];
  452. if (dtIsMRO != null && dtIsMRO.Rows.Count > 0)
  453. {
  454. bool _IsMRO = bool.Parse(dtIsMRO.Rows[0][0].ToString());
  455. if (_IsMRO != this.cboIsMROItem.Checked)
  456. {
  457. ICSBaseSimpleCode.AppshowMessageBox("一张退料单不能即出现MRO物料又出现非MRO物料!");
  458. return;
  459. }
  460. }
  461. if (txtWHCode.Text == "")
  462. {
  463. ICSBaseSimpleCode.AppshowMessageBox("请选择仓库!");
  464. return;
  465. }
  466. if (txtCode.Text == "")
  467. {
  468. ICSBaseSimpleCode.AppshowMessageBox("存货编码不能为空");
  469. return;
  470. }
  471. if (txtiQuantity.Text == "" || Convert.ToDecimal(txtiQuantity.Text) == 0)
  472. {
  473. ICSBaseSimpleCode.AppshowMessageBox("数量不能为空");
  474. return;
  475. }
  476. if (this.cboIsMROItem.Checked == true)
  477. {
  478. if (this.txtOutCategory.Text == "")
  479. {
  480. ICSBaseSimpleCode.AppshowMessageBox("入库类别不能为空");
  481. return;
  482. }
  483. }
  484. //判断,如果存货编码参数bInvBatch(是否批次管理)为打钩状态,那么零件号不能为空,需报错;
  485. //如果bInvBatch(是否批次管理)未打钩,零件号填了数值,那么也需要报错;
  486. if (true)
  487. {
  488. if (cboIsMROItem.Checked)
  489. {
  490. string sql = @" SELECT INVCONTROLTYPE FROM ICSINVENTORY a WHERE INVCODE='" + this.txtCode.Text + "' ";
  491. sql = string.Format(sql);
  492. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  493. if (dt != null && dt.Rows.Count > 0)
  494. {
  495. bool IsbInvBatch = bool.Parse(dt.Rows[0][0].ToString());
  496. if (IsbInvBatch)
  497. {
  498. if (txtMROBatch.Text == "")
  499. {
  500. ICSBaseSimpleCode.AppshowMessageBox("MRO批号不能为空");
  501. return;
  502. }
  503. }
  504. else
  505. {
  506. if (txtMROBatch.Text != "")
  507. {
  508. ICSBaseSimpleCode.AppshowMessageBox("MRO批号需要为空,不能维护");
  509. return;
  510. }
  511. }
  512. }
  513. else
  514. {
  515. ICSBaseSimpleCode.AppshowMessageBox("物料表中没有该物料,不能进行保存");
  516. return;
  517. }
  518. }
  519. else
  520. {
  521. string sql = @" SELECT INVCONTROLTYPE FROM ICSINVENTORY a WHERE INVCODE='" + this.txtCode.Text + "' ";
  522. sql = string.Format(sql);
  523. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  524. if (dt != null && dt.Rows.Count > 0)
  525. {
  526. bool IsbInvBatch = bool.Parse(dt.Rows[0][0].ToString());
  527. if (IsbInvBatch)
  528. {
  529. if (txtMoverCode.Text == "")
  530. {
  531. ICSBaseSimpleCode.AppshowMessageBox("零件号不能为空");
  532. return;
  533. }
  534. }
  535. else
  536. {
  537. if (txtMoverCode.Text != "")
  538. {
  539. ICSBaseSimpleCode.AppshowMessageBox("零件号需要为空,不能维护");
  540. return;
  541. }
  542. }
  543. }
  544. else
  545. {
  546. ICSBaseSimpleCode.AppshowMessageBox("物料表中没有该物料,不能进行保存");
  547. return;
  548. }
  549. }
  550. }
  551. #region 验证退料数量是否大于领料数量 20200413
  552. if (cboIsMROItem.Checked == false)
  553. {
  554. //工单领料数量
  555. #region delete by summer 2020.04.16
  556. // string sql = @"
  557. //SELECT ISNULL(c.HasQuantity, 0) HasQuantity FROM ICSMO a
  558. //INNER JOIN ICSMOBOM b ON a.MOCODE=b.MOCODE
  559. //INNER JOIN ICSMOPickLog c ON B.MOCODE=C.MOCODE AND B.SEQ=C.MOSEQ and B.MOBOMLINE=C.SEQ
  560. //WHERE b.MOCODE = '{0}'
  561. //AND b.SEQ = '{1}'
  562. //AND b.MOBITEMCODE = '{2}'
  563. //AND a.MOVER='{3}' ";
  564. #endregion
  565. #region delete by summer 2020.07.04
  566. // string sql = @"
  567. //SELECT ISNULL(c.HasQuantity, 0) HasQuantity FROM ICSMO A
  568. //INNER JOIN ICSMOBOM b ON a.MOCODE=b.MOCODE AND A.MOSEQ = B.SEQ
  569. //INNER JOIN ICSMOPickLog c ON B.MOCODE=C.MOCODE AND B.SEQ=C.MOSEQ and B.MOBOMLINE=C.SEQ
  570. //INNER JOIN ICSWareHouseLotInfoLog D ON D.TransNO = C.MOCODE AND D.TransLine = C.MOSEQ
  571. //INNER JOIN ICSITEMLot E ON D.LotNO = E.LotNO
  572. //WHERE b.MOCODE = '{0}' AND b.SEQ = '{1}' AND b.MOBITEMCODE = '{2}' AND E.VenderLotNO = '{3}' ";
  573. // //sql = string.Format(sql, this.txtMO.EditValue.ToString(), this.txtMORow.Text, this.txtCode.Text, this.txtMoverCode.Text);
  574. #endregion
  575. string sql = @"
  576. SELECT ISNULL(c.HasQuantity, 0) HasQuantity FROM ICSMO A INNER JOIN ICSMOBOM b ON a.MOCODE=b.MOCODE AND A.MOSEQ = B.SEQ
  577. INNER JOIN ICSMOPickLog c ON B.MOCODE=C.MOCODE AND B.SEQ=C.MOSEQ and B.MOBOMLINE=C.SEQ WHERE b.MOCODE = '{0}' AND b.SEQ = '{1}' AND B.MOBITEMCODE = '{2}' ";
  578. sql = string.Format(sql, this.txtMO.EditValue.ToString(), this.txtMORow.Text, this.txtCode.Text);
  579. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  580. Decimal Qty = 0;
  581. if (dt != null && dt.Rows.Count > 0)
  582. {
  583. foreach (DataRow item in dt.Rows)
  584. {
  585. Qty += Decimal.Parse(item["HasQuantity"].ToString());
  586. }
  587. }
  588. #region 原逻辑 delete by summer 2021.03.01
  589. // string oldTLSql = string.Empty;
  590. // if (!string.IsNullOrWhiteSpace(this.txtMoverCode.Text))
  591. // {
  592. // oldTLSql = @"SELECT Quantity FROM ICSMaterialPick
  593. // WHERE MOCode='{0}' AND MORow='{1}' AND SubInvCode='{2}' AND MoveType='退料' AND VoucherNO='{3}' ";
  594. // oldTLSql = string.Format(oldTLSql, this.txtMO.EditValue.ToString(), this.txtMORow.Text, this.txtCode.Text, this.txtMoverCode.Text);
  595. // }
  596. // else
  597. // {
  598. // oldTLSql = @"SELECT Quantity FROM ICSMaterialPick
  599. // WHERE MOCode='{0}' AND MORow='{1}' AND SubInvCode='{2}' AND MoveType='退料' ";
  600. // oldTLSql = string.Format(oldTLSql, this.txtMO.EditValue.ToString(), this.txtMORow.Text, this.txtCode.Text);
  601. // }
  602. // //历史退料信息
  603. // DataTable OldTLdt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, oldTLSql).Tables[0];
  604. // Decimal OldTLKeyQty = 0;
  605. // if (OldTLdt != null && OldTLdt.Rows.Count > 0)
  606. // {
  607. // foreach (DataRow item in OldTLdt.Rows)
  608. // {
  609. // OldTLKeyQty += Decimal.Parse(item["Quantity"].ToString());
  610. // }
  611. // }
  612. // Decimal KeyQty = 0;
  613. // KeyQty = Decimal.Parse(this.txtiQuantity.Text);
  614. // if (KeyQty + OldTLKeyQty > Qty)
  615. // {
  616. // //string msg = string.Empty;
  617. // //msg = "历史退料单数量+当前维护退料单数量>历史领料单数量";
  618. // ICSBaseSimpleCode.AppshowMessageBox("退料单数量不能大于领料单数量");
  619. // return;
  620. // }
  621. #endregion
  622. Decimal KeyQty = 0;
  623. KeyQty = Decimal.Parse(this.txtiQuantity.Text);
  624. if (KeyQty > Qty)
  625. {
  626. ICSBaseSimpleCode.AppshowMessageBox("退料单数量不能大于领料单数量");
  627. return;
  628. }
  629. }
  630. #endregion
  631. }
  632. catch (Exception ex)
  633. {
  634. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  635. return;
  636. }
  637. try
  638. {
  639. FormICSPickingModel Picking = new FormICSPickingModel();
  640. Picking.ID = guid;
  641. Picking.VouchCode = txtPickingNO.Text.Trim();
  642. //Picking.StorageID = txtStorageID.Text.Trim();
  643. Picking.MUSER = AppConfig.UserId;
  644. Picking.MUSERName = AppConfig.UserName;
  645. Picking.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  646. Picking.WorkPoint = AppConfig.WorkPointCode;
  647. Picking.CreateTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  648. Picking.CreateUSER = AppConfig.UserName;
  649. Picking.IsMROItem = cboIsMROItem.Checked;
  650. Picking.IsPickingOrBack = 3;
  651. Picking.OutCategory = txtOutCategory.Text;
  652. Picking.FormICSPickingDetail = new List<FormICSPickingDetailModel>();
  653. if (string.IsNullOrWhiteSpace(txtirowno.Text))
  654. {
  655. txtirowno.Text = ICSPickingBLL.GetPickingRowNo(guid, AppConfig.AppConnectString);//入库单行号
  656. }
  657. FormICSPickingDetailModel PickingDetail = new FormICSPickingDetailModel();
  658. bool detailIsID = false;
  659. if (txtDetailId.Text == "")
  660. {
  661. detailIsID = true;
  662. PickingDetail.ID = "0";//领料单明细ID
  663. }
  664. else
  665. {
  666. PickingDetail.ID = txtDetailId.Text; //领料单ID
  667. }
  668. PickingDetail.VoucherNO = txtMoverCode.EditValue.ToString();//批次号ZM
  669. //PickingDetail.VoucherNO = txtMoverCode.Text.Trim();//批次号ZM
  670. //20200407新增 关于MRO批号,要手写
  671. if (!string.IsNullOrWhiteSpace(this.txtMROBatch.Text))
  672. {
  673. PickingDetail.VoucherNO = txtMROBatch.Text.Trim();//MRO批号
  674. }
  675. PickingDetail.VouchCode = txtPickingNO.Text.Trim();//退料单号
  676. string strtime = DateTime.Now.ToString("yyyyMMdd");
  677. string sql = @"SELECT CONVERT(INT,RIGHT(MAX(A.VouchRow),4)) AS MAXLOT FROM ICSMaterialPick A WHERE A.VouchCode ='{0}'";
  678. sql = string.Format(sql, PickingDetail.VouchCode);//取已存的transNo后四位
  679. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  680. if (dt == null || dt.Rows.Count <= 0)
  681. {
  682. VRow = "0001";
  683. }
  684. else if (dt.Rows[0][0] == null || dt.Rows[0][0].ToString() == "")
  685. {
  686. VRow = "0001";
  687. }
  688. else
  689. {
  690. VRow = (Convert.ToInt32(dt.Rows[0][0]) + 1).ToString().PadLeft(4, '0');//自动生成transNo
  691. }
  692. //PickingDetail.
  693. PickingDetail.VouchRow = VRow; //入库单行号
  694. PickingDetail.SubInvCode = txtCode.Text.Trim();//物料代码
  695. PickingDetail.WHCode = txtWHCode.Text.Trim();//仓库
  696. PickingDetail.MOCode = txtMO.EditValue.ToString();//工单号
  697. //PickingDetail.MOCode = txtMOCode.Text.Trim();//工单号
  698. PickingDetail.Dept = txtDept.EditValue.ToString();
  699. if (!string.IsNullOrWhiteSpace(txtAllWeight.Text))
  700. {
  701. PickingDetail.SupplyQuantity = Decimal.Parse(txtAllWeight.Text.Trim());//总单重
  702. }
  703. else
  704. {
  705. PickingDetail.SupplyQuantity = 0;
  706. }
  707. if (txtMO.EditValue == null)
  708. //if (txtMOCode.Text == "")
  709. {
  710. PickingDetail.MORow = "";
  711. }
  712. else
  713. {
  714. PickingDetail.MORow = txtMORow.Text.Trim();//行号
  715. }
  716. PickingDetail.Quantity = Convert.ToDecimal(txtiQuantity.Text.Trim());//应退数量
  717. //PickingDetail.HasQuantity = Convert.ToDecimal(txtiQuantity.Text.Trim());//已退数量
  718. PickingDetail.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");//领料时间
  719. PickingDetail.DDNo = this.txtDDNo.Text.Trim();
  720. PickingDetail.Remarks = this.txtRemarks.Text.Trim();
  721. Picking.FormICSPickingDetail.Add(PickingDetail);
  722. string id = ICSPickingBLL.AddAndEditDetail(Picking, AppConfig.AppConnectString);
  723. if (guid == "" && string.IsNullOrWhiteSpace(guid))
  724. {
  725. guid = id;
  726. }
  727. if (string.IsNullOrWhiteSpace(txtDetailId.Text.Trim()))
  728. {
  729. txtDetailId.Text = "";
  730. txtirowno.Text = "";
  731. ICSBaseSimpleCode.AppshowMessageBox(0, "新增成功");
  732. txtWHCode.Text = "";
  733. txtOutCategory.Text = "";
  734. this.cboIsMROItem.Checked = false;
  735. }
  736. else
  737. {
  738. ICSBaseSimpleCode.AppshowMessageBox(0, "维护成功");
  739. txtWHCode.Text = "";
  740. txtCode.Text = "";
  741. txtcInvName.Text = "";
  742. txtcInvStd.Text = "";
  743. txtINVUOM.Text = "";
  744. txtiQuantity.Text = "";
  745. txtMOCode.Text = "";
  746. txtMORow.Text = "";
  747. txtDetailId.Text = "0";
  748. txtDDNo.Text = "";
  749. txtRemarks.Text = "";
  750. //20200407新增
  751. txtMROBatch.Text = "";
  752. }
  753. FormICSINVENTORYEditAdd_Load(null, null);
  754. }
  755. catch (Exception ex)
  756. {
  757. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  758. return;
  759. }
  760. }
  761. private void btnDelDetail_Click(object sender, EventArgs e)
  762. {
  763. grdDetail.PostEditor();
  764. this.Validate();
  765. if (grdDetail.RowCount == 0)
  766. return;
  767. List<string> guidList = new List<string>();
  768. List<string> codeList = new List<string>();
  769. for (int i = 0; i < grdDetail.RowCount; i++)
  770. {
  771. if (grdDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  772. {
  773. guidList.Add(grdDetail.GetRowCellValue(i, colID).ToString());
  774. }
  775. }
  776. if (guidList.Count == 0)
  777. {
  778. ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
  779. return;
  780. }
  781. #region 20190920ZM新增
  782. string HasQuantityMsg = string.Empty;
  783. foreach (var item in guidList)
  784. {
  785. string VouchCode = string.Empty;
  786. string VouchRow = string.Empty;
  787. string sql = @"SELECT VouchCode,VouchRow FROM ICSMaterialPick WHERE ID='" + item + "' AND HasQuantity>0";
  788. sql = string.Format(sql);
  789. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  790. if (dt != null && dt.Rows.Count > 0)
  791. {
  792. VouchCode = dt.Rows[0]["VouchCode"].ToString();
  793. VouchRow = dt.Rows[0]["VouchRow"].ToString();
  794. HasQuantityMsg += "单号:" + VouchCode + " 行号:" + VouchRow + " 已有退料不能删除该行!";
  795. }
  796. }
  797. if (!string.IsNullOrWhiteSpace(HasQuantityMsg))
  798. {
  799. ICSBaseSimpleCode.AppshowMessageBox(HasQuantityMsg);
  800. return;
  801. }
  802. #endregion
  803. if (ICSBaseSimpleCode.AppshowMessageBoxRepose("确定删除该领料信息吗?删除后无法恢复,确定吗?") != DialogResult.OK)
  804. return;
  805. try
  806. {
  807. ICSPickingBLL.deleteDetailInfo(guidList, AppConfig.AppConnectString);
  808. txtirowno.Text = "";
  809. txtDetailId.Text = "";
  810. ICSBaseSimpleCode.AppshowMessageBox(0, "删除成功");
  811. FormICSINVENTORYEditAdd_Load(null, null);
  812. }
  813. catch (Exception ex)
  814. {
  815. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  816. }
  817. }
  818. private void btnUpdateDetail_Click(object sender, EventArgs e)
  819. {
  820. int count = 0;
  821. for (int i = 0; i < grdDetail.RowCount; i++)
  822. {
  823. if (grdDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  824. {
  825. count++;
  826. }
  827. }
  828. if (count != 1)
  829. {
  830. ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行编辑!!!");
  831. return;
  832. }
  833. try
  834. {
  835. FormICSPickingModel Picking = new FormICSPickingModel();
  836. //Picking.ID = guid;
  837. Picking.VouchCode = txtPickingNO.Text.Trim();
  838. //Picking.StorageID = txtStorageID.Text.Trim();
  839. Picking.FormICSPickingDetail = new List<FormICSPickingDetailModel>();
  840. FormICSPickingDetailModel PickingDetail = new FormICSPickingDetailModel();
  841. //PickingDetail.DetailID = txtDetailId.Text.Trim();//领料单明细ID
  842. //PickingDetail.PickingID = guid;//领料单ID
  843. PickingDetail.VouchCode = txtPickingNO.Text.Trim();//退料单号
  844. PickingDetail.SubInvCode = txtCode.Text.Trim();//物料代码
  845. PickingDetail.WHCode = txtWHCode.Text.Trim();//仓库
  846. if (txtMOCode.Text == "")
  847. {
  848. PickingDetail.MOCode = "";
  849. PickingDetail.MORow = "";
  850. }
  851. else
  852. {
  853. PickingDetail.MOCode = txtMOCode.Text.Trim();//工单号
  854. PickingDetail.MORow = txtMORow.Text.Trim();//行号
  855. }
  856. PickingDetail.Quantity = Convert.ToDecimal(txtiQuantity.Text.Trim());//应退数量
  857. //PickingDetail.HasQuantity = Convert.ToDecimal(txtiQuantity.Text.Trim());//已退数量
  858. //PickingDetail.CreateTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  859. //PickingDetail.CreateUSER = AppConfig.UserName;
  860. Picking.FormICSPickingDetail.Add(PickingDetail);
  861. string id = ICSPickingBLL.AddAndEditDetail(Picking, AppConfig.AppConnectString);
  862. if (guid == "" && string.IsNullOrWhiteSpace(guid))
  863. {
  864. guid = Picking.VouchCode;
  865. }
  866. ICSBaseSimpleCode.AppshowMessageBox(0, "修改成功");
  867. FormICSINVENTORYEditAdd_Load(null, null);
  868. }
  869. catch (Exception ex)
  870. {
  871. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  872. return;
  873. }
  874. }
  875. private void grvDetail_DoubleClick(object sender, EventArgs e)
  876. {
  877. if (grdDetail.FocusedRowHandle < 0)
  878. {
  879. return;
  880. }
  881. for (int i = 0; i < grdDetail.RowCount; i++)
  882. {
  883. grdDetail.SetRowCellValue(i, colisSelect, "");
  884. }
  885. if (grdDetail.FocusedColumn == colisSelect)
  886. {
  887. if (grdDetail.GetRowCellValue(grdDetail.FocusedRowHandle, colisSelect).ToString() == "")
  888. {
  889. grdDetail.SetRowCellValue(grdDetail.FocusedRowHandle, colisSelect, "Y");
  890. }
  891. else
  892. {
  893. grdDetail.SetRowCellValue(grdDetail.FocusedRowHandle, colisSelect, "");
  894. }
  895. }
  896. string ID = "";
  897. for (int i = 0; i < grdDetail.RowCount; i++)
  898. {
  899. if (grdDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
  900. {
  901. ID = grdDetail.GetRowCellValue(i, colID).ToString();
  902. }
  903. }
  904. DataTable dt = ICSPickingBLL.GetDetailInfo(ID);
  905. foreach (DataRow dr in dt.Rows)
  906. {
  907. txtPickingNO.Text = dr["VouchCode"].ToString().Trim();
  908. txtMTIME.Text = dr["dDate"].ToString().Trim();
  909. txtMUSERName.Text = dr["cMaker"].ToString().Trim();
  910. txtWHCode.Text = dr["iWHCode"].ToString().Trim();
  911. txtCode.Text = dr["cInvCode"].ToString().Trim();
  912. txtcInvName.Text = dr["cInvName"].ToString().Trim();
  913. txtcInvStd.Text = dr["cInvStd"].ToString().Trim();
  914. txtINVUOM.Text = dr["cInvStd"].ToString().Trim();
  915. txtiQuantity.Text = dr["iQuantity"].ToString().Trim();
  916. txtINVUOM.Text = dr["INVUOM"].ToString().Trim();
  917. txtMOCode.Text = dr["MOCode"].ToString().Trim();
  918. txtMO.EditValue = dr["MOCode"].ToString().Trim();
  919. txtMORow.Text = dr["MORow"].ToString().Trim();
  920. txtDetailId.Text = dr["ID"].ToString().Trim();
  921. txtRemarks.Text = dr["Remarks"].ToString().Trim();
  922. txtMoverCode.Text = dr["VoucherNO"].ToString().Trim();
  923. txtDDNo.Text = dr["DDNo"].ToString().Trim();
  924. txtAllWeight.Text = dr["SupplyQuantity"].ToString().Trim();
  925. //20200407新增 关于界面上是否MRO勾选,将零件号赋值在不同的栏位上面
  926. if (cboIsMROItem.Checked == true)
  927. {
  928. txtMROBatch.Text = dr["VoucherNO"].ToString().Trim();
  929. }
  930. }
  931. }
  932. private void txtCode_EditValueChanged(object sender, EventArgs e)
  933. {
  934. try
  935. {
  936. string Code = txtCode.EditValue.ToString();
  937. string sql = @"select INVCODE as 存货编码, INVNAME as 存货名称,INVSTD as 规格型号,INVGROUP AS 单重, INVUOM as 单位
  938. from ICSINVENTORY WHERE INVCODE='{0}'";
  939. sql = string.Format(sql, Code);
  940. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  941. if (dt != null && dt.Rows.Count > 0)
  942. {
  943. txtcInvName.Text = dt.Rows[0]["存货名称"].ToString();
  944. txtcInvStd.Text = dt.Rows[0]["规格型号"].ToString();
  945. //txtcDepName.Text = dt.Rows[0]["生产部门"].ToString();
  946. txtINVUOM.Text = dt.Rows[0]["单位"].ToString();
  947. txtiQuantity.Text = "";
  948. txtWeight.Text = dt.Rows[0]["单重"].ToString();
  949. }
  950. }
  951. catch (Exception ex)
  952. {
  953. ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
  954. }
  955. }
  956. private void txtMORow_EditValueChanged_1(object sender, EventArgs e)
  957. {
  958. try
  959. {
  960. string Row = txtMORow.EditValue.ToString();
  961. string sql = @"select MOCODE ,MOSEQ ,MOVER from ICSMO WHERE MOCODE='{0}' and MOSEQ='{1}'";
  962. sql = string.Format(sql, txtMO.EditValue.ToString(), txtMORow.Text.Trim());
  963. //sql = string.Format(sql, txtMOCode.Text.Trim(), txtMORow.Text.Trim());
  964. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  965. if (dt != null && dt.Rows.Count > 0)
  966. {
  967. //txtMoverCode.Text = dt.Rows[0]["MOVER"].ToString();
  968. }
  969. #region
  970. #region by summer 2020-07-24
  971. ////20200413 关联领料单信息,没有领料的不需要显示
  972. ////old
  973. ////string sql1 = "SELECT MOCODE 工单号,SEQ 生产订单行号,MOBITEMCODE 存货编码 FROM ICSMOBOM WHERE MOCODE='{0}' and SEQ='{1}'";
  974. ////new
  975. //string sql1 = "SELECT a.MOBITEMCODE 存货编码 , INVNAME as 存货名称,INVSTD as 规格型号 FROM ICSMOBOM a " +
  976. // " INNER JOIN ICSMOPickLog c ON c.MOCODE=a.MOCODE AND C.MOSEQ = A.SEQ " + //AND b.MoveType='领料'
  977. // " INNER JOIN ICSINVENTORY d ON d.INVCODE=a.MOBITEMCODE " +
  978. // " WHERE a.MOCODE='{0}' and a.SEQ='{1}'";
  979. #endregion
  980. #region by summer 2020-07-24
  981. //20200413 关联领料单信息,没有领料的不需要显示
  982. //old
  983. //string sql1 = "SELECT MOCODE 工单号,SEQ 生产订单行号,MOBITEMCODE 存货编码 FROM ICSMOBOM WHERE MOCODE='{0}' and SEQ='{1}'";
  984. //new
  985. string sql1 = @"
  986. SELECT A.MOBITEMCODE AS , D.INVNAME AS ,INVSTD AS , A.MOCODE, A.SEQ FROM ICSMOBOM A
  987. INNER JOIN ICSMOPickLog C ON C.MOCODE = A.MOCODE AND C.MOSEQ = A.SEQ AND A.MOBOMLINE = C.SEQ
  988. INNER JOIN ICSINVENTORY D ON D.INVCODE = A.MOBITEMCODE WHERE A.MOCODE = '{0}' AND A.SEQ = '{1}'";
  989. #endregion
  990. sql1 = string.Format(sql1, txtMO.EditValue.ToString(), txtMORow.Text.Trim());
  991. DataTable dt1 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql1).Tables[0];
  992. txtCode.Properties.ValueMember = "存货编码";
  993. txtCode.Properties.DisplayMember = "存货编码";
  994. txtCode.Properties.DataSource = dt1;
  995. txtCode.Properties.NullText = "";//空时的值
  996. txtCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  997. txtCode.Properties.ValidateOnEnterKey = true;//回车确认
  998. txtCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  999. txtCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  1000. //自适应宽度
  1001. txtCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  1002. #endregion
  1003. //string sqlYTMoverCode = @"SELECT DISTINCT A.VenderLotNO as [零件号] FROM ICSITEMLot A where A.TransNO='{0}'";
  1004. //sqlYTMoverCode = string.Format(sqlYTMoverCode, txtMOCode.Text.Trim());
  1005. //20200407
  1006. string sqlYTMoverCode = @"SELECT DISTINCT b.VenderLotNO as [零件号]
  1007. from ICSWareHouseLotInfoLog a
  1008. left JOIN ICSITEMLot b on b.lotno=a.LotNO
  1009. where a.TransNO='{0}' and a.TransLine='{1}'";
  1010. sqlYTMoverCode = string.Format(sqlYTMoverCode, txtMO.EditValue.ToString(), txtMORow.Text);
  1011. DataTable _dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlYTMoverCode).Tables[0];
  1012. txtMoverCode.Properties.ValueMember = "零件号";
  1013. txtMoverCode.Properties.DisplayMember = "零件号";
  1014. txtMoverCode.Properties.DataSource = _dt;
  1015. txtMoverCode.Properties.NullText = "";//空时的值
  1016. txtMoverCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  1017. txtMoverCode.Properties.ValidateOnEnterKey = true;//回车确认
  1018. txtMoverCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  1019. txtMoverCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  1020. //自适应宽度
  1021. txtMoverCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  1022. if (_dt != null && _dt.Rows.Count > 0)
  1023. {
  1024. txtMoverCode.Text = _dt.Rows[0][0].ToString();
  1025. }
  1026. }
  1027. catch (Exception ex)
  1028. {
  1029. ICSBaseSimpleCode.AppshowMessageBox(ex.ToString());
  1030. }
  1031. }
  1032. private void txtcInvName_EditValueChanged(object sender, EventArgs e)
  1033. {
  1034. }
  1035. /// <summary>
  1036. /// 是否MRO物料选择事件
  1037. /// </summary>
  1038. /// <param name="sender"></param>
  1039. /// <param name="e"></param>
  1040. private void cboIsMROItem_CheckedChanged(object sender, EventArgs e)
  1041. {
  1042. //cboIsMROItem
  1043. if (this.cboIsMROItem.Checked == true)
  1044. {
  1045. //this.txtMOCode.Properties.ReadOnly = true;
  1046. //this.txtMORow.Properties.ReadOnly = true;
  1047. //this.txtOutCategory.Properties.ReadOnly = false;
  1048. this.txtOutCategory.Properties.ReadOnly = false;
  1049. this.txtMOCode.Properties.ReadOnly = true;
  1050. this.txtMOCode.Enabled = false;
  1051. this.txtMORow.Properties.ReadOnly = true;
  1052. //20200407新增
  1053. this.txtMROBatch.Enabled = true;
  1054. this.txtMROBatch.Properties.ReadOnly = false;
  1055. this.txtMoverCode.Properties.ReadOnly = true;
  1056. this.txtMoverCode.Enabled = false;
  1057. //20200608 summer 新增
  1058. txtMO.Enabled = false;
  1059. }
  1060. else
  1061. {
  1062. this.txtOutCategory.Properties.ReadOnly = true;
  1063. this.txtMOCode.Properties.ReadOnly = false;
  1064. this.txtMOCode.Enabled = true;
  1065. this.txtMORow.Properties.ReadOnly = false;
  1066. //20200407新增
  1067. this.txtMROBatch.Enabled = false;
  1068. this.txtMROBatch.Properties.ReadOnly = true;
  1069. this.txtMoverCode.Properties.ReadOnly = false;
  1070. this.txtMoverCode.Enabled = true;
  1071. //20200608 summer 新增
  1072. txtMO.Enabled = true;
  1073. }
  1074. }
  1075. private void txtMO_EditValueChanged(object sender, EventArgs e)
  1076. {
  1077. string MOCODE = txtMO.EditValue.ToString();
  1078. //string sql = "SELECT DISTINCT MOSEQ AS [行号] FROM ICSMO WHERE MOCODE='{0}' ORDER BY MOSEQ";
  1079. string sql = "SELECT MOSEQ AS [行号] FROM ICSMO WHERE MOCODE = '{0}' ORDER BY CAST (MOSEQ AS INT)";
  1080. sql = string.Format(sql, MOCODE);
  1081. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  1082. txtMORow.Properties.ValueMember = "行号";
  1083. txtMORow.Properties.DisplayMember = "行号";
  1084. txtMORow.Properties.DataSource = dt;
  1085. txtMORow.Properties.NullText = "";//空时的值
  1086. txtMORow.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  1087. txtMORow.Properties.ValidateOnEnterKey = true;//回车确认
  1088. txtMORow.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  1089. txtMORow.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  1090. //自适应宽度
  1091. txtMORow.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  1092. txtMORow.EditValue = "";
  1093. txtMoverCode.Text = "";
  1094. if (MOCODE == "")
  1095. {
  1096. //txtMoverCode.Properties.ReadOnly = false;
  1097. }
  1098. else
  1099. {
  1100. //txtMoverCode.Properties.ReadOnly = true;
  1101. }
  1102. //DataTable dt_temp = (DataTable)glue.Properties.DataSource;
  1103. //if (dt_temp.Rows.Count > 0)
  1104. if (dt.Rows.Count > 0)
  1105. {
  1106. //默认选择第一项
  1107. txtMORow.EditValue = dt.Rows[0][0].ToString().Trim();
  1108. }
  1109. initMoverCode(txtMO.EditValue.ToString());
  1110. }
  1111. //private void txtMoverCode_EditValueChanged(object sender, EventArgs e)
  1112. //{
  1113. // string MOCODE = txtMOCode.EditValue.ToString();
  1114. // string MORow = this.txtMORow.EditValue.ToString();
  1115. // //string sqlYTMoverCode = @"SELECT DISTINCT A.VenderLotNO as [零件号] FROM ICSITEMLot A where a.TransNO='{0}' and a.TransLine='{1}'";
  1116. // string sqlYTMoverCode = @"SELECT DISTINCT A.VenderLotNO as [零件号] FROM ICSITEMLot A ";
  1117. // sqlYTMoverCode = string.Format(sqlYTMoverCode, MOCODE, MORow);
  1118. // DataTable _dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlYTMoverCode).Tables[0];
  1119. // txtMoverCode.Properties.ValueMember = "零件号";
  1120. // txtMoverCode.Properties.DisplayMember = "零件号";
  1121. // txtMoverCode.Properties.DataSource = _dt;
  1122. // txtMoverCode.Properties.NullText = "";//空时的值
  1123. // txtMoverCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  1124. // txtMoverCode.Properties.ValidateOnEnterKey = true;//回车确认
  1125. // txtMoverCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  1126. // txtMoverCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  1127. // //自适应宽度
  1128. // txtMoverCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  1129. // txtMoverCode.EditValue = "";
  1130. // this.txtMOCode.Text = "";
  1131. // if (txtMOCode.Text == "")
  1132. // {
  1133. // }
  1134. // if (_dt.Rows.Count > 0)
  1135. // {
  1136. // //默认选择第一项
  1137. // txtMoverCode.EditValue = _dt.Rows[0][0].ToString().Trim();
  1138. // }
  1139. //}
  1140. //private void txtMoverCode_EditValueChanged(object sender, EventArgs e)
  1141. //{
  1142. // //string MOCODE = txtMOCode.EditValue.ToString();
  1143. // //string sql = "SELECT DISTINCT MOSEQ AS [行号] FROM ICSMO WHERE MOCODE='{0}' ORDER BY MOSEQ";
  1144. // //string MOCODE = txtMOCode.EditValue.ToString();
  1145. // string sqlYTMoverCode = @"SELECT DISTINCT A.VenderLotNO as [零件号] FROM ICSITEMLot A ";
  1146. // sqlYTMoverCode = string.Format(sqlYTMoverCode);
  1147. // DataTable _dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlYTMoverCode).Tables[0];
  1148. // txtMoverCode.Properties.ValueMember = "零件号";
  1149. // txtMoverCode.Properties.DisplayMember = "零件号";
  1150. // txtMoverCode.Properties.DataSource = _dt;
  1151. // txtMoverCode.Properties.NullText = "";//空时的值
  1152. // txtMoverCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  1153. // txtMoverCode.Properties.ValidateOnEnterKey = true;//回车确认
  1154. // txtMoverCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  1155. // txtMoverCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  1156. // //自适应宽度
  1157. // txtMoverCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  1158. // txtMoverCode.EditValue = "";
  1159. // this.txtMOCode.Text = "";
  1160. // if (txtMOCode.Text == "")
  1161. // {
  1162. // }
  1163. // if (_dt.Rows.Count > 0)
  1164. // {
  1165. // //默认选择第一项
  1166. // txtMoverCode.EditValue = _dt.Rows[0][0].ToString().Trim();
  1167. // }
  1168. //}
  1169. }
  1170. }