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;
namespace Core.LZMes.Client.UIM
{
public partial class UIM010020 : FrmBase
{
private string NODE_ID = "";
public UIM010020()
{
InitializeComponent();
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
//this.DoQuery();
break;
case "Add":
this.DoAdd();
break;
case "Update":
this.DoUpdate();
break;
case "Delete":
this.DoDelete();
break;
}
}
///
/// 根据树节点查询垛位信息
///
///
private void DoQuery(string nodeId)
{
try
{
this.dataSet1.Tables[0].Clear();
//节点类型 0为根节点,1为区域类型节点,2为区域节点
int nodeType = 2;
if ("-1".Equals(nodeId))
{
nodeType = 0;
}
else if (0 <= nodeId.IndexOf("type"))
{
nodeType = 1;
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010020";
ccp.MethodName = "queryYard";
ccp.ServerParams = new object[] { nodeType,nodeId };
ccp.SourceDataTable = this.dataSet1.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
///
/// 生成区域信息树
///
protected void bindtree()
{
this.ultraTree1.Nodes.Clear();
this.dataSet2.Tables[0].Clear();
//创建根节点
Infragistics.Win.UltraWinTree.UltraTreeNode rootNode = new Infragistics.Win.UltraWinTree.UltraTreeNode();
//Infragistics.WebUI.UltraWebNavigator.Node rootnode1 = new Infragistics.WebUI.UltraWebNavigator.Node();
//添加根节点
rootNode.Text = "区域信息";
rootNode.Tag = "-1";
rootNode.Expanded = true;
ultraTree1.Nodes.Add(rootNode);
//获取树的数据
GetTrees();
//调用递归方法添加树节点
CreateChildNode(rootNode, "-1", this.dataSet2.Tables[0]);
}
///
/// 递归添加节点
///
///
///
///
public void CreateChildNode(Infragistics.Win.UltraWinTree.UltraTreeNode parentnode, string parentId, DataTable dt)
{
DataRow[] rows = dt.Select("parentid='" + parentId + "'");
foreach (DataRow dr in rows)
{
Infragistics.Win.UltraWinTree.UltraTreeNode nd = new Infragistics.Win.UltraWinTree.UltraTreeNode();
nd.Tag = dr["treeid"].ToString();
nd.Text = dr["treename"].ToString();
nd.Expanded = true;
parentnode.Nodes.Add(nd);
CreateChildNode(nd, dr["treeid"].ToString(), dt);
}
}
///
/// 获取数据
///
public void GetTrees()
{
CoreClientParam ccp = new CoreClientParam();
//ccp.InvokeID = "C06010103";
ccp.ServerName = "UIM.UIM010020";
ccp.MethodName = "quereAreaTree";
ccp.SourceDataTable = this.dataSet2.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
}
///
/// 删除垛位信息
///
private void DoDelete()
{
try
{
long clfNo = -1;
Infragistics.Win.UltraWinGrid.SelectedRowsCollection rows = this.ultraGrid1.Selected.Rows;
string delParam = "";
for (int i = 0; i < rows.Count; i++)
{
string clfNoStr = rows[i].Cells["clf_no"].Text;
string coilNoStr = rows[i].Cells["coil_no"].Text;
if (null != clfNoStr && !"".Equals(clfNoStr))
{
clfNo = long.Parse(clfNoStr);
delParam += clfNo + "|";
}
if (null != coilNoStr && !"".Equals(coilNoStr))
{
MessageBox.Show("垛位下放置有钢卷,请先将钢卷移出。");
return;
}
}
if (rows.Count < 1)
{
MessageBox.Show("请选择要删除的垛位。");
return;
}
if (MessageBox.Show(this, "是否确认删除?", "删除", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
if (!"".Equals(delParam))
{
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010020";
ccp.MethodName = "delYard";
ccp.ServerParams = new object[] { delParam };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != 0) return;
}
this.ultraGrid1.DeleteSelectedRows(false);
MessageBox.Show("删除成功!");
}
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
///
/// 添加垛位
///
private void DoAdd()
{
try
{
string clfName = this.textBox1.Text;
string clfRow = this.textBox2.Text;
string clfCol = this.textBox3.Text;
string clfFl = this.textBox5.Text;
string remark = this.textBox4.Text;
string areaNo = this.ultraComboEditor1.Value.ToString();
string regId = this.UserInfo.GetUserID();
if (null == clfName || "".Equals(clfName))
{
MessageBox.Show("请输入垛位名称!");
this.textBox1.Focus();
return;
}
if (null == clfRow || "".Equals(clfRow))
{
MessageBox.Show("请输入行!");
this.textBox2.Focus();
return;
}
if (null == clfCol || "".Equals(clfCol))
{
MessageBox.Show("请输入列!");
this.textBox3.Focus();
return;
}
if (null == clfFl || "".Equals(clfFl))
{
MessageBox.Show("请输入层!");
}
if (-1 == this.ultraComboEditor1.SelectedIndex)
{
MessageBox.Show("请选择所属区域!");
this.ultraComboEditor1.Focus();
return;
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010020";
ccp.MethodName = "addYard";
ccp.ServerParams = new object[] { clfName, clfRow, clfCol, clfFl, remark, areaNo, regId};
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (0 != ccp.ReturnCode) return;
this.DoQuery(NODE_ID);
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
///
/// 修改垛位信息
///
private void DoUpdate()
{
string clfNo = this.ultraGrid1.ActiveRow.Cells["clf_no"].Text;
string clfName = this.textBox1.Text;
string clfRow = this.textBox2.Text;
string clfCol = this.textBox3.Text;
string clfFl = this.textBox5.Text;
string remark = this.textBox4.Text;
string areaNo = this.ultraComboEditor1.Value.ToString();
string regId = this.UserInfo.GetUserID();
if (null == clfName || "".Equals(clfName))
{
MessageBox.Show("请输入垛位名称!");
this.textBox1.Focus();
return;
}
if (null == clfRow || "".Equals(clfRow))
{
MessageBox.Show("请输入行!");
this.textBox2.Focus();
return;
}
if (null == clfCol || "".Equals(clfCol))
{
MessageBox.Show("请输入列!");
this.textBox3.Focus();
return;
}
if (null == clfFl || "".Equals(clfFl))
{
MessageBox.Show("请输入层!");
}
if (-1 == this.ultraComboEditor1.SelectedIndex)
{
MessageBox.Show("请选择所属区域!");
this.ultraComboEditor1.Focus();
return;
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010020";
ccp.MethodName = "updateYard";
ccp.ServerParams = new object[] { clfNo, clfName, clfRow, clfCol, clfFl, remark, areaNo,regId};
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (0 != ccp.ReturnCode) return;
this.DoQuery(NODE_ID);
}
///
/// 页面加载时获取区域树结构数据
///
///
///
private void UIM010020_Load(object sender, EventArgs e)
{
bindtree();
}
///
/// 选取节点查询垛位信息
///
///
///
private void ultraTree1_AfterSelect(object sender, Infragistics.Win.UltraWinTree.SelectEventArgs e)
{
Infragistics.Win.UltraWinTree.UltraTree tree = (Infragistics.Win.UltraWinTree.UltraTree)sender;
string ndId = tree.SelectedNodes[0].Tag.ToString();
NODE_ID = ndId;
this.DoQuery(ndId);
}
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
Infragistics.Win.UltraWinGrid.UltraGridRow uRow = this.ultraGrid1.ActiveRow;
this.textBox1.Text = uRow.Cells["clf_name"].Text;
this.textBox2.Text = uRow.Cells["clf_row"].Text;
this.textBox3.Text = uRow.Cells["clf_col"].Text;
this.textBox4.Text = uRow.Cells["remark"].Text;
this.textBox5.Text = uRow.Cells["clf_fl"].Text;
this.ultraComboEditor1.Text = uRow.Cells["area_name"].Text;
this.getAreaInfo(uRow.Cells["area_no"].Text.Trim());
}
///
/// 获取区域信息
///
private void getAreaInfo(string areaNo)
{
this.dataSet3.Tables[0].Clear();
this.ultraComboEditor1.Items.Clear();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010020";
ccp.MethodName = "queryAreaInfo";
ccp.ServerParams = new object[] { areaNo };
ccp.SourceDataTable = this.dataSet3.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
foreach (DataRow dr in dataSet3.Tables[0].Rows)
{
ultraComboEditor1.Items.Add(dr["area_no"].ToString(), dr["area_name"].ToString());
}
}
}
}