| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892 |
- 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 Pur.configure
- {
- 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();
- }
- /// <summary>
- /// 重写基类方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- 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.hnshituo.pur.configure.service.impl.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.hnshituo.pur.configure.service.impl.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.hnshituo.pur.configure.service.impl.CoreRegion.saveQueryName", new Object[] { regName }, this.ob);
- if (countDb.Rows.Count > 0)
- {
- MessageUtil.ShowTips("请重新输入[区域名称],区域名称存在!");
- return "xxx";
- }
- DataTable dts = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.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.hnshituo.pur.configure.service.impl.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.hnshituo.pur.configure.service.impl.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.hnshituo.pur.configure.service.impl.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.hnshituo.pur.configure.service.impl.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.hnshituo.pur.configure.service.impl.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.hnshituo.pur.configure.service.impl.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.hnshituo.pur.configure.service.impl.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.hnshituo.pur.configure.service.impl.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 = new DataTable();
- unLoad = new DataTable();
- unLoad.Columns.Add("BASENAME", typeof(System.String));
- unLoad.Columns.Add("BASECODE", typeof(System.String));
- isx = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1216" }, this.ob);
- //DataView dv = isx.DefaultView;
- //dv.RowFilter = "VALIDFLAG = '1'";
- //DataTable newTable1 = dv.ToTable();
- //unLoad = new DataTable();
- for (int i = 0; i < isx.Rows.Count; i++)
- {
- if (isx.Rows[i]["VALIDFLAG"].ToString().Trim() == "1")
- {
- 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.hnshituo.pur.configure.service.impl.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;
- }
- }
- }
- }
- }
- }
- }
- }
- /// <summary>
- /// 绑定TreeView(利用TreeNodeCollection)
- /// </summary>
- /// <param name="tnc">TreeNodeCollection(TreeView的节点集合)</param>
- /// <param name="pid_val">父id的值</param>
- /// <param name="id">数据库 id 字段名</param>
- /// <param name="pid">数据库 父id 字段名</param>
- /// <param name="text">数据库 文本 字段值</param>
- 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.hnshituo.pur.configure.service.impl.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.hnshituo.pur.configure.service.impl.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.hnshituo.pur.configure.service.impl.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();
- }
- }
- }
- }
- }
|