FrmPriceBaseSuit.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. using com.steering.pss.sale.price.entity;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using CoreFS.CA06;
  5. using Infragistics.Win.UltraWinEditors;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using System.ComponentModel;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Windows.Forms;
  16. using Core.Mes.Client.Comm.Format;
  17. namespace Core.StlMes.Client.SalePrice.BaseForm
  18. {
  19. public partial class FrmPriceBaseSuit : FrmBase
  20. {
  21. string isValid = "1";
  22. public FrmPriceBaseSuit()
  23. {
  24. InitializeComponent();
  25. }
  26. private void FrmPriceBaseSuit_Load(object sender, EventArgs e)
  27. {
  28. EntityHelper.ShowGridCaption<SlmPriceBasesuitEntity>(gdBaseSuit.DisplayLayout.Bands[0]);
  29. InitForm();
  30. }
  31. private void InitForm()
  32. {
  33. UltraComboEditor uce = new UltraComboEditor();
  34. SalePriceClass.InitComboEditor(uce, "com.steering.pss.sale.price.server.CorePriceFactor.queryTableName", "TABLE_NAME", this.ob, false);
  35. gdBaseSuit.DisplayLayout.Bands[0].Columns["TABLENAME"].EditorComponent = uce;
  36. gdBaseSuit.DisplayLayout.Bands[0].Columns["TABLENAME"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  37. this.Controls.Add(uce);
  38. uce.Visible = false;
  39. UltraComboEditor uce1 = new UltraComboEditor();
  40. SalePriceClass.InitComboEditorWithParm(uce1, "com.steering.pss.sale.price.server.CorePriceFactor.queryBaseInfo", "BASECODE", "BASENAME", this.ob, true, new object[] { "1231" });
  41. gdBaseSuit.DisplayLayout.Bands[0].Columns["VERTYPE"].EditorComponent = uce1;
  42. gdBaseSuit.DisplayLayout.Bands[0].Columns["VERTYPE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  43. this.Controls.Add(uce1);
  44. uce1.Visible = false;
  45. }
  46. public override void ToolBar_Click(object sender, string ToolbarKey)
  47. {
  48. switch (ToolbarKey)
  49. {
  50. case "Query":
  51. QueryData();
  52. break;
  53. case "Save":
  54. SaveFormData();
  55. break;
  56. case "Delete":
  57. DeleteOrResume(true);
  58. break;
  59. case "Resume":
  60. DeleteOrResume(false);
  61. break;
  62. case "Close":
  63. this.Close();
  64. break;
  65. }
  66. }
  67. private void gdBaseSuit_InitializeRow(object sender, InitializeRowEventArgs e)
  68. {
  69. if (e.Row != null)
  70. {
  71. string tabName = e.Row.Cells["TABLENAME"].Value.ToString();
  72. UltraComboEditor uce = new UltraComboEditor();
  73. SalePriceClass.InitComboEditorWithParm(uce, "com.steering.pss.sale.price.server.CorePriceFactor.queryColumnName", "COLUMN_NAME", "COLUMN_NAME", this.ob, false, new object[] { tabName });
  74. gdBaseSuit.DisplayLayout.Bands[0].Columns["COLUMNKEY"].EditorComponent = uce;
  75. gdBaseSuit.DisplayLayout.Bands[0].Columns["COLUMNKEY"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  76. this.Controls.Add(uce);
  77. uce.Visible = false;
  78. if (e.Row.Cells["VALIDFLAG"].Value.ToString() == "无效")
  79. {
  80. e.Row.Appearance.ForeColor = Color.Red;
  81. }
  82. else
  83. {
  84. e.Row.Appearance.ForeColor = Color.Black;
  85. }
  86. }
  87. }
  88. private void gdBaseSuit_CellChange(object sender, CellEventArgs e)
  89. {
  90. gdBaseSuit.UpdateData();
  91. if (e.Cell.Column.Key.ToUpper().Equals("COLUMNKEY"))
  92. {
  93. string tabName = e.Cell.Row.Cells["TABLENAME"].Value.ToString();
  94. string colName = e.Cell.Value.ToString();
  95. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.price.server.CorePriceFactor.queryColumnType", new object[] { tabName, colName }, this.ob);
  96. if (dt != null && dt.Rows.Count > 0)
  97. {
  98. string dataType = dt.Rows[0][0].ToString2().ToUpper();
  99. e.Cell.Row.Cells["COLUMNTYPE"].Value = SalePriceClass.GetColumnType(dataType);
  100. }
  101. else
  102. {
  103. e.Cell.Row.Cells["COLUMNTYPE"].Value = "";
  104. }
  105. }
  106. else if (e.Cell.Column.Key.ToUpper().Equals("CHK"))
  107. {
  108. if (Convert.ToBoolean(e.Cell.Value))
  109. {
  110. e.Cell.Row.Cells["SuitName"].Activation = Activation.AllowEdit;
  111. e.Cell.Row.Cells["TABLENAME"].Activation = Activation.AllowEdit;
  112. e.Cell.Row.Cells["COLUMNKEY"].Activation = Activation.AllowEdit;
  113. e.Cell.Row.Cells["VALSQL"].Activation = Activation.AllowEdit;
  114. e.Cell.Row.Cells["VERTYPE"].Activation = Activation.AllowEdit;
  115. }
  116. else
  117. {
  118. e.Cell.Row.Cells["SuitName"].Activation = Activation.ActivateOnly;
  119. e.Cell.Row.Cells["TABLENAME"].Activation = Activation.ActivateOnly;
  120. e.Cell.Row.Cells["COLUMNKEY"].Activation = Activation.ActivateOnly;
  121. e.Cell.Row.Cells["VALSQL"].Activation = Activation.ActivateOnly;
  122. e.Cell.Row.Cells["VERTYPE"].Activation = Activation.ActivateOnly;
  123. }
  124. }
  125. else if (e.Cell.Column.Key.ToUpper().Equals("TABLENAME"))
  126. {
  127. e.Cell.Row.Cells["COLUMNKEY"].Value = "";
  128. }
  129. }
  130. private void gdBaseSuit_AfterRowActivate(object sender, EventArgs e)
  131. {
  132. UltraGridRow uRow = gdBaseSuit.ActiveRow;
  133. if (uRow != null)
  134. {
  135. gdBaseSuit.UpdateData();
  136. if (Convert.ToBoolean(uRow.Cells["CHK"].Value))
  137. {
  138. uRow.Cells["SuitName"].Activation = Activation.AllowEdit;
  139. uRow.Cells["TABLENAME"].Activation = Activation.AllowEdit;
  140. uRow.Cells["COLUMNKEY"].Activation = Activation.AllowEdit;
  141. uRow.Cells["VALSQL"].Activation = Activation.AllowEdit;
  142. uRow.Cells["VERTYPE"].Activation = Activation.AllowEdit;
  143. }
  144. else
  145. {
  146. uRow.Cells["SuitName"].Activation = Activation.ActivateOnly;
  147. uRow.Cells["TABLENAME"].Activation = Activation.ActivateOnly;
  148. uRow.Cells["COLUMNKEY"].Activation = Activation.ActivateOnly;
  149. uRow.Cells["VALSQL"].Activation = Activation.ActivateOnly;
  150. uRow.Cells["VERTYPE"].Activation = Activation.ActivateOnly;
  151. }
  152. }
  153. }
  154. private void gdBaseSuit_AfterRowInsert(object sender, RowEventArgs e)
  155. {
  156. string maxId = gdBaseSuit.Rows.AsQueryable().Max(a => a.Cells["SUITID"].Value.ToString());
  157. if (maxId == "")
  158. {
  159. e.Row.Cells["SUITID"].Value = "S000001";
  160. }
  161. else
  162. {
  163. string str = "S" + (Convert.ToInt32(maxId.Substring(1, 6)) + 1).ToString().PadLeft(6, '0');
  164. e.Row.Cells["SUITID"].Value = str;
  165. }
  166. }
  167. private void SaveFormData()
  168. {
  169. gdBaseSuit.UpdateData();
  170. UltraGridRow[] row = gdBaseSuit.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString().ToUpper() == "TRUE").ToArray();
  171. if (row.Length <= 0)
  172. {
  173. MessageUtil.ShowWarning("请选择需要保存的数据!");
  174. return;
  175. }
  176. ArrayList parm = CheckFormData(row);
  177. if (parm == null || parm.Count <= 0)
  178. {
  179. return;
  180. }
  181. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存数据!") == DialogResult.No) return;
  182. int i = ServerHelper.SetData("com.steering.pss.sale.price.server.CorePriceBaseSuit.save",
  183. new object[] { parm }, this.ob);
  184. if (i > 0)
  185. {
  186. MessageUtil.ShowTips("数据保存成功!");
  187. QueryData();
  188. }
  189. else
  190. {
  191. MessageUtil.ShowTips("数据保存失败!");
  192. QueryData();
  193. }
  194. }
  195. /// <summary>
  196. /// 验证界面数据
  197. /// </summary>
  198. /// <param name="row">界面数据</param>
  199. /// <returns></returns>
  200. private ArrayList CheckFormData(UltraGridRow[] row)
  201. {
  202. ArrayList parm = new ArrayList();
  203. List<string> list = new List<string>();
  204. foreach (var uRow in row)
  205. {
  206. SlmPriceBasesuitEntity spf = (SlmPriceBasesuitEntity)uRow.ListObject;
  207. if (spf.Validflag == "无效" && spf.CreateName != "")
  208. {
  209. MessageUtil.ShowWarning("【" + spf.SuitId + "】的因素已经无效,不能修改!");
  210. return null;
  211. }
  212. if (spf.SuitName == "")
  213. {
  214. MessageUtil.ShowWarning("请输入【" + spf.SuitId + "】的因素名称!");
  215. return null;
  216. }
  217. if (spf.VerType == "")
  218. {
  219. MessageUtil.ShowWarning("请选择【" + spf.SuitId + "】的版本类型!");
  220. return null;
  221. }
  222. //判断因素名称是否重复
  223. parm.Add(JSONFormat.Format(spf));
  224. }
  225. return parm;
  226. }
  227. /// <summary>
  228. /// 查询
  229. /// </summary>
  230. private void QueryData()
  231. {
  232. string SuitId = "";
  233. string SuitName = "";
  234. if (labelTextBox1.Checked)
  235. SuitName = labelTextBox1.Text.Trim();
  236. if (labelTextBox2.Checked)
  237. SuitId = labelTextBox2.Text.Trim();
  238. List<SlmPriceBasesuitEntity> list = EntityHelper.GetData<SlmPriceBasesuitEntity>(
  239. "com.steering.pss.sale.price.server.CorePriceBaseSuit.query", new object[] { SuitId, SuitName, isValid }, this.ob);
  240. slmPriceBasesuitEntityBindingSource.DataSource = list;
  241. }
  242. private void chkValid_CheckedChanged(object sender, EventArgs e)
  243. {
  244. if (chkValid.Checked)
  245. {
  246. isValid = "0";
  247. }
  248. else
  249. {
  250. isValid = "1";
  251. }
  252. }
  253. private void DeleteOrResume(bool flag)
  254. {
  255. gdBaseSuit.UpdateData();
  256. UltraGridRow[] row = gdBaseSuit.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString() == "True").ToArray();
  257. if (row.Length <= 0)
  258. {
  259. MessageUtil.ShowWarning("请选择需要" + (flag ? "删除" : "恢复") + "的数据!");
  260. return;
  261. }
  262. ArrayList parm = new ArrayList();
  263. if (flag)
  264. {
  265. foreach (var uRow in row)
  266. {
  267. SlmPriceBasesuitEntity spf = (SlmPriceBasesuitEntity)uRow.ListObject;
  268. if (spf.Validflag == "无效")
  269. {
  270. MessageUtil.ShowWarning("您勾选的数据中存在已删除的数据,不必重复删除!");
  271. return;
  272. }
  273. spf.CreateName = UserInfo.GetUserName();
  274. spf.UpdateName = UserInfo.GetUserName();
  275. parm.Add(JSONFormat.Format(spf));
  276. }
  277. }
  278. else
  279. {
  280. foreach (var uRow in row)
  281. {
  282. SlmPriceBasesuitEntity spf = (SlmPriceBasesuitEntity)uRow.ListObject;
  283. if (spf.Validflag == "有效")
  284. {
  285. MessageUtil.ShowWarning("您勾选的数据中存在有效的数据,不必进行恢复!");
  286. return;
  287. }
  288. spf.CreateName = UserInfo.GetUserName();
  289. spf.UpdateName = UserInfo.GetUserName();
  290. parm.Add(JSONFormat.Format(spf));
  291. }
  292. }
  293. if (MessageUtil.ShowYesNoAndQuestion("是否" + (flag ? "删除" : "恢复") + "所选的数据!") == DialogResult.No) return;
  294. int i = ServerHelper.SetData("com.steering.pss.sale.price.server.CorePriceBaseSuit.deleteOrResume", new object[] { parm, flag }, this.ob);
  295. if (i >= 0)
  296. {
  297. MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "成功!");
  298. QueryData();
  299. }
  300. else
  301. {
  302. MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "失败!");
  303. QueryData();
  304. }
  305. }
  306. }
  307. }