华恒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.

279 lines
10 KiB

5 months ago
  1. using System;
  2. using System.Data;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using ICSSoft.Base.Config.AppConfig;
  6. using ICSSoft.Base.Config.DBHelper;
  7. namespace ICSSoft.Frame.APP
  8. {
  9. public partial class FormICSMO2SendSearch : DevExpress.XtraEditors.XtraForm
  10. {
  11. private string sqltxt = "";
  12. private string sqlconn = "";
  13. String guid = AppConfig.GetGuid();
  14. private DataTable dataSource = null;
  15. #region 构造函数
  16. public FormICSMO2SendSearch()
  17. {
  18. InitializeComponent();
  19. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  20. this.WindowState = FormWindowState.Maximized;
  21. textBoxCode.Text = AppConfig.UserCode;
  22. textBoxName.Text = AppConfig.UserName;
  23. }
  24. #endregion
  25. #region 退出
  26. private void btnClose_Click(object sender, EventArgs e)
  27. {
  28. AppConfig.CloseFormShow(this.Text);
  29. this.Close();
  30. }
  31. private void btnExit_Click(object sender, EventArgs e)
  32. {
  33. AppConfig.CloseFormShow(this.Text);
  34. this.Close();
  35. }
  36. #endregion
  37. #region 移动窗体
  38. private const int WM_NCHITTEST = 0x84;
  39. private const int HTCLIENT = 0x1;
  40. private const int HTCAPTION = 0x2;
  41. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  42. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  43. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  44. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  45. //重写窗体,使窗体可以不通过自带标题栏实现移动
  46. protected override void WndProc(ref Message m)
  47. {
  48. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  49. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  50. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  51. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  52. switch (m.Msg)
  53. {
  54. case WM_NCHITTEST:
  55. base.WndProc(ref m);
  56. if ((int)m.Result == HTCLIENT)
  57. m.Result = (IntPtr)HTCAPTION;
  58. return;
  59. }
  60. //拦截双击标题栏、移动窗体的系统消息
  61. if (m.Msg != 0xA3)
  62. {
  63. base.WndProc(ref m);
  64. }
  65. }
  66. #endregion
  67. #region 列表
  68. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  69. {
  70. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  71. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  72. }
  73. #endregion
  74. #region 分页
  75. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  76. {
  77. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  78. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  79. grdDetail.DataSource = data;
  80. }
  81. #endregion
  82. #region 操作权限
  83. public DataTable RightOfExute()
  84. {
  85. DataTable rData = new DataTable();
  86. rData.Columns.Add("BtnName");
  87. rData.Columns.Add("ActionName");
  88. //查看权限(必须有)
  89. DataRow seeRow = rData.NewRow();
  90. seeRow["BtnName"] = "see";
  91. seeRow["ActionName"] = "查看";
  92. rData.Rows.Add(seeRow);
  93. rData.AcceptChanges();
  94. return rData;
  95. }
  96. public DataTable RightOfData()// 数据权限
  97. {
  98. DataTable rData = new DataTable();
  99. rData.Columns.Add("BodyName");
  100. rData.Columns.Add("ControlName");
  101. rData.Columns.Add("ControlCaption");
  102. rData.AcceptChanges();
  103. return rData;
  104. }
  105. #endregion
  106. private void Search()
  107. {
  108. string code = textBoxCode.Text;
  109. #region sql语句原型
  110. //string sql = string.Format(@"
  111. //select eqpname as 设备型号,
  112. //C.ProjectCode AS 项目号,
  113. //C.MOCODE AS 生产订单号,
  114. //G.ROUTECODE as 途程编码,
  115. //A.OPCODE,
  116. //B.LOTSEQ AS 行号,
  117. // A.LOTNO AS 产品跟踪单号,
  118. //C.ITEMCODE AS 料品编码,
  119. //d.ItemName as 料品名称,
  120. //D.ItemStd AS 规格型号,
  121. // G.OPSEQ AS 工序次序,
  122. //h.opseq as 上一工序次序,
  123. //I.OPCODE AS 上一工序编码,
  124. //i.OPNAME as 上一工序,
  125. //e.OPNAME as 工序名称,
  126. //q.OPNAME as 当前工序,
  127. //ww.begindate,
  128. //ww.enddate,
  129. //b.lotqty as 数量,
  130. //P.STIME AS 单件工时,
  131. // CONVERT(DECIMAL(10,2),P.STIME*B.LOTQTY/60 ) AS 预估加工工时,
  132. //A.SendPlanDate AS 派工时间,
  133. //MOPLANSTARTDATE AS 预计开工时间,
  134. //MOPLANENDDATE AS 预计完工时间,
  135. //dbo.GetOpStatus(A.LOTNO,A.OPCODE,G.ROUTECODE,I.OPCODE ) as 状态
  136. //FROM ICSMO2User A
  137. //LEFT JOIN ICSMO2LOT B ON B.LOTNO=A.LOTNO
  138. //LEFT JOIN ICSMO C ON C.MOCODE=B.MOCODE
  139. //left join Base_Inventory d on d.ItemCode=C.ITEMCODE
  140. //LEFT JOIN ICSMO2ROUTE F on F.MOCODE = a.MOCODE AND F.ROUTECODE=A.RouteCode
  141. //left join icsroute2op G on G.ROUTECODE = F.ROUTECODE AND G.OPCODE=A.OPCODE
  142. //left join ICSOP E on A.OPCODE=E.OPCODE
  143. //left JOIN ICSLOTONWIP WW ON WW.LOTNO=A.LOTNO AND WW.OPCODE=A.OPCODE and ww.ACTION='good'
  144. //left join (select * from icsroute2op )H on h.ROUTECODE=f.ROUTECODE and h.OPSEQ=(select max(opseq) from icsroute2op where icsroute2op.ROUTECODE=h.ROUTECODE and icsroute2op.opseq<g.OPSEQ)
  145. //left join (select * from ICSOP) i on i.OPCODE=h.OPCODE
  146. //left join ICSEQPSTPEMODEL p ON P.ITEMCODE=C.ITEMCODE AND P.OPCODE=A.OPCODE AND P.EQPCODE=G.MainResources
  147. //left join (select ICSLOTSIMULATION.opcode,opname,lotno,BeginDate,EndDate from ICSLOTSIMULATION left join icsop on icsop.OPCODE=ICSLOTSIMULATION.OPCODE) q on q.lotno=a.lotno
  148. //where usercode='{0}'
  149. //AND NOT EXISTS(SELECT 1 FROM ICSLOTONWIP ww where ww.lotno=A.LOTNO AND isnull(ww.EndTime,'')!=''and ww.opcode=A.OPCODE)
  150. //ORDER BY A.LOTNO"
  151. //,
  152. //code);
  153. #endregion
  154. #region 新的sql
  155. string sql = string.Format(@"
  156. select
  157. A.eqpname as ,
  158. C.MOCODE AS ,
  159. A.MOSEQ AS ,
  160. B.LOTNO AS ,
  161. C.ITEMCODE AS ,
  162. d.INVNAME as ,
  163. d.invstd AS ,
  164. '' as , --
  165. G.OPSEQ AS ,
  166. e.OPDESC as ,
  167. --P.STIME AS ,
  168. 0 AS ,
  169. B.LOTQTY as ,
  170. --CONVERT(DECIMAL(10,2),P.STIME*B.LOTQTY/60 ) AS ,
  171. A.mtime AS ,
  172. A.STARTPLANDATE AS ,
  173. A.ENDPLANDATE AS ,
  174. case
  175. when ww.ACTIONRESULT is null and G.OPSEQ=(select min(OPSEQ) from ICSITEMROUTE2OPLot where lotno=a.LOTNO) then ''
  176. when ww.actionresult='COLLECT_BEGIN' then ''
  177. when ww1.actionresult='COLLECT_BEGIN' or (check1.result<>'' or check1.Result is null) then ''
  178. when ((ww1.actionresult='COLLECT_END' and check1.result='') OR (WW1.ACTIONRESULT IS NULL)) and ww.actionresult is null then ''
  179. END AS ,
  180. G.OPTIONALOP as ,
  181. case
  182. when G.OPTIONALOP='' or G.OPTIONALOP is null then null
  183. else CONVERT(DECIMAL(10,2),CONVERT(DECIMAL,h.OPTIONALOP)*B.LOTQTY/60 )
  184. end AS
  185. FROM ICSMO2User A
  186. LEFT JOIN ICSITEMLot B ON B.LOTNO=A.LOTNO
  187. left JOIN ICSMO C ON C.MOCODE=A.MOCODE AND c.MOSEQ=a.MOSEQ
  188. left join ICSINVENTORY d on d.INVCODE=C.ITEMCODE
  189. left join ICSOP E on A.OPCODE=E.OPCODE
  190. left JOIN ICSMO2ROUTE F on F.MOCODE = a.MOCODE AND F.ROUTECODE=A.RouteCode
  191. left join ICSITEMROUTE2OPlot G on G.lotno = a.lotno AND G.routecode=A.routecode and g.opcode=a.opcode
  192. left JOIN ICSLOTONWIP WW ON WW.LOTNO=A.LOTNO and WW.OPCODE=A.OPCODE
  193. left join (select * from ICSITEMROUTE2OPlot )H on h.lotno=a.lotno and h.OPSEQ=(select max(opseq) from ICSITEMROUTE2OPlot where ICSITEMROUTE2OPlot.lotno=h.lotno and ICSITEMROUTE2OPlot.opseq<g.OPSEQ)
  194. left join ICSLOTONWIP WW1 on ww1.lotno=a.lotno and ww1.opcode=H.opcode
  195. left join ICSLOTONWIPCheck check1 on check1.onwipid=ww1.id
  196. left join ICSOP i on i.OPCODE=h.OPCODE
  197. left join (select ICSLOTSIMULATION.opcode,opname,lotno,BeginTime,EndTime from ICSLOTSIMULATION left join icsop on icsop.OPCODE=ICSLOTSIMULATION.OPCODE) q on q.lotno=a.lotno
  198. where usercode='{0}' and (ww.ACTIONRESULT<>'COLLECT_END' or ww.ACTIONRESULT is null)
  199. ORDER BY A.LOTNO ", code);
  200. #endregion
  201. DataTable datasource = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  202. grdDetail.DataSource = datasource;
  203. }
  204. private void textBoxCode_KeyUp(object sender, KeyEventArgs e)
  205. {
  206. //if ((int)e.KeyCode == 13)
  207. //{
  208. // Search();
  209. //}
  210. }
  211. private void grdDetail_Click(object sender, EventArgs e)
  212. {
  213. }
  214. private void textBoxCode_KeyPress(object sender, KeyPressEventArgs e)
  215. {
  216. }
  217. private void btnFilter_Click(object sender, EventArgs e)
  218. {
  219. Search();
  220. }
  221. //0712号注释
  222. //private void can_Click(object sender, EventArgs e)
  223. //{
  224. // FormICSJJCollect collect = new FormICSJJCollect();
  225. // collect.ShowDialog();
  226. // this.Close();
  227. //}
  228. //private void simpleButton1_Click(object sender, EventArgs e)
  229. //{
  230. // FormICSZPCollect collect = new FormICSZPCollect();
  231. // collect.ShowDialog();
  232. // this.Close();
  233. //}
  234. }
  235. }