123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- 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.DataOperate;
- using UAS_MES_NEW.Entity;
- using UAS_MES_NEW.PublicMethod;
- namespace UAS_MES_NEW.Make
- {
- public partial class Make_MakeCancelDown : Form
- {
- AutoSizeFormClass asc = new AutoSizeFormClass();
- DataTable dt;
- DataTable dt1;
- DataTable dtbar;
- LogStringBuilder sql = new LogStringBuilder();
- DataHelper dh;
- public Make_MakeCancelDown()
- {
- InitializeComponent();
- }
- private void Make_MakeCancelDown_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- md_code_rb.Focus();
- ChooseAll.ChooseAll(LabelDataGridView);
- dh = SystemInf.dh;
- }
- private void Make_MakeCancelDown_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void md_code_rb_Click(object sender, EventArgs e)
- {
- if (((RadioButton)sender).Checked == true)
- {
- if (((RadioButton)sender).Name == "md_code_rb")
- {
- BaseUtil.CleanForm(this);
- inputreson.Text = "";
- mdcode.Enabled = true;
- sn_code.Enabled = false;
- mdcode.Focus();
- }
- else if (((RadioButton)sender).Name == "sn_code_rb")
- {
- BaseUtil.CleanForm(this);
- inputreson.Text = "";
- sn_code.Enabled = true;
- mdcode.Enabled = false;
- sn_code.Focus();
- }
- }
- }
- private void md_code_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (dh.CheckExist("MakeDown", "md_code = '" + mdcode.Text + "'"))
- {
- sql.Clear();
- sql.Append("select md_code,md_sncode,md_macode,md_prodcode,pr_detail from makedown left join product on pr_code=md_prodcode where md_code='" + mdcode.Text + "' and md_status=-1");
- dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt1.Rows.Count > 0)
- {
- BaseUtil.FillDgvWithDataTable(LabelDataGridView, dt1);
- }
- else
- {
- OperateResult.AppendText(">>事件号" + mdcode.Text + "无未取消下地的数据\n", Color.Red);
- BaseUtil.CleanDGVData(LabelDataGridView);
- }
- sum.Text = dt1.Rows.Count.ToString();
- make_count.Text = dt1.Rows.Count.ToString();
- }
- else
- {
- OperateResult.AppendText(">>事件号" + mdcode.Text + "不存在\n", Color.Red);
- }
- }
- }
- private void sn_code_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- sql.Clear();
- sql.Append("select md_code,md_sncode,md_macode,md_prodcode,pr_detail from makedown left join product on pr_code=md_prodcode where md_sncode='" + sn_code.Text + "' and md_status=-1");
- dtbar = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dtbar.Rows.Count > 0)
- {
- BaseUtil.FillDgvWithDataTable(LabelDataGridView, dtbar);
- }
- else
- {
- OperateResult.AppendText(">>序列号" + sn_code.Text + "无未取消下地的数据\n", Color.Red);
- }
- sum.Text = dtbar.Rows.Count.ToString();
- }
- }
- private void Sure_Click(object sender, EventArgs e)
- {
- if (inputreson.Text.Trim() != "")
- {
- Boolean cancle = false;
- Boolean haveclick = false;
- for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
- {
- if (LabelDataGridView.Rows[i].Cells["Choose"].Value != null)
- {
- if ((Boolean)LabelDataGridView.Rows[i].Cells["Choose"].Value == true)
- {
- haveclick = true;
- }
- }
- }
- if (!haveclick)
- {
- OperateResult.AppendText(">>>没有勾选下地记录\n", Color.Red);
- return;
- }
- for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
- {
- if (LabelDataGridView.Rows[i].Cells["Choose"].Value != null)
- {
- if ((Boolean)LabelDataGridView.Rows[i].Cells["Choose"].Value == true)
- {
- //更新取消下地原因
- dh.UpdateByCondition("makedown", "md_status=0,MD_UPREASON='" + inputreson.Text + "', MD_UPDATE=sysdate, MD_UPMAN='" + User.UserCode + "' ", " md_code = '" + LabelDataGridView.Rows[i].Cells["md_code"].Value.ToString() + "' and md_sncode = '" + LabelDataGridView.Rows[i].Cells["md_sncode"].Value.ToString() + "'");
- //更新序列号状态
- sql.Clear();
- sql.Append("update makeserial set ms_downstatus=0 where ms_sncode='" + LabelDataGridView.Rows[i].Cells["md_sncode"].Value.ToString() + "' and ms_makecode='" + LabelDataGridView.Rows[i].Cells["md_macode"].Value.ToString() + "'");
- dh.ExecuteSql(sql.GetString(), "update");
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, LabelDataGridView.Rows[i].Cells["md_macode"].Value.ToString(), User.UserLineCode, User.UserSourceCode, "取消下地操作", "序列号" + LabelDataGridView.Rows[i].Cells["md_sncode"].Value.ToString() + "下地成功", LabelDataGridView.Rows[i].Cells["md_sncode"].Value.ToString(), "");
- }
- }
- }
- if (sn_code.Enabled)
- {
- OperateResult.AppendText(">>>序列号" + sn_code.Text + "取消下地成功\n", Color.Green);
- sn_code.Text = "";
- sn_code.Focus();
- inputreson.Text = "";
- sum.Text = "";
- choosenum.Text = "";
- BaseUtil.CleanDGVData(LabelDataGridView);
- }
- else if (mdcode.Enabled)
- {
- sum.Text = "";
- choosenum.Text = "";
- OperateResult.AppendText(">>>事件号" + mdcode.Text + "取消下地成功\n", Color.Green);
- mdcode.Focus();
- md_code_KeyDown(sender, new KeyEventArgs(Keys.Enter));
- }
- }
- else
- {
- OperateResult.AppendText(">>>没有填写取消下地原因\n", Color.Red);
- return;
- }
- }
- //已选数据更新
- private void LabelDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- int choosecount = 0;
- for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
- {
- if (LabelDataGridView.Rows[i].Cells["Choose"].Value != null)
- {
- if ((Boolean)LabelDataGridView.Rows[i].Cells["Choose"].Value == true)
- {
- choosecount++;
- }
- }
- }
- choosenum.Text = choosecount.ToString();
- }
- //勾选框更改提交
- private void LabelDataGridView_CurrentCellDirtyStateChanged(object sender, EventArgs e)
- {
- if (LabelDataGridView.IsCurrentCellDirty)
- {
- LabelDataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
- }
- }
- }
- }
|