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 com.steering.pss.kaohe.entity; namespace Core.StlMes.Client.KaoHe.BaseForm { public partial class BaseKPI : FrmBase { public BaseKPI() { InitializeComponent(); } private void BaseKPI_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ug_KaoHeZhiBiao.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; } } private void SaveFormData() { ug_KaoHeZhiBiao.UpdateData(); UltraGridRow[] row = ug_KaoHeZhiBiao.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.kaohe.server.RpKaoheItemquanzhongDAL.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 list = new List(); foreach (var uRow in row) { RpKaoheItemquanzhongEntity spf = (RpKaoheItemquanzhongEntity)uRow.ListObject; if (spf.Validflag == "无效" && spf.Updateby != "") { MessageUtil.ShowWarning("【" + spf.ItemName + "】的因素已经无效,不能修改!"); return null; } if (spf.AwardMoney.ToString() == "") { MessageUtil.ShowWarning("奖励金额不许为空"); return null; } if (spf.AwardMoney.ToString() != "" && !StringUtil.IsNumber(spf.AwardMoney.ToString())) { MessageUtil.ShowWarning("奖励金额必须为数字"); return null; } if ((KaoHeClass.NullToZero(spf.Tegang.ToString()) + KaoHeClass.NullToZero(spf.Zhaguan.ToString()) + KaoHeClass.NullToZero(spf.Gjg.ToString()) + KaoHeClass.NullToZero(spf.Gyguanli.ToString()) + KaoHeClass.NullToZero(spf.Zhibaobu.ToString()) + KaoHeClass.NullToZero(spf.Zhizaobu.ToString()) + KaoHeClass.NullToZero(spf.Gangyansuo.ToString())!=100)) { MessageUtil.ShowWarning("奖励金额权重合计必须为100"); return null; } spf.Createby = UserInfo.GetUserName(); spf.Updateby = UserInfo.GetUserName(); parm.Add(JSONFormat.Format(spf)); } return parm; } private void QueryData() { string ITEM_NAME = ""; string VALIDFLAG = "1"; List rpKaoheItemquanzhongEntity = EntityHelper.GetData( "com.steering.pss.kaohe.server.RpKaoheItemquanzhongDAL.Query", new object[] { ITEM_NAME, VALIDFLAG }, this.ob); rpKaoheItemquanzhongEntityBindingSource.DataSource = rpKaoheItemquanzhongEntity; } private void InitForm() { UltraComboEditor uce = new UltraComboEditor(); KaoHeClass.InitComboEditor(uce, "com.steering.pss.kaohe.server.RpKaoheItemquanzhongDAL.queryItemtype", "itemtypedesc", this.ob, false); ug_KaoHeZhiBiao.DisplayLayout.Bands[0].Columns["ItemType"].EditorComponent = uce; ug_KaoHeZhiBiao.DisplayLayout.Bands[0].Columns["ItemType"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; this.Controls.Add(uce); uce.Visible = false; } private void DeleteOrResume(bool flag) { ug_KaoHeZhiBiao.UpdateData(); UltraGridRow[] row = ug_KaoHeZhiBiao.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) { RpKaoheItemquanzhongEntity spf = (RpKaoheItemquanzhongEntity)uRow.ListObject; if (spf.Validflag == "无效") { MessageUtil.ShowWarning("您勾选的数据中存在已删除的数据,不必重复删除!"); return; } spf.Createby = UserInfo.GetUserName(); spf.Updateby = UserInfo.GetUserName(); spf.Validflag = "1"; parm.Add(JSONFormat.Format(spf)); } } else { foreach (var uRow in row) { RpKaoheItemquanzhongEntity spf = (RpKaoheItemquanzhongEntity)uRow.ListObject; if (spf.Validflag == "有效") { MessageUtil.ShowWarning("您勾选的数据中存在有效的数据,不必进行恢复!"); return; } //恢复前判断是否存在相同因素名称的数据 //DataTable dt = ServerHelper.GetData("com.steering.pss.sale.price.server.CorePriceFactor.canResume", new object[] { spf.FactorId, spf.FactorName }, this.ob); //if (dt != null && dt.Rows.Count > 0) //{ // MessageUtil.ShowWarning("系统已存在名称为【" + spf.ItemName + "】并且有效的因素,不能恢复!"); // return; //} spf.Createby = UserInfo.GetUserName(); spf.Updateby = UserInfo.GetUserName(); spf.Validflag = "0"; parm.Add(JSONFormat.Format(spf)); } } if (MessageUtil.ShowYesNoAndQuestion("是否" + (flag ? "删除" : "恢复") + "所选的数据!") == DialogResult.No) return; int i = ServerHelper.SetData("com.steering.pss.kaohe.server.RpKaoheItemquanzhongDAL.UpdateValidflag", new object[] { parm, flag.ToString() }, this.ob); if (i >= 0) { MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "成功!"); QueryData(); } else { MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "失败!"); QueryData(); } } private void ug_KaoHeZhiBiao_AfterRowInsert(object sender, RowEventArgs e) { string maxId = ug_KaoHeZhiBiao.Rows.AsQueryable().Max(a => a.Cells["ItemId"].Value.ToString()); if (maxId == "") { e.Row.Cells["ItemId"].Value = "T000001"; } else { string str = "T" + (Convert.ToInt32(maxId.Substring(1, 6)) + 1).ToString().PadLeft(6, '0'); e.Row.Cells["ItemId"].Value = str; } } private void ug_KaoHeZhiBiao_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 ug_KaoHeZhiBiao_AfterRowActivate(object sender, EventArgs e) { //UltraGridRow uRow = ug_KaoHeZhiBiao.ActiveRow; //if (uRow != null) //{ // ug_KaoHeZhiBiao.UpdateData(); // if (Convert.ToBoolean(uRow.Cells["CHK"].Value)) // { // uRow.Cells["ITEM_TYPE"].Activation = Activation.AllowEdit; // uRow.Cells["ITEM_NAME"].Activation = Activation.AllowEdit; // uRow.Cells["AWARD_MONEY"].Activation = Activation.AllowEdit; // uRow.Cells["TEGANG"].Activation = Activation.AllowEdit; // uRow.Cells["ZHAGUAN"].Activation = Activation.AllowEdit; // uRow.Cells["GJG"].Activation = Activation.AllowEdit; // uRow.Cells["ZHIZAOBU"].Activation = Activation.AllowEdit; // uRow.Cells["GYGUANLI"].Activation = Activation.AllowEdit; // uRow.Cells["GANGYANSUO"].Activation = Activation.AllowEdit; // uRow.Cells["ZHIBAOBU"].Activation = Activation.AllowEdit; // } // else // { // uRow.Cells["ITEM_TYPE"].Activation = Activation.ActivateOnly; // uRow.Cells["ITEM_NAME"].Activation = Activation.ActivateOnly; // uRow.Cells["AWARD_MONEY"].Activation = Activation.ActivateOnly; // uRow.Cells["TEGANG"].Activation = Activation.ActivateOnly; // uRow.Cells["ZHAGUAN"].Activation = Activation.ActivateOnly; // uRow.Cells["GJG"].Activation = Activation.ActivateOnly; // uRow.Cells["ZHIZAOBU"].Activation = Activation.ActivateOnly; // uRow.Cells["GYGUANLI"].Activation = Activation.ActivateOnly; // uRow.Cells["GANGYANSUO"].Activation = Activation.ActivateOnly; // uRow.Cells["ZHIBAOBU"].Activation = Activation.ActivateOnly; // } //} } } }