| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717 |
- 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 Pur.Entity;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- using Pur.Entity.configureEntity;
- using Core.Mes.Client.Comm.Control;
- using Infragistics.Win.UltraWinTree;
- using Core.Mes.Client.Comm.Tool;
- using com.hnshituo.pur.vo;
- using Pur.configure;
- using Pur.Pop_upWindow;
- using System.Collections;
- namespace Pur
- {
- public partial class FrmPurMatClass : FrmPmsBase
- {
- PurmatclassEntity Q_mat = null;
- private bool QclickQueryCell = false;//是否点击查询按钮或grid1单元格
- public FrmPurMatClass()
- {
- InitializeComponent();
- ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- }
- //菜单按钮事件
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- ultraTree1.Nodes.Clear();
- getultree();// 获取物料分类树形结构
- GetPUR_MAT_CLASS(getEnSelContion(null));
- if (ultraGrid1.Rows.Count < 1)
- {
- if (ultraTree1.ActiveNode != null)
- {
- ultraTree1.ActiveNode.Expanded = true;
- }
- }
- else
- {
- QclickQueryCell = true;
- UltraTreeNode uttNode = ultraTree1.GetNodeByKey(ultraGrid1.Rows[0].Cells["BASECODE"].Value.ToString()).Parent;
- if (uttNode == ultraTree1.ActiveNode)
- {
- return;
- }
- ultraTree1.CollapseAll();
- if (uttNode == null)
- {
- ultraTree1.ActiveNode = ultraTree1.GetNodeByKey(ultraGrid1.Rows[0].Cells["BASECODE"].Value.ToString());
- }
- else
- {
- ultraTree1.ActiveNode = uttNode;
- uttNode.Expanded = true;
- while (uttNode.Parent != null)
- {
- uttNode = uttNode.Parent;
- uttNode.Expanded = true;
- }
- }
-
- }
- break;
- case "Add":
- AddPUR_MAT_CLASS();
- break;
- case "Update":
- UpdPUR_MAT_CLASS();
- break;
- case "Delete":
- DelPUR_MAT_CLASS();
- break;
- case "UpdClassName":
- UpdClassName();
- break;
- case "doExcel":
- doExcel();
- break;
- }
- }
- private void doExcel()
- {
- try
- {
- this.Cursor = Cursors.Default;
- if (ultraGrid1.Rows.Count <= 0)
- {
- MessageUtil.ShowTips("无可导出明细!");
- }
- ArrayList alUltraGrid = new ArrayList();
- alUltraGrid.Add(ultraGrid1);
- ArrayList alSheeft = new ArrayList();
- alSheeft.Add("物料分类");
- if (ultraGrid1.Rows.Count > 0)
- {
- GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "物料分类表");//导出excel
- }
- else
- {
- MessageUtil.ShowTips("无可导出明细!");
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowTips("导出失败" + e.Message);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 修改分类的父类
- /// </summary>
- private void UpdClassName()
- {
- frmPopMatClass frm = new frmPopMatClass(this.ob);
- frm.ShowDialog();
- if(frm.Q_Ultnode!=null)
- {
- //string strNode=ultraTree1.ActiveNode.Key;
- string strBaseName= ultraGrid1.ActiveRow.Cells["BASENAME"].Value.ToString().Trim();
- string strBaseCode = ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString().Trim();
- if (MessageUtil.ShowYesNoAndQuestion("确定要将分类【" + strBaseName + "】移动到分类【" + frm.Q_Ultnode.Text + "】下吗?").Equals(DialogResult.Yes))
- {
- PurmatclassEntity Purmatclass_Entity = new PurmatclassEntity();
- Purmatclass_Entity.Basecode = strBaseCode;
- Purmatclass_Entity.Parentcode = frm.Q_Ultnode.Key;
- Purmatclass_Entity.UpdateName = UserInfo.GetUserName();
- Purmatclass_Entity.UpdateUserid = UserInfo.GetUserID();
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatClassService", "doUpdate", new object[] { Purmatclass_Entity });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("修改失败 " + crt.Resultmsg);
- return;
- }
- MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- if (ultraTree1.ActiveNode != null)
- {
- //查询物料分类
- ultraTree1.Nodes.Clear();
- getultree();// 获取物料分类树形结构
- PurmatclassEntity pmcE = new PurmatclassEntity();
- pmcE.Parentcode = frm.Q_Ultnode.Key;
- GetPUR_MAT_CLASS(pmcE);
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "BASECODE", Purmatclass_Entity.Basecode);//激活当前行
- ExpNode(Purmatclass_Entity.Basecode);
- }
- }
- }
- }
- /// <summary>
- /// 查询物料分类
- /// </summary>
- public void GetPUR_MAT_CLASS(PurmatclassEntity mat)
- {
- dataTable1.Clear();
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatClassService", "getMatClass", new object[] { mat, 0, 0 });
- // GetJsonService().execute<DataTable>("com.hnshituo.pur.configure.service.MatClassService", "getMatClass", new object[] { mat, 0, 0 });
- //按创建时间降序
- if (dt.Rows.Count > 0)
- {
- dt.DefaultView.Sort = "CREATETIME DESC";
- dt = dt.DefaultView.ToTable();
- }
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);//绑定物料分类表
- Q_mat = mat;
- }
- /// <summary>
- /// 添加
- /// </summary>
- public void AddPUR_MAT_CLASS()
- {
- try
- {
- if (txt_BASENAME.Text.Trim() == "")
- {
- MessageUtil.ShowTips("填写物料分类名称");
- return;
- }
- if (txt_BASECODE.Text.Trim() == "")
- {
- MessageUtil.ShowTips("填写物料分类编码");
- return;
- }
- PurmatclassEntity Purmatclass_Entity = new PurmatclassEntity();
- Purmatclass_Entity.Basecode = txt_BASECODE.Text;//分类编码
- if (isExsitRow("com.hnshituo.pur.configure.service.MatClassService", Purmatclass_Entity))//判断分类编码是否存在
- {
- MessageUtil.ShowTips("分类编码已存在,请重新输入");
- return;
- }
- Purmatclass_Entity.Basecode = null;
- Purmatclass_Entity.Basename = txt_BASENAME.Text;
- if (isExsitRow("com.hnshituo.pur.configure.service.MatClassService", Purmatclass_Entity))//判断分类名称是否存在
- {
- MessageUtil.ShowTips("数据库中已存在相同的分类名称,请重新输入");
- return;
- }
- if (ultraCheckEditor3.Checked)//添加物料大类
- {
- if (!IsCharacter(txt_BASECODE.Text))
- {
- MessageUtil.ShowTips("物料大类必须为单个大写英文字母,请重新输入");
- return;
- }
- Purmatclass_Entity.Parentcode = null;//如果添加大类,则分类编码null
- }
- else
- { Purmatclass_Entity.Parentcode = ultraTree1.ActiveNode.Key; }
-
-
-
-
-
- //else//添加物料小类
- //{
- // if (ultraTree1.ActiveNode == null)
- // {
- // MessageUtil.ShowTips("请选择左侧树形结构的节点");
- // return;
- // }
- // if (Q_mat.Parentcode == null)
- // {
- // MessageBox.Show("请选择父类节点或者勾“选添加物料大类”", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- // return;
- // }
- // Purmatclass_Entity.Basecode = getItemCodeClass(Q_mat.Parentcode);//分类编码
- // Purmatclass_Entity.Parentcode = ultraTree1.ActiveNode.Key;
- //}
- //判断分类名称是否存在
- //if (ultraGrid1.ActiveRow.Cells["BASENAME"].Value.ToString() != txt_BASENAME.Text)
- //{
- //Purmatclass_Entity.Basecode = null;
- //}
- Purmatclass_Entity.Parentcode = ultraTree1.ActiveNode.Key;
- Purmatclass_Entity.Basecode = txt_BASECODE.Text;//分类编码
- Purmatclass_Entity.Basename = txt_BASENAME.Text.Trim();//分类名称
- Purmatclass_Entity.CreateName = UserInfo.GetUserName();
- Purmatclass_Entity.CreateTime = System.DateTime.Now;//创建时间
- Purmatclass_Entity.CreateUserid = UserInfo.GetUserID();
- Purmatclass_Entity.Validflag = "1";
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatClassService", "doInsert", new object[] { Purmatclass_Entity });//添加操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
- return;
- }
- MessageBox.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- if (ultraTree1.ActiveNode != null)
- {
- //查询物料分类
- PurmatclassEntity pmcE = new PurmatclassEntity();
- pmcE.Parentcode = ultraTree1.ActiveNode.Key;
- GetPUR_MAT_CLASS(pmcE);
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "BASECODE", Purmatclass_Entity.Basecode);//激活当前行
- //展开上次激活的节点
- if (ultraCheckEditor3.Checked)//添加根节点
- {
- ultraTree1.Nodes.Add(Purmatclass_Entity.Basecode, Purmatclass_Entity.Basename);
- }
- else
- {
- UltraTreeNode node = ultraTree1.ActiveNode;
- node.Nodes.Add(Purmatclass_Entity.Basecode, Purmatclass_Entity.Basename);
- }
- }
- }
- catch (Exception e)
- {
- MessageBox.Show(" 添加出现异常:" + e.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- return;
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- public void UpdPUR_MAT_CLASS()
- {
- try
- {
- if (MessageUtil.ShowYesNoAndQuestion("是否确定更新?") == DialogResult.No)
- {
- return;
- }
- if (ultraCheckEditor3.Checked)
- {
- MessageUtil.ShowTips("你已勾选“添加物料大类”复选框,不能进行修改操作");
- return;
- }
- if (txt_BASENAME.Text.Trim() == "")
- {
- MessageUtil.ShowTips("填写物料分类名称");
- return;
- }
- if (ultraGrid1.ActiveRow == null)
- {
- MessageBox.Show("请选择要修改的物料分类!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- if (txt_BASECODE.Text.Trim() != ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString().Trim())
- {
- MessageUtil.ShowTips("不能更新分类编码");
- //txt_BASECODE.Text = ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString();
- return;
- }
- PurmatclassEntity Purmatclass_Entity = new PurmatclassEntity();
- if (txt_BASENAME.Text.Trim() != ultraGrid1.ActiveRow.Cells["BASENAME"].Value.ToString().Trim())
- {
- Purmatclass_Entity.Basename = txt_BASENAME.Text;
- if (isExsitRow("com.hnshituo.pur.configure.service.MatClassService", Purmatclass_Entity))//判断分类名称是否存在
- {
- MessageUtil.ShowTips("数据库中已存在相同的分类名称,请重新输入");
- return;
- }
- }
- Purmatclass_Entity.Basecode = ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString();//分类编码
- Purmatclass_Entity.Basename = txt_BASENAME.Text;//分类名称
- Purmatclass_Entity.UpdateName = UserInfo.GetUserName();
- Purmatclass_Entity.UpdateUserid = UserInfo.GetUserID();
- Purmatclass_Entity.UpdateTime = System.DateTime.Now;//修改时间
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatClassService", "doUpdate", new object[] { Purmatclass_Entity });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("修改失败 " + crt.Resultmsg);
- return;
- }
- MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- if (ultraTree1.ActiveNode != null)
- {
- //查询物料分类
- PurmatclassEntity pmcE = new PurmatclassEntity();
- pmcE.Parentcode = ultraTree1.ActiveNode.Key;
- GetPUR_MAT_CLASS(pmcE);
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "BASECODE", Purmatclass_Entity.Basecode);//激活当前行
- //展开上次激活的节点
- if (ultraTree1.ActiveNode.Parent != null)
- {
- UltraTreeNode node = ultraTree1.ActiveNode.Nodes[Purmatclass_Entity.Basecode];
- node.Text = Purmatclass_Entity.Basename;
- }
- else
- {
- ultraTree1.Nodes.Add(Purmatclass_Entity.Basecode, Purmatclass_Entity.Basename);
- }
- }
- }
- catch (Exception e)
- {
- MessageBox.Show("修改出现异常:" + e.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- return;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- public void DelPUR_MAT_CLASS()
- {
- try
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageBox.Show("请选择要删除的物料分类!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定要删除物料分类【" + ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString() + "】?") == DialogResult.No)
- {
- return;
- }
- PurmatclassEntity Purmatclass_Entity = new PurmatclassEntity();
- Purmatclass_Entity.Parentcode = ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString();//分类编码
- Purmatclass_Entity.Validflag = "1";
- if (this.execute<int>("com.hnshituo.pur.configure.service.MatClassService", "count", new object[] { Purmatclass_Entity }) > 0)
- {
- MessageUtil.ShowTips("分类编码【" + ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString() + "】存在子节点,不能删除");
- return;
- }
- MatEntity mat = new MatEntity();
- mat.ArcCode = Purmatclass_Entity.Parentcode;
- mat.Validflag = "1";
- if (this.execute<int>("com.hnshituo.pur.configure.service.MatService", "count", new object[] { mat }) > 0)
- {
- MessageUtil.ShowTips("分类编码【" + ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString() + "】存在物料,不能删除");
- return;
- }
-
- Purmatclass_Entity.Basecode = ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString();//分类编码
- Purmatclass_Entity.DeleteName = UserInfo.GetUserName();
- Purmatclass_Entity.DeleteTime = System.DateTime.Now;//修改时间
- Purmatclass_Entity.DeleteUserid = UserInfo.GetUserID();//修改时间
- Purmatclass_Entity.Validflag = "0";
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatClassService", "doUpdate", new object[] { Purmatclass_Entity });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
- return;
- }
- if (Q_mat != null)
- {
- //查询物料分类
- PurmatclassEntity pmcE = new PurmatclassEntity();
- pmcE.Parentcode = ultraTree1.ActiveNode.Key;
- GetPUR_MAT_CLASS(pmcE);
- //展开上次激活的节点
- if (ultraTree1.ActiveNode != null)
- {
- UltraTreeNode node = ultraTree1.ActiveNode.Nodes[Purmatclass_Entity.Basecode];
- ultraTree1.ActiveNode.Nodes.Remove(node);
- }
- MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- }
- catch (Exception e)
- {
- MessageBox.Show("删除出现异常:" + e.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- return;
- }
- }
- /// <summary>
- /// 获取物料分类树形结构
- /// </summary>
- public void getultree()
- {
- PurmatclassEntity mat = new PurmatclassEntity();
- mat.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatClassService", "find", new object[] { mat, 0, 0 });
- if (dt == null || dt.Rows.Count < 1)
- {
- return;
- }
- DataTable dt_A = new DataTable();//物料分类
- //筛选出根节点
- DataRow[] rows = dt.Select("PARENTCODE='' or PARENTCODE is null");
- dt_A = dt.Clone(); //克隆A的结构
- foreach (DataRow row in rows)
- {
- dt_A.ImportRow(row);//复制行数据
- }
- dt_A.DefaultView.Sort = "basename";
- dt_A = dt_A.DefaultView.ToTable();
- //添加物料大类
- for (int j = 0; j < dt_A.Rows.Count; j++)
- {
- if (!ultraTree1.Nodes.Exists(dt_A.Rows[j]["BASECODE"].ToString()))
- {
- UltraTreeNode Ultnode = ultraTree1.Nodes.Add(dt_A.Rows[j]["BASECODE"].ToString(), dt_A.Rows[j]["BASENAME"].ToString());
- getChildNodes(Ultnode, dt);
- }
- }
- }
- /// <summary>
- /// 递归查询父节点下的所有子节点
- /// </summary>
- /// <param name="Tnode"></param>
- public void getChildNodes(UltraTreeNode Tnode, DataTable dt)
- {
- DataTable dt_A = dt.Clone();//物料分类
- DataRow[] rows = dt.Select("PARENTCODE='" + Tnode.Key + "'");
- foreach (DataRow row in rows)
- {
- dt_A.ImportRow(row);//复制行数据
- }
- //添加物料分类
- dt_A.DefaultView.Sort = "basename";
- dt_A = dt_A.DefaultView.ToTable();
- //添加物料分类
- for (int j = 0; j < dt_A.Rows.Count; j++)
- {
- UltraTreeNode Ultnode = Tnode.Nodes.Add(dt_A.Rows[j]["BASECODE"].ToString(), dt_A.Rows[j]["BASENAME"].ToString());
- getChildNodes(Ultnode, dt);//利用递归将当前节点的子节点添加进去
- }
- }
- /// <summary>
- /// 获取激活子节点
- /// </summary>
- /// <param name="Tnode"></param>
- public void ActiveChildNodes(UltraTreeNode Tnode)
- {
- Q_mat = new PurmatclassEntity();
- Q_mat.Validflag = "1";
- Q_mat.Parentcode = Tnode.Key;
- DataTable dt_A = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatClassService", "find", new object[] { Q_mat, 0, 100 });
-
- for (int j = 0; j < dt_A.Rows.Count; j++)
- {
- UltraTreeNode Ultnode = Tnode.Nodes.Add(dt_A.Rows[j]["BASECODE"].ToString(), dt_A.Rows[j]["BASENAME"].ToString());
- ActiveChildNodes(Ultnode);//利用递归将当前节点的子节点添加进去
- }
- }
- //选中ultraGrid1激活行事件
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- txt_BASECODE.Text = ultraGrid1.ActiveRow.Cells["BASECODE"].Value.ToString();//分类编码
- txt_BASENAME.Text = ultraGrid1.ActiveRow.Cells["Basename"].Value.ToString();//分类名称
- //txt_BUYER_UNIT_CODE.Text = ultraGrid1.ActiveRow.Cells["BuyerUnitCode"].Value.ToString();//采购科室代码
- //txt_BUYER_POST.Text = ultraGrid1.ActiveRow.Cells["BuyerPost"].Value.ToString();//采购科室描叙
- }
- //选中 ultraTree1节点事件
- private void ultraTree1_AfterSelect(object sender, SelectEventArgs e)
- {
- ////清空
- //txt_BASECODE.Text = "";
- //txt_BASENAME.Text = "";
- //UltraTreeNode Ultnode = ultraTree1.ActiveNode;
- //GetPUR_MAT_CLASS(getEnSelContion(Ultnode.Key));
- }
- /// <summary>
- /// 筛选选中节点的子记录
- /// </summary>
- //public void getNodedt(UltraTreeNode Ultnode)
- //{
- // if (dt_Purmatclass != null && dt_Purmatclass.Rows.Count > 0)
- // {
- // DataTable dt_A = dt_Purmatclass.Clone();//物料分类
- // DataRow[] rows = dt_Purmatclass.Select("PARENTCODE='" + Ultnode.Key + "'");
- // foreach (DataRow row in rows)
- // {
- // dt_A.ImportRow(row);//复制行数据
- // }
- // dataTable1.Clear();
- // GridHelper.CopyDataToDatatable(ref dt_A, ref dataTable1, true);//绑定物料分类表
- // }
- //}
- //选中后自动展开
- private void ultraTree1_BeforeSelect(object sender, BeforeSelectEventArgs e)
- {
- //UltraTreeNode Ultnode = ultraTree1.ActiveNode;
- //Ultnode.Expanded = true;
- }
- /// <summary>
- /// 获取查询条件
- /// </summary>
- /// <returns></returns>
- private PurmatclassEntity getEnSelContion(string str)
- {
- PurmatclassEntity eMatClass = new PurmatclassEntity();
- if (str == null)
- {
- if (ultraTextEditor1.Text.Trim() != "")
- {
- eMatClass.Basecode = ultraTextEditor1.Text;
- }
- if (ultraTextEditor2.Text.Trim() != "")
- {
- eMatClass.Basename = ultraTextEditor2.Text;
- }
- }
- else
- {
- eMatClass.Parentcode = str;
- }
- eMatClass.Validflag = "1";
- return eMatClass;
- }
- /// <summary>
- /// 获取物料分类编码
- /// </summary>
- /// <param name="str"></param>
- /// <returns></returns>
- public string getItemCodeClass(string str)
- {
- string strChild = "";
- PurmatclassEntity mat = new PurmatclassEntity();
- mat.Parentcode = ultraTree1.ActiveNode.Key;
- int intChild = this.execute<int>("com.hnshituo.pur.configure.service.MatClassService", "count", new object[] { mat });
- intChild++;
- strChild = intChild.ToString();
- while (strChild.Length < 2)
- {
- strChild = "0" + strChild;
- }
- //判断编码是否存在
- PurmatclassEntity matIsExsitRow = new PurmatclassEntity();
- matIsExsitRow.Basecode = str + strChild;
- while (isExsitRow("com.hnshituo.pur.configure.service.MatClassService", matIsExsitRow))
- {
- intChild++;
- strChild = intChild.ToString();
- while (strChild.Length < 2)
- {
- strChild = "0" + strChild;
- }
- matIsExsitRow.Basecode = str + strChild;
- }
- return str + strChild;
- }
- /// <summary>
- /// 添加物料大类
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraCheckEditor3_CheckedChanged(object sender, EventArgs e)
- {
- //txt_BASECODE.Enabled = ultraCheckEditor3.Checked;
- }
- private bool IsCharacter(string str)
- {
- if (str.Trim() != "" && str.Length == 1)
- {
- System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
- byte[] byteArray = asciiEncoding.GetBytes(str);
- if ((int)byteArray[0] >= 65 && (int)byteArray[0] <= 90)
- {
- return true;
- }
- }
- return false;
- }
- //判断物料中是否存在相同的列
- public bool isExsitRow(string strJavaPackName, object o)
- {
- DataTable dt = this.execute<DataTable>(strJavaPackName, "find", new object[] { o, 0, 0 });
- if (dt != null && dt.Rows.Count > 0)//存在相同的行
- {
- return true;
- }
- return false;
- }
- /// <summary>
- /// 单击grid行,自动展开左侧树形结构
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)
- {
- ExpNode(e.Cell.Row.Cells["BASECODE"].Value.ToString());
- }
- private void ExpNode(string strBASECODE)
- {
- UltraTreeNode uttNode = ultraTree1.GetNodeByKey(strBASECODE).Parent;
- if (uttNode == ultraTree1.ActiveNode)
- {
- return;
- }
- ultraTree1.CollapseAll();
- QclickQueryCell = true;
- if (uttNode == null)
- {
- ultraTree1.ActiveNode = ultraTree1.GetNodeByKey(strBASECODE);
- }
- else
- {
- ultraTree1.ActiveNode = uttNode;
- }
- ultraTree1.ActiveNode.Expanded = true;
- UltraTreeNode uttNodeExpand = ultraTree1.ActiveNode;
- while (uttNodeExpand.Parent != null)
- {
- uttNodeExpand = uttNodeExpand.Parent;
- uttNodeExpand.Expanded = true;
- }
- }
- /// <summary>
- /// 激活左侧树形结构
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraTree1_AfterActivate(object sender, NodeEventArgs e)
- {
- //清空
- if (!QclickQueryCell)
- {
- txt_BASECODE.Text = "";
- txt_BASENAME.Text = "";
- UltraTreeNode Ultnode = ultraTree1.ActiveNode;
- Ultnode.Expanded = true;
- GetPUR_MAT_CLASS(getEnSelContion(Ultnode.Key));
- }
- QclickQueryCell = false;//设置未点击
- }
- private void ultraTree1_Click(object sender, EventArgs e)
- {
-
- }
- }
- }
|