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 Core.Mes.Client.Comm.Control; using Pur.Entity.require_planEntiy; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Tool; using Pur.Entity.pur_orderEntiy; using Pur.Entity.configureEntity; using Pur.configure; using com.hnshituo.pur.vo; using Core.Mes.Client.Comm.Server; using Pur.order; using Infragistics.Win; using System.Collections; namespace Pur.ck { public partial class PurExcDeliveryNoticeAdd : FrmPmsBase { public String Tips = "0"; string Supp_Code = ""; public PurExcDeliveryNoticeAdd() { InitializeComponent(); } public PurExcDeliveryNoticeAdd(OpeBase Ob) { this.ob = Ob; InitializeComponent(); } private void PurExcDeliveryNoticeAdd_Load(object sender, EventArgs e)//load { COP_Status.SelectedIndex = 0; COP_timeBegin.Value = DateTime.Now.AddDays(-30); COP_timeEnd.Value = DateTime.Now.AddDays(1); Get_OrderType(); GetPUR_ORDER_M(); ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; ultraGrid2.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[1], new string[] { "CHK" }); } /// /// 菜单按钮 /// /// /// private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "Query": // ButtonTool GetPUR_ORDER_M(); break; case "Add": // ButtonTool Add_Purexcdeliverynotice(); break; case "Close": // ButtonTool this.Close(); break; } } /// /// 菜单按钮 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey)//菜单按钮 { switch (ToolbarKey) { case "Query": GetPUR_ORDER_M(); break; case "Add": Add_Purexcdeliverynotice(); break; case "Close": this.Close(); break; } } /// /// 生成发货通知单 /// private void Add_Purexcdeliverynotice()//生成发货通知单 { try { ArrayList list = new ArrayList(); //获取已选择的交货行 UltraGridBand bandChild = this.ultraGrid2.DisplayLayout.Bands[1]; foreach (UltraGridRow row in bandChild.GetRowEnumerator(GridRowType.DataRow)) { if (Convert.ToBoolean(row.Cells["CHK"].Value)) { String strId = row.Cells["ORDERLINEDSQE"].Value.ToString().Trim(); list.Add(strId); } } if (list.Count <= 0) { MessageUtil.ShowTips("请选择交货行" ); return; } PurExcDeliveryNoticeOk frm = new PurExcDeliveryNoticeOk(this.ob,list); frm.ShowDialog(); if (frm.Tips == "1") { getOrderCAndCD(); Tips = "1"; } } catch (Exception ex) { MessageUtil.ShowTips("操作失败:"+ex); } } /// /// 查询合同计划 /// private void GetPUR_ORDER_M()//查询合同计划 { try { this.Cursor = Cursors.WaitCursor; dataSet1.Clear(); OrderM Odm = new OrderM(); Odm.Status = COP_Status.Value == null ? null : COP_Status.Value.ToString(); Odm.OrderType = COP_OrderType.Value == null ? null : COP_OrderType.Value.ToString(); Odm.OrderId = COP_OrderId.Text; Odm.SuppName = COP_SuppName.Text; if (COP_timeBegin.Text != "") { Odm.CreateTime = Convert.ToDateTime(COP_timeBegin.Value); } if (COP_timeEnd.Text != "") { Odm.UpdateTime = Convert.ToDateTime(COP_timeEnd.Value); } if (CK_isAll.Checked == false) { Odm.DeleteName = "0"; } else { Odm.DeleteName = "1"; } Odm.Validflag = "1"; DataTable dt = this.execute("com.hnshituo.pur.order.service.OrderMService", "find_canUseOrderM", new object[] { Odm, 0, 0 }); GridHelper.CopyDataToDatatable(dt, dataTable1, true); } catch (Exception ex) { MessageUtil.ShowTips("操作失败:" + ex); } finally { this.Cursor = Cursors.Default; } } /// /// 供应商弹窗 /// /// /// private void COP_SuppName_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)// 供应商弹窗 { Supp Sp = new Supp(); Sp.Validflag = "1"; //DataTable dt = this.execute("com.hnshituo.pur.configure.service.SuppService", "find", new object[] { Sp, 0, 0 }); frmSuppSel Sky = new frmSuppSel(this.ob); Sky.ShowDialog(); if (Sky.strSUPP_CODE == null) return; COP_SuppName.Text = Sky.strSUPP_NAME.ToString(); Supp_Code = Sky.strSUPP_CODE.ToString(); } /// /// 激活行 /// /// /// private void ultraGrid1_AfterCellActivate(object sender, EventArgs e)//激活行 { getOrderCAndCD(); } /// /// 单击主表行查询从表 /// private void getOrderCAndCD()//单击主表行查询从表 { try { dataTable3.Clear(); dataTable2.Clear(); //加载合同行 UltraGridRow uge = ultraGrid1.ActiveRow; String strOrderId = uge.Cells["OrderId"].Value.ToString().Trim(); String strOrderLineSqe = COP_orderLineSqe.Text.ToString().Trim(); String strItemName = COP_ItemName.Text.ToString().Trim(); OrderC odC = new OrderC(); odC.OrderId = strOrderId; odC.OrderLineSqe = strOrderLineSqe; odC.ItemName = strItemName; odC.Validflag = "1"; DataTable dt = this.execute("com.hnshituo.pur.order.service.OrderCService", "doQueryOrderC", new object[] { odC }); GridHelper.CopyDataToDatatable(dt, dataTable2, true); foreach (DataRow row in dt.Rows) { //if (String.IsNullOrEmpty(row["RECEIVETYPE"].ToString())) //{ // MessageUtil.ShowTips("合同行:" + row["orderLineSqe"].ToString() + "交货方式为空,数据异常"); // dataTable3.Clear(); // dataTable2.Clear(); // return; //} if (String.IsNullOrEmpty(row["PURLINEID"].ToString())) { MessageUtil.ShowTips("合同行:" + row["orderLineSqe"].ToString() + "采购计划行号为空,数据异常"); dataTable3.Clear(); dataTable2.Clear(); return; } } //加载合同交货行 OrderCD odCD = new OrderCD(); odCD.OrderId = strOrderId; odCD.OrderLineSqe = strOrderLineSqe; odCD.DeleteName = strItemName; odCD.Validflag = "1"; if (CK_isAll2.Checked == false) { odCD.Status = "0"; } else { odCD.Status = ""; } DataTable dt1 = this.execute("com.hnshituo.pur.order.service.OrderCDService", "doQueryOrderCDList", new object[] { odCD }); GridHelper.CopyDataToDatatable(dt1, dataTable3, true); //初始化选择交货行 foreach(UltraGridRow row in ultraGrid2.Rows) { int count = 0; if (row.HasChild()) { foreach (UltraGridRow rows in row.ChildBands[0].Rows) { if (rows.GetCellValue("status").ToString().Trim().Equals("待通知发货")) { count = count + 1; if (count == 1) { rows.Cells["CHK"].Value = true; } else { rows.Cells["CHK"].Value = false; } rows.Cells["CHK"].Activation = Activation.AllowEdit; rows.Appearance.BackColor = Color.White; } else { rows.Cells["CHK"].Value = false; rows.Cells["CHK"].Activation = Activation.Disabled; rows.Appearance.BackColor = Color.WhiteSmoke; } } } } } catch (Exception ex) { MessageUtil.ShowTips("获取该合同明细和条款名称数据失败:" + ex); } } /// /// 加载合同类别 /// private void Get_OrderType()//加载合同类别 { DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1200" }, this.ob); comm.FilComboboxAdd(COP_OrderType, dt1, "baseCode", "baseName", "validflag NOT in ('0')", true, "全部", ""); COP_OrderType.SelectedIndex = 0; } /// /// 刷新合同行和交货行信息 /// /// /// private void btn_orderSelect_Click(object sender, EventArgs e)//刷新合同行和交货行信息 { getOrderCAndCD(); } /// /// 控制交货行输入 /// /// /// private void ultraGrid2_CellChange(object sender, CellEventArgs e)//控制交货行输入 { ultraGrid2.UpdateData(); if (e.Cell.Column.Key == "CHK") { if (Convert.ToBoolean(e.Cell.Value) == true) { foreach (UltraGridRow row in e.Cell.Row.ParentRow.ChildBands[0].Rows) { if (row.Index != e.Cell.Row.Index) { row.Cells["CHK"].Value = false; } } } } } } }