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; } } /// /// 删除物料 /// 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("com.hnshituo.pur.configure.service.ClassMatRelationService", "doDelete_Relation", new object[] { strId }); if (crt.Resultcode != 0) { MessageUtil.ShowTips("删除失败"); return; } MessageUtil.ShowTips("删除成功"); doQueryMat(strClassCode); } /// /// 查询物料 /// /// private void doQueryMat(String classCode) { if(String.IsNullOrEmpty(classCode)) { return; } PurClassMatRelationEntity purentity1 = new PurClassMatRelationEntity(); purentity1.ClassCode = classCode; DataTable dt2 = this.execute("com.hnshituo.pur.configure.service.ClassMatRelationService", "find", new object[] { purentity1, 0, 0 }); GridHelper.CopyDataToDatatable(dt2, dataTable3, true); GridHelper.RefreshAndAutoSize(ultraGrid3); } /// /// 查询属性 /// /// 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("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 ("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); } } } /// /// 查询物料类型 /// private void getPurMainTain() { dataTable1.Clear(); dataTable2.Clear(); dataTable3.Clear(); textBox1.Text = ""; txt_ClassBZ.Text = ""; DataTable dt1 = this.execute("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("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("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("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("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("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("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(); } } }