| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Collections;
- using System.IO;
- using System.Diagnostics;
- using Infragistics.Win.UltraWinGrid;
- using CoreFS.CA06;
- using Core.StlMes.Client.LgCommon;
- namespace Core.StlMes.Client.LgResMgt
- {
- public partial class frmChargeConfig : frmStyleBase
- {
- private bool ok_flag = false;
- public string WorkShopNo = "";
- public frmChargeConfig(OpeBase ob_)
- {
- InitializeComponent();
- this.ob = ob_;
- }
- private void frmCutInfoAssit_Load(object sender, EventArgs e)
- {
- proc_Query();
- }
- // 查询全部料斗信息
- /// <summary>
- /// 查询全部料斗信息
- /// </summary>
- private void proc_Query()
- {
- try
- {
- string strErr = "";
- ArrayList arry = new ArrayList();
- arry.Add(WorkShopNo);
- CommonClientToServer ccTos = new CommonClientToServer();
- ccTos.ob = this.ob;
- DataSet ds = ccTos.ExecuteQueryFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
- "QueryWithParameter", "STL_RESULT0001", 5, arry, out strErr);
- ultraDataSource1.Rows.Clear();
- if (strErr == "" && ds != null)
- {
- if (ds.Tables.Count > 0)
- {
- foreach (DataRow dr in ds.Tables[0].Rows)
- {
- ultraDataSource1.Rows.Add(new object[] {
- dr["ID"].ToString(),
- dr["CHARGENO"].ToString(),
- dr["STATUS"].ToString(),
- dr["TAREWEIGHT"].ToString(),
- dr["MEMO"].ToString()
- });
- }
- // PublicMethod.RefreshAndAutoSize(ultraGrid1);
- }
- }
- }
- catch { }
- }
- // 新增料斗信息
- /// <summary>
- /// 新增料斗信息
- /// </summary>
- private void proc_Add()
- {
- try
- {
- if (txtChargeNo.Text.Length == 0)
- {
- MessageBox.Show("料斗号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- txtChargeNo.Focus();
- return;
- }
- //if (cboCutType.SelectedIndex < 0)
- //{
- // MessageBox.Show("切割类别不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // cboCutType.Focus();
- // return;
- //}
- //if (ultraFlux.SelectedIndex < 0)
- //{
- // MessageBox.Show("流号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // ultraFlux.Focus();
- // return;
- //}
- //if (txtLength.Text.Length == 0)
- //{
- // MessageBox.Show("长度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // txtLength.Focus();
- // return;
- //}
- //if (txtWeight.Text.Length == 0)
- //{
- // MessageBox.Show("重量不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // txtWeight.Focus();
- // return;
- //}
- //if (txtThickness.Text.Length == 0)
- //{
- // MessageBox.Show("厚度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // txtThickness.Focus();
- // return;
- //}
- //if (txtWidth.Text.Length == 0)
- //{
- // MessageBox.Show("宽度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // txtWidth.Focus();
- // return;
- //}
- string strErr = "";
- string strSqlID = "STL_RESULT0002"; //SQLID
- Hashtable ht = new Hashtable();
- ht.Add("I1", txtChargeNo.Text.Trim()); //料斗号
- ht.Add("I2", chkStatus.Checked ? "1" : "0"); //是否在用
- ht.Add("I3", txtWeight.Text.Trim()); //重量
- ht.Add("I4", WorkShopNo); //车间号
- ht.Add("I5", UserInfo.GetUserName()); //维护人
- ht.Add("I6", txtMemo.Text.Trim()); //备注
- ht.Add("O1", "");
- ht.Add("O2", "");
- CommonClientToServer ccTs = new CommonClientToServer();
- ccTs.ob = ob;
- CoreClientParam ccp = ccTs.ExecuteProcedureFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
- "executeProcedure", strSqlID, 5, ht, out strErr);
- ArrayList alReturn = ccp.ReturnObject as ArrayList;
- if (alReturn[3].ToString() == "")
- {
- MessageBox.Show("料斗信息新增成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- MessageBox.Show(alReturn[3].ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- catch { }
-
- }
- // 修改
- /// <summary>
- /// 修改
- /// </summary>
- private void proc_Edit()
- {
- try
- {
-
-
- //string heatno = txtChargeNo.Text.Trim();
- //string strErr = "";
- //ArrayList arry = new ArrayList();
- //arry.Add("IncisionAssistInfo.Query"); // 位于 QueryLgIntegration.xml 中
- //arry.Add(heatno);
- //if (WorkShopNo == "1")
- //{
- // arry.Add("0");
- // arry.Add("1");
- // arry.Add("2");
- //}
- //else
- //{
- // arry.Add("3");
- // arry.Add("4");
- // arry.Add("5");
- //}
- //CommonClientToServer ccs = new CommonClientToServer();
- //ccs.ob = this.ob;
- //DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
- //if (ds.Tables[0].Rows.Count == 0)
- //{
- // MessageBox.Show("炉号【" + heatno + "】不存在切割信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // return;
- //}
-
- //if (txtChargeNo.Text.Length != 8)
- //{
- // MessageBox.Show("炉号不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // txtChargeNo.Focus();
- // return;
- //}
- //if (cboCutType.SelectedIndex < 0)
- //{
- // MessageBox.Show("切割类别不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // cboCutType.Focus();
- // return;
- //}
- //if (ultraFlux.SelectedIndex < 0)
- //{
- // MessageBox.Show("流号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // ultraFlux.Focus();
- // return;
- //}
- //if (txtLength.Text.Length == 0)
- //{
- // MessageBox.Show("长度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // txtLength.Focus();
- // return;
- //}
- //if (txtWeight.Text.Length == 0)
- //{
- // MessageBox.Show("重量不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // txtWeight.Focus();
- // return;
- //}
- //if (txtThickness.Text.Length == 0)
- //{
- // MessageBox.Show("厚度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // txtThickness.Focus();
- // return;
- //}
- //if (txtWidth.Text.Length == 0)
- //{
- // MessageBox.Show("宽度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // txtWidth.Focus();
- // return;
- //}
- string strErr = "";
- string strSqlID = "STL_RESULT0003"; //SQLID
- Hashtable ht = new Hashtable();
- ht.Add("I1", txtChargeNo.Text.Trim()); //料斗号
- ht.Add("I2", chkStatus.Checked ? "1" : "0"); //是否在用
- ht.Add("I3", txtWeight.Text.Trim()); //重量
- ht.Add("I4", WorkShopNo); //车间号
- ht.Add("I5", UserInfo.GetUserName()); //维护人
- ht.Add("I6", txtMemo.Text.Trim()); //备注
- ht.Add("I7", ultraGrid1.ActiveRow.Cells["ID"].Value.ToString()); //ID
- ht.Add("O1", "");
- ht.Add("O2", "");
- CommonClientToServer ccTs = new CommonClientToServer();
- ccTs.ob = ob;
- CoreClientParam ccp = ccTs.ExecuteProcedureFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
- "executeProcedure", strSqlID, 5, ht, out strErr);
- ArrayList alReturn = ccp.ReturnObject as ArrayList;
- if (strErr == "")
- {
- MessageBox.Show("料斗信息修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- MessageBox.Show("料斗信息修改失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- catch { }
- }
- // 删除
- /// <summary>
- /// 删除
- /// </summary>
- private void proc_Delete()
- {
- try
- {
- if (ultraGrid1.Rows.Count == 0)
- {
- MessageBox.Show("没有可删除的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- if (ultraGrid1.ActiveRow == null)
- {
- MessageBox.Show("请选择要删除的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- DialogResult dr = MessageBox.Show("是否确认删除信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
- if (dr == DialogResult.No) return;
- string ID = ultraGrid1.ActiveRow.Cells["ID"].Value.ToString().Trim();
- string strErr = "";
- Hashtable ht = new Hashtable();
- ht.Add("I1", ID); //料斗号
- ht.Add("O1", "");
- ht.Add("O2", "");
- CommonClientToServer ccTs = new CommonClientToServer();
- ccTs.ob = ob;
- CoreClientParam ccp = ccTs.ExecuteProcedureFunctionsSqlID("Core.Mes.Server.Common.ComDataAccess",
- "executeProcedure", "STL_RESULT0004", 5, ht, out strErr);
- ArrayList alReturn = ccp.ReturnObject as ArrayList;
- if (strErr == "")
- {
- MessageBox.Show("料斗信息删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- MessageBox.Show("料斗信息删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- catch { }
- }
- // 设置编辑区域是否可编辑
- /// <summary>
- /// 设置编辑区域是否可编辑
- /// </summary>
- /// <param name="t_Enable"></param>
- private void setToolEnable(bool t_Enable)
- {
- try
- {
- txtChargeNo.ReadOnly = t_Enable;
- txtWeight.ReadOnly = t_Enable;
- chkStatus.Enabled = !t_Enable;
- txtMemo.ReadOnly = t_Enable;
- }
- catch { }
- }
- // 清空编辑区域
- /// <summary>
- /// 清空编辑区域
- /// </summary>
- private void clearWidget()
- {
- txtChargeNo.Text = "";
- txtWeight.Text = "0";
- chkStatus.Checked = false;
- txtMemo.Text = "";
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- base.ToolBar_Click(sender, ToolbarKey);
- switch (ToolbarKey)
- {
- case "Query":
- this.proc_Query();
- break;
- case "Add":
- this.proc_Add();
- break;
- case "Update":
- this.proc_Edit();
- break;
- case "Delete":
- this.proc_Delete();
- break;
- case "Export":
- try
- {
- Core.Mes.Client.Comm.Globals.ulGridToExcel(ultraGrid1, Text);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- break;
- case "Upload":
- this.proc_Query();
- break;
- case "Exit":
- this.Close();
- break;
- default:
- break;
- }
- }
- private void txtWeight_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.'))
- {
- e.Handled = true;
- }
- char[] arrary = ((TextBox)sender).Text.ToCharArray();
- if (e.KeyChar == '.')
- {
- if (arrary.Length == 0)
- {
- ((TextBox)sender).Text = "0.";
- ((TextBox)sender).SelectionStart = ((TextBox)sender).Text.Trim().Length;
- e.Handled = true;
- }
- else
- {
- for (int i = 0; i < arrary.Length; i++)
- {
- if (arrary[i] == '.')
- e.Handled = true;
- }
- }
- }
- if (arrary.Length == 1)
- {
- if (e.KeyChar == '0')
- {
- if (arrary[0] == '0')
- e.Handled = true;
- }
- if (arrary[0] == '0' && e.KeyChar != '.' && e.KeyChar != '\b' && e.KeyChar != '0')
- {
- ((TextBox)sender).Text = "0." + e.KeyChar.ToString();
- ((TextBox)sender).SelectionStart = ((TextBox)sender).Text.Trim().Length;
- e.Handled = true;
- }
- }
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- try
- {
- SetDetailToolBarEnable(false, "");
- setToolEnable(true);
- txtChargeNo.Text = ultraGrid1.ActiveRow.Cells["CHARGENO"].Value.ToString();
- txtWeight.Text = ultraGrid1.ActiveRow.Cells["TAREWEIGHT"].Value.ToString();
- chkStatus.Checked = ultraGrid1.ActiveRow.Cells["STATUS"].Value.ToString() == "是" ? true : false;
- txtMemo.Text = ultraGrid1.ActiveRow.Cells["MEMO"].Value.ToString();
- }
- catch { }
- }
- // 点击修改或删除时显示确认和取消按钮
- /// <summary>
- /// 点击修改或删除时显示确认和取消按钮
- /// </summary>
- /// <param name="bEnable"></param>
- private void SetDetailToolBarEnable(bool bEnable, string flag)
- {
- int count = this.uTbMTool.Tools.Count;
- for (int i = 0; i < count; i++)
- {
- this.uTbMTool.Tools[i].SharedProps.Enabled = !bEnable;
- }
- this.uTbMTool.Tools["ok"].SharedProps.Enabled = bEnable;
- this.uTbMTool.Tools["cancel"].SharedProps.Enabled = bEnable;
- this.uTbMTool.Tools["ok"].SharedProps.Visible = bEnable;
- this.uTbMTool.Tools["cancel"].SharedProps.Visible = bEnable;
- }
- private void ultraToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "add":
- SetDetailToolBarEnable(true, "add");
- setToolEnable(false);
- this.uTbMTool.Tools["ok"].Tag = "add";
- clearWidget();
- ok_flag = false;
- break;
- case "edit":
- if (ultraGrid1.Rows.Count == 0)
- {
- MessageBox.Show("没有可修改的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- if (ultraGrid1.ActiveRow == null)
- {
- MessageBox.Show("请选择要修改的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- SetDetailToolBarEnable(true, "edit");
- setToolEnable(false);
- this.uTbMTool.Tools["ok"].Tag = "edit";
- ok_flag = false;
- txtChargeNo.ReadOnly = true;
- break;
- case "del":
- proc_Delete();
- proc_Query();
- break;
- case "ok":
- string flag = this.uTbMTool.Tools["ok"].Tag.ToString();
- if (flag == "edit")
- {
- proc_Edit();
- }
- if (flag == "add")
- {
- proc_Add();
- }
- if (ok_flag)
- {
- SetDetailToolBarEnable(false, "");
- setToolEnable(true);
- }
- proc_Query();
- break;
- case "cancel":
- SetDetailToolBarEnable(false, "");
- setToolEnable(true);
- ultraGrid1_AfterRowActivate(null, null);
- break;
- case "left":
- if (ultraGrid1.Rows.Count == 0) return;
- //将位置移动到前一条记录
- try
- {
- if (ultraGrid1.ActiveRow == null)
- {
- ultraGrid1.Rows[0].Activate();
- }
- else
- {
- int nIndex = ultraGrid1.ActiveRow.Index;
- nIndex = nIndex - 1;
- if (nIndex < 0) nIndex = ultraGrid1.Rows.Count - 1;
- ultraGrid1.Rows[nIndex].Activate();
- }
- }
- catch { }
- break;
- case "right":
- if (ultraGrid1.Rows.Count == 0) return;
- //将位置移动到后一条记录
- try
- {
- if (ultraGrid1.ActiveRow == null)
- {
- ultraGrid1.Rows[0].Activate();
- }
- else
- {
- int nIndex = ultraGrid1.ActiveRow.Index;
- nIndex = nIndex + 1;
- if (nIndex >= ultraGrid1.Rows.Count) nIndex = 0;
- ultraGrid1.Rows[nIndex].Activate();
- }
- }
- catch { }
- break;
- }
- }
- }
- }
|