华恒Mes鼎捷代码
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.

199 lines
6.4 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.Linq;
  6. using System.Linq;
  7. using System.Drawing;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using DevExpress.XtraEditors;
  11. using DevExpress.XtraGrid.Views.BandedGrid;
  12. using DevExpress.XtraGrid.Columns;
  13. using DevExpress.XtraGrid;
  14. using System.IO;
  15. using System.Threading;
  16. using ICSSoft.Base.Language.Tool;
  17. using ICSSoft.Base.Config.AppConfig;
  18. using ICSSoft.Base.UserControl.MessageControl;
  19. using ICSSoft.Base.Config.DBHelper;
  20. using ICSSoft.Base.Report.Filter;
  21. using ICSSoft.Base.UserControl.FormControl;
  22. using ICSSoft.Base.Report.GridReport;
  23. using ICSSoft.Base.ReferForm.AppReferForm;
  24. using ICSSoft.Frame.Data.BLL;
  25. using ICSSoft.Frame.Data.Entity;
  26. namespace ICSSoft.Frame.APP
  27. {
  28. public partial class FormICSSBOMS : DevExpress.XtraEditors.XtraForm
  29. {
  30. string itemcode;
  31. string BOMVER = "";
  32. #region 构造函数
  33. public FormICSSBOMS()
  34. {
  35. InitializeComponent();
  36. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  37. this.WindowState = FormWindowState.Maximized;
  38. }
  39. #endregion
  40. #region 构造函数
  41. public FormICSSBOMS(string _itemcode)
  42. {
  43. itemcode = _itemcode;
  44. InitializeComponent();
  45. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  46. this.WindowState = FormWindowState.Maximized;
  47. }
  48. #endregion
  49. #region 退出
  50. private void btnClose_Click(object sender, EventArgs e)
  51. {
  52. AppConfig.CloseFormShow(this.Text);
  53. this.Close();
  54. }
  55. private void btnExit_Click(object sender, EventArgs e)
  56. {
  57. AppConfig.CloseFormShow(this.Text);
  58. this.Close();
  59. }
  60. #endregion
  61. #region 移动窗体
  62. private const int WM_NCHITTEST = 0x84;
  63. private const int HTCLIENT = 0x1;
  64. private const int HTCAPTION = 0x2;
  65. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  66. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  67. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  68. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  69. //重写窗体,使窗体可以不通过自带标题栏实现移动
  70. protected override void WndProc(ref Message m)
  71. {
  72. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  73. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  74. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  75. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  76. switch (m.Msg)
  77. {
  78. case WM_NCHITTEST:
  79. base.WndProc(ref m);
  80. if ((int)m.Result == HTCLIENT)
  81. m.Result = (IntPtr)HTCAPTION;
  82. return;
  83. }
  84. //拦截双击标题栏、移动窗体的系统消息
  85. if (m.Msg != 0xA3)
  86. {
  87. base.WndProc(ref m);
  88. }
  89. }
  90. #endregion
  91. #region 列表
  92. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  93. {
  94. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  95. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  96. }
  97. #endregion
  98. private void FormDCT_Load(object sender, EventArgs e)
  99. {
  100. string sql = @"SELECT [SBITEMID]
  101. ,[SBSITEMID]
  102. ,[SBITEMCODE]
  103. ,[SBSITEMCODE]
  104. ,[SBITEMQTY]
  105. ,[SBITEMEFFTIME]
  106. ,[SBITEMINVTIME]
  107. ,[SBWH]
  108. ,[SEQ]
  109. ,[SBITEMECN]
  110. ,[SBITEMNAME]
  111. ,[SBITEMDESC]
  112. ,[SBITEMSTATUS]
  113. ,[SBITEMLOCATION]
  114. ,[SBITEMUOM]
  115. ,[SBITEMVER]
  116. ,[SBITEMCONTYPE]
  117. ,[SBPITEMCODE]
  118. ,[ALPGR]
  119. ,a.[MUSER]
  120. ,a.[MUSERName]
  121. ,a.[MTIME]
  122. ,a.[WorkPoint]
  123. ,[SBOMVER]
  124. ,[SBFACTORY]
  125. ,[SBUSAGE]
  126. ,[SBITEMPROJECT]
  127. ,[SBITEMSEQ]
  128. ,[LOCATION]
  129. ,a.[EATTRIBUTE1]
  130. ,b.INVCODE
  131. ,b.INVNAME
  132. ,b.INVDESC
  133. ,INVTYPE
  134. FROM [ICSSBOM] a INNER JOIN dbo.ICSINVENTORY b ON a.ITEMCODE=b.invcode and a.workpoint=b.workpoint where b.invcode='{0}' and b.workpoint='{1}'";
  135. if (BOMVER != "")
  136. {
  137. sql = string.Format(sql, itemcode,AppConfig.WorkPointCode) + "and a.SBOMVER='" + BOMVER + "'";
  138. }
  139. else {
  140. sql = string.Format(sql, itemcode, AppConfig.WorkPointCode);
  141. }
  142. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString,CommandType.Text,sql).Tables[0];
  143. if(dt.Rows.Count!=0){
  144. txtinvcode.Text = dt.Rows[0]["INVCODE"].ToString();
  145. txtinvname.Text = dt.Rows[0]["INVNAME"].ToString();
  146. txtinvtype.Text = dt.Rows[0]["INVTYPE"].ToString();
  147. }
  148. grdDetail.DataSource = dt;
  149. if (BOMVER == "") bindCbox();
  150. grvDetail.BestFitColumns();
  151. }
  152. private void bindCbox()
  153. {
  154. try {
  155. string sql = @"SELECT DISTINCT SBOMVER FROM dbo.ICSSBOM WHERE ITEMCODE='{0}' and workpoint='{1}'";
  156. sql = string.Format(sql, itemcode,AppConfig.WorkPointCode);
  157. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString,CommandType.Text,sql).Tables[0];
  158. comboBox1.DataSource = dt;
  159. comboBox1.DisplayMember = "SBOMVER";
  160. }catch(Exception ex){
  161. ICSBaseSimpleCode.AppshowMessageBox("可选BOM数据加载失败!!");
  162. }
  163. }
  164. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  165. {
  166. BOMVER = ((DataRowView)comboBox1.SelectedValue).Row["SBOMVER"].ToString();
  167. FormDCT_Load(sender, e);
  168. }
  169. }
  170. }