| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- using Core.Mes.Client.Comm.Control;
- 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 frmBaseGradePrice : FrmBase
- {
- #region 定义变量
- public frmBaseGradePrice()
- {
- InitializeComponent();
- }
- #endregion
- #region 初始化
- private void frmBaseGradePrice_Load(object sender, EventArgs e)
- {
- EntityHelper.ShowGridCaption<CostBaseGradePriceEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- for (int i = 2000; i < 2051; i++)
- {
- yeardrop.Items.Add(i);
- }
- string str1 = "";
- for (int i = 1; i < 10; i++)
- {
- str1 = "0" + i.ToString2();
- monthdrop.Items.Add(str1);
- }
- monthdrop.Items.Add(10);
- monthdrop.Items.Add(11);
- monthdrop.Items.Add(12);
- yeardrop.Value = System.DateTime.Now.Year.ToString2();
- monthdrop.Value = System.DateTime.Now.Month.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 nianyue = yeardrop.Value.ToString2() + monthdrop.Value.ToString2();
- string nian_yue = yeardrop.Value.ToString2() + "-" + monthdrop.Value.ToString2();
- #endregion
- DataTable data = ServerHelper.GetData("com.steering.pss.pncost.base.ComBaseGradePrice.query2",
- new object[] { nianyue }, ob);
- GridHelper.CopyDataToDatatable(data, dataTable1, true);
- //GridHelper.RefreshAndAutoSize(ultraGrid1);
- //管子:PLN_REQINF_GP表IFBUYPLAN ='1' 年月暂时没加;坯子:PLN_ORDER_ZG_S表 PRO_MONTH管控年月 PLINE_CODE必须是C065,C065
- //List<CostBaseGradePriceEntity> datanew = EntityHelper.GetData<CostBaseGradePriceEntity>(
- // "com.steering.pss.pncost.base.ComBaseGradePrice.query2", new object[] { nianyue, nian_yue }, ob);
- //costBaseGradePriceEntityBindingSource.DataSource = datanew;
- 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["CHK"].Value = false;
- GridEdite(ultraGrid1.Rows[i]);
- }
- ultraGrid1.UpdateData();
- ultraGrid1.ActiveRow = ultraGrid1.Rows[0];
- }
- /// 保存方法
- /// <summary>
- /// 保存方法
- /// </summary>
- private void Save()
- {
- string wuliao = "";
- string xuanze = "false";
- try
- {
- #region 验证信息
- ultraGrid1.UpdateData();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["CHK"].Value.ToString() == "True")
- {
- if (ultraGrid1.Rows[i].Cells["COST_PRICE"].Value.ToString2() == "")
- {
- 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["CHK"].Value.ToString() == "True")
- {
- wuliao = ultraGrid1.Rows[i].Cells["WLBM"].Value.ToString2();
- CostBaseGradePriceEntity parm = new CostBaseGradePriceEntity();
- parm.WlId = ultraGrid1.Rows[i].Cells["WLBM"].Value.ToString2();
- parm.WlDesc = ultraGrid1.Rows[i].Cells["WLMS"].Value.ToString2();
- parm.BalYearMonth = ultraGrid1.Rows[i].Cells["YEAR_MONTH"].Value.ToString2();
- parm.CostPrice = Convert.ToDecimal(ultraGrid1.Rows[i].Cells["COST_PRICE"].Value.ToString3());
- parm.Memo = ultraGrid1.Rows[i].Cells["MEMO"].Value.ToString();
- if (ultraGrid1.Rows[i].Cells["create_name"].Value.ToString() == "")//判断是新增还是修改的保存
- {
- parm.CreateName = this.UserInfo.GetUserName();//新增保存
- string JsonStr = JSONFormat.Format(parm);
- ServerHelper.SetData("com.steering.pss.pncost.base.ComBaseGradePrice.isave", new object[] { JsonStr }, ob);
- }
- else
- {
- parm.UpdateName = this.UserInfo.GetUserName();//修改保存
- string JsonStr = JSONFormat.Format(parm);
- ServerHelper.SetData("com.steering.pss.pncost.base.ComBaseGradePrice.usave", 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["WLBM"].Value.ToString() == wuliao)
- {
- ultraGrid1.Rows[i].Activate();
- }
- }
- }
- /// 删除方法
- /// <summary>
- /// 删除方法
- /// </summary>
- private void Delete()
- {
- string wuliao = "";
- string xuanze = "false";
- try
- {
- #region 验证信息
- ultraGrid1.UpdateData();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["CHK"].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["CHK"].Value.ToString() == "True")
- {
- wuliao = ultraGrid1.Rows[i].Cells["WLBM"].Value.ToString2();
- CostBaseGradePriceEntity parm = new CostBaseGradePriceEntity();
- parm.WlId = ultraGrid1.Rows[i].Cells["WLBM"].Value.ToString2();
- parm.BalYearMonth = ultraGrid1.Rows[i].Cells["YEAR_MONTH"].Value.ToString2();
- parm.UpdateName = this.UserInfo.GetUserName();
- parm.DeleteName = this.UserInfo.GetUserName();
- string JsonStr = JSONFormat.Format(parm);
- ServerHelper.SetData("com.steering.pss.pncost.base.ComBaseGradePrice.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["WLBM"].Value.ToString() == wuliao)
- {
- ultraGrid1.Rows[i].Activate();
- }
- }
- }
- /// 恢复方法
- /// <summary>
- /// 恢复方法
- /// </summary>
- private void Resume()
- {
- string wuliao = "";
- string xuanze = "false";
- try
- {
- #region 验证信息
- ultraGrid1.UpdateData();
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells["CHK"].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["CHK"].Value.ToString() == "True")
- {
- wuliao = ultraGrid1.Rows[i].Cells["WLBM"].Value.ToString2();
- CostBaseGradePriceEntity parm = new CostBaseGradePriceEntity();
- parm.WlId = ultraGrid1.Rows[i].Cells["WLBM"].Value.ToString2();
- parm.BalYearMonth = ultraGrid1.Rows[i].Cells["YEAR_MONTH"].Value.ToString2();
- parm.UpdateName = this.UserInfo.GetUserName();
- string JsonStr = JSONFormat.Format(parm);
- ServerHelper.SetData("com.steering.pss.pncost.base.ComBaseGradePrice.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["WLBM"].Value.ToString() == wuliao)
- {
- 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 == "CHK")
- {
- GridEdite(e.Cell.Row);
- }
- }
- /// 选择判断
- /// <summary>
- /// 选择判断
- /// </summary>
- private void GridEdite(UltraGridRow row)
- {
- if (row.GetValue("CHK") == "True")
- {
- 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 == "CHK") continue;
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.ActivateOnly;
- }
- }
- }
- }
- #endregion
- }
- }
|