| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- 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 Core.Mes.Client.Comm.Server;
- using System.Collections;
- using Infragistics.Win.UltraWinGrid;
-
- namespace Core.StlMes.Client.YdmBase
- {
- public partial class frmRackDefine : FrmBase
- {
- public frmRackDefine()
- {
- InitializeComponent();
- this.IsLoadUserView = true;
- }
-
- /// <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 "Close":
- this.Close();
- break;
- }
- }
- ArrayList list = new ArrayList();
- bool isValid = false;
- private void frmRackDefine_Load(object sender, EventArgs e)
- {
- InitComBox();
- // QueryTree();
- getDepartMent();
- getDepartMent1();
- this.cmb_dw.Enabled = false;
- }
- /// <summary>
- /// 刷新
- /// </summary>
- private void DoRefresh()
- {
- InitComBox();
- //QueryTree();
- getDepartMent();
- getDepartMent1();
- }
- private void getDepartMent()
- {
- DataTable dt = new DataTable();
- string flag = "0";
- dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreRackDefine.doQueryData", new object[] {"1" }, this.ob);
- if (dt.Rows.Count > 0)
- {
- cmb_dw.DataSource = dt;
- cmb_dw.DisplayMember = "DEPARTNAME";
- cmb_dw.ValueMember = "DEPARTID";
- this.cmb_dw.SelectedIndex = -1;
- }
- }
- private void getDepartMent1()
- {
- DataTable dt = new DataTable();
- string flag = "0";
- dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreRackDefine.doQueryData", new object[] { "1" }, this.ob);
- if (dt.Rows.Count > 0)
- {
- cmbManage1.DataSource = dt;
- cmbManage1.DisplayMember = "DEPARTNAME";
- cmbManage1.ValueMember = "DEPARTID";
- }
- }
- //刷新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 InitComBox()
- {
- YdmBaseClass.InitComboEditor(cmbRackType, "com.steering.pss.ydm.base.YdmBaseQuery.getRackType", "BASECODE", this.ob, true);
- YdmBaseClass.InitComboEditor(cmbType1, "com.steering.pss.ydm.base.YdmBaseQuery.getRackType", "BASECODE", this.ob, false);
- //YdmBaseClass.InitComboEditor(cmbManage1, "com.steering.pss.ydm.base.YdmBaseQuery.getManagement", "BASECODE", this.ob, false);
- YdmBaseClass.InitComboEditor(cmbSupportRoom, "com.steering.pss.ydm.base.YdmBaseQuery.getRackSp", "BASECODE", this.ob, false);
- }
- private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
- {
- if (ultraCheckEditor1.Checked)
- {
- cmbRackType.ReadOnly = false;
- }
- else
- {
- cmbRackType.ReadOnly = true;
- }
- }
- /// <summary>
- /// 导出数据
- /// </summary>
- private void ExportGridData()
- {
- GridHelper.ulGridToExcel(gdRack,this.Text);
- }
- /// <summary>
- /// 获取编辑区的数据
- /// </summary>
- private bool GetData()
- {
- list = new ArrayList();
- if (cmbType1.SelectedItem == null)
- {
- MessageBox.Show("请选择料架类型", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false ;
- }
- if (cmbManage1.SelectedItem == null)
- {
- MessageBox.Show("请选择所属单位", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (txtRackWidth.Value==null)
- {
- MessageBox.Show("请输入料架宽度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (txtRackHeight.Value == null)
- {
- MessageBox.Show("请输入料架高度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (txtRackLen.Value == null)
- {
- MessageBox.Show("请输入料架长度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (txtBaseWidth.Value == null)
- {
- MessageBox.Show("请输入基座宽度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (txtBaseHeight == null)
- {
- MessageBox.Show("请输入基座高度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (Convert.ToInt32(txtRackWidth.Value) >Convert.ToInt32(txtBaseWidth.Value))
- {
- MessageBox.Show("基座宽度不能小于料架宽度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (Convert.ToInt32(txtRackHeight.Value) >Convert.ToInt32(txtBaseHeight.Value))
- {
- MessageBox.Show("基座高度不能小于料架高度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (cmbSupportRoom.SelectedItem == null)
- {
- MessageBox.Show("请选择支持空间", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- list.Add(cmbType1.Text.Trim()); //用于编码类型
- list.Add(cmbType1.Text.Trim()); //料架类型
- list.Add(txtBaseWidth.Value.ToString());
- list.Add(txtBaseHeight.Value.ToString());
- list.Add(txtRackWidth.Value.ToString());
- list.Add(txtRackHeight.Value.ToString());
- list.Add(txtRackLen.Value.ToString());
- list.Add(cmbSupportRoom.Text.Trim());
- list.Add(cmbManage1.Value.ToString());
- list.Add(cmbManage1.Text.Trim());
- list.Add(txtMemo.Text.Trim());
- list.Add(this.UserInfo.GetUserName());
- return true;
- }
- /// <summary>
- /// 新增数据
- /// </summary>
- private void DoAdd()
- {
- if(!GetData())return;
- if (list.Count <= 0)
- return;
- int count = ServerHelper.SetData("com.steering.pss.ydm.base.CoreRackDefine.doAdd", new Object[] { list }, this.ob);
- if (count > 0)
- {
- MessageBox.Show("数据新增成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- DoQuery();
- DataRow[] dr = dataTable1.Select("", "CREATE_TIME DESC");
- if (dr.Length > 0)
- YdmBaseClass.Postioning(gdRack,"RACK_NO",dr[0]["RACK_NO"].ToString());
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void DoQuery()
- {
- string manage = "";
- string racktype = "";
- if (this.ultraCheckEditor2.Checked)
- {
- if (string.IsNullOrEmpty(cmb_dw.Text.Trim()))
- {
- MessageBox.Show("请选择料架所属单位!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- else
- {
- manage = cmb_dw.Text.ToString();
- }
- }
- else
- {
- manage = "";
- }
- if (cmbRackType.SelectedItem != null && cmbRackType.Text != "")
- racktype = cmbRackType.Text;
- else
- racktype = "%";
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreRackDefine.doQuery", new Object[] { manage, racktype, isValid }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
- YdmBaseClass.SetGridRowColor(gdRack);
- YdmBaseClass.SetGridActivateOnly(gdRack);
- YdmBaseClass.SetColAutoSizeExceptMemo(gdRack);
- gdRack.DisplayLayout.Bands[0].Columns["CREATE_TIME"].SortIndicator = SortIndicator.Ascending;
- }
- /// <summary>
- /// 更新数据
- /// </summary>
- private void DoUpdate()
- {
- this.gdRack.UpdateData();
- UltraGridRow ugr = gdRack.ActiveRow;
- if (ugr == null)
- {
- MessageBox.Show("请选择需要修改的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- string rackNo = ugr.Cells["RACK_NO"].Text.ToString();
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreRackDefine.getReferRack", new object[] { rackNo }, this.ob);
- if (dt.Rows.Count > 0)
- {
- if (dt.Rows[0]["VALIDFLAG"].ToString() == "0")
- {
- MessageBox.Show("无效数据,无法修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (dt.Rows[0]["USE_FLAG"].ToString() == "1")
- {
- MessageBox.Show("数据已被引用,无法修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- if(!GetData())return;
- string newrackno="";
- if (list.Count > 0)
- {
- string rackno = ugr.Cells["RACK_NO"].Value.ToString();
- newrackno = rackno.Replace(rackno.Substring(0, 1), cmbType1.Text.Trim());
- list.RemoveAt(0);
- list.Add(newrackno);
- list.Add(rackno);
- }
- if (MessageBox.Show("是否确认修改该行数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- int count = ServerHelper.SetData("com.steering.pss.ydm.base.CoreRackDefine.doUpdate", new Object[] { list }, this.ob);
- if (count > 0)
- {
- MessageBox.Show("数据修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- DoQuery();
- YdmBaseClass.Postioning(gdRack,"RACK_NO",newrackno);
- }
- }
- /// <summary>
- /// 行激活事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void gdRack_AfterRowActivate(object sender, EventArgs e)
- {
- this.gdRack.UpdateData();
- UltraGridRow ugr = gdRack.ActiveRow;
- if (ugr == null)
- {
- return;
- }
- string rackno = ugr.Cells["RACK_NO"].Value.ToString();
- txtRacknoHead.Value = rackno.Substring(0, 1);
- txtRacknoTail.Value = rackno.Substring(1, 5);
- cmbType1.Text= ugr.Cells["RACK_TYPE"].Value.ToString();
- this.cmbManage1.Text = ugr.Cells["HL_MANAGEMENT_NAME"].Text.ToString();
- txtRackWidth.Value = ugr.Cells["RACK_WIDTH"].Value.ToString();
- txtRackHeight.Value = ugr.Cells["RACK_HEIGHT"].Value.ToString();
- txtRackLen.Value = ugr.Cells["RACK_LEN"].Value.ToString();
- txtBaseWidth.Value = ugr.Cells["BASE_WIDTH"].Value.ToString();
- txtBaseHeight.Value = ugr.Cells["BASE_HEIGHT"].Value.ToString();
- switch (ugr.Cells["RACK_RL"].Value.ToString())
- {
- case"左侧":
- cmbSupportRoom.Text = "L";
- break;
- case "右侧":
- cmbSupportRoom.Text = "R";
- break;
- case "两侧":
- cmbSupportRoom.Text = "LR";
- break;
- }
- txtMemo.Value = ugr.Cells["MEMO"].Value.ToString();
- }
- /// <summary>
- /// 作废或恢复数据
- /// </summary>
- /// <param name="flag">true 作废 false 恢复</param>
- private void DoDeleteOrResume(bool flag)
- {
- UltraGridRow ugr = gdRack.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 (MessageBox.Show("是否确认" + (flag ? "作废" : "恢复") + "该行数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- string rackno = ugr.Cells["RACK_NO"].Value.ToString();
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.CoreRackDefine.getReferRack", new object[] { rackno }, this.ob);
- if (dt.Rows.Count > 0)
- {
- if (dt.Rows[0]["VALIDFLAG"].ToString() == "0")
- {
- MessageBox.Show("无效数据,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (dt.Rows[0]["USE_FLAG"].ToString() == "1")
- {
- MessageBox.Show("数据已被引用,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- string name = this.UserInfo.GetUserName();
- int count = ServerHelper.SetData("com.steering.pss.ydm.base.CoreRackDefine.doDelete", new Object[] { rackno,name,flag }, this.ob);
- if (count > 0)
- {
- MessageBox.Show("数据" + (flag ? "作废" : "恢复") + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- DoQuery();
- }
- }
- private void chkValid_CheckedChanged(object sender, EventArgs e)
- {
- if (chkValid.Checked)
- {
- isValid = true;
- }
- else
- {
- isValid = false;
- }
- }
- private void ultraCheckEditor2_CheckedChanged(object sender, EventArgs e)
- {
- this.cmb_dw.Enabled = this.ultraCheckEditor2.Checked;
- }
- }
- }
|