| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421 |
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.PnCost.Models;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.PnCost
- {
- public partial class frmBasePrice : FrmBase
- {
- #region 定义变量
- public frmBasePrice()
- {
- InitializeComponent();
- }
- #endregion
- #region 初始化
- private void frmBasePrice_Load(object sender, EventArgs e)
- {
- EntityHelper.ShowGridCaption<CostBasePriceEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- DataTable dt = ServerHelper.GetData("com.steering.pss.pncost.base.ComBasePrice.queryPliao",
- new object[] { }, ob);
- for (int i = 2000; i < 2051; i++)
- {
- year.Items.Add(i);
- }
- for (int i = 2000; i < 2051; i++)
- {
- ultraComboYear.Items.Add(i);
- }
- ultraComboYear.Value = System.DateTime.Now.Year.ToString2();
- Query();
- }
- #endregion
- #region 方法
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- base.ToolBar_Click(sender, ToolbarKey);
- switch (ToolbarKey)
- {
- case "Query":
- Query();
- break;
- case "Update":
- Save();
- break;
- case "Delete":
- Delete();
- break;
- case "Resume":
- Resume();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// 查询方法
- /// <summary>
- /// 查询方法
- /// </summary>
- private void Query()
- {
- #region 条件验证
- string gang = ultraComboYear.Value.ToString2();
- #endregion
- List<CostBasePriceEntity> data = EntityHelper.GetData<CostBasePriceEntity>(
- "com.steering.pss.pncost.base.ComBasePrice.query", new object[] { gang }, ob);
- costBasePriceEntityBindingSource.DataSource = data;
- if (ultraGrid1.Rows.Count == 0)
- {
- return;
- }
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["VALIDFLAG"].Value.ToString() == "无效")
- {
- ultraGrid1.Rows[i].Appearance.ForeColor = Color.Red;
- }
- ultraGrid1.Rows[i].Cells["xuanze"].Value = false;
- ultraGrid1.Rows[i].Cells["YEAR"].Value = ultraComboYear.Value.ToString2();
- GridEdite(ultraGrid1.Rows[i]);
- }
- ultraGrid1.UpdateData();
- ultraGrid1.ActiveRow = ultraGrid1.Rows[0];
- }
- /// 保存方法
- /// <summary>
- /// 保存方法
- /// </summary>
- private void Save()
- {
- string stringnew = "";
- string year = "";
- string xuanze = "false";
- try
- {
- #region 验证信息
- ultraGrid1.UpdateData();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["xuanze"].Value.ToString() == "True")
- {
- if (ultraGrid1.Rows[i].Cells["ARCCODE"].Value.ToString() == "")
- {
- MessageUtil.ShowWarning("分类描述不能为空!请选择分类");
- return;
- }
- if (ultraGrid1.Rows[i].Cells["ITEMCODE"].Value.ToString() == "")
- {
- MessageUtil.ShowWarning("物料名称不能为空!请选择物料");
- return;
- }
- if (ultraGrid1.Rows[i].Cells["YEAR"].Value.ToString2() == "")
- {
- MessageUtil.ShowWarning("年份不能为空!请选择年份");
- return;
- }
- if (ultraGrid1.Rows[i].Cells["CREATENAME"].Value.ToString() == "")//判断是新增还是修改的保存
- {
- stringnew = ultraGrid1.Rows[i].Cells["ITEMCODE"].Value.ToString();
- year = ultraGrid1.Rows[i].Cells["YEAR"].Value.ToString();
- DataTable dt = ServerHelper.GetData("com.steering.pss.pncost.base.ComBasePrice.queryNum", new Object[] { stringnew, year }, ob);
- if (dt.Rows[0][0].ToString() == "1")
- {
- MessageUtil.ShowWarning("年份'" + year + "'重复!,请重新输入");
- return;
- }
- }
- else //修改
- {
- stringnew = ultraGrid1.Rows[i].Cells["ITEMCODE"].Value.ToString();
- year = ultraGrid1.Rows[i].Cells["YEAR"].Value.ToString();
- if (ultraGrid1.Rows[i].Cells["YEAR"].Value.ToString2() != ultraGrid1.Rows[i].Cells["YEARNEW"].Value.ToString2())
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.pncost.base.ComBasePrice.queryNum", new Object[] { stringnew, year }, ob);
- if (dt.Rows[0][0].ToString() == "1")
- {
- MessageUtil.ShowWarning("年份'" + year + "'重复!,请重新输入");
- return;
- }
- }
- }
- xuanze = "true";
- }
- }
- if (xuanze == "false")
- {
- MessageUtil.ShowWarning("请选择你要保存的记录!");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == System.Windows.Forms.DialogResult.No)
- {
- return;
- }
- #endregion
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["xuanze"].Value.ToString() == "True")
- {
- CostBasePriceEntity parm = new CostBasePriceEntity();
- parm.ItemCode = ultraGrid1.Rows[i].Cells["ITEMCODE"].Value.ToString();
- parm.ItemName = ultraGrid1.Rows[i].Cells["ITEMNAME"].Value.ToString();
- parm.ArcCode = ultraGrid1.Rows[i].Cells["ARCCODE"].Value.ToString();
- parm.ArcItem = ultraGrid1.Rows[i].Cells["ARCITEM"].Value.ToString();
- parm.Memo = ultraGrid1.Rows[i].Cells["MEMO"].Value.ToString();
- parm.Year = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["YEAR"].Value.ToString());
- parm.Month1 = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["MONTH1"].Value.ToString3());
- parm.Month2 = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["MONTH2"].Value.ToString3());
- parm.Month3 = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["MONTH3"].Value.ToString3());
- parm.Month4 = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["MONTH4"].Value.ToString3());
- parm.Month5 = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["MONTH5"].Value.ToString3());
- parm.Month6 = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["MONTH6"].Value.ToString3());
- parm.Month7 = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["MONTH7"].Value.ToString3());
- parm.Month8 = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["MONTH8"].Value.ToString3());
- parm.Month9 = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["MONTH9"].Value.ToString3());
- parm.Month10 = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["MONTH10"].Value.ToString3());
- parm.Month11 = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["MONTH11"].Value.ToString3());
- parm.Month12 = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["MONTH12"].Value.ToString3());
- if (ultraGrid1.Rows[i].Cells["CREATENAME"].Value.ToString() == "")//判断是新增还是修改的保存
- {
- parm.CreateName = this.UserInfo.GetUserName();//新增保存
- string JsonStr = JSONFormat.Format(parm);
- ServerHelper.SetData("com.steering.pss.pncost.base.ComBasePrice.isave", new object[] { JsonStr }, ob);
- }
- else
- {
- parm.UpdateName = this.UserInfo.GetUserName();//修改保存
- string JsonStr = JSONFormat.Format(parm);
- string yeranew = "";
- yeranew = ultraGrid1.Rows[i].Cells["YEARNEW"].Value.ToString();
- ServerHelper.SetData("com.steering.pss.pncost.base.ComBasePrice.usave", new object[] { JsonStr, yeranew }, ob);
- }
- }
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowError("保存失败!'" + ex.Message + "'");
- return;
- }
- MessageUtil.ShowTips("保存成功!");
- Query();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["ITEMCODE"].Value.ToString() == stringnew)
- {
- if (ultraGrid1.Rows[i].Cells["YEAR"].Value.ToString() == year)
- {
- ultraGrid1.Rows[i].Activate();
- }
- }
- }
- }
- /// 删除方法
- /// <summary>
- /// 删除方法
- /// </summary>
- private void Delete()
- {
- string stringnew = "";
- string year = "";
- string xuanze = "false";
- try
- {
- #region 验证信息
- ultraGrid1.UpdateData();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["xuanze"].Value.ToString() == "True")
- {
- if (ultraGrid1.Rows[i].Cells["VALIDFLAG"].Value.ToString() != "有效")
- {
- MessageUtil.ShowWarning("选择的数据已经作废!");
- return;
- }
- xuanze = "true";
- }
- }
- if (xuanze == "false")
- {
- MessageUtil.ShowWarning("请选择你要删除的记录!");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == System.Windows.Forms.DialogResult.No)
- {
- return;
- }
- #endregion
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["xuanze"].Value.ToString() == "True")
- {
- stringnew = ultraGrid1.Rows[i].Cells["ITEMCODE"].Value.ToString();
- year = ultraGrid1.Rows[i].Cells["YEAR"].Value.ToString();
- CostBasePriceEntity parm = new CostBasePriceEntity();
- parm.ItemCode = ultraGrid1.Rows[i].Cells["ITEMCODE"].Value.ToString();
- parm.Year = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["YEAR"].Value.ToString());
- parm.UpdateName = this.UserInfo.GetUserName();
- parm.DeleteName = this.UserInfo.GetUserName();
- string JsonStr = JSONFormat.Format(parm);
- ServerHelper.SetData("com.steering.pss.pncost.base.ComBasePrice.delete", new object[] { JsonStr }, ob);
- }
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowError("删除失败!'" + ex.Message + "'");
- return;
- }
- MessageUtil.ShowTips("删除成功!");
- Query();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["ITEMCODE"].Value.ToString() == stringnew)
- {
- if (ultraGrid1.Rows[i].Cells["YEAR"].Value.ToString() == year)
- {
- ultraGrid1.Rows[i].Activate();
- }
- }
- }
- }
- /// 恢复方法
- /// <summary>
- /// 恢复方法
- /// </summary>
- private void Resume()
- {
- string stringnew = "";
- string year = "";
- string xuanze = "false";
- try
- {
- #region 验证信息
- ultraGrid1.UpdateData();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["xuanze"].Value.ToString() == "True")
- {
- if (ultraGrid1.Rows[i].Cells["VALIDFLAG"].Value.ToString() != "无效")
- {
- MessageUtil.ShowWarning("选择的数据没有作废!");
- return;
- }
- xuanze = "true";
- }
- }
- if (xuanze == "false")
- {
- MessageUtil.ShowWarning("请选择你要恢复的记录!");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认恢复?") == System.Windows.Forms.DialogResult.No)
- {
- return;
- }
- #endregion
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["xuanze"].Value.ToString() == "True")
- {
- stringnew = ultraGrid1.Rows[i].Cells["ITEMCODE"].Value.ToString();
- year = ultraGrid1.Rows[i].Cells["YEAR"].Value.ToString();
- CostBasePriceEntity parm = new CostBasePriceEntity();
- parm.ItemCode = ultraGrid1.Rows[i].Cells["ITEMCODE"].Value.ToString();
- parm.Year = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["YEAR"].Value.ToString());
- parm.UpdateName = this.UserInfo.GetUserName();
- string JsonStr = JSONFormat.Format(parm);
- ServerHelper.SetData("com.steering.pss.pncost.base.ComBasePrice.resume", new object[] { JsonStr }, ob);
- }
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowError("恢复失败!'" + ex.Message + "'");
- return;
- }
- MessageUtil.ShowTips("恢复成功!");
- Query();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["ITEMCODE"].Value.ToString() == stringnew)
- {
- if (ultraGrid1.Rows[i].Cells["YEAR"].Value.ToString() == year)
- {
- ultraGrid1.Rows[i].Activate();
- }
- }
- }
- }
- #endregion
- #region 事件
- /// 选择事件
- /// <summary>
- /// 选择事件
- /// </summary>
- private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- ultraGrid1.UpdateData();
- if (e.Cell.Column.Key == "xuanze")
- {
- GridEdite(e.Cell.Row);
- }
- }
- /// 选择判断
- /// <summary>
- /// 选择判断
- /// </summary>
- private void GridEdite(UltraGridRow row)
- {
- if (row.GetValue("xuanze") == "True")
- {
- row.Cells["YEARNEW"].Value = row.Cells["YEAR"].Value;
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.AllowEdit;
- }
- }
- }
- else
- {
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.Key == "xuanze") continue;
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.ActivateOnly;
- }
- }
- }
- }
- #endregion
- }
- }
|