Query_MakeInf.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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.CustomControl.TextBoxWithIcon;
  10. using UAS_MES.DataOperate;
  11. using UAS_MES.Entity;
  12. using UAS_MES.PublicMethod;
  13. namespace UAS_MES.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. rangesn_qty.Text = rangebefore + "/" + rangeafter;
  83. sql.Clear();
  84. sql.Append("select count(1) beforesn_qty from makesnlist where msl_makecode='" + MakeCode.Text + "' and msl_type='before'");
  85. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  86. if (dt.Rows.Count > 0)
  87. {
  88. rangebefore = dt.Rows[0]["beforesn_qty"].ToString();
  89. BaseUtil.SetFormValue(this.Controls, dt);
  90. }
  91. sql.Clear();
  92. sql.Append("select count(1) aftersn_qty from makesnlist where msl_makecode='" + MakeCode.Text + "' and msl_type='after'");
  93. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  94. if (dt.Rows.Count > 0)
  95. {
  96. rangeafter = dt.Rows[0]["aftersn_qty"].ToString();
  97. BaseUtil.SetFormValue(this.Controls, dt);
  98. }
  99. importsn_qty.Text = rangebefore + "/" + rangeafter;
  100. //获取SN关联信息
  101. Mac_Num.Text = dh.getFieldDataByCondition("Makeaddresslist", "count(1)", "mal_makecode='" + MakeCode.Text + "' and mal_mac is not null").ToString();
  102. BT_Num.Text = dh.getFieldDataByCondition("Makeaddresslist", "count(1)", "mal_makecode='" + MakeCode.Text + "' and mal_bt is not null").ToString();
  103. IMEI_Num.Text = dh.getFieldDataByCondition("Makeimeilist", "count(1)", "mil_makecode='" + MakeCode.Text + "' and mil_imei1 is not null").ToString();
  104. sql.Clear();
  105. sql.Append("select * from StepProduct left join product on pr_code=sp_soncode where sp_bomversion='" + ma_bomversion + "' and sp_mothercode='" + ma_prodcode + "' and sp_craftcode='" + ma_craftcode + "'");
  106. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  107. if (dt.Rows.Count > 0)
  108. {
  109. BaseUtil.FillDgvWithDataTable(BOM, dt);
  110. }
  111. sql.Clear();
  112. sql.Append("select * from label where la_prodcode='" + ma_prodcode + "'");
  113. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  114. if (dt.Rows.Count > 0)
  115. {
  116. BaseUtil.FillDgvWithDataTable(Label, dt);
  117. }
  118. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, MakeCode.Text, User.UserLineCode, User.UserSourceCode, "查询工单综合信息", "查询成功", "", "");
  119. }
  120. else MessageBox.Show("工单号不存在");
  121. }
  122. /// <summary>
  123. /// 清除DataGridView的数据
  124. /// </summary>
  125. /// <param name="dgv"></param>
  126. public static void CleanDGVData(DataGridView dgv)
  127. {
  128. for (int i = dgv.Rows.Count - 1; i >= 0; i--)
  129. {
  130. dgv.Rows.RemoveAt(i);
  131. }
  132. DataTable dt = dgv.DataSource as DataTable;
  133. if (dt != null)
  134. {
  135. dt.AcceptChanges();
  136. }
  137. }
  138. public static void CleanForm(Form Form)
  139. {
  140. for (int i = 0; i < Form.Controls.Count; i++)
  141. {
  142. if (Form.Controls[i].Controls.Count > 0)
  143. {
  144. CleanControls(Form.Controls[i].Controls);
  145. }
  146. if ((Form.Controls[i] is Label && GetCharInStringCount("_", Form.Controls[i].Name) != 2))
  147. Form.Controls[i].Text = "";
  148. if (Form.Controls[i] is DataGridView)
  149. CleanDGVData((DataGridView)Form.Controls[i]);
  150. }
  151. }
  152. public static void CleanControls(Control.ControlCollection collection)
  153. {
  154. for (int i = 0; i < collection.Count; i++)
  155. {
  156. if (collection[i].Controls.Count > 0)
  157. CleanControls(collection[i].Controls);
  158. if ((collection[i] is Label && GetCharInStringCount("_", collection[i].Name) != 2))
  159. collection[i].Text = "";
  160. if (collection[i] is DataGridView)
  161. CleanDGVData((DataGridView)collection[i]);
  162. }
  163. }
  164. public static int GetCharInStringCount(string Char, string String)
  165. {
  166. string str = String.Replace(Char, "");
  167. return (String.Length - str.Length) / Char.Length;
  168. }
  169. }
  170. }