| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- 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<SlmPriceBasesuitEntity>(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();
- }
- }
- /// <summary>
- /// 验证界面数据
- /// </summary>
- /// <param name="row">界面数据</param>
- /// <returns></returns>
- private ArrayList CheckFormData(UltraGridRow[] row)
- {
- ArrayList parm = new ArrayList();
- List<string> list = new List<string>();
- 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;
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void QueryData()
- {
- string SuitId = "";
- string SuitName = "";
- if (labelTextBox1.Checked)
- SuitName = labelTextBox1.Text.Trim();
- if (labelTextBox2.Checked)
- SuitId = labelTextBox2.Text.Trim();
- List<SlmPriceBasesuitEntity> list = EntityHelper.GetData<SlmPriceBasesuitEntity>(
- "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();
- }
- }
-
- }
- }
|