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.CA03; using CoreFS.CA04; using CoreFS.CA06; using System.Collections; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Tool; namespace Core.StlMes.Client.SaleOrder { public partial class frmTransitLine : FrmBase { public frmTransitLine() { InitializeComponent(); } public frmTransitLine(OpeBase ob) { InitializeComponent(); this.ob = ob; } /// /// 窗体加载事件 /// /// /// private void frmTransitLine_Load(object sender, EventArgs e) { bindType(); //线路明细相关控件数据绑定。 bindTypeMx(); //专用线数据源绑定。 bindZy(); //运输方式 bindYsfs(); //承运单位 bindCydw(); //是否代办 cmbIsD.SelectedIndex = 0; doQuery(); } /// /// 重写基类load事件,屏蔽平台过滤功能。 /// /// protected override void OnLoad(EventArgs e) { base.OnLoad(e); ultraGridMx.DisplayLayout.Bands[0].Override.HeaderClickAction = HeaderClickAction.Select; } /// /// 承运单位 /// private void bindCydw() { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.GetCydw", null, this.ob); //起始地数据源绑定 cmbCydw.DataSource = dt; cmbCydw.DisplayMember = "BASENAME"; cmbCydw.ValueMember = "BASECODE"; cmbCydw.DataBind(); cmbCydw.SelectedIndex = 0; } /// /// 运输方式 /// private void bindYsfs() { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.GetYsfs", null, this.ob); cmbYsfs.DataSource = dt; cmbYsfs.DisplayMember = "BASENAME"; cmbYsfs.ValueMember = "BASECODE"; cmbYsfs.DataBind(); cmbYsfs.SelectedIndex = 0; } /// /// 专用线数据源绑定 /// private void bindZy() { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.GetSpclNo", null, this.ob); //起始地数据源绑定 cmbZy.DataSource = dt; cmbZy.DisplayMember = "SPCL_LN_NM"; cmbZy.ValueMember = "SPCL_LN_NO"; cmbZy.DataBind(); cmbZy.SelectedIndex = 0; } /// /// 线路明细地域类型数据源绑定。 /// private void bindTypeMx() { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.GetType", null, this.ob); //始发地数据源绑定 cmbSfmxType.DataSource = dt; cmbSfmxType.DisplayMember = "BASENAME"; cmbSfmxType.ValueMember = "BASECODE"; cmbSfmxType.DataBind(); cmbSfmxType.SelectedIndex = 0; //终止地数据源绑定 cmbZzmxType.DataSource = dt; cmbZzmxType.DisplayMember = "BASENAME"; cmbZzmxType.ValueMember = "BASECODE"; cmbZzmxType.DataBind(); cmbZzmxType.SelectedIndex = 0; } /// /// 绑定始发地类型,他与终止地类型属于同一个数据源。 /// private void bindType() { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.GetType", null, this.ob); //始发地数据源绑定 cmbSfType.DataSource = dt; cmbSfType.DisplayMember = "BASENAME"; cmbSfType.ValueMember = "BASECODE"; cmbSfType.DataBind(); cmbSfType.SelectedIndex = 0; //终止地数据源绑定 cmbZZType.DataSource = dt; cmbZZType.DisplayMember = "BASENAME"; cmbZZType.ValueMember = "BASECODE"; cmbZZType.DataBind(); cmbZZType.SelectedIndex = 0; } /// /// 清空查询起始地查询条件 /// /// /// private void chkQsd_CheckedChanged(object sender, EventArgs e) { txtQsTitle.Enabled = chkQsd.Checked; if (txtQsTitle.Enabled == false) { txtQsTitle.Text = ""; } } /// /// 清空目的地查询条件 /// /// /// private void chkMdd_CheckedChanged(object sender, EventArgs e) { txtMdTitle.Enabled = chkMdd.Checked; if (txtMdTitle.Enabled == false) { txtMdTitle.Text = ""; } } /// /// tool工具栏 /// /// /// private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "doQuery": doQuery(); break; case "doAdd": doAdd(); break; case "doUpdate": doUpdate(); break; case "doDelete": doDelete(); break; case "doRecovery": doRecovery(); break; case "doOk": doOk(); break; case "doClose": this.Close(); break; default: break; } } /// /// 委托方法 /// /// public delegate void GetTransitLineHander(UltraGridRow xl, UltraGridRow fa, DataTable mx); public event GetTransitLineHander GetTransitLine; /// /// 确认 /// private void doOk() { if (ultraGridXl.ActiveRow == null || ultraGridFa.ActiveRow == null || ultraGridMx.ActiveRow == null) { MessageBox.Show("当前运输线路不可用,请重新选择。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //返回2行记录和1个Table回主界面。 UltraGridRow xl = ultraGridXl.ActiveRow; UltraGridRow fa = ultraGridFa.ActiveRow; GetTransitLine(xl, fa, this.dataTable3); this.Close(); } /// /// 恢复 /// private void doRecovery() { switch (ultraTabControl1.SelectedTab.Key) { case "0": doDelete_Main(false); break; case "1": doDelete_Mode(false); break; case "2": doDelete_ModeLine(false); break; default: break; } } /// /// 删除 /// private void doDelete() { switch (ultraTabControl1.SelectedTab.Key) { case "0": doDelete_Main(true); break; case "1": doDelete_Mode(true); break; case "2": doDelete_ModeLine(true); break; default: break; } } /// /// 主线路删除 /// /// private void doDelete_Main(bool isDelete) { if (ultraGridXl.ActiveRow == null) { MessageBox.Show("请选择需要" + (isDelete ? "废除" : "恢复") + "的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Boolean validflagStr = Convert.ToBoolean(ultraGridXl.ActiveRow.Cells["VALIDFLAG"].Value); if (isDelete) { //无效数据不允许删除。 if (!validflagStr) { MessageBox.Show("无效数据不支持废除操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } else { //有效数据不允许恢复 if (validflagStr) { MessageBox.Show("有效数据不支持恢复操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } ArrayList param = new ArrayList(); string transitNo = ultraGridXl.ActiveRow.Cells["TRANSIT_NO"].Value.ToString(); if (isDelete) { param.Add(UserInfo.GetUserName()); } else { param.Add(""); } param.Add(transitNo); if (param.Count > 0 && MessageBox.Show("是否确认" + (isDelete ? "废除" : "恢复") + "选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { //需要先废除或恢复他全部子记录 //从服务端一次性删除 int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreTransitLine.doDelete_Main", new Object[] { param, isDelete }, this.ob); if (count > 0) { //吨运费计算。 //UpdateTransitMny(transitNo, modeNo); doQuery(); Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null; for (int i = 0; i < ultraGridXl.Rows.Count; i++) { rowD = ultraGridXl.Rows[i]; if (rowD.Cells["TRANSIT_NO"].Value.ToString().Equals(transitNo)) { rowD.Activate(); break; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } /// /// 删除方案 /// /// private void doDelete_Mode(bool isDelete) { if (ultraGridFa.ActiveRow == null) { MessageBox.Show("请选择需要" + (isDelete ? "废除" : "恢复") + "的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Boolean validflagStr = Convert.ToBoolean(ultraGridFa.ActiveRow.Cells["VALIDFLAG"].Value); if (isDelete) { //无效数据不允许删除。 if (!validflagStr) { MessageBox.Show("无效数据不支持废除操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } else { //有效数据不允许恢复 if (validflagStr) { MessageBox.Show("有效数据不支持恢复操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //方案无效的情况下,线路明细不支持恢复操作。 Boolean validflagMain = Convert.ToBoolean(ultraGridXl.ActiveRow.Cells["VALIDFLAG"].Value); if (!validflagMain) { MessageBox.Show("主线路无效的情况下,方案不支持恢复操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } ArrayList param = new ArrayList(); string transitNo = ultraGridFa.ActiveRow.Cells["TRANSIT_NO"].Value.ToString(); string modeNo = ultraGridFa.ActiveRow.Cells["MODE_NO"].Value.ToString(); if (isDelete) { param.Add(UserInfo.GetUserName()); } else { param.Add(""); } param.Add(transitNo); param.Add(modeNo); if (param.Count > 0 && MessageBox.Show("是否确认" + (isDelete ? "废除" : "恢复") + "选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { //需要先废除或恢复他全部子记录 int countItem = ServerHelper.SetData("com.steering.pss.sale.order.CoreTransitLine.doDelete_Mode_Item", new Object[] { param, isDelete }, this.ob); if (countItem > 0) { int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreTransitLine.doDelete_Mode", new Object[] { param, isDelete }, this.ob); if (count > 0) { //吨运费计算。 UpdateTransitMny(transitNo, modeNo); doQuery_Mode(); Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null; for (int i = 0; i < ultraGridFa.Rows.Count; i++) { rowD = ultraGridFa.Rows[i]; if (rowD.Cells["MODE_NO"].Value.ToString().Equals(modeNo)) { rowD.Activate(); break; } } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } /// /// 删除线路明细。 /// private void doDelete_ModeLine(bool isDelete) { if (ultraGridMx.ActiveRow == null) { MessageBox.Show("请选择需要" + (isDelete ? "废除" : "恢复") + "的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Boolean validflagStr = Convert.ToBoolean(ultraGridMx.ActiveRow.Cells["VALIDFLAG"].Value); if (isDelete) { //无效数据不允许删除。 if (!validflagStr) { MessageBox.Show("无效数据不支持废除操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } else { //有效数据不允许恢复 if (validflagStr) { MessageBox.Show("有效数据不支持恢复操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //方案无效的情况下,线路明细不支持恢复操作。 Boolean validflagMode = Convert.ToBoolean(ultraGridFa.ActiveRow.Cells["VALIDFLAG"].Value); if (!validflagMode) { MessageBox.Show("方案无效的情况下,线路明细不支持恢复操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } if (isDelete) { if (MessageBox.Show("废除当前线路明细,将导致当前方案不可用,是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { doDelete_ModeMM(true); } } else { if (MessageBox.Show("恢复当前线路明细,将恢复当前方案,是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { doDelete_ModeMM(false); } } //ArrayList param = new ArrayList(); //string transitNo = ultraGridMx.ActiveRow.Cells["TRANSIT_NO"].Value.ToString(); //string modeNo = ultraGridMx.ActiveRow.Cells["MODE_NO"].Value.ToString(); //string indexSeq = ultraGridMx.ActiveRow.Cells["INDEX_SEQ"].Value.ToString(); //if (isDelete) //{ // param.Add(UserInfo.GetUserName()); //} //else //{ // param.Add(""); //} //param.Add(transitNo); //param.Add(modeNo); //param.Add(indexSeq); //if (param.Count > 0 && MessageBox.Show("是否确认" + (isDelete ? "废除" : "恢复") + "选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) //{ // try // { // int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreTransitLine.doDelete_ModeLine", new Object[] { param, isDelete }, this.ob); // if (count > 0) // { // //吨运费计算。 // UpdateTransitMny(transitNo, modeNo); // doQuery_ModeLine(); // Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null; // for (int i = 0; i < ultraGridMx.Rows.Count; i++) // { // rowD = ultraGridMx.Rows[i]; // if (rowD.Cells["INDEX_SEQ"].Value.ToString().Equals(indexSeq)) // { // rowD.Activate(); // break; // } // } // } // } // catch (Exception ex) // { // MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // } //} } /// /// 删除方案MX使用 /// /// private void doDelete_ModeMM(bool isDelete) { if (ultraGridFa.ActiveRow == null) { MessageBox.Show("请选择需要" + (isDelete ? "废除" : "恢复") + "的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Boolean validflagStr = Convert.ToBoolean(ultraGridFa.ActiveRow.Cells["VALIDFLAG"].Value); if (isDelete) { //无效数据不允许删除。 if (!validflagStr) { MessageBox.Show("无效数据不支持废除操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } else { //有效数据不允许恢复 if (validflagStr) { MessageBox.Show("有效数据不支持恢复操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //方案无效的情况下,线路明细不支持恢复操作。 Boolean validflagMain = Convert.ToBoolean(ultraGridXl.ActiveRow.Cells["VALIDFLAG"].Value); if (!validflagMain) { MessageBox.Show("主线路无效的情况下,方案不支持恢复操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } ArrayList param = new ArrayList(); string transitNo = ultraGridFa.ActiveRow.Cells["TRANSIT_NO"].Value.ToString(); string modeNo = ultraGridFa.ActiveRow.Cells["MODE_NO"].Value.ToString(); if (isDelete) { param.Add(UserInfo.GetUserName()); } else { param.Add(""); } param.Add(transitNo); param.Add(modeNo); try { //需要先废除或恢复他全部子记录 int countItem = ServerHelper.SetData("com.steering.pss.sale.order.CoreTransitLine.doDelete_Mode_Item", new Object[] { param, isDelete }, this.ob); if (countItem > 0) { int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreTransitLine.doDelete_Mode", new Object[] { param, isDelete }, this.ob); if (count > 0) { //吨运费计算。 UpdateTransitMny(transitNo, modeNo); doQuery_Mode(); Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null; for (int i = 0; i < ultraGridFa.Rows.Count; i++) { rowD = ultraGridFa.Rows[i]; if (rowD.Cells["MODE_NO"].Value.ToString().Equals(modeNo)) { rowD.Activate(); break; } } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } /// /// 修改操作 /// private void doUpdate() { //判断线路、方案还是线路明细。 switch (ultraTabControl1.SelectedTab.Key) { case "0": doUpdate_Main(); break; case "1": doUpdate_Mode(); break; case "2": doUpdate_ModeLine(); break; default: break; } } private static string VstartDescMx = ""; private static string VterminationDescMx = ""; /// /// 线路明细修改 /// private void doUpdate_ModeLine() { if (ultraGridMx.ActiveRow == null) { MessageBox.Show("请选择需要修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Boolean validflagStr = Convert.ToBoolean(ultraGridMx.ActiveRow.Cells["VALIDFLAG"].Value); //无效数据不允许修改 if (!validflagStr) { MessageBox.Show("无效数据不支持修改操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (ValidInput_ModeLine()) { string transitNo = ultraGridMx.ActiveRow.Cells["TRANSIT_NO"].Value.ToString(); string modeNo = ultraGridMx.ActiveRow.Cells["MODE_NO"].Value.ToString(); string indexSeq = ultraGridMx.ActiveRow.Cells["INDEX_SEQ"].Value.ToString(); string startDesc = utxtSfmx.Text.Trim(); string terminationDesc = utxtZzmx.Text.Trim(); //始发地类别 string regionNoB_Typ = cmbSfmxType.Text.ToString(); //始发地REGION_NO_B string regionNoB = utxtSfmx.Text.Trim(); //终止地类别 string regionNoE_Typ = cmbZzmxType.Text.ToString(); //终止地 string regionNoE = utxtZzmx.Text.Trim(); if (VstartDescMx.Equals(startDesc) && VterminationDescMx.Equals(terminationDesc)) { } else { if (isRepeatModeLine(transitNo, modeNo, startDesc, terminationDesc)) { MessageBox.Show("\"" + startDesc + "-" + terminationDesc + "\"运输线路已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } //判断当前是否只有一条记录。 if (dataTable3.Rows.Count > 1) { //获取最大顺序号。 int maxSeq = GetMaxIndexSeq(transitNo,modeNo) - 1; string maxSeqStr = maxSeq.ToString(); if ("1".Equals(indexSeq)) { DataRow[] row = dataTable3.Select(" INDEX_SEQ=" + "2"); string regionNoB_twoType = row[0]["REGION_NO_B_TYP"].ToString(); string regionNoB_two = row[0]["REGION_NO_B"].ToString(); //判断终止地是否与x+1的始发地一致。 if (!regionNoE_Typ.Equals(regionNoB_twoType) || !regionNoE.Equals(regionNoB_two)) { MessageBox.Show("终止地,必须与顺序号\"2\"始发地一致,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } else if (maxSeqStr.Equals(indexSeq)) { //判断当前顺序号是否等于最大顺序号 DataRow[] row = dataTable3.Select(" INDEX_SEQ=" + (maxSeq - 1).ToString()); string regionNoE_twoType = row[0]["REGION_NO_E_TYP"].ToString(); string regionNoE_two = row[0]["REGION_NO_E"].ToString(); //判断始发地是否与上一条记录终止地完全一致。 if (!regionNoB_Typ.Equals(regionNoE_twoType) || !regionNoB.Equals(regionNoE_two)) { MessageBox.Show("始发地,必须与顺序号\"" + (maxSeq - 1).ToString() + "\"终止地一致,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } else { int sIndex = Convert.ToInt32(indexSeq); DataRow[] minrow = dataTable3.Select(" INDEX_SEQ=" + (sIndex - 1).ToString()); DataRow[] manrow = dataTable3.Select(" INDEX_SEQ=" + (sIndex + 1).ToString()); string regionNoE_twoType = minrow[0]["REGION_NO_E_TYP"].ToString(); string regionNoE_two = minrow[0]["REGION_NO_E"].ToString(); //判断始发地是否与上一条记录终止地完全一致。 if (!regionNoB_Typ.Equals(regionNoE_twoType) || !regionNoB.Equals(regionNoE_two)) { MessageBox.Show("始发地,必须与顺序号\"" + (sIndex - 1).ToString() + "\"终止地一致,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string regionNoB_twoType = manrow[0]["REGION_NO_B_TYP"].ToString(); string regionNoB_two = manrow[0]["REGION_NO_B"].ToString(); //判断终止地是否与下一条记录的始发地一致。 if (!regionNoE_Typ.Equals(regionNoB_twoType) || !regionNoE.Equals(regionNoB_two)) { MessageBox.Show("终止地,必须与顺序号\"" + (sIndex + 1).ToString() + "\"始发地一致,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } //确认修改吗? if (MessageBox.Show("是否确认修改选中的数据!", "提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } ArrayList parm = new ArrayList(); //执行新增操作。 //AGENCY_FL代办标识 string agencyFl = cmbIsD.Value.ToString(); parm.Add(agencyFl); //运输方式TRANSIT_TYP string transitTyp = cmbYsfs.Text.ToString(); parm.Add(transitTyp); //始发地类型REGION_NO_B_TYP parm.Add(cmbSfmxType.Text.ToString()); //始发区域 parm.Add(regionNoB); //终止地类型REGION_NO_E_TYP parm.Add(cmbZzmxType.Text.ToString()); //终止区域 parm.Add(regionNoE); //SPCL_LN_NO专用线 string spclLnNo = cmbZy.Text.ToString(); parm.Add(spclLnNo); //CARRIER_UNIT承运单位 string carrierUnit = cmbCydw.Text.ToString(); parm.Add(carrierUnit); //RECEIVOR接货人 string receivor = utxtJhr.Text.Trim(); parm.Add(receivor); //TRANSIT_LN_MNY吨运费 string transitLnMny = uNumericFy.Value.ToString(); parm.Add(transitLnMny); //有效标识 //创建人 parm.Add(this.UserInfo.GetUserName()); //主线路编号。 parm.Add(transitNo); //方案编号 parm.Add(modeNo); //顺序号 parm.Add(indexSeq); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.sale.order.CoreTransitLine"; ccp.MethodName = "doUpdate_ModeLine"; ccp.ServerParams = new object[] { parm }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; UpdateTransitMny(transitNo, modeNo); doQuery_ModeLine(); Infragistics.Win.UltraWinGrid.UltraGridRow rowT = null; for (int i = 0; i < ultraGridMx.Rows.Count; i++) { rowT = ultraGridMx.Rows[i]; if (rowT.Cells["INDEX_SEQ"].Value.ToString().Equals(indexSeq)) { rowT.Activate(); break; } } MessageBox.Show("修改成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } /// /// 用于验证方案重复项。 /// private static string VmodeDesc = ""; /// /// 方案修改 /// private void doUpdate_Mode() { if (ultraGridFa.ActiveRow == null) { MessageBox.Show("请选择需要修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Boolean validflagStr = Convert.ToBoolean(ultraGridFa.ActiveRow.Cells["VALIDFLAG"].Value); //无效数据不允许修改 if (!validflagStr) { MessageBox.Show("无效数据不支持修改操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (ValidInput_Mode()) { string transitNo = ultraGridFa.ActiveRow.Cells["TRANSIT_NO"].Value.ToString(); //验证方案描述是否存在。 string modeDesc = utxtModeDesc.Text.Trim(); if (VmodeDesc.Equals(modeDesc)) { } else { if (isRepeatMode(transitNo, modeDesc)) { MessageBox.Show("方案描述\"" + modeDesc + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } //确认修改吗? if (MessageBox.Show("是否确认修改选中的数据!", "提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } ArrayList parm = new ArrayList(); //执行新增操作。 //(TRANSIT_NO,MODE_NO,MODE_DESC,TRANSIT_MNY,CREATE_NAME,CREATE_TIME) //方案描述 parm.Add(utxtModeDesc.Text.Trim()); //吨运费 //有效标识 //创建人 parm.Add(this.UserInfo.GetUserName()); //运输线路编号TRANSIT_NO parm.Add(transitNo); //方案编号。 string modeNo = ultraGridFa.ActiveRow.Cells["MODE_NO"].Value.ToString(); parm.Add(modeNo); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.sale.order.CoreTransitLine"; ccp.MethodName = "doUpdate_Mode"; ccp.ServerParams = new object[] { parm }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; doQuery_Mode(); //高亮显示新增的数据 Infragistics.Win.UltraWinGrid.UltraGridRow row = null; for (int i = 0; i < ultraGridFa.Rows.Count; i++) { row = ultraGridFa.Rows[i]; if (row.Cells["MODE_NO"].Value.ToString().Equals(modeNo)) { row.Activate(); break; } } MessageBox.Show("修改成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } /// /// 用于验证主线路重复项。 /// private static string VstartDesc = ""; private static string VterminationDesc = ""; /// /// 主线路修改操作 /// private void doUpdate_Main() { if (ultraGridXl.ActiveRow == null) { MessageBox.Show("请选择需要修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Boolean validflagStr = Convert.ToBoolean(ultraGridXl.ActiveRow.Cells["VALIDFLAG"].Value); //无效数据不允许修改 if (!validflagStr) { MessageBox.Show("无效数据不支持修改操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (ValidInput_Main()) { //验证主线路不允许重复。Start,Termination string startDesc = utxtEditSf.Text.Trim(); string terminationDesc = utxtEditZz.Text.Trim(); if (VstartDesc.Equals(startDesc) && VterminationDesc.Equals(terminationDesc)) { } else { if (isRepeatMain(startDesc, terminationDesc)) { MessageBox.Show("\"" + startDesc + "-" + terminationDesc + "\"运输线路已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } //确认修改吗? if (MessageBox.Show("是否确认修改选中的数据!", "提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } ArrayList parm = new ArrayList(); string transit_No = ultraGridXl.ActiveRow.Cells["TRANSIT_NO"].Value.ToString(); //始发地REGION_NO_B string regionNoB = utxtEditSf.Text.Trim(); //终止地 string regionNoE = utxtEditZz.Text.Trim(); //运输线路描述TRANSIT_DESC parm.Add(regionNoB + "-" + regionNoE); //始发地类型REGION_NO_B_TYP parm.Add(cmbSfType.Text.ToString()); //始发区域 parm.Add(regionNoB); //终止地类型REGION_NO_E_TYP parm.Add(cmbZZType.Text.ToString()); //终止区域 parm.Add(regionNoE); //有效标识 //修改人 parm.Add(this.UserInfo.GetUserName()); //依据主键id parm.Add(transit_No); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.sale.order.CoreTransitLine"; ccp.MethodName = "doUpdate_Main"; ccp.ServerParams = new object[] { parm }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; doQuery(); //高亮显示新增的数据 Infragistics.Win.UltraWinGrid.UltraGridRow row = null; for (int i = 0; i < ultraGridXl.Rows.Count; i++) { row = ultraGridXl.Rows[i]; if (row.Cells["TRANSIT_NO"].Value.ToString().Equals(transit_No)) { row.Activate(); break; } } MessageBox.Show("修改成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } /// /// 新增操作 /// private void doAdd() { //判断线路、方案还是线路明细。 switch (ultraTabControl1.SelectedTab.Key) { case "0": doAdd_Main(); break; case "1": doAdd_Mode(); break; case "2": doAdd_ModeLine(); break; default: break; } } /// /// 线路明细新增。 /// private void doAdd_ModeLine() { //验证非空项。 if (ValidInput_ModeLine()) { try { //验证线路明细不允许重复。Start,Termination string transitNo = ultraGridFa.ActiveRow.Cells["TRANSIT_NO"].Value.ToString(); string modeNo = ultraGridFa.ActiveRow.Cells["MODE_NO"].Value.ToString(); string modeDesc = ultraGridFa.ActiveRow.Cells["MODE_DESC"].Value.ToString(); //始发地类型REGION_NO_B_TYP string regionNoB_Typ = cmbSfmxType.Text.ToString(); //始发地REGION_NO_B string regionNoB = utxtSfmx.Text.Trim(); //终止地类型REGION_NO_E_TYP string regionNoE_Typ = cmbZzmxType.Text.ToString(); //终止地REGION_NO_E string regionNoE = utxtZzmx.Text.Trim(); if (isRepeatModeLine(transitNo, modeNo, regionNoB, regionNoE)) { MessageBox.Show("\"" + regionNoB + "-" + regionNoE + "\"运输线路已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //顺序号,获取最大顺序号+1返回。 int indexSeq = GetMaxIndexSeq(transitNo, modeNo); //新增时,判断顺序号,如果不为1,则9的始发地必须与9-1的终止地一致。 if (indexSeq > 1) { string seqTwo = (indexSeq - 1).ToString(); //获取顺序号-1的终止地类型和终止地。 DataRow[] rowT = dataTable3.Select(" INDEX_SEQ=" + seqTwo); string regionNoE_twoType = rowT[0]["REGION_NO_E_TYP"].ToString(); string regionNoE_two = rowT[0]["REGION_NO_E"].ToString(); //判断当前始发地类型与始发地与当前顺序号-1的终止地类型与终止地是否一致。 if (!regionNoB_Typ.Equals(regionNoE_twoType) || !regionNoB.Equals(regionNoE_two)) { MessageBox.Show("始发地,必须与顺序号\"" + seqTwo + "\"终止地一致,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } ArrayList parm = new ArrayList(); //执行新增操作。 //主线路编号。 parm.Add(transitNo); //方案编号 parm.Add(modeNo); //方案描述 parm.Add(modeDesc); //顺序号 parm.Add(indexSeq); //AGENCY_FL代办标识 string agencyFl = cmbIsD.Value.ToString(); parm.Add(agencyFl); //运输方式TRANSIT_TYP string transitTyp = cmbYsfs.Text.ToString(); parm.Add(transitTyp); //始发地类型REGION_NO_B_TYP parm.Add(regionNoB_Typ); //始发 parm.Add(regionNoB); //终止地类型REGION_NO_E_TYP parm.Add(regionNoE_Typ); //终止 parm.Add(regionNoE); //SPCL_LN_NO专用线 string spclLnNo = cmbZy.Text.ToString(); parm.Add(spclLnNo); //CARRIER_UNIT承运单位 string carrierUnit = cmbCydw.Text.ToString(); parm.Add(carrierUnit); //RECEIVOR接货人 string receivor = utxtJhr.Text.Trim(); parm.Add(receivor); //TRANSIT_LN_MNY吨运费 string transitLnMny = uNumericFy.Value.ToString(); parm.Add(transitLnMny); //有效标识 //创建人 parm.Add(this.UserInfo.GetUserName()); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.sale.order.CoreTransitLine"; ccp.MethodName = "doAdd_ModeLine"; ccp.ServerParams = new object[] { parm }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; //更新吨运费TRANSIT_MNY UpdateTransitMny(transitNo, modeNo); doQuery_ModeLine(); //高亮显示新增的数据 Infragistics.Win.UltraWinGrid.UltraGridRow row = null; for (int i = 0; i < ultraGridMx.Rows.Count; i++) { row = ultraGridMx.Rows[i]; if (row.Cells["INDEX_SEQ"].Value.ToString().Equals(indexSeq)) { row.Activate(); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } /// /// 更新吨运费 /// /// /// private void UpdateTransitMny(string transitNo, string modeNo) { //先获取吨运费。 string transiMny = GetTransitMny(transitNo, modeNo); //再更新方案表记录。 int j = 0; j = ServerHelper.SetData("com.steering.pss.sale.order.CoreTransitLine.UpdateTransitMny", new Object[] { transiMny, transitNo, modeNo }, this.ob); //再刷新记录,并选中修改后的行。 if (j > 0) { doQuery_Mode(); //高亮显示新增的数据 Infragistics.Win.UltraWinGrid.UltraGridRow row = null; for (int i = 0; i < ultraGridFa.Rows.Count; i++) { row = ultraGridFa.Rows[i]; if (row.Cells["MODE_NO"].Value.ToString().Equals(modeNo)) { row.Activate(); break; } } } } /// /// 获取当前方案吨运费 /// /// /// /// private string GetTransitMny(string transitNo, string modeNo) { DataTable dt = new DataTable(); dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.GetTransitMny", new Object[] { transitNo, modeNo }, this.ob); string transitMny = ""; if ("".Equals(dt.Rows[0][0].ToString())) { transitMny = "0"; } else { transitMny = dt.Rows[0][0].ToString(); } return transitMny; } /// /// 获取最大顺序号 /// /// private int GetMaxIndexSeq(string transitNo, string modeNo) { DataTable dt = new DataTable(); dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.GetMaxIndexSeq", new Object[] { transitNo, modeNo }, this.ob); int maxIndexSeq = 0; if ("".Equals(dt.Rows[0][0].ToString())) { maxIndexSeq = 1; } else { maxIndexSeq = Convert.ToInt32(dt.Rows[0][0]) + 1; } return maxIndexSeq; } /// /// 验证线路明细是否重复。 /// /// /// /// /// /// private bool isRepeatModeLine(string transitNo, string modeNo, string startDesc, string terminationDesc) { DataTable dt = new DataTable(); dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.isRepeatModeLine", new Object[] { transitNo, modeNo, startDesc, terminationDesc }, this.ob); if (dt.Rows.Count > 0) { return true; } else { return false; } } /// /// 验证线路明细非空项。 /// /// private bool ValidInput_ModeLine() { if (string.IsNullOrEmpty(utxtSfmx.Text.Trim())) { MessageBox.Show("请输入始发地!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (string.IsNullOrEmpty(utxtZzmx.Text.Trim())) { MessageBox.Show("请输入终止地!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (string.IsNullOrEmpty(utxtJhr.Text.Trim())) { MessageBox.Show("请输入接货人!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (uNumericFy.Value == null) { MessageBox.Show("请输入费用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (string.IsNullOrEmpty(uNumericFy.Value.ToString())) { MessageBox.Show("请输入费用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } return true; } /// /// 方案表新增操作。 /// private void doAdd_Mode() { //验证非空项。 if (ValidInput_Mode()) { try { //当前选中的主线路编号。 string transitNo = ultraGridXl.ActiveRow.Cells["TRANSIT_NO"].Value.ToString(); //验证方案描述不允许重复 string modeDesc = utxtModeDesc.Text.Trim(); if (isRepeatMode(transitNo, modeDesc)) { MessageBox.Show("方案描述\"" + modeDesc + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ArrayList parm = new ArrayList(); //自动生成编号 string autoCode = GetMaxCode_Mode(transitNo); if ("".Equals(autoCode)) { MessageBox.Show("编号超出限制,请与管理员联系。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //执行新增操作。 //(TRANSIT_NO,MODE_NO,MODE_DESC,TRANSIT_MNY,CREATE_NAME,CREATE_TIME) //运输线路编号TRANSIT_NO parm.Add(transitNo); //方案编号。 parm.Add(autoCode); //方案描述 parm.Add(utxtModeDesc.Text.Trim()); //吨运费 //有效标识 //创建人 parm.Add(this.UserInfo.GetUserName()); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.sale.order.CoreTransitLine"; ccp.MethodName = "doAdd_Mode"; ccp.ServerParams = new object[] { parm }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; doQuery_Mode(); //高亮显示新增的数据 Infragistics.Win.UltraWinGrid.UltraGridRow row = null; for (int i = 0; i < ultraGridFa.Rows.Count; i++) { row = ultraGridFa.Rows[i]; if (row.Cells["MODE_NO"].Value.ToString().Equals(autoCode)) { row.Activate(); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } /// /// 方案编号自动生成。 /// /// /// private string GetMaxCode_Mode(string transitNo) { //获取当前线路下,最大方案编号。 //从数据库中获取最大编号。 DataTable dt = new DataTable(); dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.GetMaxCode_Mode", new Object[] { transitNo }, this.ob); string modeNo = ""; if ("".Equals(dt.Rows[0][0].ToString())) { modeNo = "001"; } else { modeNo = (Convert.ToInt32(dt.Rows[0][0]) + 1).ToString(); while(modeNo.Length < 3) { modeNo = "0" + modeNo; } } return modeNo; } /// /// 方案表非空项验证。 /// /// /// private bool isRepeatMode(string transitNo, string modeDesc) { DataTable dt = new DataTable(); dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.isRepeatMode", new Object[] { transitNo,modeDesc }, this.ob); if (dt.Rows.Count > 0) { return true; } else { return false; } } /// /// 方案表非空项验证。 /// /// private bool ValidInput_Mode() { if (string.IsNullOrEmpty(utxtModeDesc.Text.Trim())) { MessageBox.Show("请输入方案描述!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } return true; } /// /// 主表新增 /// private void doAdd_Main() { //验证非空项。 if (ValidInput_Main()) { try { //验证主线路不允许重复。Start,Termination string startDesc = utxtEditSf.Text.Trim(); string terminationDesc = utxtEditZz.Text.Trim(); if (isRepeatMain(startDesc,terminationDesc)) { MessageBox.Show("\"" + startDesc + "-" + terminationDesc + "\"运输线路已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ArrayList parm = new ArrayList(); //自动生成编号 string autoCode = GetMaxCode_Main(); if ("".Equals(autoCode)) { MessageBox.Show("编号超出限制,请与管理员联系。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //执行新增操作。 //始发地REGION_NO_B string regionNoB = utxtEditSf.Text.Trim(); //终止地 string regionNoE = utxtEditZz.Text.Trim(); //运输线路编号TRANSIT_NO string transit_No = autoCode; parm.Add(transit_No); //运输线路描述TRANSIT_DESC parm.Add(regionNoB + "-" + regionNoE); //始发地类型REGION_NO_B_TYP parm.Add(cmbSfType.Text.ToString()); //始发区域 parm.Add(regionNoB); //终止地类型REGION_NO_E_TYP parm.Add(cmbZZType.Text.ToString()); //终止区域 parm.Add(regionNoE); //有效标识 //创建人 parm.Add(this.UserInfo.GetUserName()); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.sale.order.CoreTransitLine"; ccp.MethodName = "doAdd_Main"; ccp.ServerParams = new object[] { parm }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; doQuery(); //高亮显示新增的数据 Infragistics.Win.UltraWinGrid.UltraGridRow row = null; for (int i = 0; i < ultraGridXl.Rows.Count; i++) { row = ultraGridXl.Rows[i]; if (row.Cells["TRANSIT_NO"].Value.ToString().Equals(transit_No)) { row.Activate(); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } /// /// 主记录编号自动生成 /// /// private string GetMaxCode_Main() { //110701、110702、110703 + 7位流水号 string type = cmbSfType.Value.ToString(); //从数据库中获取最大编号。 DataTable dt = new DataTable(); dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.GetMaxCode_Main", new Object[] { type }, this.ob); string transitLineCode = ""; string lineMCode = dt.Rows[0][0].ToString(); if ("".Equals(lineMCode)) { transitLineCode = type + "0000001"; } else { transitLineCode = (Convert.ToInt64(lineMCode) + 1).ToString(); } return transitLineCode; } /// /// 验证主线路是否已经存在。 /// /// /// /// private bool isRepeatMain(string startDesc, string terminationDesc) { DataTable dt = new DataTable(); dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.isRepeatMain", new Object[] { startDesc, terminationDesc }, this.ob); if (dt.Rows.Count > 0) { return true; } else { return false; } } /// /// 主线路非空项验证。 /// /// private bool ValidInput_Main() { if (string.IsNullOrEmpty(utxtEditSf.Text.Trim())) { MessageBox.Show("请输入始发地!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (string.IsNullOrEmpty(utxtEditZz.Text.Trim())) { MessageBox.Show("请输入终止地!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } return true; } /// /// 查询功能,刷新主表信息即可。 /// private void doQuery() { string txtQsd = txtQsTitle.Text.Trim(); string txtMdd = txtMdTitle.Text.Trim(); DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.doQuery", new Object[] { txtQsd, txtMdd }, this.ob); if (dt.Rows.Count > 0) { GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true); //不同颜色区分是否有效数据 Infragistics.Win.UltraWinGrid.UltraGridRow row = null; for (int i = 0; i < ultraGridXl.Rows.Count; i++) { row = ultraGridXl.Rows[i]; if (!"1".Equals(row.Cells["VALIDFLAG"].Value.ToString())) { row.Cells["VALIDFLAG"].Value = false; row.Appearance.ForeColor = Color.Red; } else { row.Cells["VALIDFLAG"].Value = true; row.Appearance.ForeColor = Color.Black; } } //列自适应 GridHelper.RefreshAndAutoSizeExceptRows(ultraGridXl, new UltraGridColumn[] { }); } else { GridHelper.ClearGridDataSourceData(ultraGridFa); GridHelper.ClearGridDataSourceData(ultraGridMx); } } /// /// 按钮点击事件。 /// /// /// private void utxtEditSf_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { //从数据库中获取数据源,并显示弹窗cmbSfType if ("110702".Equals(cmbSfType.Value.ToString())) { //到站 frmStation frmStationName = new frmStation(ob); frmStationName.GetStationDesc += delegate(string stationDesc) { utxtEditSf.Text = stationDesc; }; frmStationName.ShowDialog(); } else if ("110703".Equals(cmbSfType.Value.ToString())) { //港口码头 frmPort frmPortN = new frmPort(ob); frmPortN.GetPortDesc += delegate(string portDesc) { utxtEditSf.Text = portDesc; }; frmPortN.ShowDialog(); } else { FrmOrderRegion orderRegion=new FrmOrderRegion(ob); orderRegion.GetOrderLen += delegate(string id,string name) { utxtEditSf.Text = name; orderRegion.Close(); }; orderRegion.ShowDialog(); } } private void utxtEditZz_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { //从数据库中获取数据源,并显示弹窗 if ("110702".Equals(cmbZZType.Value.ToString())) { //到站 frmStation frmStationName = new frmStation(ob); frmStationName.GetStationDesc += delegate(string stationDesc) { utxtEditZz.Text = stationDesc; }; frmStationName.ShowDialog(); } else if ("110703".Equals(cmbZZType.Value.ToString())) { //港口码头 frmPort frmPortN = new frmPort(ob); frmPortN.GetPortDesc += delegate(string portDesc) { utxtEditZz.Text = portDesc; }; frmPortN.ShowDialog(); } else { FrmOrderRegion orderRegion = new FrmOrderRegion(ob); orderRegion.GetOrderLen += delegate(string id, string name) { utxtEditZz.Text = name; orderRegion.Close(); }; orderRegion.ShowDialog(); } } /// /// 将主线路选中记录带入编辑区 /// /// /// private void ultraGridXl_AfterRowActivate(object sender, EventArgs e) { doQuery_Mode(); //ultraGridFa.ActiveRow = null; ultraTabControl1.Tabs[0].Selected = true; cmbSfType.Text = ultraGridXl.ActiveRow.Cells["region_no_b_typ"].Value.ToString(); VstartDesc = ultraGridXl.ActiveRow.Cells["region_no_b"].Value.ToString(); utxtEditSf.Text = VstartDesc; cmbZZType.Text = ultraGridXl.ActiveRow.Cells["region_no_e_typ"].Value.ToString(); VterminationDesc = ultraGridXl.ActiveRow.Cells["region_no_e"].Value.ToString(); utxtEditZz.Text = VterminationDesc; } /// /// 方案表展示。 /// private void doQuery_Mode() { string transitNo = ultraGridXl.ActiveRow.Cells["TRANSIT_NO"].Value.ToString(); DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.doQuery_Mode", new Object[] { transitNo }, this.ob); if (dt.Rows.Count > 0) { GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable2, true); //不同颜色区分是否有效数据 Infragistics.Win.UltraWinGrid.UltraGridRow row = null; for (int i = 0; i < ultraGridFa.Rows.Count; i++) { row = ultraGridFa.Rows[i]; if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("1")) { row.Cells["VALIDFLAG"].Value = false; row.Appearance.ForeColor = Color.Red; } else { row.Cells["VALIDFLAG"].Value = true; row.Appearance.ForeColor = Color.Black; } } //列自适应 GridHelper.RefreshAndAutoSizeExceptRows(ultraGridFa, new UltraGridColumn[] { }); } else { this.dataTable2.Rows.Clear(); this.dataTable3.Rows.Clear(); } } /// /// 方案行选中事件。 /// /// /// private void ultraGridFa_AfterRowActivate(object sender, EventArgs e) { doQuery_ModeLine(); //ultraGridMx.ActiveRow = null; ultraTabControl1.Tabs[1].Selected = true; utxtTransitDesc.Text = ultraGridXl.ActiveRow.Cells["TRANSIT_DESC"].Value.ToString(); VmodeDesc = ultraGridFa.ActiveRow.Cells["MODE_DESC"].Value.ToString(); utxtModeDesc.Text = VmodeDesc; } /// /// 线路明细查询 /// private void doQuery_ModeLine() { string transitNo = ultraGridFa.ActiveRow.Cells["TRANSIT_NO"].Value.ToString(); string modeNo = ultraGridFa.ActiveRow.Cells["MODE_NO"].Value.ToString(); DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreTransitLine.doQuery_ModeLine", new Object[] { transitNo, modeNo }, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable3, true); //不同颜色区分是否有效数据 Infragistics.Win.UltraWinGrid.UltraGridRow row = null; for (int i = 0; i < ultraGridMx.Rows.Count; i++) { row = ultraGridMx.Rows[i]; if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("1")) { row.Cells["VALIDFLAG"].Value = false; row.Appearance.ForeColor = Color.Red; } else { row.Cells["VALIDFLAG"].Value = true; row.Appearance.ForeColor = Color.Black; } if (!row.Cells["AGENCY_FL"].Value.ToString().Equals("1")) { row.Cells["AGENCY_FL"].Value = false; } else { row.Cells["AGENCY_FL"].Value = true; } } //列自适应 GridHelper.RefreshAndAutoSizeExceptRows(ultraGridMx, new UltraGridColumn[] { }); } /// /// 线路明细Grid单击事件。 /// /// /// private void ultraGridMx_AfterRowActivate(object sender, EventArgs e) { if (ultraGridFa.ActiveRow == null) { return; } ultraTabControl1.Tabs[2].Selected = true; //给编辑区赋值。 labelDesc.Text = ultraGridXl.ActiveRow.Cells["TRANSIT_DESC"].Value.ToString() +","+ ultraGridFa.ActiveRow.Cells["MODE_DESC"].Value.ToString(); ////AGENCY_FL代办标识 if (Convert.ToBoolean(ultraGridMx.ActiveRow.Cells["AGENCY_FL"].Value)) { cmbIsD.Value = "1"; } else { cmbIsD.Value = "0"; } ////运输方式TRANSIT_TYP cmbYsfs.Text = ultraGridMx.ActiveRow.Cells["TRANSIT_TYP"].Value.ToString(); ////始发地类型REGION_NO_B_TYP cmbSfmxType.Text = ultraGridMx.ActiveRow.Cells["REGION_NO_B_TYP"].Value.ToString(); ////始发区域 VstartDescMx = ultraGridMx.ActiveRow.Cells["REGION_NO_B"].Value.ToString(); utxtSfmx.Text = VstartDescMx; ////终止地类型REGION_NO_E_TYP cmbZzmxType.Text = ultraGridMx.ActiveRow.Cells["REGION_NO_E_TYP"].Value.ToString(); ////终止区域 VterminationDescMx = ultraGridMx.ActiveRow.Cells["REGION_NO_E"].Value.ToString(); utxtZzmx.Text = VterminationDescMx; ////SPCL_LN_NO专用线 cmbZy.Text = ultraGridMx.ActiveRow.Cells["SPCL_LN_NO"].Value.ToString(); ////CARRIER_UNIT承运单位 cmbCydw.Text = ultraGridMx.ActiveRow.Cells["CARRIER_UNIT"].Value.ToString(); ////RECEIVOR接货人 utxtJhr.Text = ultraGridMx.ActiveRow.Cells["RECEIVOR"].Value.ToString(); ////TRANSIT_LN_MNY费用 uNumericFy.Value = ultraGridMx.ActiveRow.Cells["TRANSIT_LN_MNY"].Value.ToString(); } private void utxtSfmx_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { //从数据库中获取数据源,并显示弹窗 if ("110702".Equals(cmbSfmxType.Value.ToString())) { //到站 frmStation frmStationName = new frmStation(ob); frmStationName.GetStationDesc += delegate(string stationDesc) { utxtSfmx.Text = stationDesc; }; frmStationName.ShowDialog(); } else if ("110703".Equals(cmbSfmxType.Value.ToString())) { //港口码头 frmPort frmPortN = new frmPort(ob); frmPortN.GetPortDesc += delegate(string portDesc) { utxtSfmx.Text = portDesc; }; frmPortN.ShowDialog(); } else { FrmOrderRegion orderRegion = new FrmOrderRegion(ob); orderRegion.GetOrderLen += delegate(string id, string name) { utxtSfmx.Text = name; orderRegion.Close(); }; orderRegion.ShowDialog(); } } private void utxtZzmx_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { //从数据库中获取数据源,并显示弹窗 if ("110702".Equals(cmbZzmxType.Value.ToString())) { //到站 frmStation frmStationName = new frmStation(ob); frmStationName.GetStationDesc += delegate(string stationDesc) { utxtZzmx.Text = stationDesc; }; frmStationName.ShowDialog(); } else if ("110703".Equals(cmbZzmxType.Value.ToString())) { //港口码头 frmPort frmPortN = new frmPort(ob); frmPortN.GetPortDesc += delegate(string portDesc) { utxtZzmx.Text = portDesc; }; frmPortN.ShowDialog(); } else { FrmOrderRegion orderRegion = new FrmOrderRegion(ob); orderRegion.GetOrderLen += delegate(string id, string name) { utxtZzmx.Text = name; orderRegion.Close(); }; orderRegion.ShowDialog(); } } private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { switch (ultraTabControl1.SelectedTab.Key) { case "0": if (ultraGridXl.ActiveRow == null) { cmbSfType.SelectedIndex = 0; utxtEditSf.Text = ""; cmbZZType.SelectedIndex = 0; utxtEditZz.Text = ""; } break; case "1": if (ultraGridXl.ActiveRow == null) { MessageBox.Show("请先输入主线路!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraTabControl1.Tabs["0"].Selected = true; return; } if (ultraGridFa.ActiveRow == null) { utxtTransitDesc.Text = ultraGridXl.ActiveRow.Cells["TRANSIT_DESC"].Value.ToString(); utxtModeDesc.Text = ""; } break; case "2": if (ultraGridXl.ActiveRow == null) { MessageBox.Show("请先输入主线路!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraTabControl1.Tabs["0"].Selected = true; return; } if (ultraGridFa.ActiveRow == null) { MessageBox.Show("请先输入方案!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ultraTabControl1.Tabs["1"].Selected = true; return; } if (ultraGridMx.ActiveRow == null) { //给编辑区赋值。 labelDesc.Text = ultraGridXl.ActiveRow.Cells["TRANSIT_DESC"].Value.ToString() + "," + ultraGridFa.ActiveRow.Cells["MODE_DESC"].Value.ToString(); cmbIsD.Value = "1"; ////运输方式TRANSIT_TYP cmbYsfs.SelectedIndex = 0; ////始发地类型REGION_NO_B_TYP cmbSfmxType.SelectedIndex = 0; ////始发区域 utxtSfmx.Text = ""; ////终止地类型REGION_NO_E_TYP cmbZzmxType.SelectedIndex = 0; ////终止区域 utxtZzmx.Text = ""; ////SPCL_LN_NO专用线 cmbZy.SelectedIndex = 0; ////CARRIER_UNIT承运单位 cmbCydw.SelectedIndex = 0; ////RECEIVOR接货人 utxtJhr.Text = ""; ////TRANSIT_LN_MNY费用 uNumericFy.Value = null; } break; default: break; } } private void cmbSfType_ValueChanged(object sender, EventArgs e) { utxtEditSf.Text = ""; } private void cmbZZType_ValueChanged(object sender, EventArgs e) { utxtEditZz.Text = ""; } private void cmbSfmxType_ValueChanged(object sender, EventArgs e) { utxtSfmx.Text = ""; } private void cmbZzmxType_ValueChanged(object sender, EventArgs e) { utxtZzmx.Text = ""; } } }