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; namespace Core.StlMes.Client.SalePrice.BaseForm { public partial class FrmPriceBaseSuit : FrmBase { string isValid = "1"; public FrmPriceBaseSuit() { InitializeComponent(); } private void FrmPriceBaseSuit_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(gdBaseSuit.DisplayLayout.Bands[0]); InitForm(); } private void InitForm() { UltraComboEditor uce = new UltraComboEditor(); SalePriceClass.InitComboEditor(uce, "com.steering.pss.sale.price.server.CorePriceFactor.queryTableName", "TABLE_NAME", this.ob, false); gdBaseSuit.DisplayLayout.Bands[0].Columns["TABLENAME"].EditorComponent = uce; gdBaseSuit.DisplayLayout.Bands[0].Columns["TABLENAME"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; this.Controls.Add(uce); uce.Visible = false; UltraComboEditor uce1 = new UltraComboEditor(); SalePriceClass.InitComboEditorWithParm(uce1, "com.steering.pss.sale.price.server.CorePriceFactor.queryBaseInfo", "BASECODE", "BASENAME", this.ob, true, new object[] { "1231" }); gdBaseSuit.DisplayLayout.Bands[0].Columns["VERTYPE"].EditorComponent = uce1; gdBaseSuit.DisplayLayout.Bands[0].Columns["VERTYPE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; this.Controls.Add(uce1); uce1.Visible = false; } 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 gdBaseSuit_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row != null) { string tabName = e.Row.Cells["TABLENAME"].Value.ToString(); UltraComboEditor uce = new UltraComboEditor(); SalePriceClass.InitComboEditorWithParm(uce, "com.steering.pss.sale.price.server.CorePriceFactor.queryColumnName", "COLUMN_NAME", "COLUMN_NAME", this.ob, false, new object[] { tabName }); gdBaseSuit.DisplayLayout.Bands[0].Columns["COLUMNKEY"].EditorComponent = uce; gdBaseSuit.DisplayLayout.Bands[0].Columns["COLUMNKEY"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; this.Controls.Add(uce); uce.Visible = false; if (e.Row.Cells["VALIDFLAG"].Value.ToString() == "无效") { e.Row.Appearance.ForeColor = Color.Red; } else { e.Row.Appearance.ForeColor = Color.Black; } } } private void gdBaseSuit_CellChange(object sender, CellEventArgs e) { gdBaseSuit.UpdateData(); if (e.Cell.Column.Key.ToUpper().Equals("COLUMNKEY")) { string tabName = e.Cell.Row.Cells["TABLENAME"].Value.ToString(); string colName = e.Cell.Value.ToString(); DataTable dt = ServerHelper.GetData("com.steering.pss.sale.price.server.CorePriceFactor.queryColumnType", new object[] { tabName, colName }, this.ob); if (dt != null && dt.Rows.Count > 0) { string dataType = dt.Rows[0][0].ToString2().ToUpper(); e.Cell.Row.Cells["COLUMNTYPE"].Value = SalePriceClass.GetColumnType(dataType); } else { e.Cell.Row.Cells["COLUMNTYPE"].Value = ""; } } else if (e.Cell.Column.Key.ToUpper().Equals("CHK")) { if (Convert.ToBoolean(e.Cell.Value)) { e.Cell.Row.Cells["SuitName"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["TABLENAME"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["COLUMNKEY"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["VALSQL"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["VERTYPE"].Activation = Activation.AllowEdit; } else { e.Cell.Row.Cells["SuitName"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["TABLENAME"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["COLUMNKEY"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["VALSQL"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["VERTYPE"].Activation = Activation.ActivateOnly; } } else if (e.Cell.Column.Key.ToUpper().Equals("TABLENAME")) { e.Cell.Row.Cells["COLUMNKEY"].Value = ""; } } private void gdBaseSuit_AfterRowActivate(object sender, EventArgs e) { UltraGridRow uRow = gdBaseSuit.ActiveRow; if (uRow != null) { gdBaseSuit.UpdateData(); if (Convert.ToBoolean(uRow.Cells["CHK"].Value)) { uRow.Cells["SuitName"].Activation = Activation.AllowEdit; uRow.Cells["TABLENAME"].Activation = Activation.AllowEdit; uRow.Cells["COLUMNKEY"].Activation = Activation.AllowEdit; uRow.Cells["VALSQL"].Activation = Activation.AllowEdit; uRow.Cells["VERTYPE"].Activation = Activation.AllowEdit; } else { uRow.Cells["SuitName"].Activation = Activation.ActivateOnly; uRow.Cells["TABLENAME"].Activation = Activation.ActivateOnly; uRow.Cells["COLUMNKEY"].Activation = Activation.ActivateOnly; uRow.Cells["VALSQL"].Activation = Activation.ActivateOnly; uRow.Cells["VERTYPE"].Activation = Activation.ActivateOnly; } } } private void gdBaseSuit_AfterRowInsert(object sender, RowEventArgs e) { string maxId = gdBaseSuit.Rows.AsQueryable().Max(a => a.Cells["SUITID"].Value.ToString()); if (maxId == "") { e.Row.Cells["SUITID"].Value = "S000001"; } else { string str = "S" + (Convert.ToInt32(maxId.Substring(1, 6)) + 1).ToString().PadLeft(6, '0'); e.Row.Cells["SUITID"].Value = str; } } private void SaveFormData() { gdBaseSuit.UpdateData(); UltraGridRow[] row = gdBaseSuit.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; int i = ServerHelper.SetData("com.steering.pss.sale.price.server.CorePriceBaseSuit.save", new object[] { parm }, this.ob); if (i > 0) { MessageUtil.ShowTips("数据保存成功!"); QueryData(); } else { MessageUtil.ShowTips("数据保存失败!"); QueryData(); } } /// /// 验证界面数据 /// /// 界面数据 /// private ArrayList CheckFormData(UltraGridRow[] row) { ArrayList parm = new ArrayList(); List list = new List(); foreach (var uRow in row) { SlmPriceBasesuitEntity spf = (SlmPriceBasesuitEntity)uRow.ListObject; if (spf.Validflag == "无效" && spf.CreateName != "") { MessageUtil.ShowWarning("【" + spf.SuitId + "】的因素已经无效,不能修改!"); return null; } if (spf.SuitName == "") { MessageUtil.ShowWarning("请输入【" + spf.SuitId + "】的因素名称!"); return null; } if (spf.VerType == "") { MessageUtil.ShowWarning("请选择【" + spf.SuitId + "】的版本类型!"); return null; } //判断因素名称是否重复 parm.Add(JSONFormat.Format(spf)); } return parm; } /// /// 查询 /// private void QueryData() { string SuitId = ""; string SuitName = ""; if (labelTextBox1.Checked) SuitName = labelTextBox1.Text.Trim(); if (labelTextBox2.Checked) SuitId = labelTextBox2.Text.Trim(); List list = EntityHelper.GetData( "com.steering.pss.sale.price.server.CorePriceBaseSuit.query", new object[] { SuitId, SuitName, isValid }, this.ob); slmPriceBasesuitEntityBindingSource.DataSource = list; } private void chkValid_CheckedChanged(object sender, EventArgs e) { if (chkValid.Checked) { isValid = "0"; } else { isValid = "1"; } } private void DeleteOrResume(bool flag) { gdBaseSuit.UpdateData(); UltraGridRow[] row = gdBaseSuit.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) { SlmPriceBasesuitEntity spf = (SlmPriceBasesuitEntity)uRow.ListObject; if (spf.Validflag == "无效") { MessageUtil.ShowWarning("您勾选的数据中存在已删除的数据,不必重复删除!"); return; } spf.CreateName = UserInfo.GetUserName(); spf.UpdateName = UserInfo.GetUserName(); parm.Add(JSONFormat.Format(spf)); } } else { foreach (var uRow in row) { SlmPriceBasesuitEntity spf = (SlmPriceBasesuitEntity)uRow.ListObject; if (spf.Validflag == "有效") { MessageUtil.ShowWarning("您勾选的数据中存在有效的数据,不必进行恢复!"); return; } spf.CreateName = UserInfo.GetUserName(); spf.UpdateName = UserInfo.GetUserName(); parm.Add(JSONFormat.Format(spf)); } } if (MessageUtil.ShowYesNoAndQuestion("是否" + (flag ? "删除" : "恢复") + "所选的数据!") == DialogResult.No) return; int i = ServerHelper.SetData("com.steering.pss.sale.price.server.CorePriceBaseSuit.deleteOrResume", new object[] { parm, flag }, this.ob); if (i >= 0) { MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "成功!"); QueryData(); } else { MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "失败!"); QueryData(); } } } }