BaseKPI.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. using Core.Mes.Client.Comm.Server;
  2. using Core.Mes.Client.Comm.Tool;
  3. using CoreFS.CA06;
  4. using Infragistics.Win.UltraWinEditors;
  5. using Infragistics.Win.UltraWinGrid;
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. using Core.Mes.Client.Comm.Format;
  16. using Core.Mes.Client.Comm.Control;
  17. using com.steering.pss.kaohe.entity;
  18. namespace Core.StlMes.Client.KaoHe.BaseForm
  19. {
  20. public partial class BaseKPI : FrmBase
  21. {
  22. public BaseKPI()
  23. {
  24. InitializeComponent();
  25. }
  26. private void BaseKPI_Load(object sender, EventArgs e)
  27. {
  28. EntityHelper.ShowGridCaption<RpKaoheItemquanzhongEntity>(ug_KaoHeZhiBiao.DisplayLayout.Bands[0]);
  29. InitForm();
  30. }
  31. public override void ToolBar_Click(object sender, string ToolbarKey)
  32. {
  33. switch (ToolbarKey)
  34. {
  35. case "Query":
  36. QueryData();
  37. break;
  38. case "Save":
  39. SaveFormData();
  40. break;
  41. case "Delete":
  42. DeleteOrResume(true);
  43. break;
  44. case "Resume":
  45. DeleteOrResume(false);
  46. break;
  47. case "Close":
  48. this.Close();
  49. break;
  50. }
  51. }
  52. private void SaveFormData()
  53. {
  54. ug_KaoHeZhiBiao.UpdateData();
  55. UltraGridRow[] row = ug_KaoHeZhiBiao.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString().ToUpper() == "TRUE").ToArray();
  56. if (row.Length <= 0)
  57. {
  58. MessageUtil.ShowWarning("请选择需要保存的数据!");
  59. return;
  60. }
  61. if (row.Length > 0)
  62. {
  63. ArrayList parm = CheckFormData(row);
  64. if (parm == null || parm.Count <= 0)
  65. {
  66. return;
  67. }
  68. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存数据!") == DialogResult.No) return;
  69. int i = ServerHelper.SetData("com.steering.pss.kaohe.server.RpKaoheItemquanzhongDAL.Save",
  70. new object[] { parm }, this.ob);
  71. if (i > 0)
  72. {
  73. MessageUtil.ShowTips("数据保存成功!");
  74. QueryData();
  75. }
  76. else
  77. {
  78. MessageUtil.ShowTips("数据保存失败!");
  79. QueryData();
  80. }
  81. }
  82. }
  83. private ArrayList CheckFormData(UltraGridRow[] row)
  84. {
  85. ArrayList parm = new ArrayList();
  86. List<string> list = new List<string>();
  87. foreach (var uRow in row)
  88. {
  89. RpKaoheItemquanzhongEntity spf = (RpKaoheItemquanzhongEntity)uRow.ListObject;
  90. if (spf.Validflag == "无效" && spf.Updateby != "")
  91. {
  92. MessageUtil.ShowWarning("【" + spf.ItemName + "】的因素已经无效,不能修改!");
  93. return null;
  94. }
  95. if (spf.AwardMoney.ToString() == "")
  96. {
  97. MessageUtil.ShowWarning("奖励金额不许为空");
  98. return null;
  99. }
  100. if (spf.AwardMoney.ToString() != "" && !StringUtil.IsNumber(spf.AwardMoney.ToString()))
  101. {
  102. MessageUtil.ShowWarning("奖励金额必须为数字");
  103. return null;
  104. }
  105. 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))
  106. {
  107. MessageUtil.ShowWarning("奖励金额权重合计必须为100");
  108. return null;
  109. }
  110. spf.Createby = UserInfo.GetUserName();
  111. spf.Updateby = UserInfo.GetUserName();
  112. parm.Add(JSONFormat.Format(spf));
  113. }
  114. return parm;
  115. }
  116. private void QueryData()
  117. {
  118. string ITEM_NAME = "";
  119. string VALIDFLAG = "1";
  120. List<RpKaoheItemquanzhongEntity> rpKaoheItemquanzhongEntity = EntityHelper.GetData<RpKaoheItemquanzhongEntity>(
  121. "com.steering.pss.kaohe.server.RpKaoheItemquanzhongDAL.Query", new object[] { ITEM_NAME, VALIDFLAG }, this.ob);
  122. rpKaoheItemquanzhongEntityBindingSource.DataSource = rpKaoheItemquanzhongEntity;
  123. }
  124. private void InitForm()
  125. {
  126. UltraComboEditor uce = new UltraComboEditor();
  127. KaoHeClass.InitComboEditor(uce, "com.steering.pss.kaohe.server.RpKaoheItemquanzhongDAL.queryItemtype", "itemtypedesc", this.ob, false);
  128. ug_KaoHeZhiBiao.DisplayLayout.Bands[0].Columns["ItemType"].EditorComponent = uce;
  129. ug_KaoHeZhiBiao.DisplayLayout.Bands[0].Columns["ItemType"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  130. this.Controls.Add(uce);
  131. uce.Visible = false;
  132. }
  133. private void DeleteOrResume(bool flag)
  134. {
  135. ug_KaoHeZhiBiao.UpdateData();
  136. UltraGridRow[] row = ug_KaoHeZhiBiao.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString() == "True").ToArray();
  137. if (row.Length <= 0)
  138. {
  139. MessageUtil.ShowWarning("请选择需要" + (flag ? "删除" : "恢复") + "的数据!");
  140. return;
  141. }
  142. ArrayList parm = new ArrayList();
  143. if (flag)
  144. {
  145. foreach (var uRow in row)
  146. {
  147. RpKaoheItemquanzhongEntity spf = (RpKaoheItemquanzhongEntity)uRow.ListObject;
  148. if (spf.Validflag == "无效")
  149. {
  150. MessageUtil.ShowWarning("您勾选的数据中存在已删除的数据,不必重复删除!");
  151. return;
  152. }
  153. spf.Createby = UserInfo.GetUserName();
  154. spf.Updateby = UserInfo.GetUserName();
  155. spf.Validflag = "1";
  156. parm.Add(JSONFormat.Format(spf));
  157. }
  158. }
  159. else
  160. {
  161. foreach (var uRow in row)
  162. {
  163. RpKaoheItemquanzhongEntity spf = (RpKaoheItemquanzhongEntity)uRow.ListObject;
  164. if (spf.Validflag == "有效")
  165. {
  166. MessageUtil.ShowWarning("您勾选的数据中存在有效的数据,不必进行恢复!");
  167. return;
  168. }
  169. //恢复前判断是否存在相同因素名称的数据
  170. //DataTable dt = ServerHelper.GetData("com.steering.pss.sale.price.server.CorePriceFactor.canResume", new object[] { spf.FactorId, spf.FactorName }, this.ob);
  171. //if (dt != null && dt.Rows.Count > 0)
  172. //{
  173. // MessageUtil.ShowWarning("系统已存在名称为【" + spf.ItemName + "】并且有效的因素,不能恢复!");
  174. // return;
  175. //}
  176. spf.Createby = UserInfo.GetUserName();
  177. spf.Updateby = UserInfo.GetUserName();
  178. spf.Validflag = "0";
  179. parm.Add(JSONFormat.Format(spf));
  180. }
  181. }
  182. if (MessageUtil.ShowYesNoAndQuestion("是否" + (flag ? "删除" : "恢复") + "所选的数据!") == DialogResult.No) return;
  183. int i = ServerHelper.SetData("com.steering.pss.kaohe.server.RpKaoheItemquanzhongDAL.UpdateValidflag", new object[] { parm, flag.ToString() }, this.ob);
  184. if (i >= 0)
  185. {
  186. MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "成功!");
  187. QueryData();
  188. }
  189. else
  190. {
  191. MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "失败!");
  192. QueryData();
  193. }
  194. }
  195. private void ug_KaoHeZhiBiao_AfterRowInsert(object sender, RowEventArgs e)
  196. {
  197. string maxId = ug_KaoHeZhiBiao.Rows.AsQueryable().Max(a => a.Cells["ItemId"].Value.ToString());
  198. if (maxId == "")
  199. {
  200. e.Row.Cells["ItemId"].Value = "T000001";
  201. }
  202. else
  203. {
  204. string str = "T" + (Convert.ToInt32(maxId.Substring(1, 6)) + 1).ToString().PadLeft(6, '0');
  205. e.Row.Cells["ItemId"].Value = str;
  206. }
  207. }
  208. private void ug_KaoHeZhiBiao_InitializeRow(object sender, InitializeRowEventArgs e)
  209. {
  210. if (e.Row != null)
  211. {
  212. if (e.Row.Cells["VALIDFLAG"].Value.ToString() == "无效")
  213. {
  214. e.Row.Appearance.ForeColor = Color.Red;
  215. }
  216. else
  217. {
  218. e.Row.Appearance.ForeColor = Color.Black;
  219. }
  220. }
  221. }
  222. private void ug_KaoHeZhiBiao_AfterRowActivate(object sender, EventArgs e)
  223. {
  224. //UltraGridRow uRow = ug_KaoHeZhiBiao.ActiveRow;
  225. //if (uRow != null)
  226. //{
  227. // ug_KaoHeZhiBiao.UpdateData();
  228. // if (Convert.ToBoolean(uRow.Cells["CHK"].Value))
  229. // {
  230. // uRow.Cells["ITEM_TYPE"].Activation = Activation.AllowEdit;
  231. // uRow.Cells["ITEM_NAME"].Activation = Activation.AllowEdit;
  232. // uRow.Cells["AWARD_MONEY"].Activation = Activation.AllowEdit;
  233. // uRow.Cells["TEGANG"].Activation = Activation.AllowEdit;
  234. // uRow.Cells["ZHAGUAN"].Activation = Activation.AllowEdit;
  235. // uRow.Cells["GJG"].Activation = Activation.AllowEdit;
  236. // uRow.Cells["ZHIZAOBU"].Activation = Activation.AllowEdit;
  237. // uRow.Cells["GYGUANLI"].Activation = Activation.AllowEdit;
  238. // uRow.Cells["GANGYANSUO"].Activation = Activation.AllowEdit;
  239. // uRow.Cells["ZHIBAOBU"].Activation = Activation.AllowEdit;
  240. // }
  241. // else
  242. // {
  243. // uRow.Cells["ITEM_TYPE"].Activation = Activation.ActivateOnly;
  244. // uRow.Cells["ITEM_NAME"].Activation = Activation.ActivateOnly;
  245. // uRow.Cells["AWARD_MONEY"].Activation = Activation.ActivateOnly;
  246. // uRow.Cells["TEGANG"].Activation = Activation.ActivateOnly;
  247. // uRow.Cells["ZHAGUAN"].Activation = Activation.ActivateOnly;
  248. // uRow.Cells["GJG"].Activation = Activation.ActivateOnly;
  249. // uRow.Cells["ZHIZAOBU"].Activation = Activation.ActivateOnly;
  250. // uRow.Cells["GYGUANLI"].Activation = Activation.ActivateOnly;
  251. // uRow.Cells["GANGYANSUO"].Activation = Activation.ActivateOnly;
  252. // uRow.Cells["ZHIBAOBU"].Activation = Activation.ActivateOnly;
  253. // }
  254. //}
  255. }
  256. }
  257. }