| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- using com.hnshituo.pur.vo;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Tool;
- using Infragistics.Win.UltraWinGrid;
- using Pur.Entity;
- using Pur.Entity.configureEntity;
- using Pur.Pop_upWindow;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Pur.configure
- {
- public partial class FrmMainTain : FrmPmsBase
- {
- public FrmMainTain()
- {
- InitializeComponent();
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "doQuery":
- getPurMainTain();
- break;
- case "doAdd":
- addPurMainTain();
- break;
- case "doDelete":
- delPurMainTain();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 删除物料
- /// </summary>
- private void delPurMainTain()
- {
-
- UltraGridRow rug = ultraGrid3.ActiveRow;
- if (rug == null)
- {
- MessageUtil.ShowTips("请选择删除物料");
- return;
- }
- String strId = ultraGrid3.ActiveRow.Cells["ID"].Value.ToString();
- String strClassCode = ultraGrid3.ActiveRow.Cells["classCode"].Value.ToString();
- if (String.IsNullOrEmpty(strId))
- {
- MessageUtil.ShowTips("数据异常,物料编号为空");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定删除? 备注:若删除,该物料关联的属性将全部删除!")!= DialogResult.Yes)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMatRelationService", "doDelete_Relation", new object[] { strId });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败");
- return;
- }
- MessageUtil.ShowTips("删除成功");
- doQueryMat(strClassCode);
- }
- /// <summary>
- /// 查询物料
- /// </summary>
- /// <param name="classCode"></param>
- private void doQueryMat(String classCode)
- {
- if(String.IsNullOrEmpty(classCode))
- {
- return;
- }
- PurClassMatRelationEntity purentity1 = new PurClassMatRelationEntity();
- purentity1.ClassCode = classCode;
- DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.configure.service.ClassMatRelationService", "find", new object[] { purentity1, 0, 0 });
- GridHelper.CopyDataToDatatable(dt2, dataTable3, true);
- GridHelper.RefreshAndAutoSize(ultraGrid3);
- }
- /// <summary>
- /// 查询属性
- /// </summary>
- /// <param name="itemCode"></param>
- private void doQueryAttr(String itemCode)
- {
- txt_AttrBZ.Text = "";
- textBox3.Text = "";
- if (String.IsNullOrEmpty(itemCode))
- {
- return;
- }
- PurClassMatAttrEntity purentity1 = new PurClassMatAttrEntity();
- purentity1.ItemCode = itemCode;
- DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.configure.service.ClassMatAttrService", "find", new object[] { purentity1, 0, 0 });
- GridHelper.CopyDataToDatatable(dt2, dataTable2, true);
- GridHelper.RefreshAndAutoSize(ultraGrid2);
- }
- private void addPurMainTain()
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择类型");
- return;
- }
- String strCLASSCODE = ultraGrid1.ActiveRow.GetCellValue("CLASSCODE").ToString().Trim();
- if (String.IsNullOrEmpty(strCLASSCODE))
- {
- MessageUtil.ShowTips("请选择类型编号为空");
- return;
- }
- ArrayList list=new ArrayList();
- frmPopMatSelect frm = new frmPopMatSelect(this.ob);
- frm.ShowDialog();
- if (frm.tips == "1")
- {
-
- for (int i = 0; i <frm.List_item.Count; i++)
- {
- PurClassMatRelationEntity purentity = new PurClassMatRelationEntity();
- purentity.ItemCode = ((MatEntity)frm.List_item[i]).ItemCode;
- purentity.ItemName = ((MatEntity)frm.List_item[i]).ItemName;
- purentity.ClassCode = strCLASSCODE;
- purentity.CreateName = UserInfo.GetUserName();
- purentity.CreateTime = DateTime.Now;
- purentity.CreateUserid = UserInfo.GetUserID();
- list.Add(purentity);
- }
- if (list.Count <= 0)
- {
- MessageUtil.ShowTips("未选择物料");
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMatRelationService", "doInsert_Relation", new object[] { list, 0, 0 });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("绑定失败:" + crt.Resultmsg);
- }
- else {
- MessageUtil.ShowTips("操作成功");
- doQueryMat(strCLASSCODE);
- }
- }
- }
- /// <summary>
- /// 查询物料类型
- /// </summary>
- private void getPurMainTain()
- {
- dataTable1.Clear();
- dataTable2.Clear();
- dataTable3.Clear();
- textBox1.Text = "";
- txt_ClassBZ.Text = "";
- DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.configure.service.ClassMainService", "findAll", new object[] {});
- GridHelper.CopyDataToDatatable(dt1, dataTable1,true);
- GridHelper.RefreshAndAutoSize(ultraGrid1);
- }
- private void ultraButton6_Click(object sender, EventArgs e)
- {
- PurClassEntity purentity = new PurClassEntity();
- if (textBox1.Text != "")
- {
- purentity.ClassName = textBox1.Text.Trim();
-
- }
- else
- {
- MessageUtil.ShowTips("类型名称不能为空");
- return;
- }
- purentity.CreateName = UserInfo.GetUserName();
- purentity.CreateUserid = UserInfo.GetUserID();
- purentity.Remark = txt_ClassBZ.Text;
- if (MessageUtil.ShowYesNoAndQuestion("确定添加?") != DialogResult.Yes )
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMainService", "insert_id", new object[] { purentity });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("添加失败:"+crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("添加成功");
- getPurMainTain();
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "CLASSNAME", purentity.ClassName);//激活当前行
- }
- private void ultraButton4_Click(object sender, EventArgs e)
- {
- PurClassEntity purentity = new PurClassEntity();
- UltraGridRow rug = ultraGrid1.ActiveRow;
- if (rug == null)
- {
- MessageUtil.ShowTips("请选中修改行");
- }
- if (textBox1.Text == "")
- {
- MessageUtil.ShowTips("修改内容不能为空");
- return;
- }
- if (textBox1.Text == ultraGrid1.ActiveRow.Cells["CLASSNAME"].Value.ToString())
- {
- MessageUtil.ShowTips("修改内容不能重复");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确定修改?") == DialogResult.No)
- {
- return;
- }
- purentity.ClassCode = ultraGrid1.ActiveRow.Cells["CLASSCODE"].Value.ToString();
- purentity.ClassName = textBox1.Text.Trim();
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMainService", "doUpdate", new object[] { purentity, 0, 0 });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("修改失败");
- return;
- }
- MessageUtil.ShowTips("修改成功");
- getPurMainTain();
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "CLASSCODE", purentity.ClassCode);
- }
- private void ultraButton5_Click(object sender, EventArgs e)
- {
- if (ultraGrid1.ActiveRow != null)
- {
- String strClassCode = ultraGrid1.ActiveRow.Cells["CLASSCODE"].Value.ToString();
- if (String.IsNullOrEmpty(strClassCode))
- {
- MessageUtil.ShowTips("类型编号为空");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确定删除类型【" + ultraGrid1.ActiveRow.Cells["CLASSNAME"].Value.ToString() + "】? 备注:若删除,其关联的物料和物料属性将同步删除") != DialogResult.Yes)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMainService", "doDelete_id", new object[] { strClassCode });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败:" + crt.Resultmsg);
- }
- MessageUtil.ShowTips("删除成功");
- getPurMainTain();
- }
- }
- private void ultraButton1_Click(object sender, EventArgs e)
- {
- if (ultraGrid3.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择物料");
- return;
- }
- String strItemCode = ultraGrid3.ActiveRow.GetCellValue("itemCode").ToString().Trim();
- if (String.IsNullOrEmpty(strItemCode))
- {
- MessageUtil.ShowTips("选择的物料物料编号为空");
- return;
- }
- PurClassMatAttrEntity puren = new PurClassMatAttrEntity();
- if (textBox3.Text != "")
- {
- puren.AttrName = textBox3.Text.Trim();
- }
- else
- {
- MessageUtil.ShowTips("属性名称不能为空");
- return;
- }
- puren.CreateName = UserInfo.GetUserName();
- puren.CreateUserid = UserInfo.GetUserID();
- puren.CreateTime = DateTime.Now;
- puren.ItemCode = strItemCode;
- puren.Remark = txt_AttrBZ.Text;
- if (MessageUtil.ShowYesNoAndQuestion("确定添加?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMatAttrService", "insert_id", new object[] { puren });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("添加失败:"+crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("添加成功");
- doQueryAttr(strItemCode);
- ConfigureClassCommon.doActiveSelRow(ultraGrid2, "attrName", puren.AttrName);
-
- }
- private void FrmMainTain_Load(object sender, EventArgs e)
- {
- getPurMainTain();
- }
- private void ultraButton3_Click(object sender, EventArgs e)
- {
- PurClassMatAttrEntity puren = new PurClassMatAttrEntity();
- UltraGridRow rug = ultraGrid2.ActiveRow;
- puren.Id = ultraGrid2.ActiveRow.Cells["ID"].Value.ToString();
- if (rug == null)
- {
- MessageUtil.ShowTips("请选中修改行");
- }
- if (textBox3.Text != "")
- {
- puren.AttrName = textBox3.Text.Trim();
- }
- else
- {
- MessageUtil.ShowTips("属性名称不能为空");
- return;
- }
- //if (textBox3.Text == ultraGrid1.ActiveRow.Cells["ATTRNAME"].Value.ToString())
- //{
- // MessageUtil.ShowTips("属性名称不能重复");
- // return;
- //}
- if (MessageUtil.ShowYesNoAndQuestion("是否确定修改?") == DialogResult.No)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMatAttrService", "doUpdate", new object[] { puren, 0, 0 });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("修改失败");
- return;
- }
- MessageUtil.ShowTips("修改成功");
- }
- private void ultraButton2_Click(object sender, EventArgs e)
- {
- UltraGridRow rug = ultraGrid2.ActiveRow;
- if (rug == null)
- {
- MessageUtil.ShowTips("请选择需删除的属性");
- return;
- }
- String strId = ultraGrid2.ActiveRow.Cells["ID"].Value.ToString();
- if(String.IsNullOrEmpty(strId))
- {
- MessageUtil.ShowTips("请选择需删除的属性编号为空");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定删除?") == DialogResult.No)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.ClassMatAttrService", "doDelete", new object[] { strId });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败");
- return;
- }
- MessageUtil.ShowTips("删除成功");
- string strItemCode = ultraGrid3.ActiveRow.Cells["ItemCode"].Value.ToString();
- doQueryAttr(strItemCode);
- }
- private void ultraGrid3_AfterRowActivate(object sender, EventArgs e)
- {
- dataTable2.Clear();
- UltraGridRow uge = ultraGrid3.ActiveRow;
- if (uge == null)
- {
- return;
- }
- textBox3.Text = "";
- txt_AttrBZ.Text = "";
- String stritemCode = ultraGrid3.ActiveRow.GetCellValue("itemCode").ToString().Trim();
- doQueryAttr(stritemCode);
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- dataTable2.Clear();
- dataTable3.Clear();
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- return;
- }
-
- String strClassCode = ultraGrid1.ActiveRow.GetCellValue("classCode").ToString().Trim();
- doQueryMat(strClassCode);
- }
- private void ultraGrid2_ClickCell(object sender, ClickCellEventArgs e)
- {
- textBox3.Text = e.Cell.Row.Cells["ATTRNAME"].Value.ToString();
- txt_AttrBZ.Text = e.Cell.Row.Cells["REMARK"].Value.ToString(); ;
- }
- private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)
- {
- textBox1.Text = e.Cell.Row.Cells["classname"].Value.ToString();
- txt_ClassBZ.Text = e.Cell.Row.Cells["REMARK"].Value.ToString();
- }
- }
- }
|