| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- 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 System.Collections;
- using CoreFS.CA06;
- using Core.StlMes.Client.LgCommon;
- namespace Core.StlMes.Client.LgResMgt
- {
- public partial class frmSteelConfiger : frmStyleBase
- {
- public string WorkShopNo = "";
- private ArrayList BeforeCode; //初始物料编码
- private ArrayList BeforeName; //初始物料名称
- public frmSteelConfiger(OpeBase oba)
- {
- InitializeComponent();
- this.ob = oba;
- BeforeCode = new ArrayList();
- BeforeName = new ArrayList();
- }
- private void frmSteelConfiger_Load(object sender, EventArgs e)
- {
- GetMater();
- GetConfigMater();
- }
- // 获得钢铁物料
- /// <summary>
- /// 获得钢铁物料
- /// </summary>
- private void GetMater()
- {
- try
- {
- string strErr = "";
- ArrayList arry = new ArrayList();
- arry.Add("ScrapSteelConfig.Query");
- CommonClientToServer ccs = new CommonClientToServer();
- ccs.ob = this.ob;
- DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
- try
- {
- if (ultraGrid2.Rows.Count > 0)
- {
- ((DataSet)ultraGrid2.DataSource).Tables[0].Rows.Clear();
- }
- }
- catch (Exception)
- {
- }
- if (ds.Tables[0].Rows.Count > 0)
- {
- this.ultraGrid2.DataSource = ds;
- }
- PublicMethod.RefreshAndAutoSize(ultraGrid2);
- }
- catch { }
- }
- // 获得已经配置的物料
- /// <summary>
- /// 获得已经配置的物料
- /// </summary>
- private void GetConfigMater()
- {
- try
- {
- string strErr = "";
- ArrayList arry = new ArrayList();
- arry.Add("ScrapSteel.Config");
- arry.Add(WorkShopNo);
- CommonClientToServer ccs = new CommonClientToServer();
- ccs.ob = this.ob;
- DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
- if (ds != null && ds.Tables[0].Rows.Count > 0)
- {
- string matercode = "";
- string matername = "";
- for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
- {
- matercode = ds.Tables[0].Rows[i]["SCRAPSTEELCODE"].ToString();
- matername = ds.Tables[0].Rows[i]["SCRAPSTEELNAME"].ToString();
- for (int j = 0; j < ultraGrid2.Rows.Count; j++)
- {
- if (matercode == ultraGrid2.Rows[j].Cells["MATERIELCODE"].Value.ToString())
- {
- ultraGrid2.Rows[j].Cells["FLAG"].Value = "True";
- string code = ultraGrid2.Rows[j].Cells["MATERIELCODE"].Value.ToString();
- string name = ultraGrid2.Rows[j].Cells["MATERIELNAME"].Value.ToString();
- BeforeCode.Add(code);
- BeforeName.Add(name);
- SetMater(code, name);
- }
- }
- }
- }
- }
- catch { }
- }
- private void SetMater(string matercode, string matername)
- {
- try
- {
- if (Mater1.Text.ToString() == "")
- {
- // Mater1.Tag = matercode;
- Mater1.Text = matername;
- return;
- }
- if (Mater2.Text.ToString() == "")
- {
- // Mater2.Tag = matercode;
- Mater2.Text = matername;
- return;
- }
- if ( Mater3.Text.ToString() == "")
- {
- // Mater3.Tag = matercode;
- Mater3.Text = matername;
- return;
- }
- if (Mater3.Text.ToString() == "")
- {
- // Mater3.Tag = matercode;
- Mater3.Text = matername;
- return;
- }
- if (Mater4.Text.ToString() == "")
- {
- // Mater4.Tag = matercode;
- Mater4.Text = matername;
- return;
- }
- if ( Mater5.Text.ToString() == "")
- {
- // Mater5.Tag = matercode;
- Mater5.Text = matername;
- return;
- }
- if ( Mater6.Text.ToString() == "")
- {
- // Mater6.Tag = matercode;
- Mater6.Text = matername;
- return;
- }
- else
- {
- // MessageBox.Show("最多只能配置6个物料!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- }
- catch { }
- }
- private void CancelMater(string matercode, string matername)
- {
- try
- {
- if (Mater1.Text.ToString() == matername)
- {
- // Mater1.Tag = "";
- Mater1.Text = "";
- return;
- }
- if (Mater2.Text.ToString() == matername)
- {
- // Mater2.Tag = "";
- Mater2.Text = "";
- return;
- }
- if (Mater3.Text.ToString() == matername)
- {
- // Mater3.Tag = "";
- Mater3.Text = "";
- return;
- }
- if (Mater3.Text.ToString() == matername)
- {
- // Mater3.Tag = "";
- Mater3.Text = "";
- return;
- }
- if (Mater4.Text.ToString() == matername)
- {
- // Mater4.Tag = "";
- Mater4.Text = "";
- return;
- }
- if ( Mater5.Text.ToString() == matername)
- {
- // Mater5.Tag = "";
- Mater5.Text = "";
- return;
- }
- if (Mater6.Text.ToString() == matername)
- {
- // Mater6.Tag = "";
- Mater6.Text = "";
- return;
- }
- }
- catch { }
- }
- private void ultraGrid2_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- try
- {
- ultraGrid2.UpdateData();
- string code = "";
- string name = "";
- int nvl = 0;
- int index = e.Cell.Row.Index;
- if (e.Cell.Column.Key.ToString() == "FLAG")
- {
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- if (ultraGrid2.Rows[i].Cells["FLAG"].Value.ToString() == "True")
- {
- nvl++;
- }
- }
- if (nvl > 6)
- {
- e.Cell.Value = "False";
- MessageBox.Show("最多只能配置6个物料!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (e.Cell.Value.ToString() == "True")
- {
- code = ultraGrid2.Rows[index].Cells["MATERIELCODE"].Value.ToString();
- name = ultraGrid2.Rows[index].Cells["MATERIELNAME"].Value.ToString();
- SetMater(code,name);
- }
- else
- {
- code = ultraGrid2.Rows[index].Cells["MATERIELCODE"].Value.ToString();
- name = ultraGrid2.Rows[index].Cells["MATERIELNAME"].Value.ToString();
- CancelMater(code, name);
- }
- }
- }
- catch { }
- }
- // 保存物料配置
- /// <summary>
- /// 保存物料配置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (ultraGrid2.Rows.Count == 0)
- {
- MessageBox.Show("没有可选的物料!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- ArrayList listMcode = new ArrayList(); //物料编码
- ArrayList listMname = new ArrayList(); //物料名称
- string flag = "0";
- bool blValue = false;
- if (ultraGrid2.Rows.Count > 0)
- {
- ultraGrid2.UpdateData();
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- if (Convert.ToBoolean(ultraGrid2.Rows[i].Cells["FLAG"].Value) == true)
- {
- listMcode.Add(ultraGrid2.Rows[i].Cells["MATERIELCODE"].Value.ToString().Trim());
- listMname.Add(ultraGrid2.Rows[i].Cells["MATERIELNAME"].Value.ToString().Trim());
- blValue = true;
- }
- }
- if (blValue == false)
- {
- if (MessageBox.Show("你当前没有选择任何物料!你确定保存?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- return;
- listMcode = BeforeCode;
- listMname = BeforeName;
- flag = "1";
- }
- }
- if (listMcode.Count > 0)
- {
- //定义一个ArrayList集合存储变量[参数]值
- string strErr = "";
- string strSqlID = "frmScrapMater.Config";
- object[] sArgs = new object[5];
- sArgs[0] = listMcode;
- sArgs[1] = listMname; //炉号
- sArgs[2] =this.UserInfo.GetUserName();
- sArgs[3] = flag;
- sArgs[4] = WorkShopNo;
- CommonClientToServer ccTs = new CommonClientToServer();
- ccTs.ob = ob;
- string strRCode = ccTs.ExecuteProcedureFunctions("Core.LgMes.Server.Common.ComDBProcedure",
- "ExecProcWithCollParam", strSqlID, sArgs, out strErr);
- if (strErr == "")
- {
- frmScrapSteel frm = (frmScrapSteel)this.Tag;
- frm.GetConfigMater();
- MessageBox.Show("物料保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- System.Threading.Thread.Sleep(500);
- this.Close();
- }
- else
- {
- MessageBox.Show("物料保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- }
- else
- {
- MessageBox.Show("物料保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- this.Close();
- }
- }
- catch { }
- }
- /// <summary>
- /// 取消
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
|