| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using UAS_MES.DataOperate;
- using UAS_MES.PublicMethod;
- namespace UAS_MES.OQC
- {
- public partial class OQC_PlanMaintain : Form
- {
- AutoSizeFormClass asc = new AutoSizeFormClass();
- LogStringBuilder sql = new LogStringBuilder();
- DataTable dt;
- DataHelper dh;
- string ErrorMessage = "";
- public OQC_PlanMaintain()
- {
- InitializeComponent();
- }
- private void 抽样计划维护_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- dh = new DataHelper();
- ob_projectcode.TableName = "QUA_Project";
- ob_projectcode.SelectField = "pr_code # 方案编号,pr_name # 方案名称,pr_class # 检验单类型,pr_standard # 方案标准,pr_startdate # 生效日期,pr_enddate #失效日期 ,pr_status # 状态";
- ob_projectcode.SetValueField = new string[] { "ob_projectcode" };
- ob_projectcode.FormName = Name;
- ob_aqlcode.TableName = "QUA_AQL";
- ob_aqlcode.DBTitle = "抽样标准查询";
- ob_aqlcode.SelectField = "AL_CODE # 流水编号,AL_NAME # 检验标准名称";
- ob_aqlcode.SetValueField = new string[] { "ob_aqlcode" };
- ob_aqlcode.FormName = Name;
- ob_aqlcode.Condition = "al_statuscode='AUDITED'";
- }
- private void 抽样计划维护_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- /// <summary>
- /// 获取批次点击按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void GetBatch_Click(object sender, EventArgs e)
- {
- DataTable[] dt = LogicHandler.GetOQCBatch(ms_sncode.Text, obd_outboxcode.Text, ob_checkno.Text, "OQCPlanMaintain", out ErrorMessage);
- if (dt != null)
- {
- if (ErrorMessage == "")
- {
- BaseUtil.SetFormValue(Controls, dt[0]);
- BaseUtil.FillDgvWithDataTable(CheckTypeDGV, dt[1]);
- ob_aqlcode.Text = "";
- ob_aqlcode.Text = dt[0].Rows[0]["ob_aqlcode"].ToString();
- }
- else
- {
- BaseUtil.CleanForm(this);
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
- ErrorMessage = "";
- }
- }
- else
- {
- BaseUtil.CleanForm(this);
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
- }
- }
- private void SaveConfiguration_Click(object sender, EventArgs e)
- {
- if (ob_status.Text == "待检验")
- {
- //新增的数据
- List<string> oi_id = new List<string>();
- List<string> ci_kind = new List<string>();
- List<string> oi_sampleqty = new List<string>();
- //更新的数据
- List<string> ci_kind_update = new List<string>();
- List<string> oi_sampleqty_update = new List<string>();
- for (int i = 0; i < CheckTypeDGV.Rows.Count; i++)
- {
- //用户勾选的数据才进行操作
- if (CheckTypeDGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
- {
- if (!(int.Parse(CheckTypeDGV.Rows[i].Cells["oi_sampleqty"].Value.ToString()) > int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text)))
- {
- oi_id.Add(CheckTypeDGV.Rows[i].Cells["oi_id"].Value.ToString());
- ci_kind.Add(CheckTypeDGV.Rows[i].Cells["ci_kind"].Value.ToString());
- oi_sampleqty.Add(CheckTypeDGV.Rows[i].Cells["oi_sampleqty"].Value.ToString());
- }
- else
- {
- OperateResult.AppendText(">>第" + (i + 1) + "行的数量大于送检批数量\n", Color.Red);
- return;
- }
- }
- }
- //如果ID为0的数组存在内容则进行插入操作
- dh.ExecuteSql("delete from oqcitems where oi_checkno='" + ob_checkno.Text + "'", "delete");
- if (oi_id.Count > 0)
- {
- sql.Clear();
- sql.Append("insert into OQCItems(oi_id,oi_checkno, oi_projectcode,oi_batchqty ,oi_checkkind,oi_sampleqty,oi_itemcode) select ");
- sql.Append("OQCItems_seq.nextval,'" + ob_checkno.Text + "','" + ob_projectcode.Text + "','" + ob_batchqty.Text + "',:ci_kind,");
- sql.Append(":oi_sampleqty,ci_code from QUA_PROJECT left join QUA_PROJECTDETAIL on pd_prid=pr_id ");
- sql.Append("LEFT JOIN QUA_CHECKITEM ON PD_CIID=CI_ID where pr_code='" + ob_projectcode.Text + "' and ci_kind=:ci_kind1");
- dh.BatchInsert(sql.GetString(), new string[] { "ci_kind", "oi_sampleqty", "ci_kind1" }, ci_kind.ToArray(), oi_sampleqty.ToArray(), ci_kind.ToArray());
- }
- }
- else
- OperateResult.AppendText(">>送检批次必须为待检验状态\n", Color.Red);
- }
- private void Save_Click(object sender, EventArgs e)
- {
- if (ob_aqlcode.Text != "" || ob_maxngacceptqty.Text != "")
- {
- if (Checkob_maxngacceptqty())
- {
- SaveConfiguration_Click(sender, e);
- GetBatch.PerformClick();
- }
- }
- else
- OperateResult.AppendText(">>AQL和最大不合格允许通过数至少填写一个\n", Color.Red);
- }
- //对于最大不合格允通过数的校验
- private bool Checkob_maxngacceptqty()
- {
- if (ob_maxngacceptqty.Text == "0" || ob_maxngacceptqty.Text == "" || int.Parse(ob_maxngacceptqty.Text) < 0)
- {
- OperateResult.AppendText(">>最大不合格允通过数必须大于0\n", Color.Red);
- ob_maxngacceptqty.Text = null;
- return false;
- }
- else
- {
- int result = (int)dh.ExecuteSql("update OQCBatch set ob_projectcode='" + ob_projectcode.Text + "',ob_remark = '" + ob_remark.Text + "',ob_aqlcode='" + ob_aqlcode.Text + "',ob_maxngacceptqty='" + ob_maxngacceptqty.Text + "' where ob_checkno='" + ob_checkno.Text + "' ", "update");
- if (result > 0)
- {
- OperateResult.AppendText(">>保存成功\n", Color.Green);
- return true;
- }
- else
- {
- OperateResult.AppendText(">>保存失败\n", Color.Red);
- return false;
- }
- }
- }
- private void Clean_Click(object sender, EventArgs e)
- {
- OperateResult.Clear();
- }
- private void ob_checkno_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- GetBatch.PerformClick();
- }
- private void ms_sncode_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- GetBatch.PerformClick();
- }
- private void obd_outboxcode_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- GetBatch.PerformClick();
- }
- private void ob_aqlcode_UserControlTextChanged(object sender, EventArgs e)
- {
- if (ob_aqlcode.Text != "")
- {
- bool Find = false;
- dt = (DataTable)dh.ExecuteSql("select nvl(ad_minqty,0)ad_minqty,nvl(ad_maxqty,0)ad_maxqty,nvl(ad_maxngacceptqty,0)ad_maxngacceptqty,ad_qty from QUA_Aql left join qua_aqldetail on ad_alid=al_id where al_code='" + ob_aqlcode.Text + "'", "select");
- if (dt.Rows.Count > 0)
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- int batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
- int minqty = int.Parse(dt.Rows[i]["ad_minqty"].ToString());
- int maxqty = int.Parse(dt.Rows[i]["ad_maxqty"].ToString());
- if (batchqty > minqty && batchqty <= maxqty)
- {
- ob_maxngacceptqty.Text = dt.Rows[i]["ad_maxngacceptqty"].ToString();
- ad_qty.Text = dt.Rows[i]["ad_qty"].ToString();
- Find = true;
- }
- }
- }
- if (!Find)
- {
- ob_maxngacceptqty.Text = "";
- ad_qty.Text = "";
- }
- }
- }
- private void ad_qty_TextChanged_1(object sender, EventArgs e)
- {
- for (int i = 0; i < CheckTypeDGV.Rows.Count; i++)
- {
- CheckTypeDGV.Rows[i].Cells["oi_sampleqty"].Value = ad_qty.Text;
- }
- }
- }
- }
|