| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480 |
- 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<SlmPriceAddpriceHeadEntity>(ugPriceAddHead.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<SlmPriceAddpriceLineEntity>(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<string> list = new List<string>();
-
- 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<string> list = new List<string>();
- 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<SlmPriceAddpriceHeadEntity> list = EntityHelper.GetData<SlmPriceAddpriceHeadEntity>(
- "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<SlmPriceAddpriceLineEntity> list = EntityHelper.GetData<SlmPriceAddpriceLineEntity>(
- "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;
- }
- }
- }
|