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_NEW.CustomControl.TextBoxWithIcon; using UAS_MES_NEW.DataOperate; using UAS_MES_NEW.Entity; using UAS_MES_NEW.PublicMethod; namespace UAS_MES_NEW.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); } 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); } sql.Clear(); 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 "); sql.Append("left join makeserial A on mcd_macode = A.ms_makecode and mcd_stepcode = "); 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"); dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (dt.Rows.Count > 0) { BaseUtil.FillDgvWithDataTable(BOM, dt); } LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, MakeCode.Text, User.UserLineCode, User.UserSourceCode, "查询工单综合信息", "查询成功", "", ""); } else MessageBox.Show("工单号不存在"); } /// /// 清除DataGridView的数据 /// /// 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; } } }