| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- 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 FrmPriceDoc : FrmBase
- {
- string isValid = "1";
- public FrmPriceDoc()
- {
- InitializeComponent();
- }
- private void FrmPriceDoc_Load(object sender, EventArgs e)
- {
- EntityHelper.ShowGridCaption<SlmPriceDocEntity>(gdPriceDoc.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;
- }
- }
- /// <summary>
- /// 删除或恢复
- /// </summary>
- /// <param name="flag"></param>
- private void DeleteOrResume(bool flag)
- {
- gdPriceDoc.UpdateData();
- UltraGridRow[] row = gdPriceDoc.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)
- {
- SlmPriceDocEntity spf = (SlmPriceDocEntity)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)
- {
- SlmPriceDocEntity spf = (SlmPriceDocEntity)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.CorePriceBaseDoc.deleteOrResume", new object[] { parm, flag }, this.ob);
- if (i >= 0)
- {
- MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "成功!");
- QueryData();
- }
- else
- {
- MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "失败!");
- QueryData();
- }
- }
- private void SaveFormData()
- {
- gdPriceDoc.UpdateData();
- UltraGridRow[] row = gdPriceDoc.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString().ToUpper() == "TRUE").ToArray();
-
- if (row.Length <= 0)
- {
- MessageUtil.ShowWarning("请选择需要保存的数据!");
- return;
- }
- if (row.Length > 0)
- {
- 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.CorePriceBaseDoc.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<string> list = new List<string>();
- foreach (var uRow in row)
- {
- SlmPriceDocEntity spf = (SlmPriceDocEntity)uRow.ListObject;
- if (spf.Validflag == "无效" && spf.Updatename != "")
- {
- MessageUtil.ShowWarning("【" + spf.PriceVerId + "】的因素已经无效,不能修改!");
- return null;
- }
- spf.ValiddateBegin = Convert.ToDateTime(spf.ValiddateBegin).ToString("yyyy-MM-dd");
- spf.ValiddateEnd = Convert.ToDateTime(spf.ValiddateEnd).ToString("yyyy-MM-dd");
- ; spf.Createname= UserInfo.GetUserName();
- spf.Updatename = UserInfo.GetUserName();
- parm.Add(JSONFormat.Format(spf));
- }
- return parm;
- }
-
- /// <summary>
- /// 查询数据
- /// </summary>
- private void QueryData()
- {
- string priceVerId = "";
- string priceVerDesc = "";
- if (labelTextBox1.Checked)
- priceVerDesc = labelTextBox1.Text.Trim();
- if (labelTextBox2.Checked)
- priceVerId = labelTextBox2.Text.Trim();
- List<SlmPriceDocEntity> list = EntityHelper.GetData<SlmPriceDocEntity>(
- "com.steering.pss.sale.price.server.CorePriceBaseDoc.query", new object[] { priceVerId, priceVerDesc, isValid }, this.ob);
- slmPriceDocEntityBindingSource.DataSource = list;
- UltraGridBand ugb = this.gdPriceDoc.DisplayLayout.Bands[0];
- UltraGridColumn[] col = new UltraGridColumn[] { ugb.Columns["priceVerDesc"] };
- GridHelper.RefreshAndAutoSizeExceptColumns(gdPriceDoc, col);
- }
- private void gdPriceDoc_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 gdPriceDoc_AfterRowInsert(object sender, RowEventArgs e)
- {
- string maxId = gdPriceDoc.Rows.AsQueryable().Max(a => a.Cells["PriceVerId"].Value.ToString());
- if (maxId == "")
- {
- e.Row.Cells["PriceVerId"].Value = "D000001";
- }
- else
- {
- string str = "D" + (Convert.ToInt32(maxId.Substring(1, 6)) + 1).ToString().PadLeft(6, '0');
- e.Row.Cells["PriceVerId"].Value = str;
- }
- }
- private void chkValid_CheckedChanged(object sender, EventArgs e)
- {
- if (chkValid.Checked)
- {
- isValid = "0";
- }
- else
- {
- isValid = "1";
- }
- }
- }
- }
|