Query_MakeInf.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 UAS_MES_NEW.CustomControl.TextBoxWithIcon;
  10. using UAS_MES_NEW.DataOperate;
  11. using UAS_MES_NEW.Entity;
  12. using UAS_MES_NEW.PublicMethod;
  13. namespace UAS_MES_NEW.Query
  14. {
  15. public partial class Query_MakeInf : Form
  16. {
  17. AutoSizeFormClass asc = new AutoSizeFormClass();
  18. DataHelper dh;
  19. public Query_MakeInf()
  20. {
  21. InitializeComponent();
  22. }
  23. private void Query_MakeInf_Load(object sender, EventArgs e)
  24. {
  25. asc.controllInitializeSize(this);
  26. dh = SystemInf.dh;
  27. }
  28. private void Query_MakeInf_SizeChanged(object sender, EventArgs e)
  29. {
  30. asc.controlAutoSize(this);
  31. }
  32. private void Search_Click(object sender, EventArgs e)
  33. {
  34. LogStringBuilder sql = new LogStringBuilder();
  35. sql.Clear();
  36. sql.Append("select ma_prodcode,ma_qty,ma_craftcode,ma_wccode,ma_salecode,ma_custname,ma_unlimitageqty");
  37. sql.Append(",ma_softversion,ma_bomversion from make where ma_code='" + MakeCode.Text + "'");
  38. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  39. CleanForm(this);
  40. if (dt.Rows.Count > 0)
  41. {
  42. BaseUtil.SetFormValue(this.Controls, dt);
  43. string ma_prodcode = dt.Rows[0]["ma_prodcode"].ToString();
  44. string ma_craftcode = dt.Rows[0]["ma_craftcode"].ToString();
  45. string ma_bomversion = dt.Rows[0]["ma_bomversion"].ToString();
  46. string ma_salecode = dt.Rows[0]["ma_salecode"].ToString();
  47. sql.Clear();
  48. sql.Append("select pr_code,pr_outboxinnerqty,case pr_sendchecktype when 'SaleCode' then '按合同送检' when 'LineCode' then '按线别送检' end pr_sendchecktype,pr_detail,pr_agingtime");
  49. sql.Append(",( CASE WHEN pr_colorboxminw LIKE '.%' THEN '0'||pr_colorboxminw ELSE to_char(pr_colorboxminw) END ||'-'|| CASE WHEN pr_colorboxmaxw LIKE '.%' THEN '0'||pr_colorboxmaxw ELSE to_char(pr_colorboxmaxw) END ||' '||pr_colorboxunit)pr_colorboxweight,");
  50. sql.Append("(CASE WHEN pr_cartonminw LIKE '.%' THEN '0'||pr_cartonminw ELSE to_char(pr_cartonminw) END ||'-'|| CASE WHEN pr_cartonmaxw LIKE '.%' THEN '0'||pr_cartonmaxw ELSE to_char(pr_cartonmaxw) END ||' '||pr_cartonunit)pr_cartonweight from product where pr_code='" + ma_prodcode + "'");
  51. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  52. if (dt.Rows.Count > 0)
  53. {
  54. BaseUtil.SetFormValue(this.Controls, dt);
  55. }
  56. sn_relation.Text = dh.getFieldDataByCondition("productsnrelation", "wm_concat(psr_type)", "psr_prodcode='" + ma_prodcode + "'").ToString();
  57. sql.Clear();
  58. sql.Append("select * from craftdetail left join craft on cd_crid=cr_id where cr_code='" + ma_craftcode + "' and cr_prodcode='" + ma_prodcode + "' order by cd_detno");
  59. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  60. if (dt.Rows.Count > 0)
  61. {
  62. BaseUtil.FillDgvWithDataTable(Carft, dt);
  63. }
  64. sql.Clear();
  65. sql.Append("select (msr_startno||'-'||msr_endno) before_snrange,msr_qty beforesn_qty from makesnrule where msr_makecode='" + MakeCode.Text + "' and msr_type='before'");
  66. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  67. string rangebefore = "0";
  68. if (dt.Rows.Count > 0)
  69. {
  70. rangebefore = dt.Rows[0]["beforesn_qty"].ToString();
  71. BaseUtil.SetFormValue(this.Controls, dt);
  72. }
  73. sql.Clear();
  74. sql.Append("select (msr_startno||'-'||msr_endno) aftersn_range,msr_qty aftersn_qty from makesnrule where msr_makecode='" + MakeCode.Text + "' and msr_type='after'");
  75. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  76. string rangeafter = "0";
  77. if (dt.Rows.Count > 0)
  78. {
  79. rangeafter = dt.Rows[0]["aftersn_qty"].ToString();
  80. BaseUtil.SetFormValue(this.Controls, dt);
  81. }
  82. sql.Clear();
  83. sql.Append("select count(1) beforesn_qty from makesnlist where msl_makecode='" + MakeCode.Text + "' and msl_type='before'");
  84. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  85. if (dt.Rows.Count > 0)
  86. {
  87. rangebefore = dt.Rows[0]["beforesn_qty"].ToString();
  88. BaseUtil.SetFormValue(this.Controls, dt);
  89. }
  90. sql.Clear();
  91. sql.Append("select count(1) aftersn_qty from makesnlist where msl_makecode='" + MakeCode.Text + "' and msl_type='after'");
  92. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  93. if (dt.Rows.Count > 0)
  94. {
  95. rangeafter = dt.Rows[0]["aftersn_qty"].ToString();
  96. BaseUtil.SetFormValue(this.Controls, dt);
  97. }
  98. sql.Clear();
  99. sql.Append("select mcd_detno,mcd_stepcode,mcd_stepname,nvl(count(distinct A.ms_sncode),0) n,nvl(count(distinct B.ms_sncode),0) bn,(select nvl(count(distinct sp_sncode),0) from STEPPASSED where SP_MAKECODE = mcd_macode AND SP_STEPCODE = mcd_stepcode) inqty from MAKECRAFTdetail ");
  100. sql.Append("left join makeserial A on mcd_macode = A.ms_makecode and mcd_stepcode = ");
  101. sql.Append("A.ms_nextstepcode AND A.MS_STATUS = 1 LEFT JOIN MAKESERIAL B ON mcd_macode = B.ms_makecode AND MCD_STEPCODE = B.MS_STEPCODE AND B.MS_STATUS = 3 where mcd_macode = '" + MakeCode.Text + "' group by mcd_macode,mcd_detno, mcd_stepcode, mcd_stepname order by mcd_detno asc");
  102. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  103. if (dt.Rows.Count > 0)
  104. {
  105. BaseUtil.FillDgvWithDataTable(BOM, dt);
  106. }
  107. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, MakeCode.Text, User.UserLineCode, User.UserSourceCode, "查询工单综合信息", "查询成功", "", "");
  108. }
  109. else MessageBox.Show("工单号不存在");
  110. }
  111. /// <summary>
  112. /// 清除DataGridView的数据
  113. /// </summary>
  114. /// <param name="dgv"></param>
  115. public static void CleanDGVData(DataGridView dgv)
  116. {
  117. for (int i = dgv.Rows.Count - 1; i >= 0; i--)
  118. {
  119. dgv.Rows.RemoveAt(i);
  120. }
  121. DataTable dt = dgv.DataSource as DataTable;
  122. if (dt != null)
  123. {
  124. dt.AcceptChanges();
  125. }
  126. }
  127. public static void CleanForm(Form Form)
  128. {
  129. for (int i = 0; i < Form.Controls.Count; i++)
  130. {
  131. if (Form.Controls[i].Controls.Count > 0)
  132. {
  133. CleanControls(Form.Controls[i].Controls);
  134. }
  135. if ((Form.Controls[i] is Label && GetCharInStringCount("_", Form.Controls[i].Name) != 2))
  136. Form.Controls[i].Text = "";
  137. if (Form.Controls[i] is DataGridView)
  138. CleanDGVData((DataGridView)Form.Controls[i]);
  139. }
  140. }
  141. public static void CleanControls(Control.ControlCollection collection)
  142. {
  143. for (int i = 0; i < collection.Count; i++)
  144. {
  145. if (collection[i].Controls.Count > 0)
  146. CleanControls(collection[i].Controls);
  147. if ((collection[i] is Label && GetCharInStringCount("_", collection[i].Name) != 2))
  148. collection[i].Text = "";
  149. if (collection[i] is DataGridView)
  150. CleanDGVData((DataGridView)collection[i]);
  151. }
  152. }
  153. public static int GetCharInStringCount(string Char, string String)
  154. {
  155. string str = String.Replace(Char, "");
  156. return (String.Length - str.Length) / Char.Length;
  157. }
  158. }
  159. }