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; using Core.StlMes.Client.SalePrice.dialog; namespace Core.StlMes.Client.SalePrice.BaseForm { public partial class FrmPriceAddPrice : FrmBase { string isValid = "1"; public FrmPriceAddPrice() { InitializeComponent(); } private void FrmPriceAddPrice_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ugPriceAddHead.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ugPriceAddLine.DisplayLayout.Bands[0]); InitCombo(); } private void InitCombo() { UltraComboEditor uce1 = new UltraComboEditor(); SalePriceClass.InitComboEditorWithParm(uce1, "com.steering.pss.sale.price.server.CorePriceFactor.queryBaseInfo", "BASECODE", "BASENAME", this.ob, true, new object[] { "1229" }); ugPriceAddHead.DisplayLayout.Bands[0].Columns["PriceaddType"].EditorComponent = uce1; ugPriceAddHead.DisplayLayout.Bands[0].Columns["PriceaddType"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; this.Controls.Add(uce1); uce1.Visible = false; //UltraComboEditor uce2 = new UltraComboEditor(); //SalePriceClass.InitComboEditorWithParm(uce2, "com.steering.pss.sale.price.server.CorePriceFactor.queryBaseInfo", "BASECODE", "BASENAME", this.ob, true, new object[] { "1230" }); //ugPriceAddLine.DisplayLayout.Bands[0].Columns["PriceaddClassify"].EditorComponent = uce2; //ugPriceAddLine.DisplayLayout.Bands[0].Columns["PriceaddClassify"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; //this.Controls.Add(uce2); //uce2.Visible = false; string VerType = "123102";//1为 适用项目 2为 加价优惠分类 UltraComboEditor uce2 = new UltraComboEditor(); SalePriceClass.InitComboEditorWithParm(uce2, "com.steering.pss.sale.price.server.CorePriceBaseSuit.GetSUITCLASSIFY", "SUIT_ID", "SUIT_NAME", this.ob, true, new object[] { VerType }); ugPriceAddLine.DisplayLayout.Bands[0].Columns["PriceaddClassify"].EditorComponent = uce2; ugPriceAddLine.DisplayLayout.Bands[0].Columns["PriceaddClassify"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; this.Controls.Add(uce2); uce2.Visible = false; } private void chkValid_CheckedChanged(object sender, EventArgs e) { if (chkValid.Checked) { isValid = "0"; } else { isValid = "1"; } } 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 DeleteOrResume(bool flag) { ugPriceAddHead.UpdateData(); ugPriceAddLine.UpdateData(); UltraGridRow[] row = ugPriceAddHead.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString().ToUpper() == "TRUE").ToArray(); UltraGridRow[] row_price = GridHelper.GetRowsWithKey(ugPriceAddLine, new string[] { "CHK" }, new string[] { "True" }); if (row.Length <= 0 && row_price.Length <= 0) { MessageUtil.ShowWarning("请选择需要" + (flag ? "删除" : "恢复") + "的数据!"); return; } ArrayList parm = new ArrayList(); ArrayList parm_price = new ArrayList(); if (flag) { foreach (var uRow in row) { SlmPriceAddpriceHeadEntity spf = new SlmPriceAddpriceHeadEntity(); ; spf.PriceaddId = uRow.Cells["PriceaddId"].Text.ToString(); if (spf.Validflag == "无效") { MessageUtil.ShowWarning("您勾选的数据中存在已删除的数据,不必重复删除!"); return; } spf.CreateName = UserInfo.GetUserName(); spf.UpdateName = UserInfo.GetUserName(); parm.Add(JSONFormat.Format(spf)); } foreach (var uRow_p in row_price) { SlmPriceAddpriceLineEntity spf_p = (SlmPriceAddpriceLineEntity)uRow_p.ListObject; if (spf_p.Validflag == "无效") { MessageUtil.ShowWarning("您勾选的数据中存在已删除的数据,不必重复删除!"); return; } spf_p.CreateName = UserInfo.GetUserName(); spf_p.UpdateName = UserInfo.GetUserName(); parm_price.Add(JSONFormat.Format(spf_p)); } } else { foreach (var uRow in row) { SlmPriceAddpriceHeadEntity spf = new SlmPriceAddpriceHeadEntity(); ; spf.PriceaddId = uRow.Cells["PriceaddId"].Text.ToString(); if (spf.Validflag == "有效") { MessageUtil.ShowWarning("您勾选的数据中存在有效的数据,不必进行恢复!"); return; } spf.CreateName = UserInfo.GetUserName(); spf.UpdateName = UserInfo.GetUserName(); parm.Add(JSONFormat.Format(spf)); } foreach (var uRow_p in row_price) { SlmPriceAddpriceLineEntity spf_p = (SlmPriceAddpriceLineEntity)uRow_p.ListObject; if (spf_p.Validflag == "有效") { MessageUtil.ShowWarning("您勾选的数据中存在有效的数据,不必进行恢复!"); return; } spf_p.CreateName = UserInfo.GetUserName(); spf_p.UpdateName = UserInfo.GetUserName(); parm_price.Add(JSONFormat.Format(spf_p)); } } if (MessageUtil.ShowYesNoAndQuestion("是否" + (flag ? "删除" : "恢复") + "所选的数据!") == DialogResult.No) return; int i = ServerHelper.SetData("com.steering.pss.sale.price.server.CorePriceAddPriceHead.deleteOrResume", new object[] { parm, parm_price, flag }, this.ob); if (i >= 0) { MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "成功!"); QueryData(); } else { MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "失败!"); QueryData(); } } private void SaveFormData() { ugPriceAddHead.UpdateData(); ugPriceAddLine.UpdateData(); UltraGridRow[] row = ugPriceAddHead.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString().ToUpper() == "TRUE").ToArray(); UltraGridRow[] row_price = GridHelper.GetRowsWithKey(ugPriceAddLine, new string[] { "CHK" }, new string[] { "True" }); if (row.Length <= 0 && row_price.Length <= 0) { MessageUtil.ShowWarning("请选择需要保存的数据!"); return; } ArrayList parm = CheckFormData(row); ArrayList parm_price = CheckFormData_price(row_price); //if (parm == null || parm.Count <= 0 ) //{ // return; //} if (MessageUtil.ShowYesNoAndQuestion("是否确认保存数据!") == DialogResult.No) return; int i = ServerHelper.SetData("com.steering.pss.sale.price.server.CorePriceAddPriceHead.save", new object[] { parm, parm_price }, this.ob); if (i > 0) { MessageUtil.ShowTips("数据保存成功!"); QueryData(); } else { MessageUtil.ShowTips("数据保存失败!"); QueryData(); } } private ArrayList CheckFormData_price(UltraGridRow[] row_price) { ArrayList parm = new ArrayList(); List list = new List(); foreach (var uRow in row_price) { SlmPriceAddpriceLineEntity spf = (SlmPriceAddpriceLineEntity)uRow.ListObject; spf.CreateName = UserInfo.GetUserName(); spf.UpdateName = UserInfo.GetUserName(); spf.Validflag = uRow.Cells["VALIDFLAG"].Text.ToString(); if (spf.Validflag == "无效" && spf.CreateName != "") { MessageUtil.ShowWarning("【" + spf.PriceaddLineId + "】的因素已经无效,不能修改!"); return null; } parm.Add(JSONFormat.Format(spf)); } return parm; } private ArrayList CheckFormData(UltraGridRow[] row) { ArrayList parm = new ArrayList(); List list = new List(); foreach (var uRow in row) { SlmPriceAddpriceHeadEntity spf = (SlmPriceAddpriceHeadEntity)uRow.ListObject; spf.CreateName = UserInfo.GetUserName(); spf.UpdateName = UserInfo.GetUserName(); spf.Validflag = uRow.Cells["VALIDFLAG"].Text.ToString(); if (spf.Validflag == "无效" && spf.CreateName != "") { MessageUtil.ShowWarning("【" + spf.PriceaddId + "】的因素已经无效,不能修改!"); return null; } parm.Add(JSONFormat.Format(spf)); } return parm; } private void QueryData() { string PriceAdd_ID = ""; string PriceAdd_Desc = ""; if (labelTextBox1.Checked) PriceAdd_Desc = labelTextBox1.Text.Trim(); if (labelTextBox2.Checked) PriceAdd_ID = labelTextBox2.Text.Trim(); List list = EntityHelper.GetData( "com.steering.pss.sale.price.server.CorePriceAddPriceHead.query", new object[] { PriceAdd_ID, PriceAdd_Desc, isValid }, this.ob); slmPriceAddpriceHeadEntityBindingSource.DataSource = list; UltraGridBand ugb = this.ugPriceAddHead.DisplayLayout.Bands[0]; UltraGridColumn[] col = new UltraGridColumn[] { ugb.Columns["PriceaddDesc"] }; GridHelper.RefreshAndAutoSizeExceptColumns(ugPriceAddHead, col); } private void ugPriceAddHead_AfterRowActivate(object sender, EventArgs e) { if (ugPriceAddHead.ActiveRow.Cells["PriceaddId"].Value.ToString() != "") { string PriceAdd_ID = ugPriceAddHead.ActiveRow.Cells["PriceaddId"].Value.ToString(); QueryDataLine(PriceAdd_ID, isValid); } } private void QueryDataLine(string PriceAdd_ID, string isValid) { List list = EntityHelper.GetData( "com.steering.pss.sale.price.server.CorePriceAddPriceHead.queryById", new object[] { PriceAdd_ID, isValid }, this.ob); slmPriceAddpriceLineEntityBindingSource.DataSource = list; UltraGridBand ugb = this.ugPriceAddLine.DisplayLayout.Bands[0]; UltraGridColumn[] col = new UltraGridColumn[] { ugb.Columns["PriceaddId"] }; GridHelper.RefreshAndAutoSizeExceptColumns(ugPriceAddLine, col); } private void ugPriceAddLine_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row != null) { string PriceaddClassify = e.Row.Cells["PriceaddClassify"].Value.ToString(); // suitValueBind(PriceaddClassify); DataTable SuitInfo = ServerHelper.GetData("com.steering.pss.sale.price.server.CorePriceBaseSuit.GetSuitInfo", new object[] { PriceaddClassify }, this.ob); if (SuitInfo != null && SuitInfo.Rows.Count > 0 && SuitInfo.Rows[0]["Table_Name"].ToString() != "") { UltraComboEditor uce1 = new UltraComboEditor(); string sql_getFactorBind = ""; string TableName = SuitInfo.Rows[0]["TABLE_NAME"].ToString(); string DataValue = SuitInfo.Rows[0]["COLUMN_KEY"].ToString(); string DataDesc = SuitInfo.Rows[0]["COLUMN_NAME"].ToString(); string sql_getSQL = SuitInfo.Rows[0]["VAL_SQL"].ToString(); DataTable dtFactor = ServerHelper.GetData("com.steering.pss.sale.price.server.CorePriceBaseSuit.FactorBind", new object[] { TableName, DataValue, DataDesc, sql_getSQL }, this.ob); if (dtFactor != null && dtFactor.Rows.Count > 0) { Object[] obj = new Object[] { "", "" }; DataRow dr = dtFactor.NewRow(); dr.ItemArray = obj; dtFactor.Rows.InsertAt(dr, 0); uce1.DataSource = dtFactor; uce1.DataMember = ""; uce1.ValueMember = DataValue; uce1.DisplayMember = DataDesc; ClsBaseInfo.SetComboItemHeight(uce1); } //ugPriceAddLine.DisplayLayout.Bands[0].Columns["PriceaddItem"].EditorComponent = uce1; //ugPriceAddLine.DisplayLayout.Bands[0].Columns["PriceaddItem"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; e.Row.Cells["PriceaddItem"].EditorComponent = uce1; e.Row.Cells["PriceaddItem"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; this.Controls.Add(uce1); uce1.Visible = false; } if (e.Row.Cells["VALIDFLAG"].Value.ToString() == "无效") { e.Row.Appearance.ForeColor = Color.Red; } else { e.Row.Appearance.ForeColor = Color.Black; } } } private void ugPriceAddLine_ClickCellButton(object sender, CellEventArgs e) { string AddPrice_Line_Id = e.Cell.Row.Cells["PriceaddLineId"].Value.ToString(); if (e.Cell.Column.Key == "PriceaddSuit") { AddPriceSuit popup = null; try { this.Cursor = Cursors.WaitCursor; popup = new AddPriceSuit(AddPrice_Line_Id, this.ob); } finally { this.Cursor = Cursors.Default; } popup.ShowDialog(); } } private void ugPriceAddHead_AfterRowInsert(object sender, RowEventArgs e) { string maxId = ugPriceAddHead.Rows.AsQueryable().Max(a => a.Cells["PriceaddId"].Value.ToString()); if (maxId == "") { e.Row.Cells["PriceaddId"].Value = "T000001"; } else { string str = "T" + (Convert.ToInt32(maxId.Substring(1, 6)) + 1).ToString().PadLeft(6, '0'); e.Row.Cells["PriceaddId"].Value = str; } } private void ugPriceAddHead_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row != null) { if (e.Row.Cells["VALIDFLAG"].Value.ToString() == "无效") { e.Row.Appearance.ForeColor = Color.Red; } else { e.Row.Appearance.ForeColor = Color.Black; } } } private void suitValueBind(string SUITCLASSIFY) { } private void ugPriceAddLine_InitializeLayout(object sender, InitializeLayoutEventArgs e) { } private void ugPriceAddLine_AfterRowInsert(object sender, RowEventArgs e) { string PriceaddId = this.ugPriceAddHead.ActiveRow.Cells["PriceaddId"].Value.ToString2(); e.Row.Cells["PriceaddId"].Value = PriceaddId; } } }