using com.steering.pss.sale.price.entity; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using CoreFS.CA06; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; 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; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Control; namespace Core.StlMes.Client.SalePrice.BaseForm { public partial class FrmPriceFactorRange : FrmBase { string isValid = "1"; public FrmPriceFactorRange() { InitializeComponent(); } private void FrmPriceFactorRange_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(gdFactorRange.DisplayLayout.Bands[0]); InitForm(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": QueryData(); break; case "Save": SaveFormData(); break; case "Delete": DeleteOrResume(true); break; case "Resume": DeleteOrResume(false); break; case "Close": this.Close(); break; } } /// /// 查询数据 /// private void QueryData() { string rangeId = ""; string rangeName = ""; if (labelTextBox1.Checked) rangeName = labelTextBox1.Text.Trim(); if (labelTextBox2.Checked) rangeId = labelTextBox2.Text.Trim(); List list = EntityHelper.GetData( "com.steering.pss.sale.price.server.CorePriceFactorRange.query", new object[] { rangeId, rangeName, isValid }, this.ob); slmPriceFactorClassifyEntityBindingSource.DataSource = list; UltraGridBand ugb = this.gdFactorRange.DisplayLayout.Bands[0]; UltraGridColumn[] col = new UltraGridColumn[] { ugb.Columns["CLASSDNAME"]}; GridHelper.RefreshAndAutoSizeExceptColumns(gdFactorRange, col); } /// /// 初始化数据 /// private void InitForm() { //UltraComboEditor uce = new UltraComboEditor(); //SalePriceClass.NitializeSignMin(uce); //gdFactorRange.DisplayLayout.Bands[0].Columns["factorMinSign"].EditorComponent = uce; //gdFactorRange.DisplayLayout.Bands[0].Columns["factorMinSign"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //this.Controls.Add(uce); //uce.Visible = false; //UltraComboEditor uce1 = new UltraComboEditor(); //SalePriceClass.NitializeSignMax(uce1); //gdFactorRange.DisplayLayout.Bands[0].Columns["factorMaxSign"].EditorComponent = uce1; //gdFactorRange.DisplayLayout.Bands[0].Columns["factorMaxSign"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //this.Controls.Add(uce1); //uce1.Visible = false; //UltraComboEditor uce2 = new UltraComboEditor(); //SalePriceClass.NitializeSignMin(uce2); //gdFactorRange.DisplayLayout.Bands[0].Columns["pertainMinSign"].EditorComponent = uce2; //gdFactorRange.DisplayLayout.Bands[0].Columns["pertainMinSign"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //this.Controls.Add(uce2); //uce2.Visible = false; //UltraComboEditor uce3 = new UltraComboEditor(); //SalePriceClass.NitializeSignMax(uce3); //gdFactorRange.DisplayLayout.Bands[0].Columns["PertainMaxSign"].EditorComponent = uce3; //gdFactorRange.DisplayLayout.Bands[0].Columns["pertainMinSign"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //this.Controls.Add(uce3); //uce3.Visible = false; UltraComboEditor uce4 = new UltraComboEditor(); SalePriceClass.InitComboEditorWithParm(uce4, "com.steering.pss.sale.price.server.CorePriceFactorRange.queryBaseInfo", "BASECODE", "BASENAME", this.ob, true, new object[] { "1228" }); gdFactorRange.DisplayLayout.Bands[0].Columns["VERTYPE"].EditorComponent = uce4; gdFactorRange.DisplayLayout.Bands[0].Columns["VERTYPE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; this.Controls.Add(uce4); uce4.Visible = false; UltraComboEditor uce5 = new UltraComboEditor(); SalePriceClass.InitComboEditorWithParm(uce5, "com.steering.pss.sale.price.server.CorePriceFactorRange.queryFacName", "FACTOR_ID", "FACTOR_NAME", this.ob, false, null); gdFactorRange.DisplayLayout.Bands[0].Columns["factorId"].EditorComponent = uce5; gdFactorRange.DisplayLayout.Bands[0].Columns["factorId"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; this.Controls.Add(uce5); uce5.Visible = false; //UltraComboEditor uce6 = new UltraComboEditor(); //SalePriceClass.InitComboEditorWithParm(uce6, "com.steering.pss.sale.price.server.CorePriceFactorRange.queryFacName", "FACTOR_ID", "FACTOR_NAME", this.ob, false, null); //gdFactorRange.DisplayLayout.Bands[0].Columns["pertainFactorId"].EditorComponent = uce6; //gdFactorRange.DisplayLayout.Bands[0].Columns["pertainFactorId"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //this.Controls.Add(uce6); //uce6.Visible = false; } /// /// 保存界面数据 /// private void SaveFormData() { gdFactorRange.UpdateData(); UltraGridRow[] row = gdFactorRange.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString().ToUpper() == "TRUE").ToArray(); if (row.Length <= 0) { MessageUtil.ShowWarning("请选择需要保存的数据!"); return; } ArrayList parm = CheckFormData(row); if (parm == null || parm.Count <= 0) { return; } if (MessageUtil.ShowYesNoAndQuestion("是否确认保存数据!") == DialogResult.No) return; CoreClientParam ccp = new CoreClientParam(); ccp.IfShowErrMsg = false; ccp.ServerName = "com.steering.pss.sale.price.server.CorePriceFactorRange"; ccp.MethodName = "saveData"; ccp.ServerParams = new object[] { parm, UserInfo.GetUserName() }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } MessageUtil.ShowTips("数据保存成功!"); QueryData(); } } /// /// 验证界面数据 /// /// 界面数据 /// private ArrayList CheckFormData(UltraGridRow[] row) { ArrayList parm = new ArrayList(); List list = new List(); foreach (var uRow in row) { SlmPriceFactorClassifyEntity spf = (SlmPriceFactorClassifyEntity)uRow.ListObject; if (spf.Validflag == "无效" && spf.CreateName != "") { MessageUtil.ShowWarning("【" + spf.FactorId + "】的因素已经无效,不能修改!"); return null; } if (spf.FactorId == "") { MessageUtil.ShowWarning("请输入【" + spf.FactorId + "】的因素名称!"); return null; } if (spf.ClassDName == "") { MessageUtil.ShowWarning("请选择【" + spf.ClassDId + "】的范围名称!"); return null; } //if (spf.ColumnKey == "") //{ // MessageUtil.ShowWarning("请选择【" + spf.FactorId + "】的字段KEY!"); // return null; //} //if (spf.FactorMaxVal!="" && !StringUtil.IsNumber(spf.FactorMaxVal)) //{ // MessageUtil.ShowWarning("因素最大值必须为数字"); // return null; //} //if (spf.FactorMaxVal != "" && spf.FactorMaxSign=="") //{ // MessageUtil.ShowWarning("因素上限值不为空,请输入因素上限值符号"); // return null; //} //if (spf.FactorMinVal !="" && !StringUtil.IsNumber(spf.FactorMinVal)) //{ // MessageUtil.ShowWarning("因素最小值必须为数字"); // return null; //} //if (spf.FactorMinVal != "" && spf.FactorMinSign == "") //{ // MessageUtil.ShowWarning("因素下限值不为空,请输入因素下限值符号"); // return null; //} //if (spf.PertainMaxVal !="" && !StringUtil.IsNumber(spf.PertainMaxVal)) //{ // MessageUtil.ShowWarning("附属因素最大值必须为数字"); // return null; //} //if (spf.PertainMaxVal != "" && spf.PertainMaxSign == "") //{ // MessageUtil.ShowWarning("附属因素上限值不为空,请输入附属因素上限值符号"); // return null; //} //if (spf.PertainMinVal !="" && !StringUtil.IsNumber(spf.PertainMinVal)) //{ // MessageUtil.ShowWarning("附属因素最小值必须为数字"); // return null; //} //if (spf.PertainMinVal != "" && spf.PertainMinSign == "") //{ // MessageUtil.ShowWarning("附属因素下限值不为空,请输入附属因素下限值符号"); // return null; //} //if (spf.SortNo.ToString()!="" && !StringUtil.IsNumber(spf.SortNo.ToString())) //{ // MessageUtil.ShowWarning("序号必须为数字"); // return null; //} //if (spf.PertainMaxSign!="" && spf.PertainMaxVal=="") //{ // MessageUtil.ShowWarning("请输入附属因素最大值"); // return null; //} //if (spf.PertainMinSign != "" && spf.PertainMinVal == "") //{ // MessageUtil.ShowWarning("请输入附属因素最小值"); // return null; //} //if (spf.FactorMaxSign != "" && spf.FactorMaxVal == "") //{ // MessageUtil.ShowWarning("请输入因素最大值"); // return null; //} //if (spf.FactorMinSign != "" && spf.FactorMinVal == "") //{ // MessageUtil.ShowWarning("请输入因素最小值"); // return null; //} //if (spf.FactorVal != "" && (spf.FactorMaxVal != "" || spf.FactorMinVal!="")) //{ // MessageUtil.ShowWarning("因素值与上下限范围值不允许同时输入"); // return null; //} //if (spf.FactorMinVal!="" && spf.FactorMaxVal!="") //{ // if (Convert.ToDecimal(spf.FactorMinVal) > Convert.ToDecimal(spf.FactorMaxVal)) // { // MessageUtil.ShowWarning("因素上限值必须大于因素下限值"); // return null; // } //} //if (spf.PertainMaxVal!="" && spf.PertainMinVal!="") //{ // if (Convert.ToDecimal(spf.PertainMinVal) > Convert.ToDecimal(spf.PertainMaxVal)) // { // MessageUtil.ShowWarning("附属因素上限值必须大于附属因素下限值"); // return null; // } //} if (spf.VerType == "") { MessageUtil.ShowWarning("请选择【" + spf.ClassDId + "】的版本类型!"); return null; } //判断因素名称是否重复 if (spf.Validflag == "") //新增 { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.price.server.CorePriceFactorRange.queryFacRNameByName", new object[] { spf.ClassDName }, this.ob); if (dt != null && dt.Rows.Count >= 1) { MessageUtil.ShowWarning("【" + spf.ClassDId + "】您输入的因素名称【" + spf.ClassDName + "】已存在!"); return null; } } else { DataTable dt = ServerHelper.GetData("com.steering.pss.sale.price.server.CorePriceFactorRange.queryFacRNameById", new object[] { spf.ClassDId }, this.ob); if (dt != null && dt.Rows.Count > 0) { if (spf.ClassDName != dt.Rows[0][0].ToString()) { DataTable dt1 = ServerHelper.GetData("com.steering.pss.sale.price.server.CorePriceFactorRange.queryFacRNameByName", new object[] { spf.ClassDName }, this.ob); if (dt1 != null && dt1.Rows.Count >= 1) { MessageUtil.ShowWarning("【" + spf.ClassDId + "】您输入的因素名称【" + spf.ClassDName + "】已存在!"); return null; } } } } if (list.Contains(spf.ClassDName)) { MessageUtil.ShowWarning("输入的因素名称重复!"); return null; } else { list.Add(spf.ClassDName); } parm.Add(JSONFormat.Format(spf)); } return parm; } private void gdFactorRange_AfterRowInsert(object sender, RowEventArgs e) { string maxId = gdFactorRange.Rows.AsQueryable().Max(a => a.Cells["ClassDId"].Value.ToString()); if (maxId == "") { e.Row.Cells["ClassDId"].Value = "C000001"; } else { string str = "C" + (Convert.ToInt32(maxId.Substring(1, 6)) + 1).ToString().PadLeft(6, '0'); e.Row.Cells["ClassDId"].Value = str; } } private void gdFactorRange_AfterRowActivate(object sender, EventArgs e) { UltraGridRow uRow = gdFactorRange.ActiveRow; if (uRow != null) { gdFactorRange.UpdateData(); if (Convert.ToBoolean(uRow.Cells["CHK"].Value)) { uRow.Cells["ClassDName"].Activation = Activation.AllowEdit; uRow.Cells["sortNo"].Activation = Activation.AllowEdit; uRow.Cells["verType"].Activation = Activation.AllowEdit; //uRow.Cells["factorVal"].Activation = Activation.AllowEdit; //uRow.Cells["factorMinSign"].Activation = Activation.AllowEdit; //uRow.Cells["factorMinVal"].Activation = Activation.AllowEdit; //uRow.Cells["factorMaxSign"].Activation = Activation.AllowEdit; //uRow.Cells["factorMaxVal"].Activation = Activation.AllowEdit; //uRow.Cells["pertainFactorId"].Activation = Activation.AllowEdit; //uRow.Cells["pertainVal"].Activation = Activation.AllowEdit; //uRow.Cells["pertainMinSign"].Activation = Activation.AllowEdit; //uRow.Cells["pertainMinVal"].Activation = Activation.AllowEdit; //uRow.Cells["pertainMaxSign"].Activation = Activation.AllowEdit; //uRow.Cells["pertainMaxVal"].Activation = Activation.AllowEdit; uRow.Cells["FactorId"].Activation = Activation.AllowEdit; } else { uRow.Cells["ClassDName"].Activation = Activation.ActivateOnly; uRow.Cells["sortNo"].Activation = Activation.ActivateOnly; uRow.Cells["verType"].Activation = Activation.ActivateOnly; //uRow.Cells["factorVal"].Activation = Activation.ActivateOnly; //uRow.Cells["factorMinSign"].Activation = Activation.ActivateOnly; //uRow.Cells["factorMinVal"].Activation = Activation.ActivateOnly; //uRow.Cells["factorMaxSign"].Activation = Activation.ActivateOnly; //uRow.Cells["factorMaxVal"].Activation = Activation.ActivateOnly; //uRow.Cells["pertainFactorId"].Activation = Activation.ActivateOnly; //uRow.Cells["pertainVal"].Activation = Activation.ActivateOnly; //uRow.Cells["pertainMinSign"].Activation = Activation.ActivateOnly; //uRow.Cells["pertainMinVal"].Activation = Activation.ActivateOnly; //uRow.Cells["pertainMaxSign"].Activation = Activation.ActivateOnly; //uRow.Cells["pertainMaxVal"].Activation = Activation.ActivateOnly; uRow.Cells["FactorId"].Activation = Activation.ActivateOnly; } } } /// /// 删除或恢复 /// /// private void DeleteOrResume(bool flag) { gdFactorRange.UpdateData(); UltraGridRow[] row = gdFactorRange.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString() == "True").ToArray(); if (row.Length <= 0) { MessageUtil.ShowWarning("请选择需要" + (flag ? "删除" : "恢复") + "的数据!"); return; } ArrayList parm = new ArrayList(); if (flag) { foreach (var uRow in row) { SlmPriceFactorClassifyEntity spf = (SlmPriceFactorClassifyEntity)uRow.ListObject; if (spf.Validflag == "无效") { MessageUtil.ShowWarning("您勾选的数据中存在已删除的数据,不必重复删除!"); return; } parm.Add(spf.ClassDId); } } else { foreach (var uRow in row) { SlmPriceFactorClassifyEntity spf = (SlmPriceFactorClassifyEntity)uRow.ListObject; if (spf.Validflag == "有效") { MessageUtil.ShowWarning("您勾选的数据中存在有效的数据,不必进行恢复!"); return; } //恢复前判断是否存在相同因素名称的数据 DataTable dt = ServerHelper.GetData("com.steering.pss.sale.price.server.CorePriceFactorRange.canResume", new object[] { spf.ClassDId, spf.ClassDName }, this.ob); if (dt != null && dt.Rows.Count > 0) { MessageUtil.ShowWarning("系统已存在名称为【" + spf.ClassDName + "】并且有效的因素范围,不能恢复!"); return; } parm.Add(spf.ClassDId); } } if (MessageUtil.ShowYesNoAndQuestion("是否" + (flag ? "删除" : "恢复") + "所选的数据!") == DialogResult.No) return; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.sale.price.server.CorePriceFactorRange"; ccp.MethodName = "deleteOrResume"; ccp.ServerParams = new object[] { parm, UserInfo.GetUserName(), flag }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode != -1) { MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "成功!"); QueryData(); } } } private void chkValid_CheckedChanged(object sender, EventArgs e) { if (chkValid.Checked) { isValid = "0"; } else { isValid = "1"; } } private void gdFactorRange_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row.Cells["VALIDFLAG"].Value.ToString() == "无效") { e.Row.Appearance.ForeColor = Color.Red; } else { e.Row.Appearance.ForeColor = Color.Black; } } private void gdFactorRange_CellChange(object sender, CellEventArgs e) { if (e.Cell.Column.Key.ToUpper().Equals("CHK")) { if (Convert.ToBoolean(e.Cell.Text)) { e.Cell.Row.Cells["ClassDName"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["sortNo"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["verType"].Activation = Activation.AllowEdit; //e.Cell.Row.Cells["factorVal"].Activation = Activation.AllowEdit; //e.Cell.Row.Cells["factorMinSign"].Activation = Activation.AllowEdit; //e.Cell.Row.Cells["factorMinVal"].Activation = Activation.AllowEdit; //e.Cell.Row.Cells["factorMaxSign"].Activation = Activation.AllowEdit; //e.Cell.Row.Cells["factorMaxVal"].Activation = Activation.AllowEdit; //e.Cell.Row.Cells["pertainFactorId"].Activation = Activation.AllowEdit; //e.Cell.Row.Cells["pertainVal"].Activation = Activation.AllowEdit; //e.Cell.Row.Cells["pertainMinSign"].Activation = Activation.AllowEdit; //e.Cell.Row.Cells["pertainMinVal"].Activation = Activation.AllowEdit; //e.Cell.Row.Cells["pertainMaxSign"].Activation = Activation.AllowEdit; //e.Cell.Row.Cells["pertainMaxVal"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["FactorId"].Activation = Activation.AllowEdit; } else { e.Cell.Row.Cells["ClassDName"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["sortNo"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["verType"].Activation = Activation.ActivateOnly; //e.Cell.Row.Cells["factorVal"].Activation = Activation.ActivateOnly; //e.Cell.Row.Cells["factorMinSign"].Activation = Activation.ActivateOnly; //e.Cell.Row.Cells["factorMinVal"].Activation = Activation.ActivateOnly; //e.Cell.Row.Cells["factorMaxSign"].Activation = Activation.ActivateOnly; //e.Cell.Row.Cells["factorMaxVal"].Activation = Activation.ActivateOnly; //e.Cell.Row.Cells["pertainFactorId"].Activation = Activation.ActivateOnly; //e.Cell.Row.Cells["pertainVal"].Activation = Activation.ActivateOnly; //e.Cell.Row.Cells["pertainMinSign"].Activation = Activation.ActivateOnly; //e.Cell.Row.Cells["pertainMinVal"].Activation = Activation.ActivateOnly; //e.Cell.Row.Cells["pertainMaxSign"].Activation = Activation.ActivateOnly; //e.Cell.Row.Cells["pertainMaxVal"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["FactorId"].Activation = Activation.ActivateOnly; } } } } }