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.Server;
using Infragistics.Win.UltraWinGrid;
using System.Collections;
using Core.Mes.Client.Comm.Tool;
using Core.Mes.Client.Comm.Control;
namespace Core.StlMes.Client.SaleBase
{
public partial class FrmRegion : FrmBase
{
TreeNode tNode = new TreeNode();//保存上一次树点
string strShift = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserOrder();
string strTerm = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserGroup();
string strOperator = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
string regIonID = "";
string nodeId = "";
string region_no = "";
DataTable isx = new DataTable();
DataTable unLoad = new DataTable();
protected override void OnLoad(EventArgs e)
{
try
{
base.OnLoad(e);
ultraGridRegion.DisplayLayout.Override.FilterUIType = Infragistics.Win.UltraWinGrid.FilterUIType.FilterRow;
ultraGridRegion.DisplayLayout.Override.FilterOperatorDefaultValue = Infragistics.Win.UltraWinGrid.FilterOperatorDefaultValue.Contains;
//ultraGridRegion.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;
}
catch (System.Exception ex)
{ }
}
public FrmRegion()
{
InitializeComponent();
}
///
/// 重写基类方法
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "doQuery":
doQuery();
break;
case "doAdd":
if (string.IsNullOrEmpty(txtName.Text))
{
MessageUtil.ShowTips("区域名称不允许为空!");
return;
}
if (string.IsNullOrEmpty(ComboEdiRegPro.Text))
{
MessageUtil.ShowTips("区域属性不允许为空!");
return;
}
if (string.IsNullOrEmpty(ComboEditorPro.Text))
{
MessageUtil.ShowTips("上级区域不允许为空!");
return;
}
if (comboRegIon.SelectedItem == null || comboRegIon.Text.Equals(""))
{
MessageUtil.ShowWarning("请选择[行政片区]!");
return ;
}
if (MessageUtil.ShowQuestion("是否新增数据?").ToString().ToLower().Equals("yes"))
{
string dosave = doSave();
if (dosave.Equals("doAddTrue"))
{
MessageUtil.ShowTips("添加成功!");
}
else if (dosave.Equals("doAddFalse"))
{
MessageUtil.ShowTips("添加失败!");
return;
}
else if (dosave.Equals("saveCoint"))
{
MessageUtil.ShowTips("已经维护!");
return;
}
else if (dosave.Equals("updateTrue"))
{
MessageUtil.ShowTips("添加成功!");
}
else if (dosave.Equals("updateFalse"))
{
MessageUtil.ShowTips("添加失败!");
return;
}
regIonCode();
try {
doQueryClick(ComboEditorPro.Value.ToString());
}catch(Exception){}
QueryTree();
}
break;
case "doDelete":
if (ultraGridRegion.ActiveRow == null)
{
MessageUtil.ShowTips("未找到需要操作的数据!");
return;
}
if (string.IsNullOrEmpty(regIonID))
{
MessageUtil.ShowTips("请选择需要作废的数据!");
return;
}
foreach (UltraGridRow ugr in this.ultraGridRegion.Rows)
{
if (ugr.Cells["REGION_NO"].Value.ToString().Equals(regIonID))
{
if (ugr.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
{
MessageUtil.ShowTips("数据无效不能重复操作!");
return;
}
}
}
if (MessageUtil.ShowQuestion("是否作废数据?").ToString().ToLower().Equals("yes"))
{
if (doDelete())
{
MessageUtil.ShowTips("作废成功!");
}
else
{
MessageUtil.ShowTips("作废失败!");
return;
}
regIonCode();
try
{
doQueryClick(ComboEditorPro.Value.ToString());
}catch( Exception){
}
QueryTree();
//doQuery();
}
break;
//case "doRecovery":
// if (ultraGridRegion.ActiveRow == null)
// {
// MessageUtil.ShowTips("未找到需要操作的数据!");
// return;
// }
// if (string.IsNullOrEmpty(regIonID))
// {
// MessageUtil.ShowTips("请选择需要恢复的数据!");
// return;
// }
// foreach (UltraGridRow ugr in this.ultraGridRegion.Rows)
// {
// if (ugr.Cells["REGION_NO"].Value.ToString().Equals(regIonID))
// {
// if (ugr.Cells["VALIDFLAG"].Value.ToString().Equals("有效"))
// {
// MessageUtil.ShowTips("数据有效不能恢复!");
// return;
// }
// }
// }
// if (MessageUtil.ShowQuestion("是否恢复数据?").ToString().ToLower().Equals("yes"))
// {
// if (doResume())
// {
// MessageUtil.ShowTips("恢复成功!");
// }
// else
// {
// MessageUtil.ShowTips("恢复失败!");
// return;
// }
// doQueryClick(ComboEditorPro.Value == null ? "" : ComboEditorPro.Value.ToString());
// }
// break;
case "doUpdate":
if (ultraGridRegion.ActiveRow == null)
{
MessageUtil.ShowWarning("请选择一行您要修改的数据!");
return ;
}
if (string.IsNullOrEmpty(txtName.Text))
{
MessageUtil.ShowTips("区域名称不允许为空!");
return;
}
if (string.IsNullOrEmpty(ComboEdiRegPro.Text))
{
MessageUtil.ShowTips("区域属性不允许为空!");
return;
}
if (string.IsNullOrEmpty(ComboEditorPro.Text))
{
MessageUtil.ShowTips("上级区域不允许为空!");
return;
}
if (string.IsNullOrEmpty(comboRegIon.Text))
{
MessageUtil.ShowTips("行政片区不允许为空!");
return;
}
if (string.IsNullOrEmpty(regIonID))
{
MessageUtil.ShowTips("请选择需要修改的数据!");
return;
}
if (MessageUtil.ShowQuestion("是否修改数据?").ToString().ToLower().Equals("yes"))
{
if (doUpdate())
{
MessageUtil.ShowTips("修改成功!");
}
else
{
//MessageUtil.ShowTips("修改失败!");
return;
}
regIonCode();
try
{
doQueryClick(ComboEditorPro.Value.ToString());
}
catch (Exception)
{
}
QueryTree();
}
break;
case "doClose":
this.Close();
break;
}
}
//查询
public void doQuery()
{
QueryTree();
//if (nodeId != "")
//{
// doQueryClick(nodeId);
// return;
//}
DataTable dts = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetQueryReg", new Object[] { }, this.ob);
uldtsCoupling.Tables[0].Clear();
foreach (DataRow dr in dts.Rows)
{
DataRow _dr = uldtsCoupling.Tables[0].NewRow();
foreach (DataColumn dc in uldtsCoupling.Tables[0].Columns)
{
_dr[dc.ColumnName] = dr[dc.ColumnName];
}
uldtsCoupling.Tables[0].Rows.Add(_dr);
}
foreach (UltraGridRow ugr in this.ultraGridRegion.Rows)
{
if (ugr.Cells["VALIDFLAG"].Value.ToString().ToLower() == "0")
{
ugr.Cells["VALIDFLAG"].Value = "无效";
this.ultraGridRegion.Rows[ugr.Index].CellAppearance.ForeColor = Color.Red;
}
if (ugr.Cells["VALIDFLAG"].Value.ToString().ToLower() == "1")
{
ugr.Cells["VALIDFLAG"].Value = "有效";
}
if (ugr.Cells["REGION_NM"].Value.ToString().Equals(region_no))
{
ugr.Activate();
}
else if (ugr.Cells["REGION_NO"].Value.ToString().Equals(region_no))
{
ugr.Activate();
}
}
//内容自适应
GridHelper.RefreshAndAutoSizeExceptRows(ultraGridRegion, new UltraGridColumn[] {
ultraGridRegion.DisplayLayout.Bands[0].Columns["MEMO"]
});
}
//单击树形视图查询
public void doQueryClick(string regIon)
{
DataTable dts = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetQueryRegIonCode", new Object[] { regIon }, this.ob);
uldtsCoupling.Tables[0].Clear();
foreach (DataRow dr in dts.Rows)
{
DataRow _dr = uldtsCoupling.Tables[0].NewRow();
foreach (DataColumn dc in uldtsCoupling.Tables[0].Columns)
{
_dr[dc.ColumnName] = dr[dc.ColumnName];
}
uldtsCoupling.Tables[0].Rows.Add(_dr);
}
foreach (UltraGridRow ugr in this.ultraGridRegion.Rows)
{
if (ugr.Cells["VALIDFLAG"].Value.ToString().ToLower() == "0")
{
ugr.Cells["VALIDFLAG"].Value = "无效";
this.ultraGridRegion.Rows[ugr.Index].CellAppearance.ForeColor = Color.Red;
}
if (ugr.Cells["VALIDFLAG"].Value.ToString().ToLower() == "1")
{
ugr.Cells["VALIDFLAG"].Value = "有效";
}
if (ugr.Cells["REGION_NM"].Value.ToString().Equals(region_no))
{
ugr.Activate();
}
else if (ugr.Cells["REGION_NO"].Value.ToString().Equals(region_no))
{
ugr.Activate();
}
}
//内容自适应
GridHelper.RefreshAndAutoSizeExceptRows(ultraGridRegion, new UltraGridColumn[] {
ultraGridRegion.DisplayLayout.Bands[0].Columns["MEMO"]
});
}
//保存
public string doSave()
{
if (string.IsNullOrEmpty(ComboEditorPro.Text))
{
MessageUtil.ShowTips("请选择[上级区域],不允许为空!");
return "xxx";
}
if (string.IsNullOrEmpty(ComboEdiRegPro.Text))
{
MessageUtil.ShowTips("请选择[区域属性],不允许为空!");
return "xxx";
}
if (string.IsNullOrEmpty(txtName.Text))
{
MessageUtil.ShowTips("请选择[区域名称],不允许为空!");
return "xxx";
}
if (txtName.Text.Equals("/"))
{
MessageUtil.ShowTips("请选择[区域名称],不允许填 / !");
return "xxx";
}
//if (string.IsNullOrEmpty(comboRegIon.Text))
//{
// MessageUtil.ShowTips("行政片区不允许为空!");
// return "xxx";
//}
//区域名称
string regName = txtName.Text;
//属性区域
string regionno = ComboEdiRegPro.Text;
string regionnm = ComboEdiRegPro.Value.ToString();
//上级区域
string pregionno = ComboEditorPro.Text == "" ? " " : ComboEditorPro.Text;
string regiontype = ComboEditorPro.Value == null? " " : ComboEditorPro.Value.ToString();
//行政片区
string bigareaName = comboRegIon.Text == "" ? " " : comboRegIon.Text.ToString();
string bigareaCode = comboRegIon.Value == null ? " " : comboRegIon.Value.ToString();
//根据名称查找数据,如果有数据,而且是有效的,提示不允许新增。
DataTable countDb = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.saveQueryName", new Object[] { regName }, this.ob);
if (countDb.Rows.Count > 0)
{
MessageUtil.ShowTips("请重新输入[区域名称],区域名称存在!");
return "xxx";
}
DataTable dts = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetSaveQuery", new Object[] { regName, regiontype }, this.ob);
ArrayList parm = new ArrayList();
CoreClientParam ccp = new CoreClientParam();
if (dts.Rows.Count > 0)
{
if (dts.Rows[0]["VALIDFLAG"].ToString().Equals("1"))
{
return "saveCoint";
}
else if (dts.Rows[0]["VALIDFLAG"].ToString().Equals("0"))
{
parm = new ArrayList();
parm.Add("1"); //0恢复
parm.Add(dts.Rows[0]["REGION_NO"].ToString()); //ID
ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.sale.base.CoreRegion";
ccp.MethodName = "SetResumeIon";
ccp.ServerParams = new object[] { parm };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1)
{
return "updateFalse";
}
region_no = regName;
return "updateTrue";
}
}
parm = new ArrayList();
parm.Add(regiontype); //如果是区域首次默认上级+01.
parm.Add(regiontype); //如果是区域首次默认Where.
parm.Add(regName); //区域名称
parm.Add(regiontype); //上级区域代码
parm.Add(regionnm);
parm.Add(regiontype); //上级区域代码
parm.Add(this.textBoxMemo.Text);
parm.Add(strOperator);
parm.Add(bigareaCode);//行政片区
ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.sale.base.CoreRegion";
ccp.MethodName = "SetAddRegion";
ccp.ServerParams = new object[] { parm };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1)
{
return "doAddFalse";
}
region_no = regName;
return "doAddTrue";
}
//0删除,1恢复
public bool doDelete()
{
if (string.IsNullOrEmpty(regIonID))
{
MessageUtil.ShowTips("请选择需要修改的数据!");
return false;
}
ArrayList parm = new ArrayList();
parm.Add("0"); //0删除
parm.Add(strOperator);//删除人
parm.Add(regIonID); //ID
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.sale.base.CoreRegion";
ccp.MethodName = "SetDleteRegion";
ccp.ServerParams = new object[] { parm };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1)
{
return false;
}
return true;
}
//恢复
public bool doResume()
{
if (string.IsNullOrEmpty(regIonID))
{
MessageUtil.ShowTips("请选择需要修改的数据!");
return false;
}
ArrayList parm = new ArrayList();
parm.Add("1"); //0恢复
parm.Add(regIonID); //ID
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.sale.base.CoreRegion";
ccp.MethodName = "SetResumeIon";
ccp.ServerParams = new object[] { parm };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1)
{
return false;
}
return true;
}
//修改
public bool doUpdate()
{
if (string.IsNullOrEmpty(regIonID))
{
MessageUtil.ShowTips("请选择需要修改的数据!");
return false;
}
if (string.IsNullOrEmpty(txtName.Text))
{
MessageUtil.ShowTips("区域名称不允许为空!");
return false;
}
if (string.IsNullOrEmpty(ComboEdiRegPro.Text))
{
MessageUtil.ShowTips("属性区域不允许为空!");
return false;
}
if (string.IsNullOrEmpty(ComboEditorPro.Text))
{
MessageUtil.ShowTips("上级区域不允许为空!");
return false;
}
if (string.IsNullOrEmpty(comboRegIon.Text))
{
MessageUtil.ShowTips("行政区域不允许为空!");
return false;
}
if (ultraGridRegion.ActiveRow != null && !ultraGridRegion.ActiveRow.Cells["REGION_NM"].Value.ToString().Equals(txtName.Text))
{
DataTable dts = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetSaveQuery", new Object[] { txtName.Text, ComboEditorPro.Value }, this.ob);
if (dts.Rows.Count > 0)
{
MessageUtil.ShowTips("城市名称已存在,不能修改!");
return false;
}
}
ArrayList parm = new ArrayList();
parm.Add(txtName.Text); //0恢复
parm.Add(ComboEdiRegPro.Value); //type
parm.Add(textBoxMemo.Text);//备注
parm.Add(strOperator);//修改人
parm.Add(comboRegIon.Value == null ? " " : comboRegIon.Value.ToString());//行政片区
parm.Add(ComboEditorPro.Value);
parm.Add(regIonID);//ID
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.sale.base.CoreRegion";
ccp.MethodName = "SetUpdateIon";
ccp.ServerParams = new object[] { parm };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1)
{
return false;
}
region_no = regIonID;
return true;
}
private void frmRegion_Load(object sender, EventArgs e)
{
regIonCode();
//this.treeRegion.Parent.Font = new Font("宋体", 8F, System.Drawing.FontStyle.Bold);
//this.treeRegion.BackColor = Color.Empty;
QueryTree();//刷新树结构
ClsBaseInfo.SetComboItemHeight(ComboEditorPro);
ClsBaseInfo.SetComboItemHeight(ComboEdiRegPro);
ClsBaseInfo.SetComboItemHeight(comboRegIon);
}
//加载区域和上级区域属性
private void regIonCode()
{
unLoad = new DataTable();
unLoad.Columns.Add("Name", typeof(System.String));
unLoad.Columns.Add("Code", typeof(System.String));
//查询区域属性
isx = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetRegIonCodeS", new Object[] { }, this.ob);
for (int i = 0; i < isx.Rows.Count; i++)
{
unLoad.Rows.Add(isx.Rows[i]["REGION_TYPE_NM"].ToString(), isx.Rows[i]["REGION_TYPE_NO"].ToString());
}
ComboEdiRegPro.DataSource = unLoad;
ComboEdiRegPro.DisplayMember = "Name";
ComboEdiRegPro.ValueMember = "Code";
//查询上级区域属性
isx = new DataTable();
unLoad = new DataTable();
unLoad.Columns.Add("Name", typeof(System.String));
unLoad.Columns.Add("Code", typeof(System.String));
isx = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetSelAdminRegion", new Object[] { }, this.ob);
for (int i = 0; i < isx.Rows.Count; i++)
{
unLoad.Rows.Add(isx.Rows[i]["REGION_NM"].ToString(), isx.Rows[i]["REGION_NO"].ToString());
}
ComboEditorPro.DataSource = unLoad;
ComboEditorPro.DisplayMember = "Name";
ComboEditorPro.ValueMember = "Code";
//行政片区
isx = ServerHelper.GetData("com.steering.pss.sale.base.CoreBuyerOrder.GetQueryBaseInfo", new Object[] { "1007" }, this.ob);
unLoad = new DataTable();
unLoad.Columns.Add("BASENAME", typeof(System.String));
unLoad.Columns.Add("BASECODE", typeof(System.String));
for (int i = 0; i < isx.Rows.Count; i++)
{
unLoad.Rows.Add(isx.Rows[i]["BASENAME"].ToString(), isx.Rows[i]["BASECODE"].ToString());
}
DataRow dr = unLoad.NewRow();
unLoad.Rows.Add(dr);
comboRegIon.DataSource = unLoad;
comboRegIon.DisplayMember = "BASENAME";
comboRegIon.ValueMember = "BASECODE";
}
//刷新Tree
public void QueryTree()
{
this.treeRegion.Nodes.Clear();
DataTable dt = new DataTable();
dt = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetTivCode", new Object[] { }, this.ob);
//树控件递归绑定方法。
Bind_Tv(dt, treeRegion.Nodes, null, "REGION_NO", "P_REGION_NO", "REGION_NM");
if (!string.IsNullOrEmpty(tNode.Name))
{
for (int e = 0; e < this.treeRegion.Nodes.Count; e++)
{
//展开一级节点
//if (this.treeRegion.Nodes[e].Name.Equals(tNode.Name))
//{
// this.treeRegion.Nodes[e].Expand();
// return;
//}
//展开二级节点
for (int w = 0; w < this.treeRegion.Nodes[e].Nodes.Count; w++)
{
if (this.treeRegion.Nodes[e].Nodes[w].Name.Equals(tNode.Name))
{
this.treeRegion.Nodes[e].Expand();
this.treeRegion.Nodes[e].Nodes[w].ExpandAll();
return;
}
}
//展开三级子节点
for (int w = 0; w < this.treeRegion.Nodes[e].Nodes.Count; w++)
{
for (int r = 0; r < this.treeRegion.Nodes[e].Nodes[w].Nodes.Count; r++)
{
if (this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Name.Equals(tNode.Name))
{
this.treeRegion.Nodes[e].Expand();
this.treeRegion.Nodes[e].Nodes[w].Expand();
this.treeRegion.Nodes[e].Nodes[w].Nodes[r].ExpandAll();
return;
}
}
}
//展开四级子节点
for (int w = 0; w < this.treeRegion.Nodes[e].Nodes.Count; w++)
{
for (int r = 0; r < this.treeRegion.Nodes[e].Nodes[w].Nodes.Count; r++)
{
for (int x = 0; x < this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes.Count; x++)
{
if (this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes[x].Name.Equals(tNode.Name))
{
this.treeRegion.Nodes[e].Expand();
this.treeRegion.Nodes[e].Nodes[w].Expand();
this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Expand();
this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes[x].ExpandAll();
return;
}
}
}
}
//展开五级子节点
for (int w = 0; w < this.treeRegion.Nodes[e].Nodes.Count; w++)
{
for (int r = 0; r < this.treeRegion.Nodes[e].Nodes[w].Nodes.Count; r++)
{
for (int x = 0; x < this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes.Count; x++)
{
for (int j = 0; j < this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes[x].Nodes.Count; j++)
{
if (this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes[x].Nodes[j].Name.Equals(tNode.Name))
{
this.treeRegion.Nodes[e].Expand();
this.treeRegion.Nodes[e].Nodes[w].Expand();
this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Expand();
this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes[x].ExpandAll();
this.treeRegion.Nodes[e].Nodes[w].Nodes[r].Nodes[j].ExpandAll();
return;
}
}
}
}
}
}
}
}
///
/// 绑定TreeView(利用TreeNodeCollection)
///
/// TreeNodeCollection(TreeView的节点集合)
/// 父id的值
/// 数据库 id 字段名
/// 数据库 父id 字段名
/// 数据库 文本 字段值
private void Bind_Tv(DataTable dt, TreeNodeCollection tnc, string pid_val, string id, string pid, string text)
{
DataView dv = new DataView(dt);//将DataTable存到DataView中,以便于筛选数据
TreeNode tn;//建立TreeView的节点(TreeNode),以便将取出的数据添加到节点中
//以下为三元运算符,如果父id为空,则为构建“父id字段 is null”的查询条件,否则构建“父id字段=父id字段值”的查询条件
string filter = string.IsNullOrEmpty(pid_val) ? pid + " is null" : string.Format(pid + "='{0}'", pid_val);
dv.RowFilter = filter;//利用DataView将数据进行筛选,选出相同 父id值 的数据
foreach (DataRowView drv in dv)
{
tn = new TreeNode();//建立一个新节点(学名叫:一个实例)
tn.Tag = drv[id].ToString();//节点的Value值,一般为数据库的id值
tn.Text = drv[text].ToString();//节点的Text,节点的文本显示
tn.Name = drv["REGION_LVL_NO"].ToString();//区域属性代码
tn.ImageKey = drv["REGION_LVL_NM"].ToString();
if (!string.IsNullOrEmpty(drv["P_REGION_NO"].ToString()))
{
tn.ToolTipText = drv["P_REGION_NO"].ToString();
}
else
{
tn.ImageIndex = 0;
}
tnc.Add(tn);//将该节点加入到TreeNodeCollection(节点集合)中
Bind_Tv(dt, tn.Nodes, tn.Tag.ToString(), id, pid, text);//递归(反复调用这个方法,直到把数据取完为止)
}
}
private void treeRegion_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
//选择节点改变字体大小
if (tNode.Text.Trim() != "")
{
tNode.NodeFont = new Font("宋体", 8F, System.Drawing.FontStyle.Bold);
tNode.BackColor = Color.Empty;
}
e.Node.NodeFont = new Font("宋体", 9F, System.Drawing.FontStyle.Underline);
e.Node.BackColor = Color.Empty;
e.Node.BackColor = Color.LightBlue;
tNode = e.Node;
//查询上级区域属性
isx = new DataTable();
unLoad = new DataTable();
unLoad.Columns.Add("Name", typeof(System.String));
unLoad.Columns.Add("Code", typeof(System.String));
isx = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetSelAdminRegionFilter", new Object[] { tNode.Tag.ToString() }, this.ob);
for (int i = 0; i < isx.Rows.Count; i++)
{
unLoad.Rows.Add(isx.Rows[i]["REGION_NM"].ToString(), isx.Rows[i]["REGION_NO"].ToString());
}
ComboEditorPro.DataSource = unLoad;
ComboEditorPro.DisplayMember = "Name";
ComboEditorPro.ValueMember = "Code";
////保存上一级区域属性信息
//if (!string.IsNullOrEmpty(e.Node.ImageKey))
//{
// ComboEditorPro.Text = e.Node.ImageKey;
// ComboEditorPro.Value = e.Node.ToolTipText;
//}
//保存上一级区域属性信息
if (unLoad.Rows.Count > 0)
{
ComboEditorPro.Text = unLoad.Rows[0][0].ToString();
ComboEditorPro.Value = unLoad.Rows[0][1].ToString();
}
//查询区域属性
//string indexCode = "";
//string indexName = e.Node.Text.Substring(0, e.Node.Text.IndexOf(" ")).Trim();
//ComboEdiRegPro.Text = indexName;
txtName.Text = e.Node.Text.Substring(e.Node.Text.IndexOf(" ")).Trim();
DataTable countDb = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.saveQueryName", new Object[] { txtName.Text }, this.ob);
if (countDb.Rows.Count > 0)
{
comboRegIon.Value = countDb.Rows[0]["BIGAREA"].ToString();
}
doQueryClick(e.Node.Tag.ToString());
nodeId = e.Node.Tag.ToString();
}
private void ultraGridRegion_Click(object sender, EventArgs e)
{
DataTable unLoad = new DataTable();
unLoad.Columns.Add("Name", typeof(System.String));
unLoad.Columns.Add("Code", typeof(System.String));
if (this.ultraGridRegion.Rows.Count > 0)
{
//查询区域属性
ComboEdiRegPro.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_TYPE_NM"].Text.Trim();
ComboEdiRegPro.Value = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_TYPE_NO"].Value.ToString();
regIonID = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_NO"].Value.ToString(); //修改使用的id
this.txtName.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_NM"].Text.Trim();
textBoxMemo.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["MEMO"].Text.Trim();
this.comboRegIon.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["BIGAREA"].Text.Trim();
//保存上一级区域属性信息
if (!string.IsNullOrEmpty(this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NO"].Value.ToString()))
{
ComboEditorPro.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NM"].Value.ToString();
ComboEditorPro.Value = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NO"].Value.ToString();
}
}
}
private void ComboEditorPro_TextChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(ComboEditorPro.Text))
{
DataTable unLoad = new DataTable();
unLoad.Columns.Add("Name", typeof(System.String));
unLoad.Columns.Add("Code", typeof(System.String));
//查询区域属性
isx = ServerHelper.GetData("com.steering.pss.sale.base.CoreRegion.GetRegIonCodeNo", new Object[] { ComboEditorPro.Value }, this.ob);
for (int i = 0; i < isx.Rows.Count; i++)
{
unLoad.Rows.Add(isx.Rows[i]["REGION_TYPE_NM"].ToString(), isx.Rows[i]["REGION_TYPE_NO"].ToString());
}
ComboEdiRegPro.DataSource = unLoad;
ComboEdiRegPro.DisplayMember = "Name";
ComboEdiRegPro.ValueMember = "Code";
}
}
private void txtName_TextChanged(object sender, EventArgs e)
{
if (this.txtName.Text.Length > 40)
{
MessageUtil.ShowTips("长度过长!");
this.txtName.Text = this.txtName.Text.Substring(0,40);
}
}
private void textBoxMemo_TextChanged(object sender, EventArgs e)
{
if (this.textBoxMemo.Text.Length > 180)
{
MessageUtil.ShowTips("长度过长!");
this.textBoxMemo.Text = this.textBoxMemo.Text.Substring(0, 180);
}
}
private void ultraGridRegion_AfterCellActivate(object sender, EventArgs e)
{
if (this.ultraGridRegion.ActiveRow!=null)
{
//查询区域属性
ComboEdiRegPro.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_TYPE_NM"].Text.Trim();
ComboEdiRegPro.Value = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_TYPE_NO"].Value.ToString();
regIonID = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_NO"].Value.ToString(); //修改使用的id
this.txtName.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_NM"].Text.Trim();
textBoxMemo.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["MEMO"].Text.Trim();
this.comboRegIon.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["BIGAREA"].Text.Trim();
//保存上一级区域属性信息
if (!string.IsNullOrEmpty(this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NO"].Value.ToString()))
{
ComboEditorPro.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NM"].Value.ToString();
ComboEditorPro.Value = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NO"].Value.ToString();
}
}
}
private void ultraGridRegion_AfterRowActivate(object sender, EventArgs e)
{
if (this.ultraGridRegion.ActiveRow != null)
{
//查询区域属性
ComboEdiRegPro.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_TYPE_NM"].Text.Trim();
ComboEdiRegPro.Value = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_TYPE_NO"].Text.Trim();
regIonID = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_NO"].Value.ToString(); //修改使用的id
this.txtName.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["REGION_NM"].Text.Trim();
textBoxMemo.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["MEMO"].Text.Trim();
this.comboRegIon.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["BIGAREA"].Value.ToString();
//保存上一级区域属性信息
if (!string.IsNullOrEmpty(this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NO"].Value.ToString()))
{
ComboEditorPro.Text = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NM"].Value.ToString();
ComboEditorPro.Value = this.ultraGridRegion.DisplayLayout.ActiveRow.Cells["P_REGION_NO"].Value.ToString();
}
}
}
}
}