| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268 |
- 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 frmOrderModel : FrmBase
- {
- public frmOrderModel()
- {
- InitializeComponent();
- }
- public frmOrderModel(OpeBase ob)
- {
- InitializeComponent();
- this.ob = ob;
- }
- private string use_unit;
- public string Use_unit
- {
- get { return use_unit; }
- set { use_unit = value; }
- }
- /// <summary>
- /// 范本描述模糊查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraCheckEditor2_CheckedChanged(object sender, EventArgs e)
- {
- if (ultraCheckEditor2.Checked)
- {
- txtNMTitle.Enabled = true;
- }
- else
- {
- txtNMTitle.Text = "";
- txtNMTitle.Enabled = false;
- }
- }
- /// <summary>
- /// 适用单位模糊查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
- {
- if (uceUnit.Checked)
- {
- cmbSyTitle.Enabled = true;
- }
- else
- {
- //cmbSyTitle.Value = "";
- cmbSyTitle.Enabled = false;
- }
- }
- private void frmOrderModel_Load(object sender, EventArgs e)
- {
- string saleRegion = doGetSaleOrg();
- //适用单位数据源绑定
- BindCmbSy(saleRegion);
- if (!"".Equals(Use_unit))
- {
- uceUnit.Checked = true;
- cmbSy.Enabled = false;
- cmbSy.Value = Use_unit;
- cmbSyTitle.Text = Use_unit;
- }
- doQuery();
- }
- /// <summary>
- /// 重写基类load事件,屏蔽平台过滤功能。
- /// </summary>
- /// <param name="e"></param>
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- ultraGrid2.DisplayLayout.Bands[0].Override.HeaderClickAction = HeaderClickAction.Select;
- }
- /// <summary>
- /// 手动添加toolbar
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- if ("doQuery".Equals(e.Tool.Key))
- {
- doQueryNew();
- }
- else if ("doAdd".Equals(e.Tool.Key))
- {
- doAdd();
- }
- else if ("doUpdate".Equals(e.Tool.Key))
- {
- doUpdate();
- }
- else if ("doDelete".Equals(e.Tool.Key))
- {
- doDeleteOrRecovery(true);
- }
- else if ("doRecovery".Equals(e.Tool.Key))
- {
- doDeleteOrRecovery(false);
- }
- else if ("doLase".Equals(e.Tool.Key))
- {
- //上移功能。
- doLase();
- }
- else if ("doNext".Equals(e.Tool.Key))
- {
- //下移功能
- doNext();
- }
- else if ("doOk".Equals(e.Tool.Key))
- {
- //确认功能
- doOk();
- }
- else
- {
- this.Close();
- }
- }
- /// <summary>
- /// 委托方法
- /// </summary>
- /// <param name="ROrdLen"></param>
- public delegate void GetOrderModelHander(DataRow row,DataTable dt);
- public event GetOrderModelHander GetOrderModel;
- /// <summary>
- /// 确认功能
- /// </summary>
- private void doOk()
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageBox.Show("请选择一条商务条款范本!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- string orderModelNo = ultraGrid1.ActiveRow.Cells["ORDER_MODEL_NO"].Value.ToString();
- //子表Table记录也要返回。
- BindOrderModelItem(orderModelNo);
- foreach (DataRow row in this.dataTable1.Rows)
- {
- if (orderModelNo.Equals(row["ORDER_MODEL_NO"].ToString()))
- {
- if (Convert.ToBoolean(row["CUSTOMER_MODEL_FL"]))
- {
- row["CUSTOMER_MODEL_FL"] = "1";
- }
- else
- {
- row["CUSTOMER_MODEL_FL"] = "0";
- }
- GetOrderModel(row, dataTable2);
- this.Close();
- return;
- }
- }
- }
- /// <summary>
- /// 下移功能
- /// </summary>
- private void doNext()
- {
- if (ultraGrid2.ActiveRow == null)
- {
- MessageBox.Show("请先选择需要范本条目!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
-
- //获取当前顺序号
- string modelIndex = ultraGrid2.ActiveRow.Cells["MODEL_INDEX"].Value.ToString();
- string orderModelNo = ultraGrid2.ActiveRow.Cells["ORDER_MODEL_NO"].Value.ToString();
- string modelSeqNo = ultraGrid2.ActiveRow.Cells["MODEL_SEQ_NO"].Value.ToString();
- //获取最大顺序号。
- string IndexMax = (GetIndex(orderModelNo) - 1).ToString();
- if (IndexMax.Equals(modelIndex))
- {
- //最大顺序号,无法下移。
- return;
- }
- ServerHelper.SetData("com.steering.pss.sale.order.CoreOrderModel.doNext", new Object[] { modelIndex, orderModelNo, modelSeqNo }, this.ob);
- BindOrderModelItem(orderModelNo);
- //聚焦当前操作行
- Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null;
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- rowD = ultraGrid2.Rows[i];
- if (rowD.Cells["ORDER_MODEL_NO"].Value.ToString().Equals(orderModelNo) && rowD.Cells["MODEL_SEQ_NO"].Value.ToString().Equals(modelSeqNo))
- {
- rowD.Activate();
- break;
- }
- }
- }
- /// <summary>
- /// 上移功能
- /// </summary>
- private void doLase()
- {
- if (ultraGrid2.ActiveRow == null)
- {
- MessageBox.Show("请先选择需要范本条目!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- //获取当前选中项的顺序号和相关主键。
- //ORDER_MODEL_NO,
- // MODEL_SEQ_NO,
- // MODEL_SEQ,
- // MODEL_INDEX,
- string modelIndex = ultraGrid2.ActiveRow.Cells["MODEL_INDEX"].Value.ToString();
- string orderModelNo = ultraGrid2.ActiveRow.Cells["ORDER_MODEL_NO"].Value.ToString();
- string modelSeqNo = ultraGrid2.ActiveRow.Cells["MODEL_SEQ_NO"].Value.ToString();
- //如果modelIndex=1,则不执行任何操作。
- if ("1".Equals(modelIndex))
- {
- return;
- }
-
- //UPDATE 顺序号=Y WHERE 顺序号=Y-1
- //UPDATE 顺序号=Y-1 where 顺序号=当前顺序号所对应的主键id。
- //将当前顺序号与相关主键id作为参数,传递到后台执行事物操作。
- ServerHelper.SetData("com.steering.pss.sale.order.CoreOrderModel.doLase", new Object[] { modelIndex, orderModelNo, modelSeqNo }, this.ob);
- BindOrderModelItem(orderModelNo);
- //聚焦当前操作行
- Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null;
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- rowD = ultraGrid2.Rows[i];
- if (rowD.Cells["ORDER_MODEL_NO"].Value.ToString().Equals(orderModelNo) && rowD.Cells["MODEL_SEQ_NO"].Value.ToString().Equals(modelSeqNo))
- {
- rowD.Activate();
- break;
- }
- }
- }
- /// <summary>
- /// 废除或恢复
- /// </summary>
- /// <param name="isDelete">true废除 false恢复</param>
- private void doDeleteOrRecovery(bool isDelete)
- {
- //判断是主表还是从表
- if ("1".Equals(ultraTabControl1.SelectedTab.Key))
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageBox.Show("请选择需要" + (isDelete ? "废除" : "恢复") + "的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- Boolean validflagStr = Convert.ToBoolean(ultraGrid1.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 orderModelNo = ultraGrid1.ActiveRow.Cells["ORDER_MODEL_NO"].Value.ToString();
- param.Add(orderModelNo);
- if (param.Count > 0 && MessageBox.Show("是否确认" + (isDelete ? "废除" : "恢复") + "选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- try
- {
- int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreOrderModel.deleteLineInfo", new Object[] { param, UserInfo.GetUserName(), isDelete }, this.ob);
- if (count > 0)
- {
- doQuery();
- Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null;
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- rowD = ultraGrid1.Rows[i];
- if (rowD.Cells["ORDER_MODEL_NO"].Value.ToString().Equals(orderModelNo))
- {
- rowD.Activate();
- break;
- }
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- else
- {
- //从表删除恢复。
- if (ultraGrid2.ActiveRow == null)
- {
- MessageBox.Show("请选择需要" + (isDelete ? "废除" : "恢复") + "的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- Boolean validflagStr = Convert.ToBoolean(ultraGrid2.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 validflagStrMain = Convert.ToBoolean(ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Value);
- if (!validflagStrMain)
- {
- MessageBox.Show("范本主体无效,范本条目不允许恢复。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- ArrayList param = new ArrayList();
- string orderModelNo = ultraGrid2.ActiveRow.Cells["ORDER_MODEL_NO"].Value.ToString();
- string xhNo = ultraGrid2.ActiveRow.Cells["MODEL_SEQ_NO"].Value.ToString();
- param.Add(orderModelNo);
- param.Add(xhNo);
- if (param.Count > 0 && MessageBox.Show("是否确认" + (isDelete ? "废除" : "恢复") + "选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- try
- {
- int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreOrderModel.deleteLineInfo_ITEM", new Object[] { param, UserInfo.GetUserName(), isDelete }, this.ob);
- if (count > 0)
- {
- BindOrderModelItem(orderModelNo);
- Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null;
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- rowD = ultraGrid2.Rows[i];
- if (rowD.Cells["MODEL_SEQ_NO"].Value.ToString().Equals(xhNo))
- {
- rowD.Activate();
- break;
- }
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
-
- }
- /// <summary>
- /// 用于验证修改时,描述是否已存在
- /// </summary>
- private static string VName = "";
- /// <summary>
- /// 用于验证从表修改时,描述是否已存在
- /// </summary>
- private static string VName_Item = "";
-
- /// <summary>
- /// 修改功能
- /// </summary>
- private void doUpdate()
- {
- //判断主从表。
- if ("1".Equals(ultraTabControl1.SelectedTab.Key.ToString()))
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageBox.Show("请选择需要修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- Boolean validflagStr = Convert.ToBoolean(ultraGrid1.ActiveRow.Cells["VALIDFLAG"].Value);
- //无效数据不允许修改
- if (!validflagStr)
- {
- MessageBox.Show("无效数据不支持修改操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (ValidInput())
- {
- //验证描述不允许重复。
- string name = txtNM.Text.Trim();
- if (!VName.Equals(name))
- {
- if (isRepeatName(name))
- {
- MessageBox.Show("范本描述\"" + name + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- //确认修改吗?
- if (MessageBox.Show("是否确认修改选中的数据!", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
- {
- return;
- }
- ArrayList parm = new ArrayList();
- string orderModelNo = ultraGrid1.ActiveRow.Cells["ORDER_MODEL_NO"].Value.ToString();
- //适用单位编号
- parm.Add(cmbSy.Value.ToString());
- //适用单位值
- parm.Add(cmbSy.Text.Trim());
- //范本描述
- parm.Add(name);
- //是否通用
- parm.Add(chkTy.Checked ? "1" : "0");
- //是否客户范本
- parm.Add(chkFb.Checked ? "1" : "0");
- //修改人
- parm.Add(this.UserInfo.GetUserName());
- //主键id
- parm.Add(orderModelNo);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.sale.order.CoreOrderModel";
- ccp.MethodName = "doUpdate";
- 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 < ultraGrid1.Rows.Count; i++)
- {
- row = ultraGrid1.Rows[i];
- if (row.Cells["ORDER_MODEL_NO"].Value.ToString().Equals(orderModelNo))
- {
- row.Activate();
- break;
- }
- }
- MessageBox.Show("修改成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- else
- {
- //从表修改操作
- if (ultraGrid2.ActiveRow == null)
- {
- MessageBox.Show("请选择需要修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- Boolean validflagStr = Convert.ToBoolean(ultraGrid2.ActiveRow.Cells["VALIDFLAG"].Value);
- //无效数据不允许修改
- if (!validflagStr)
- {
- MessageBox.Show("无效数据不支持修改操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (ValidInput_Item())
- {
- //验证描述不允许重复。
- string name = txtXh.Text.Trim();
- string no = ultraGrid1.ActiveRow.Cells["ORDER_MODEL_NO"].Value.ToString();
- if (!VName_Item.Equals(name))
- {
- if (isRepeatName_Item(name,no))
- {
- MessageBox.Show("条目序号\"" + name + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- //确认修改吗?
- if (MessageBox.Show("是否确认修改选中的数据!", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
- {
- return;
- }
- ArrayList parm = new ArrayList();
- string xhNo = ultraGrid2.ActiveRow.Cells["Model_Seq_No"].Value.ToString();
- //条目序号
- parm.Add(txtXh.Text.Trim());
- //条目内容
- parm.Add(txtTmDetails.Text.Trim());
- //修改人
- parm.Add(this.UserInfo.GetUserName());
- //合同范本编号
- string orderModelNo = ultraGrid2.ActiveRow.Cells["ORDER_MODEL_NO"].Value.ToString();
- parm.Add(orderModelNo);
- //主键id
- parm.Add(xhNo);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.sale.order.CoreOrderModel";
- ccp.MethodName = "doUpdate_Item";
- ccp.ServerParams = new object[] { parm };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode == -1) return;
- BindOrderModelItem(orderModelNo);
- //高亮显示修改的数据
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- row = ultraGrid2.Rows[i];
- if (row.Cells["Model_Seq_No"].Value.ToString().Equals(xhNo))
- {
- row.Activate();
- break;
- }
- }
- MessageBox.Show("修改成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void doQuery()
- {
- //ORDER_MODEL_DESC,USE_UNIT
- string orderModelDesc = txtNMTitle.Text.Trim();
- string userUnit = cmbSyTitle.Value.ToString();
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderModel.doQuery", new Object[] { orderModelDesc, userUnit }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- //不同颜色区分是否有效数据
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- row = ultraGrid1.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["GENERAL_FL"].Value.ToString().Equals("1"))
- {
- row.Cells["GENERAL_FL"].Value = false;
- }
- else
- {
- row.Cells["GENERAL_FL"].Value = true;
- }
- //是否合同范本
- if (!row.Cells["CUSTOMER_MODEL_FL"].Value.ToString().Equals("1"))
- {
- row.Cells["CUSTOMER_MODEL_FL"].Value = false;
- }
- else
- {
- row.Cells["CUSTOMER_MODEL_FL"].Value = true;
- }
- //合同范本状态W:待审;S:审核通过;F审核失败
- if (row.Cells["ORDER_MODEL_STS"].Value.ToString().Equals("W"))
- {
- row.Cells["ORDER_MODEL_STS"].Value = "待审";
- }
- else if (row.Cells["ORDER_MODEL_STS"].Value.ToString().Equals("S"))
- {
- row.Cells["ORDER_MODEL_STS"].Value = "审核通过";
- }
- else
- {
- row.Cells["ORDER_MODEL_STS"].Value = "审核失败";
- }
- }
- //列自适应
- GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, new UltraGridColumn[] {
- });
- }
- /// <summary>
- /// 查询mm
- /// </summary>
- private void doQueryNew()
- {
- //ORDER_MODEL_DESC,USE_UNIT
- string orderModelDesc = txtNMTitle.Text.Trim();
- string userUnit = "";
- if (uceUnit.Checked)
- {
- userUnit = cmbSyTitle.Value.ToString();
- }
-
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderModel.doQueryNew", new Object[] { orderModelDesc, userUnit }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- //不同颜色区分是否有效数据
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- row = ultraGrid1.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["GENERAL_FL"].Value.ToString().Equals("1"))
- {
- row.Cells["GENERAL_FL"].Value = false;
- }
- else
- {
- row.Cells["GENERAL_FL"].Value = true;
- }
- //是否合同范本
- if (!row.Cells["CUSTOMER_MODEL_FL"].Value.ToString().Equals("1"))
- {
- row.Cells["CUSTOMER_MODEL_FL"].Value = false;
- }
- else
- {
- row.Cells["CUSTOMER_MODEL_FL"].Value = true;
- }
- //合同范本状态W:待审;S:审核通过;F审核失败
- if (row.Cells["ORDER_MODEL_STS"].Value.ToString().Equals("W"))
- {
- row.Cells["ORDER_MODEL_STS"].Value = "待审";
- }
- else if (row.Cells["ORDER_MODEL_STS"].Value.ToString().Equals("S"))
- {
- row.Cells["ORDER_MODEL_STS"].Value = "审核通过";
- }
- else
- {
- row.Cells["ORDER_MODEL_STS"].Value = "审核失败";
- }
- }
- //列自适应
- GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, new UltraGridColumn[] {
- });
- }
- /// <summary>
- /// 验证非空字段。
- /// </summary>
- /// <returns></returns>
- private bool ValidInput()
- {
- if (string.IsNullOrEmpty(txtNM.Text.Trim()))
- {
- MessageBox.Show("请输入范本描述!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- return true;
- }
- /// <summary>
- /// 验证范本条目非空项
- /// </summary>
- /// <returns></returns>
- private bool ValidInput_Item()
- {
- if (string.IsNullOrEmpty(txtXh.Text.Trim()))
- {
- MessageBox.Show("请输入条目序号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (string.IsNullOrEmpty(txtTmDetails.Text.Trim()))
- {
- MessageBox.Show("请输入条目内容!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- return true;
- }
- /// <summary>
- /// 范本描述是否重复。
- /// </summary>
- /// <param name="name"></param>
- /// <returns></returns>
- private bool isRepeatName(string name)
- {
- DataTable dt = new DataTable();
- dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderModel.isRepeatName", new Object[] { name }, this.ob);
- if (dt.Rows.Count > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 判断条目序号是否已存在
- /// </summary>
- /// <param name="name"></param>
- /// <returns></returns>
- private bool isRepeatName_Item(string name,string modelNo)
- {
- DataTable dt = new DataTable();
- dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderModel.isRepeatName_Item", new Object[] { name, modelNo }, this.ob);
- if (dt.Rows.Count > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 获取范本条目顺序号
- /// </summary>
- /// <returns></returns>
- private int GetIndex(string orderModelNo)
- {
- int index = 1;
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderModel.GetIndex", new Object[] { orderModelNo }, this.ob);
- if (dt.Rows.Count > 0)
- {
- if (!"".Equals(dt.Rows[0][0].ToString()))
- {
- index = Convert.ToInt32(dt.Rows[0][0]) + 1;
- }
- }
- return index;
- }
- /// <summary>
- /// 自动生成编号
- /// </summary>
- /// <returns></returns>
- private string GetMaxCode()
- {
- //获取适用单位编码
- string syNo = cmbSy.Value.ToString();
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderModel.GetMaxCode", new Object[] { syNo }, this.ob);
- string maxCode = "";
- if (dt.Rows.Count > 0)
- {
- if (!"".Equals(dt.Rows[0][0].ToString()))
- {
- maxCode = dt.Rows[0][0].ToString();
- //获取最后三位数字。
- string maxNumber = (Convert.ToInt32(maxCode.Substring(maxCode.Length - 3)) + 1).ToString();
- string codeStr = maxCode.Substring(0, maxCode.Length - 3);
- while (maxNumber.Length < 3)
- {
- maxNumber = "0" + maxNumber;
- }
- maxCode = codeStr + maxNumber;
- }
- else
- {
- maxCode = syNo + "001";
- }
- }
- return maxCode;
- }
- /// <summary>
- /// 条目序号自动生成编号
- /// </summary>
- /// <returns></returns>
- private string GetMaxCode_Item(string orderModelNo)
- {
- //获取最大序号
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderModel.GetMaxCode_Item", new Object[] { orderModelNo }, this.ob);
- string maxCode = "";
- if (dt.Rows.Count > 0)
- {
- if (!"".Equals(dt.Rows[0][0].ToString()))
- {
- maxCode = (Convert.ToInt32(dt.Rows[0][0]) + 1).ToString();
- while (maxCode.Length < 3)
- {
- maxCode = "0" + maxCode;
- }
- }
- else
- {
- maxCode = "001";
- }
- }
- return maxCode;
- }
- /// <summary>
- /// 新增
- /// </summary>
- private void doAdd()
- {
- //判断当前编辑区显示的是范本主体,还是范本条目。
- if ("1".Equals(ultraTabControl1.SelectedTab.Key))
- {
- if (ValidInput())
- {
- try
- {
- //验证描述不允许重复。
- string name = txtNM.Text.Trim();
- if (isRepeatName(name))
- {
- MessageBox.Show("范本描述\"" + name + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- ArrayList parm = new ArrayList();
- //自动生成编号
- string autoCode = GetMaxCode();
- if ("".Equals(autoCode))
- {
- MessageBox.Show("编号超出限制,请与管理员联系。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- string syNo = autoCode;
- parm.Add(syNo);
- parm.Add(name);
- //适用单位编码
- parm.Add(cmbSy.Value.ToString());
- //适用单位描述
- parm.Add(cmbSy.Text.ToString());
- //是否通用
- parm.Add(chkTy.Checked ? "1" : "0");
- //是否合同范本
- parm.Add(chkFb.Checked ? "1" : "0");
- //合同范本状态
- parm.Add("W");
- //有效标识
- //创建人
- parm.Add(this.UserInfo.GetUserName());
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.sale.order.CoreOrderModel";
- ccp.MethodName = "doAdd";
- 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 < ultraGrid1.Rows.Count; i++)
- {
- row = ultraGrid1.Rows[i];
- if (row.Cells["ORDER_MODEL_NO"].Value.ToString().Equals(syNo))
- {
- row.Activate();
- break;
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- else
- {
- //从表新增
- //验证非空项。
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowWarning("请先选择商务条款或者先新增商务条款!");
- return;
- }
- if (ValidInput_Item())
- {
- try
- {
- //验证条目序号是否存在
- string name = txtXh.Text.Trim();
- string no = ultraGrid1.ActiveRow.Cells["ORDER_MODEL_NO"].Value.ToString();
- if (isRepeatName_Item(name,no))
- {
- MessageBox.Show("条目标题\"" + name + "\"已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- ArrayList parm = new ArrayList();
- string orderModelNo = ultraGrid1.ActiveRow.Cells["ORDER_MODEL_NO"].Value.ToString();
- //自动生成编号
- string autoCode = GetMaxCode_Item(orderModelNo);
- if ("".Equals(autoCode))
- {
- MessageBox.Show("编号超出限制,请与管理员联系。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- string seqNo = autoCode;
- //合同范本编码
-
- parm.Add(orderModelNo);
- //条目序号编码
- parm.Add(autoCode);
- //条目序号值
- parm.Add(name);
- //条目顺序号
- parm.Add(GetIndex(orderModelNo));
- //范本条目值
- parm.Add(txtTmDetails.Text.Trim());
- //有效标识
- //创建人
- parm.Add(this.UserInfo.GetUserName());
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.sale.order.CoreOrderModel";
- ccp.MethodName = "doAdd_Item";
- ccp.ServerParams = new object[] { parm };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode == -1) return;
- BindOrderModelItem(orderModelNo);
- //高亮显示新增的数据
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- row = ultraGrid2.Rows[i];
- if (row.Cells["Model_Seq_No"].Value.ToString().Equals(seqNo))
- {
- row.Activate();
- break;
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- }
- /// <summary>
- /// 适用单位数据源绑定
- /// </summary>
- /// <param name="saleRegion"></param>
- private void BindCmbSy(string saleRegion)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderModel.GetSy", new Object[] { saleRegion }, this.ob);
- //编辑区域适用单位绑定,不提供空值。
- cmbSy.DataSource = dt;
- cmbSy.DisplayMember = "CUSTOMER_NM";
- cmbSy.ValueMember = "CUSTOMER_NO";
- cmbSy.DataBind();
- cmbSy.SelectedIndex = 0;
- //查询区域适用单位绑定,提供空值。
- ComboBoxHelper.FillUltraComboItems(cmbSyTitle, dt);
- cmbSyTitle.SelectedIndex = 0;
- }
- /// <summary>
- /// 根据登录账户,判断所属部门。
- /// </summary>
- private string doGetSaleOrg()
- {
- // string departmentId = UserInfo.GetDepartment();
- string saleRegion = ClsBaseInfo.GetSaleOrg(UserInfo.GetDeptid());
- //if ("销售公司".Equals(departmentId))
- //{
- // saleRegion = "100101";
- //}
- //else if ("国贸公司".Equals(departmentId))
- //{
- // saleRegion = "100102";
- //}
- //else if ("钢贸公司".Equals(departmentId))
- //{
- // saleRegion = "100103";
- //}
- //else
- //{
- // saleRegion = "100101";
- //}
- return saleRegion;
- }
- /// <summary>
- /// 主表行选中事件,选中主表行,绑定合同条目数据源。
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- string orderModelNo = ultraGrid1.ActiveRow.Cells["ORDER_MODEL_NO"].Value.ToString();
- BindOrderModelItem(orderModelNo);
- //编辑区,Tab页面切换到合同范本主界面,并给编辑区Tab页面赋值。
- ultraTabControl1.Tabs[0].Selected = true;
- //编辑区控件赋值。
- //cmbSy.Value = ultraGrid1.ActiveRow.Cells["USE_UNIT"].Value.ToString();
- VName = ultraGrid1.ActiveRow.Cells["ORDER_MODEL_DESC"].Value.ToString();
- txtNM.Text = VName;
- chkTy.Checked = Convert.ToBoolean(ultraGrid1.ActiveRow.Cells["GENERAL_FL"].Value);
- chkFb.Checked = Convert.ToBoolean(ultraGrid1.ActiveRow.Cells["CUSTOMER_MODEL_FL"].Value);
- //子表不聚焦,聚焦编辑区会切换到子表编辑区。
- ultraGrid2.ActiveRow = null;
- txtXh.Text = "";
- txtTmDetails.Text = "";
- }
- /// <summary>
- /// 绑定范本条目数据源
- /// </summary>
- private void BindOrderModelItem(string orderModelNo)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreOrderModel.GetOrderModelItem", new Object[] { orderModelNo }, this.ob);
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable2, true);
- //不同颜色区分是否有效数据
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- for (int i = 0; i < ultraGrid2.Rows.Count; i++)
- {
- row = ultraGrid2.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;
- }
- }
- }
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- ultraTabControl1.Tabs[1].Selected = true;
- VName_Item = ultraGrid2.ActiveRow.Cells["MODEL_SEQ"].Value.ToString();
- txtXh.Text = VName_Item;
- txtTmDetails.Text = ultraGrid2.ActiveRow.Cells["MODEL_ITM_VAL"].Value.ToString();
- }
- }
- }
|