FrmPriceAddPrice.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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. using Core.Mes.Client.Comm.Control;
  18. using Core.StlMes.Client.SalePrice.dialog;
  19. namespace Core.StlMes.Client.SalePrice.BaseForm
  20. {
  21. public partial class FrmPriceAddPrice : FrmBase
  22. {
  23. string isValid = "1";
  24. public FrmPriceAddPrice()
  25. {
  26. InitializeComponent();
  27. }
  28. private void FrmPriceAddPrice_Load(object sender, EventArgs e)
  29. {
  30. EntityHelper.ShowGridCaption<SlmPriceAddpriceHeadEntity>(ugPriceAddHead.DisplayLayout.Bands[0]);
  31. EntityHelper.ShowGridCaption<SlmPriceAddpriceLineEntity>(ugPriceAddLine.DisplayLayout.Bands[0]);
  32. InitCombo();
  33. }
  34. private void InitCombo()
  35. {
  36. UltraComboEditor uce1 = new UltraComboEditor();
  37. SalePriceClass.InitComboEditorWithParm(uce1, "com.steering.pss.sale.price.server.CorePriceFactor.queryBaseInfo", "BASECODE", "BASENAME", this.ob, true, new object[] { "1229" });
  38. ugPriceAddHead.DisplayLayout.Bands[0].Columns["PriceaddType"].EditorComponent = uce1;
  39. ugPriceAddHead.DisplayLayout.Bands[0].Columns["PriceaddType"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  40. this.Controls.Add(uce1);
  41. uce1.Visible = false;
  42. //UltraComboEditor uce2 = new UltraComboEditor();
  43. //SalePriceClass.InitComboEditorWithParm(uce2, "com.steering.pss.sale.price.server.CorePriceFactor.queryBaseInfo", "BASECODE", "BASENAME", this.ob, true, new object[] { "1230" });
  44. //ugPriceAddLine.DisplayLayout.Bands[0].Columns["PriceaddClassify"].EditorComponent = uce2;
  45. //ugPriceAddLine.DisplayLayout.Bands[0].Columns["PriceaddClassify"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  46. //this.Controls.Add(uce2);
  47. //uce2.Visible = false;
  48. string VerType = "123102";//1为 适用项目 2为 加价优惠分类
  49. UltraComboEditor uce2 = new UltraComboEditor();
  50. SalePriceClass.InitComboEditorWithParm(uce2, "com.steering.pss.sale.price.server.CorePriceBaseSuit.GetSUITCLASSIFY", "SUIT_ID", "SUIT_NAME", this.ob, true, new object[] { VerType });
  51. ugPriceAddLine.DisplayLayout.Bands[0].Columns["PriceaddClassify"].EditorComponent = uce2;
  52. ugPriceAddLine.DisplayLayout.Bands[0].Columns["PriceaddClassify"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  53. this.Controls.Add(uce2);
  54. uce2.Visible = false;
  55. }
  56. private void chkValid_CheckedChanged(object sender, EventArgs e)
  57. {
  58. if (chkValid.Checked)
  59. {
  60. isValid = "0";
  61. }
  62. else
  63. {
  64. isValid = "1";
  65. }
  66. }
  67. public override void ToolBar_Click(object sender, string ToolbarKey)
  68. {
  69. switch (ToolbarKey)
  70. {
  71. case "Query":
  72. QueryData();
  73. break;
  74. case "Save":
  75. SaveFormData();
  76. break;
  77. case "Delete":
  78. DeleteOrResume(true);
  79. break;
  80. case "Resume":
  81. DeleteOrResume(false);
  82. break;
  83. case "Close":
  84. this.Close();
  85. break;
  86. }
  87. }
  88. private void DeleteOrResume(bool flag)
  89. {
  90. ugPriceAddHead.UpdateData();
  91. ugPriceAddLine.UpdateData();
  92. UltraGridRow[] row = ugPriceAddHead.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString().ToUpper() == "TRUE").ToArray();
  93. UltraGridRow[] row_price = GridHelper.GetRowsWithKey(ugPriceAddLine, new string[] { "CHK" }, new string[] { "True" });
  94. if (row.Length <= 0 && row_price.Length <= 0)
  95. {
  96. MessageUtil.ShowWarning("请选择需要" + (flag ? "删除" : "恢复") + "的数据!");
  97. return;
  98. }
  99. ArrayList parm = new ArrayList();
  100. ArrayList parm_price = new ArrayList();
  101. if (flag)
  102. {
  103. foreach (var uRow in row)
  104. {
  105. SlmPriceAddpriceHeadEntity spf = new SlmPriceAddpriceHeadEntity(); ;
  106. spf.PriceaddId = uRow.Cells["PriceaddId"].Text.ToString();
  107. if (spf.Validflag == "无效")
  108. {
  109. MessageUtil.ShowWarning("您勾选的数据中存在已删除的数据,不必重复删除!");
  110. return;
  111. }
  112. spf.CreateName = UserInfo.GetUserName();
  113. spf.UpdateName = UserInfo.GetUserName();
  114. parm.Add(JSONFormat.Format(spf));
  115. }
  116. foreach (var uRow_p in row_price)
  117. {
  118. SlmPriceAddpriceLineEntity spf_p = (SlmPriceAddpriceLineEntity)uRow_p.ListObject;
  119. if (spf_p.Validflag == "无效")
  120. {
  121. MessageUtil.ShowWarning("您勾选的数据中存在已删除的数据,不必重复删除!");
  122. return;
  123. }
  124. spf_p.CreateName = UserInfo.GetUserName();
  125. spf_p.UpdateName = UserInfo.GetUserName();
  126. parm_price.Add(JSONFormat.Format(spf_p));
  127. }
  128. }
  129. else
  130. {
  131. foreach (var uRow in row)
  132. {
  133. SlmPriceAddpriceHeadEntity spf = new SlmPriceAddpriceHeadEntity(); ;
  134. spf.PriceaddId = uRow.Cells["PriceaddId"].Text.ToString();
  135. if (spf.Validflag == "有效")
  136. {
  137. MessageUtil.ShowWarning("您勾选的数据中存在有效的数据,不必进行恢复!");
  138. return;
  139. }
  140. spf.CreateName = UserInfo.GetUserName();
  141. spf.UpdateName = UserInfo.GetUserName();
  142. parm.Add(JSONFormat.Format(spf));
  143. }
  144. foreach (var uRow_p in row_price)
  145. {
  146. SlmPriceAddpriceLineEntity spf_p = (SlmPriceAddpriceLineEntity)uRow_p.ListObject;
  147. if (spf_p.Validflag == "有效")
  148. {
  149. MessageUtil.ShowWarning("您勾选的数据中存在有效的数据,不必进行恢复!");
  150. return;
  151. }
  152. spf_p.CreateName = UserInfo.GetUserName();
  153. spf_p.UpdateName = UserInfo.GetUserName();
  154. parm_price.Add(JSONFormat.Format(spf_p));
  155. }
  156. }
  157. if (MessageUtil.ShowYesNoAndQuestion("是否" + (flag ? "删除" : "恢复") + "所选的数据!") == DialogResult.No) return;
  158. int i = ServerHelper.SetData("com.steering.pss.sale.price.server.CorePriceAddPriceHead.deleteOrResume", new object[] { parm, parm_price, flag }, this.ob);
  159. if (i >= 0)
  160. {
  161. MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "成功!");
  162. QueryData();
  163. }
  164. else
  165. {
  166. MessageUtil.ShowTips("数据" + (flag ? "删除" : "恢复") + "失败!");
  167. QueryData();
  168. }
  169. }
  170. private void SaveFormData()
  171. {
  172. ugPriceAddHead.UpdateData();
  173. ugPriceAddLine.UpdateData();
  174. UltraGridRow[] row = ugPriceAddHead.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString().ToUpper() == "TRUE").ToArray();
  175. UltraGridRow[] row_price = GridHelper.GetRowsWithKey(ugPriceAddLine, new string[] { "CHK" }, new string[] { "True" });
  176. if (row.Length <= 0 && row_price.Length <= 0)
  177. {
  178. MessageUtil.ShowWarning("请选择需要保存的数据!");
  179. return;
  180. }
  181. ArrayList parm = CheckFormData(row);
  182. ArrayList parm_price = CheckFormData_price(row_price);
  183. //if (parm == null || parm.Count <= 0 )
  184. //{
  185. // return;
  186. //}
  187. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存数据!") == DialogResult.No) return;
  188. int i = ServerHelper.SetData("com.steering.pss.sale.price.server.CorePriceAddPriceHead.save",
  189. new object[] { parm, parm_price }, this.ob);
  190. if (i > 0)
  191. {
  192. MessageUtil.ShowTips("数据保存成功!");
  193. QueryData();
  194. }
  195. else
  196. {
  197. MessageUtil.ShowTips("数据保存失败!");
  198. QueryData();
  199. }
  200. }
  201. private ArrayList CheckFormData_price(UltraGridRow[] row_price)
  202. {
  203. ArrayList parm = new ArrayList();
  204. List<string> list = new List<string>();
  205. foreach (var uRow in row_price)
  206. {
  207. SlmPriceAddpriceLineEntity spf = (SlmPriceAddpriceLineEntity)uRow.ListObject;
  208. spf.CreateName = UserInfo.GetUserName();
  209. spf.UpdateName = UserInfo.GetUserName();
  210. spf.Validflag = uRow.Cells["VALIDFLAG"].Text.ToString();
  211. if (spf.Validflag == "无效" && spf.CreateName != "")
  212. {
  213. MessageUtil.ShowWarning("【" + spf.PriceaddLineId + "】的因素已经无效,不能修改!");
  214. return null;
  215. }
  216. parm.Add(JSONFormat.Format(spf));
  217. }
  218. return parm;
  219. }
  220. private ArrayList CheckFormData(UltraGridRow[] row)
  221. {
  222. ArrayList parm = new ArrayList();
  223. List<string> list = new List<string>();
  224. foreach (var uRow in row)
  225. {
  226. SlmPriceAddpriceHeadEntity spf = (SlmPriceAddpriceHeadEntity)uRow.ListObject;
  227. spf.CreateName = UserInfo.GetUserName();
  228. spf.UpdateName = UserInfo.GetUserName();
  229. spf.Validflag = uRow.Cells["VALIDFLAG"].Text.ToString();
  230. if (spf.Validflag == "无效" && spf.CreateName != "")
  231. {
  232. MessageUtil.ShowWarning("【" + spf.PriceaddId + "】的因素已经无效,不能修改!");
  233. return null;
  234. }
  235. parm.Add(JSONFormat.Format(spf));
  236. }
  237. return parm;
  238. }
  239. private void QueryData()
  240. {
  241. string PriceAdd_ID = "";
  242. string PriceAdd_Desc = "";
  243. if (labelTextBox1.Checked)
  244. PriceAdd_Desc = labelTextBox1.Text.Trim();
  245. if (labelTextBox2.Checked)
  246. PriceAdd_ID = labelTextBox2.Text.Trim();
  247. List<SlmPriceAddpriceHeadEntity> list = EntityHelper.GetData<SlmPriceAddpriceHeadEntity>(
  248. "com.steering.pss.sale.price.server.CorePriceAddPriceHead.query", new object[] { PriceAdd_ID, PriceAdd_Desc, isValid }, this.ob);
  249. slmPriceAddpriceHeadEntityBindingSource.DataSource = list;
  250. UltraGridBand ugb = this.ugPriceAddHead.DisplayLayout.Bands[0];
  251. UltraGridColumn[] col = new UltraGridColumn[] { ugb.Columns["PriceaddDesc"] };
  252. GridHelper.RefreshAndAutoSizeExceptColumns(ugPriceAddHead, col);
  253. }
  254. private void ugPriceAddHead_AfterRowActivate(object sender, EventArgs e)
  255. {
  256. if (ugPriceAddHead.ActiveRow.Cells["PriceaddId"].Value.ToString() != "")
  257. {
  258. string PriceAdd_ID = ugPriceAddHead.ActiveRow.Cells["PriceaddId"].Value.ToString();
  259. QueryDataLine(PriceAdd_ID, isValid);
  260. }
  261. }
  262. private void QueryDataLine(string PriceAdd_ID, string isValid)
  263. {
  264. List<SlmPriceAddpriceLineEntity> list = EntityHelper.GetData<SlmPriceAddpriceLineEntity>(
  265. "com.steering.pss.sale.price.server.CorePriceAddPriceHead.queryById", new object[] { PriceAdd_ID, isValid }, this.ob);
  266. slmPriceAddpriceLineEntityBindingSource.DataSource = list;
  267. UltraGridBand ugb = this.ugPriceAddLine.DisplayLayout.Bands[0];
  268. UltraGridColumn[] col = new UltraGridColumn[] { ugb.Columns["PriceaddId"] };
  269. GridHelper.RefreshAndAutoSizeExceptColumns(ugPriceAddLine, col);
  270. }
  271. private void ugPriceAddLine_InitializeRow(object sender, InitializeRowEventArgs e)
  272. {
  273. if (e.Row != null)
  274. {
  275. string PriceaddClassify = e.Row.Cells["PriceaddClassify"].Value.ToString();
  276. // suitValueBind(PriceaddClassify);
  277. DataTable SuitInfo = ServerHelper.GetData("com.steering.pss.sale.price.server.CorePriceBaseSuit.GetSuitInfo", new object[] { PriceaddClassify }, this.ob);
  278. if (SuitInfo != null && SuitInfo.Rows.Count > 0 && SuitInfo.Rows[0]["Table_Name"].ToString() != "")
  279. {
  280. UltraComboEditor uce1 = new UltraComboEditor();
  281. string sql_getFactorBind = "";
  282. string TableName = SuitInfo.Rows[0]["TABLE_NAME"].ToString();
  283. string DataValue = SuitInfo.Rows[0]["COLUMN_KEY"].ToString();
  284. string DataDesc = SuitInfo.Rows[0]["COLUMN_NAME"].ToString();
  285. string sql_getSQL = SuitInfo.Rows[0]["VAL_SQL"].ToString();
  286. DataTable dtFactor = ServerHelper.GetData("com.steering.pss.sale.price.server.CorePriceBaseSuit.FactorBind", new object[] { TableName, DataValue, DataDesc, sql_getSQL }, this.ob);
  287. if (dtFactor != null && dtFactor.Rows.Count > 0)
  288. {
  289. Object[] obj = new Object[] { "", "" };
  290. DataRow dr = dtFactor.NewRow();
  291. dr.ItemArray = obj;
  292. dtFactor.Rows.InsertAt(dr, 0);
  293. uce1.DataSource = dtFactor;
  294. uce1.DataMember = "";
  295. uce1.ValueMember = DataValue;
  296. uce1.DisplayMember = DataDesc;
  297. ClsBaseInfo.SetComboItemHeight(uce1);
  298. }
  299. //ugPriceAddLine.DisplayLayout.Bands[0].Columns["PriceaddItem"].EditorComponent = uce1;
  300. //ugPriceAddLine.DisplayLayout.Bands[0].Columns["PriceaddItem"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  301. e.Row.Cells["PriceaddItem"].EditorComponent = uce1;
  302. e.Row.Cells["PriceaddItem"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  303. this.Controls.Add(uce1);
  304. uce1.Visible = false;
  305. }
  306. if (e.Row.Cells["VALIDFLAG"].Value.ToString() == "无效")
  307. {
  308. e.Row.Appearance.ForeColor = Color.Red;
  309. }
  310. else
  311. {
  312. e.Row.Appearance.ForeColor = Color.Black;
  313. }
  314. }
  315. }
  316. private void ugPriceAddLine_ClickCellButton(object sender, CellEventArgs e)
  317. {
  318. string AddPrice_Line_Id = e.Cell.Row.Cells["PriceaddLineId"].Value.ToString();
  319. if (e.Cell.Column.Key == "PriceaddSuit")
  320. {
  321. AddPriceSuit popup = null;
  322. try
  323. {
  324. this.Cursor = Cursors.WaitCursor;
  325. popup = new AddPriceSuit(AddPrice_Line_Id, this.ob);
  326. }
  327. finally
  328. {
  329. this.Cursor = Cursors.Default;
  330. }
  331. popup.ShowDialog();
  332. }
  333. }
  334. private void ugPriceAddHead_AfterRowInsert(object sender, RowEventArgs e)
  335. {
  336. string maxId = ugPriceAddHead.Rows.AsQueryable().Max(a => a.Cells["PriceaddId"].Value.ToString());
  337. if (maxId == "")
  338. {
  339. e.Row.Cells["PriceaddId"].Value = "T000001";
  340. }
  341. else
  342. {
  343. string str = "T" + (Convert.ToInt32(maxId.Substring(1, 6)) + 1).ToString().PadLeft(6, '0');
  344. e.Row.Cells["PriceaddId"].Value = str;
  345. }
  346. }
  347. private void ugPriceAddHead_InitializeRow(object sender, InitializeRowEventArgs e)
  348. {
  349. if (e.Row != null)
  350. {
  351. if (e.Row.Cells["VALIDFLAG"].Value.ToString() == "无效")
  352. {
  353. e.Row.Appearance.ForeColor = Color.Red;
  354. }
  355. else
  356. {
  357. e.Row.Appearance.ForeColor = Color.Black;
  358. }
  359. }
  360. }
  361. private void suitValueBind(string SUITCLASSIFY)
  362. {
  363. }
  364. private void ugPriceAddLine_InitializeLayout(object sender, InitializeLayoutEventArgs e)
  365. {
  366. }
  367. private void ugPriceAddLine_AfterRowInsert(object sender, RowEventArgs e)
  368. {
  369. string PriceaddId = this.ugPriceAddHead.ActiveRow.Cells["PriceaddId"].Value.ToString2();
  370. e.Row.Cells["PriceaddId"].Value = PriceaddId;
  371. }
  372. }
  373. }