| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972 |
- 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 CoreFS.CA06;
- using Core.Mes.Client.Comm.Control;
- using System.Text.RegularExpressions;
- using Core.Mes.Client.Comm.Server;
- using Infragistics.Win.UltraWinGrid;
- using Core.Mes.Client.Comm.Tool;
- using System.Collections;
- using Infragistics.Win;
- namespace Core.StlMes.Client.YdmBase
- {
- public partial class frmLocationDefine : FrmBase
- {
- public frmLocationDefine()
- {
- InitializeComponent();
- this.IsLoadUserView = true;
- }
- bool isvalid = false; //包含无效
- string isdummy = "0"; //是否虚拟 默认不虚拟
- string islock = "1"; //是否封锁 默认释放
- ArrayList parms = new ArrayList();
- private ArrayList listLoca = new ArrayList(); //勾选的奇数位的料位编码
- private ArrayList listRack = new ArrayList(); //供选择的料架
- private ArrayList listSelected = new ArrayList(); //已经选择的料架
- private ArrayList returnlist; //传回来的料位码-料架码
- public ArrayList Returnlist
- {
- get { return returnlist; }
- set { returnlist = value; }
- }
- /// <summary>
- /// 重写基类方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- DoQuery();
- break;
- case "Add":
- DoAdd();
- break;
- case "Update":
- DoUpdate();
- break;
- case "Delete":
- DoDeleteOrResume(true);
- break;
- case "Resume":
- DoDeleteOrResume(false);
- break;
- case "Refresh":
- DoRefresh();
- break;
- case "Export":
- ExportGridData();
- break;
- case "Rack":
- DoRack();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 初始化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void frmLocationDefine_Load(object sender, EventArgs e)
- {
- InitComBo();
- //InitGrid2();
- //QueryTree();
- //getDepartMent();
- cbm_Dw.Enabled = false;
- YdmBaseClass.InitSection(cbm_Dw, this.ValidDataPurviewIds, this.ob);
-
- }
- //加载作业单位
- private void getDepartMent()
- {
- //DataTable dt = new DataTable();
- //string flag = "0";
- //string userName = this.UserInfo.GetUserName();
- //string departMent = ClsBaseInfo.GetDepartBySectionId(UserInfo.GetDeptid(), this.ob);
- //if (userName.Equals("admin"))
- //{
- // dt = ServerHelper.GetData("com.steering.pss.ydm.base.YdmBaseQuery.departQuery", new object[] { departMent, flag }, this.ob);
- // if (dt.Rows.Count > 0)
- // {
- // cbm_Dw.DataSource = dt;
- // cbm_Dw.DisplayMember = "DEPARTNAME";
- // cbm_Dw.ValueMember = "DEPARTID";
- // this.cbm_Dw.SelectedIndex = -1;
- // }
- //}
- //else
- //{
- // flag = "1";
- // dt = ServerHelper.GetData("com.steering.pss.ydm.base.YdmBaseQuery.departQuery", new object[] { departMent, flag }, this.ob);
- // if (dt.Rows.Count > 0)
- // {
- // cbm_Dw.DataSource = dt;
- // cbm_Dw.DisplayMember = "DEPARTNAME";
- // cbm_Dw.ValueMember = "DEPARTID";
- // this.cbm_Dw.SelectedIndex = 0;
- // }
- //}
- }
- //刷新Tree
- public void QueryTree()
- {
- //this.cmbManage.Nodes.Clear();
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.YdmBaseQuery.departQuery", null, this.ob);
- //树控件递归绑定方法。
- //YdmBaseClass.MakeTree(dt, "PID", null, "DEPARTID", "DEPARTNAME", cmbManage.Nodes, -1);
- }
- /// <summary>
- /// 初始化下拉框
- /// </summary>
- private void InitComBo()
- {
- YdmBaseClass.InitComboEditor(cmbLocationType, "com.steering.pss.ydm.base.YdmBaseQuery.getLocationType", "BASECODE", this.ob,false);
- YdmBaseClass.InitComboEditor(cmbLocationAttr, "com.steering.pss.ydm.base.YdmBaseQuery.getLocationAttribute", "BASECODE", this.ob, false);
- }
- /// <summary>
- /// 初始化左边GRID的仓库数据
- /// </summary>
- private void InitGrid2()
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.getStorage", null, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
- YdmBaseClass.SetGridActivateOnly(ultraGrid2);
- }
- /// <summary>
- /// 刷新
- /// </summary>
- private void DoRefresh()
- {
- // InitGrid2();
- InitComBo();
- //QueryTree();
- }
- /// <summary>
- /// 导出
- /// </summary>
- private void ExportGridData()
- {
- GridHelper.ulGridToExcel(ultraGrid1, this.Text);
- }
- /// <summary>
- /// 获取编辑区的数据
- /// </summary>
- private void GetEditData()
- {
- ultraGrid2.UpdateData();
- UltraGridRow ugr = ultraGrid2.ActiveRow;
- if (ugr == null)
- {
- MessageBox.Show("请选择对应的库号行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- parms = new ArrayList();
- if (cmbLocationType.SelectedItem == null)
- {
- MessageBox.Show("请选择料位类型", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- string locatype="";
- switch (cmbLocationType.Text.Trim())
- {
- case "垛位":
- locatype = "D";
- break;
- case "料架":
- locatype = "J";
- break;
- }
- if (cmbLocationAttr.SelectedItem == null)
- {
- MessageBox.Show("请选择料位属性", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (txtArea.Text.Trim() == "")
- {
- MessageBox.Show("请输入区号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (txtRow.Text.Trim() == "")
- {
- MessageBox.Show("请输入行号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (txtColStart.Text.Trim() == "")
- {
- MessageBox.Show("请输入列号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (txtColEnd.Text.Trim() != "")
- {
- if (Convert.ToInt16(txtColEnd.Value.ToString()) < Convert.ToInt16(txtColStart.Value.ToString()))
- {
- MessageBox.Show("列号结束位置不能小于起始位置", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- if (txtXCoordinates.Text.Trim() == "")
- {
- MessageBox.Show("请输入X坐标", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (!StringUtil.Is_Below_zero(txtXCoordinates.Value.ToString()))
- {
- MessageBox.Show("X坐标,请输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (txtYCoordinates.Text.Trim() == "")
- {
- MessageBox.Show("请输入Y坐标", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (!StringUtil.Is_Below_zero(txtYCoordinates.Value.ToString()))
- {
- MessageBox.Show("Y坐标,请输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (locatype == "D")
- {
- if (txtLocationWidth.Text.Trim() == "")
- {
- MessageBox.Show("请输入料位宽度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (!StringUtil.Is_Below_zero(txtLocationWidth.Value.ToString()))
- {
- MessageBox.Show("料位宽度,请输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (txtLocationHeght.Text.Trim() == "")
- {
- MessageBox.Show("请输入料位高度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (!StringUtil.Is_Below_zero(txtLocationHeght.Value.ToString()))
- {
- MessageBox.Show("料位高度,请输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (txtLocationLen.Text.Trim() == "")
- {
- MessageBox.Show("请输入料位长度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (!StringUtil.Is_Below_zero(txtLocationLen.Value.ToString()))
- {
- MessageBox.Show("料位长度,请输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- parms.Add(txtStorNo.Text.Trim());
- parms.Add(locatype);
- parms.Add(txtArea.Text.Trim());
- parms.Add(txtRow.Text.Trim());
- parms.Add(txtColStart.Text.Trim()); //初始列号
- parms.Add(txtColEnd.Text.Trim()); //结束列号
- parms.Add(txtLocationLen.Text.Trim()); //长
- parms.Add(txtLocationWidth.Text.Trim()); //宽
- parms.Add(txtLocationHeght.Text.Trim()); //高
- parms.Add(txtXCoordinates.Text.Trim());
- parms.Add(txtYCoordinates.Text.Trim());
- parms.Add(islock);
- parms.Add(cmbLocationAttr.Value.ToString());
- parms.Add(cmbLocationAttr.Text.Trim());
- parms.Add(isdummy);
- parms.Add(ugr.Cells["MANAGEMENT_NO"].Value.ToString());
- parms.Add(ugr.Cells["MANAGEMENT_NAME"].Value.ToString());
- parms.Add(ugr.Cells["DEPARTMENT_CODE"].Value.ToString());
- parms.Add(ugr.Cells["DEPARTMENT_DESC"].Value.ToString());
- parms.Add(this.UserInfo.GetUserName());
- parms.Add(txtMemo.Text.Trim()); //备注
- parms.Add(txtLocationName.Text.Trim());//料位名称
- parms.Add(txtRackType.Value.ToString3());
- parms.Add(txtRackQuality.Value.ToString3());
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void DoQuery()
- {
- if (!CheckQuery()) return;
- string LocationNo = "";//库位编码
- string RackNo = "";//料位号
- string storageno = "";
- //if (chkStorageNo.Checked)
- //{
- // storageno = txtStorageNo.Text.Trim();
- //}
- //else
- //{
- // storageno = ugr.Cells["STORAGE_NO"].Value.ToString();
- //}
- //if (chkLocationNo.Checked)
- // LocationNo = txtLocationNo.Text.Trim();
- //if (chkRackNo.Checked)
- // RackNo = txtRackNo.Text.Trim();
- string management="";
- string departMent = "";
- //if (ultraCheckEditor2.Checked)
- //{
- // management = cbm_Dw.SelectedValue.ToString();
- //}
- if (this.ultrlSection.Checked)
- {
- if (cbm_Dw.Text.ToString() == "")
- {
- MessageBox.Show("请选择作业科室!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- else
- {
- departMent = cbm_Dw.Value.ToString();
- }
- }
- string[] arr = YdmBaseClass.BaseSection(this.ValidDataPurviewIds, this.ob);
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.getStorage", new object[] { departMent, arr }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
- YdmBaseClass.SetGridActivateOnly(ultraGrid2);
- }
- /// <summary>
- /// 查询时验证
- /// </summary>
- /// <returns></returns>
- private bool CheckQuery()
- {
- if (chkStorageNo.Checked && string.IsNullOrEmpty(txtStorageNo.Text.Trim()))
- {
- MessageBox.Show("请输入库号编码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (chkLocationNo.Checked && string.IsNullOrEmpty(txtLocationNo.Text.Trim()))
- {
- MessageBox.Show("请输入库位编码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (chkRackNo.Checked && string.IsNullOrEmpty(txtRackNo.Text.Trim()))
- {
- MessageBox.Show("请输入料架号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- //if (ultraCheckEditor2.Checked && string.IsNullOrEmpty(cmbManage.Text.Trim()))
- //{
- // MessageBox.Show("请选择作业单位!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return false;
- //}
- return true;
- }
- /// <summary>
- /// 增加、修改时数据验证
- /// </summary>
- /// <returns></returns>
- private bool updateAddCheck()
- {
-
- if(txtArea.Text.Trim() == "")
- {
- MessageBox.Show("区号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (txtRow.Text.Trim() == "")
- {
- MessageBox.Show("行号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (!StringUtil.IsInt32(txtColStart.Text.Trim()))
- {
- MessageBox.Show("开始列号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (!StringUtil.IsInt32(txtColEnd.Text.Trim()))
- {
- MessageBox.Show("结束列号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (!StringUtil.IsInt32(txtXCoordinates.Text.Trim()))
- {
- MessageBox.Show("X坐标不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (!StringUtil.IsInt32(txtYCoordinates.Text.Trim()))
- {
- MessageBox.Show("Y坐标不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (!StringUtil.IsInt32(txtLocationWidth.Text.Trim()))
- {
- MessageBox.Show("料位宽度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (!StringUtil.IsInt32(txtLocationHeght.Text.Trim()))
- {
- MessageBox.Show("料位高度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (!StringUtil.IsInt32(txtLocationLen.Text.Trim()))
- {
- MessageBox.Show("料位长度不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- return true;
- }
- /// <summary>
- /// 新增
- /// </summary>
- private void DoAdd()
- {
- string type = "";
- if (!updateAddCheck()) return;
- if(this.cmbLocationType.Text.ToString() == "垛位")
- {
- type = "D";
- }
- else if(this.cmbLocationType.Text.ToString() == "料架")
- {
- type = "J";
- }
- string row = this.txtRow.Text.Trim();//行号
- string storeNo = this.txtStorNo.Text.Trim();//库号
- string areNo = this.txtArea.Text.Trim();//区号
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.getDorJ", new object[] { row, storeNo,areNo }, this.ob);
- if (dt.Rows.Count > 0)
- {
- if (!dt.Rows[0]["LOCATION_TYPE"].ToString().Equals(type))
- {
- MessageBox.Show("一排中不允许既维护垛位又维护料架!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- GetEditData();
- if (parms.Count <=0)
- {
- return;
- }
- int count = 0;
-
- try
- {
- count = ServerHelper.SetData("com.steering.pss.ydm.base.CoreLocationDefine.doAdd", new Object[] { parms }, this.ob);
- }catch(Exception )
- {
- return;
- }
- if (count > 0)
- {
- MessageBox.Show("数据新增成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- //DoQuery();
- queryUltraGrid1();
- }
- }
- /// <summary>
- /// 更新数据
- /// </summary>
- private void DoUpdate()
- {
- string locano = "";
- string type = "";
- if (!updateAddCheck()) return;
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (ugr == null)
- {
- MessageBox.Show("请选择需要修改的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (ugr.Cells["VALIDFLAG"].Value.ToString() == "无效")
- {
- MessageBox.Show("无效数据,无法修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
-
- if (this.cmbLocationType.Text.ToString() == "垛位")
- {
- type = "D";
- }
- else if (this.cmbLocationType.Text.ToString() == "料架")
- {
- type = "J";
- }
- string row = this.txtRow.Text.Trim();
- string storeNo = this.txtStorNo.Text.Trim();//库号
- string areNo = this.txtArea.Text.Trim();//区号
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.getDorJ", new object[] { row, storeNo, areNo }, this.ob);
- if (dt.Rows.Count > 0)
- {
- if (!dt.Rows[0]["LOCATION_TYPE"].ToString().Equals(type))
- {
- MessageBox.Show("一排中不允许既维护垛位又维护料架!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- GetEditData();
- if (parms.Count > 0)
- {
- locano = ugr.Cells["LOCATION_NO"].Value.ToString();
- parms.Add(locano);
- }
- //if (txtArea.Text.Trim() != this.ultraGrid1.ActiveRow.Cells["AREA_NO"].Text.Trim())
- //{
- // MessageBox.Show("区号不允许修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return;
- //}
- //if (txtRow.Text.Trim() != this.ultraGrid1.ActiveRow.Cells["ROW_NO"].Text.Trim())
- //{
- // MessageBox.Show("行号不允许修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return;
- //}
- //if (txtColStart.Text.Trim() != this.ultraGrid1.ActiveRow.Cells["COL_NO"].Text.Trim())
- //{
- // MessageBox.Show("列号不允许修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return;
- //}
-
- int count = 0;
- if (MessageBox.Show("是否确认修改该行数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- try
- {
- count = ServerHelper.SetData("com.steering.pss.ydm.base.CoreLocationDefine.doUpdate", new Object[] { parms }, this.ob);
- }catch(Exception)
- {
- return;
- }
- if (count > 0)
- {
- MessageBox.Show("数据修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- queryUltraGrid1();
- foreach(UltraGridRow ulgr in ultraGrid1.Rows){
- if (ulgr.Cells["LOCATION_NO"].Value.ToString().Equals(locano))
- {
- ulgr.Activate();
- }
- }
-
- }
- }
- /// <summary>
- /// UltraGrid激活某行
- /// </summary>
- /// <param name="ug">UltraGrid</param>
- /// <param name="keys">列名</param>
- /// <param name="values">对应的值</param>
- public static void UltraGridLocation(UltraGrid ug, String[] keys, String[] values)
- {
- if (ug.Rows.Count == 0)
- {
- return;
- }
- if (keys.Length == 0 || values.Length == 0 || values.Length != keys.Length)
- {
- return;
- }
- foreach (UltraGridRow ugr in ug.Rows)
- {
- Boolean flag = true;
- for (int i = 0; i < keys.Length; i++)
- {
- if (!ugr.Cells[keys[i]].ToString().Equals(values[i]))
- {
- flag = false;
- }
- }
- if (flag == true)
- {
- ugr.Activate();
- return;
- }
- }
- }
- /// <summary>
- /// 作废或恢复
- /// </summary>
- /// <param name="flag">true 作废 false 恢复</param>
- private void DoDeleteOrResume(bool flag)
- {
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (ugr == null)
- {
- MessageBox.Show("请选择你要操作的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (flag == false && ugr.Cells["VALIDFLAG"].Value.ToString().ToUpper() == "有效")
- {
- MessageBox.Show("有效数据,无法恢复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (flag == true && ugr.Cells["VALIDFLAG"].Value.ToString().ToUpper() != "有效")
- {
- MessageBox.Show("无效数据,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (flag == true && ugr.Cells["RACK_NO"].Text.ToString() != "")
- {
- MessageBox.Show("此料位维护了料架信息,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- else
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.getButessCount", new object[] { ugr.Cells["LOCATION_NO"].Text.ToString().Trim() }, this.ob);
- if (int.Parse(dt.Rows[0][0].ToString()) > 0)
- {
- MessageBox.Show("此料位已存放实物,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- if (MessageBox.Show("是否确认" + (flag ? "删除" : "恢复") + "该行数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- string rackno = ugr.Cells["LOCATION_NO"].Value.ToString();
- string name = this.UserInfo.GetUserName();
- int count = ServerHelper.SetData("com.steering.pss.ydm.base.CoreLocationDefine.doDelete", new Object[] { rackno, name, flag }, this.ob);
- if (count > 0)
- {
- MessageBox.Show("数据" + (flag ? "删除" : "恢复") + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- //DoQuery();
- queryUltraGrid1();
-
- }
- }
- /// <summary>
- /// 料架维护
- /// </summary>
- private void DoRack()
- {
- listLoca = new ArrayList();
- listRack= new ArrayList();
- listSelected= new ArrayList();
- returnlist = new ArrayList();
- ArrayList locarack = new ArrayList(); //料位-料架
- ArrayList rackupdate = new ArrayList(); //需要更新的料架
- ArrayList newrackno = new ArrayList(); //更新后的料架编号
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (row.Selected || row.Activated)
- {
- string locationno = row.Cells["LOCATION_NO"].Value.ToString();
- int _locationNo = int.Parse(locationno.Substring(locationno.Length -1,1));
- if (_locationNo % 2 != 0)
- {
- //int col = Convert.ToInt16(locationno.Substring(locationno.Length - 2, 2));
- //col % 2 == 1&&
- if (row.Cells["LOCATION_TYPE"].Value.ToString() == "J" && row.Cells["VALIDFLAG"].Value.ToString() == "有效") // 垛位不能维护料架
- {
- listLoca.Add(locationno);
- listSelected.Add(row.Cells["RACK_NO"].Value.ToString());
- }
- }
- }
- }
- if (listLoca.Count > 0)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.getRack", null, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- listRack.Add(dt.Rows[i][0]);
- }
- }
- else
- {
- MessageBox.Show("没有可供选择的料架", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- FrmRackSelect frs = new FrmRackSelect();
- frs.Localist = listLoca;
- frs.Racklist = listRack;
- frs.Selectlist = listSelected;
- frs.ShowDialog();
- if (frs.flag == false)
- return; //窗口的关闭不是确定引起的 不进行信息更新。
- this.Returnlist = frs.ReturnData;
- if (returnlist.Count > 0)
- {
- for (int i = 0; i < returnlist.Count; i++)
- {
- ArrayList list = new ArrayList();
- string msg = returnlist[i].ToString();
- char[] ch = { ',' };
- string[] str = msg.Split(ch, StringSplitOptions.RemoveEmptyEntries);
- if (str.Length >0)
- {
- string locationno = str[0];
- string rackno="";
- if(str.Length==2)
- rackno = str[1];
- DataRow[] dr = dt.Select("RACK_NO='"+rackno+"'", "");
- if (dr.Length > 0)
- {
- string basewidth = dr[0]["BASE_WIDTH"].ToString();
- string baseheight = dr[0]["BASE_HEIGHT"].ToString();
- string racklen = dr[0]["RACK_LEN"].ToString();
- list.Add(rackno);
- list.Add(Convert.ToDouble(racklen) / 1000);
- list.Add(Convert.ToDouble(basewidth) / 1000);
- list.Add(Convert.ToDouble(baseheight) / 1000);
- list.Add(locationno);
- newrackno.Add(rackno);
- locarack.Add(list);
- }
- else
- {
- list.Add(rackno);
- list.Add("");
- list.Add("");
- list.Add("");
- list.Add(locationno);
- newrackno.Add(rackno);
- locarack.Add(list);
- }
- }
- }
- }
- //以前的料架编码和选择以后的料架编码作比较,被取消了的就该把其状态更新为未使用。
- for (int i = 0; i < listSelected.Count; i++)
- {
- if (!newrackno.Contains(listSelected[i].ToString()))
- rackupdate.Add(listSelected[i].ToString());
- }
- int count = ServerHelper.SetData("com.steering.pss.ydm.base.CoreLocationDefine.setRack", new Object[] { locarack,rackupdate }, this.ob);
- if (count > 0)
- {
- MessageBox.Show("料架维护成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- queryUltraGrid1();
- }
- }
- else
- {
- MessageBox.Show("垛位与料位偶数位不能维护料架!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
-
- private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
- {
- if (chkLocationNo.Checked)
- {
- txtLocationNo.ReadOnly = false;
- }
- else
- {
- txtLocationNo.ReadOnly = true;
- }
- }
- private void ultraCheckEditor3_CheckedChanged(object sender, EventArgs e)
- {
- if (chkRackNo.Checked)
- {
- txtRackNo.ReadOnly = false;
- }
- else
- {
- txtRackNo.ReadOnly = true;
- }
- }
- private void ultraCheckEditor6_CheckedChanged(object sender, EventArgs e)
- {
- if (chkStorageNo.Checked)
- {
- txtStorageNo.ReadOnly = false;
- }
- else
- {
- txtStorageNo.ReadOnly = true;
- }
- }
- private void ultraCheckEditor7_CheckedChanged(object sender, EventArgs e)
- {
- if (chkValid.Checked)
- {
- isvalid = true;
- }
- else
- {
- isvalid = false;
- }
- }
- /// <summary>
- /// 文本框输入事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraTextEditor5_KeyPress(object sender, KeyPressEventArgs e)
- {
- string reg = "^[1-9A-Z]$"; //只能输入1-9 A-Z和退格键
- string word = e.KeyChar.ToString();
- if (Regex.IsMatch(word, reg)||e.KeyChar=='\b')
- e.Handled = false;
- else
- e.Handled = true;
- }
- /// <summary>
- /// 查询ultraGrid1
- /// </summary>
- private void queryUltraGrid1()
- {
- UltraGridRow ugr = ultraGrid2.ActiveRow;
- if (ugr == null)
- return;
- txtStorNo.Value = ugr.Cells["STORAGE_NO"].Value.ToString();
- string dummy = ugr.Cells["DUMMY_FLAG"].Value.ToString();
- if (dummy == "1") //库是虚拟的 料位也必须是虚拟的
- {
- chkVitual.Checked = true;
- chkVitual.Enabled = false;
- }
- else //库不是虚拟的 料位可以虚拟 也可不虚拟
- {
- chkVitual.Checked = false;
- chkVitual.Enabled = true;
- }
- string storageno = ugr.Cells["STORAGE_NO"].Value.ToString(); ;//库号编码
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreLocationDefine.doQuery", new Object[] { isvalid, storageno }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);
- YdmBaseClass.SetGridActivateOnly(ultraGrid1);
- YdmBaseClass.SetGridRowColor(ultraGrid1);
- YdmBaseClass.SetColAutoSizeExceptMemo(ultraGrid1);
- }
- /// <summary>
- /// 行激活事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- queryUltraGrid1();
- }
- //private void ultraTextEditor6_KeyPress(object sender, KeyPressEventArgs e)
- //{
- // if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)13 && e.KeyChar != (char)8)
- // {
- // e.Handled = true;
- // }
- //}
- private void ultraTextEditor9_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)13 && e.KeyChar != (char)8)
- {
- e.Handled = true;
- }
- }
- private void ultraTextEditor8_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)13 && e.KeyChar != (char)8)
- {
- e.Handled = true;
- }
- }
- private void ultraCheckEditor5_CheckedChanged(object sender, EventArgs e)
- {
- if (chkVitual.Checked)
- isdummy = "1";
- else
- isdummy = "0";
- }
- private void ultraCheckEditor4_CheckedChanged(object sender, EventArgs e)
- {
- if (chkLock.Checked)
- islock = "0";
- else
- islock = "1";
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- ultraGrid1.UpdateData();
- UltraGridRow ugr = ultraGrid1.ActiveRow;
- if (ugr == null)
- return;
- switch (ugr.Cells["LOCATION_TYPE"].Value.ToString())
- {
- case "D":
- cmbLocationType.Text = "垛位";
- break;
- case "J":
- cmbLocationType.Text = "料架";
- break;
- }
- txtLocaNo.Text = ugr.Cells["LOCATION_NO"].Value.ToString();
- cmbLocationAttr.Text = ugr.Cells["LOCATION_ATTR_NAME"].Value.ToString();
- txtArea.Value = ugr.Cells["AREA_NO"].Value.ToString();
- txtRow.Value = ugr.Cells["ROW_NO"].Value.ToString();
- txtColStart.Value = ugr.Cells["COL_NO"].Value.ToString();
- txtColEnd.Value = ugr.Cells["COL_NO"].Value.ToString();
- txtMemo.Value = ugr.Cells["MEMO"].Value.ToString();
- txtXCoordinates.Value = ugr.Cells["X_COORDINATE"].Value.ToString();
- txtYCoordinates.Value = ugr.Cells["Y_COORDINATE"].Value.ToString();
- txtLocationWidth.Value = ugr.Cells["LOCATION_WIDTH"].Value.ToString();
- txtLocationHeght.Value = ugr.Cells["LOCATION_HEIGHT"].Value.ToString();
- txtLocationLen.Value = ugr.Cells["LOCATION_LEN"].Value.ToString();
- chkLock.Checked = Convert.ToBoolean(ugr.Cells["LOCATION_STATE"].Value);
- chkVitual.Checked = Convert.ToBoolean(ugr.Cells["DUMMY_FLAG"].Value);
- txtLocationName.Text = ugr.Cells["LOCATION_NAME"].Text.ToString();
- txtRackType.Value = ugr.Cells["RACK_TYPE"].Value.ToString();
- txtRackQuality.Value = ugr.Cells["RACK_QUALITY"].Value.ToString();
- }
- private void frmLocationDefine_Shown(object sender, EventArgs e)
- {
- //toolMenu.Toolbars[0].Tools["Resume"].InstanceProps.Visible = DefaultableBoolean.False;
-
- }
- private void ultrlSection_CheckedChanged(object sender, EventArgs e)
- {
- cbm_Dw.Enabled = this.ultrlSection.Checked;
- }
- }
- }
|