123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using UAS_MES.CustomControl.TextBoxWithIcon;
- using UAS_MES.DataOperate;
- using UAS_MES.Entity;
- using UAS_MES.PublicMethod;
- namespace UAS_MES.Query
- {
- public partial class Query_MakeInf : Form
- {
- AutoSizeFormClass asc = new AutoSizeFormClass();
- DataHelper dh;
- public Query_MakeInf()
- {
- InitializeComponent();
- }
- private void Query_MakeInf_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- dh = SystemInf.dh;
- }
- private void Query_MakeInf_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void Search_Click(object sender, EventArgs e)
- {
- LogStringBuilder sql = new LogStringBuilder();
- sql.Clear();
- sql.Append("select ma_prodcode,ma_qty,ma_craftcode,ma_wccode,ma_salecode,ma_custname,ma_unlimitageqty");
- sql.Append(",ma_softversion,ma_bomversion from make where ma_code='" + MakeCode.Text + "'");
- DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- CleanForm(this);
- if (dt.Rows.Count > 0)
- {
- BaseUtil.SetFormValue(this.Controls, dt);
- string ma_prodcode = dt.Rows[0]["ma_prodcode"].ToString();
- string ma_craftcode = dt.Rows[0]["ma_craftcode"].ToString();
- string ma_bomversion = dt.Rows[0]["ma_bomversion"].ToString();
- string ma_salecode = dt.Rows[0]["ma_salecode"].ToString();
- sql.Clear();
- sql.Append("select pr_code,pr_outboxinnerqty,case pr_sendchecktype when 'SaleCode' then '按合同送检' when 'LineCode' then '按线别送检' end pr_sendchecktype,pr_detail,pr_agingtime");
- 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,");
- 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 + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- BaseUtil.SetFormValue(this.Controls, dt);
- }
- sn_relation.Text = dh.getFieldDataByCondition("productsnrelation", "wm_concat(psr_type)", "psr_prodcode='" + ma_prodcode + "'").ToString();
- sql.Clear();
- 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");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- BaseUtil.FillDgvWithDataTable(Carft, dt);
- }
- sql.Clear();
- sql.Append("select (msr_startno||'-'||msr_endno) before_snrange,msr_qty beforesn_qty from makesnrule where msr_makecode='" + MakeCode.Text + "' and msr_type='before'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- string rangebefore = "0";
- if (dt.Rows.Count > 0)
- {
- rangebefore = dt.Rows[0]["beforesn_qty"].ToString();
- BaseUtil.SetFormValue(this.Controls, dt);
- }
- sql.Clear();
- sql.Append("select (msr_startno||'-'||msr_endno) aftersn_range,msr_qty aftersn_qty from makesnrule where msr_makecode='" + MakeCode.Text + "' and msr_type='after'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- string rangeafter = "0";
- if (dt.Rows.Count > 0)
- {
- rangeafter = dt.Rows[0]["aftersn_qty"].ToString();
- BaseUtil.SetFormValue(this.Controls, dt);
- }
- rangesn_qty.Text = rangebefore + "/" + rangeafter;
- sql.Clear();
- sql.Append("select count(1) beforesn_qty from makesnlist where msl_makecode='" + MakeCode.Text + "' and msl_type='before'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- rangebefore = dt.Rows[0]["beforesn_qty"].ToString();
- BaseUtil.SetFormValue(this.Controls, dt);
- }
- sql.Clear();
- sql.Append("select count(1) aftersn_qty from makesnlist where msl_makecode='" + MakeCode.Text + "' and msl_type='after'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- rangeafter = dt.Rows[0]["aftersn_qty"].ToString();
- BaseUtil.SetFormValue(this.Controls, dt);
- }
- importsn_qty.Text = rangebefore + "/" + rangeafter;
- //获取SN关联信息
- Mac_Num.Text = dh.getFieldDataByCondition("Makeaddresslist", "count(1)", "mal_makecode='" + MakeCode.Text + "' and mal_mac is not null").ToString();
- BT_Num.Text = dh.getFieldDataByCondition("Makeaddresslist", "count(1)", "mal_makecode='" + MakeCode.Text + "' and mal_bt is not null").ToString();
- IMEI_Num.Text = dh.getFieldDataByCondition("Makeimeilist", "count(1)", "mil_makecode='" + MakeCode.Text + "' and mil_imei1 is not null").ToString();
- sql.Clear();
- 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 + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- BaseUtil.FillDgvWithDataTable(BOM, dt);
- }
- sql.Clear();
- sql.Append("select * from label where la_prodcode='" + ma_prodcode + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- BaseUtil.FillDgvWithDataTable(Label, dt);
- }
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, MakeCode.Text, User.UserLineCode, User.UserSourceCode, "查询工单综合信息", "查询成功", "", "");
- }
- else MessageBox.Show("工单号不存在");
- }
- /// <summary>
- /// 清除DataGridView的数据
- /// </summary>
- /// <param name="dgv"></param>
- public static void CleanDGVData(DataGridView dgv)
- {
- for (int i = dgv.Rows.Count - 1; i >= 0; i--)
- {
- dgv.Rows.RemoveAt(i);
- }
- DataTable dt = dgv.DataSource as DataTable;
- if (dt != null)
- {
- dt.AcceptChanges();
- }
- }
- public static void CleanForm(Form Form)
- {
- for (int i = 0; i < Form.Controls.Count; i++)
- {
- if (Form.Controls[i].Controls.Count > 0)
- {
- CleanControls(Form.Controls[i].Controls);
- }
- if ((Form.Controls[i] is Label && GetCharInStringCount("_", Form.Controls[i].Name) != 2))
- Form.Controls[i].Text = "";
- if (Form.Controls[i] is DataGridView)
- CleanDGVData((DataGridView)Form.Controls[i]);
- }
- }
- public static void CleanControls(Control.ControlCollection collection)
- {
- for (int i = 0; i < collection.Count; i++)
- {
- if (collection[i].Controls.Count > 0)
- CleanControls(collection[i].Controls);
- if ((collection[i] is Label && GetCharInStringCount("_", collection[i].Name) != 2))
- collection[i].Text = "";
- if (collection[i] is DataGridView)
- CleanDGVData((DataGridView)collection[i]);
- }
- }
- public static int GetCharInStringCount(string Char, string String)
- {
- string str = String.Replace(Char, "");
- return (String.Length - str.Length) / Char.Length;
- }
- }
- }
|