using System; using System.Data; using System.Drawing; using System.Windows.Forms; using UAS_MES_NEW.DataOperate; using UAS_MES_NEW.Entity; using UAS_MES_NEW.PublicMethod; namespace UAS_MES_NEW.Special { public partial class Special_CancelMaekBad : Form { DataHelper dh = SystemInf.dh; LogStringBuilder sql = new LogStringBuilder(); AutoSizeFormClass asc = new AutoSizeFormClass(); public Special_CancelMaekBad() { InitializeComponent(); } private void Special_CancelProdinout_Load(object sender, EventArgs e) { ma_code.TableName = "make left join product on pr_code=ma_prodcode"; ma_code.DBTitle = "工单号查询"; ma_code.SelectField = "ma_code # 工单号,ma_qty # 工单数量,pr_detail # 产品名称,pr_code # 产品编号"; ma_code.SetValueField = new string[] { "ma_code", "pr_detail", "pr_code" }; ma_code.FormName = Name; asc.controllInitializeSize(this); } private void LoadGridData() { DataTable dt = (DataTable)dh.ExecuteSql("select mb_id,mb_sncode,mb_badcode,mb_badname,mbr_dutycode,mbr_brname,mbr_solutionname,mb_stepcode,st_name from makebad left join MAKEBADREASON on mbr_mbid=mb_id left join step on mb_stepcode=st_code where mb_makecode='" + ma_code.Text + "'", "select"); BaseUtil.FillDgvWithDataTable(Info, dt); } private void Special_AfterSaleIn_SizeChanged(object sender, EventArgs e) { asc.controlAutoSize(this); } private void ma_code_UserControlTextChanged(object sender, EventArgs e) { LoadGridData(); } private void Search_Click(object sender, EventArgs e) { string sql = "select mb_id,mb_sncode,mb_badcode,mb_badname,mbr_dutycode,mbr_brname,mbr_solutionname,mb_stepcode,st_name from makebad left join MAKEBADREASON on mbr_mbid=mb_id left join step on mb_stepcode=st_code where mb_makecode='" + ma_code.Text + "' "; if (badname.Text != "") { sql += " and mb_badname like '%" + badname.Text + "%'"; } if (badreason.Text != "") { sql += " and mbr_brname like '%" + badreason.Text + "%'"; } DataTable dt = (DataTable)dh.ExecuteSql(sql, "select"); BaseUtil.FillDgvWithDataTable(Info, dt); } private void Delete_Click(object sender, EventArgs e) { for (int i = 0; i < Info.Rows.Count; i++) { if (Info.Rows[i].Cells["Choose"].FormattedValue != null && Info.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True") { string mb_id = Info.Rows[i].Cells["mb_id"].Value.ToString(); string mb_sncode = Info.Rows[i].Cells["mb_sncode"].Value.ToString(); string mb_stepcode = Info.Rows[i].Cells["mb_stepcode"].Value.ToString(); dh.ExecuteSql("delete from makebadreason where mbr_mbid='" + mb_id + "'", "delete"); dh.ExecuteSql("delete from makebad where mb_id='" + mb_id + "'", "delete"); dh.ExecuteSql("update steppassed set sp_ifng=0,sp_result='良品' where sp_id= (select max(sp_id) from steppassed where sp_sncode='" + mb_sncode + "' and sp_stepcode='" + mb_stepcode + "' and sp_ifng=-1)", "update"); } } LoadGridData(); } } }