FrmPop_GetMinPrice.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;using Pur.Entity;using Pur.Entity;
  10. using Pur.Entity.pur_planEntity;
  11. using Core.Mes.Client.Comm.Tool;
  12. using Core.Mes.Client.Comm.Control;
  13. using System.Collections;
  14. using Pur.Entity.configureEntity;
  15. using com.hnshituo.pur.vo;
  16. namespace Pur.Pop_upWindow
  17. {
  18. public partial class FrmPop_GetMinPrice : FrmPmsBase
  19. {
  20. string Q_strTASKID = "";
  21. DataTable Q_dtMinPrice = null;//保存显示最低价格供应商
  22. public FrmPop_GetMinPrice(OpeBase ob, string strTASKID, DataTable dt)
  23. {
  24. InitializeComponent();
  25. this.ob = ob;
  26. Q_strTASKID = strTASKID;
  27. GetMinPrice(dt);
  28. GetTaskM(strTASKID);
  29. //ultraGrid1.DataSource = dt;
  30. }
  31. /// <summary>
  32. /// 查询任务主表
  33. /// </summary>
  34. public void GetTaskM(string strTASKID)
  35. {
  36. PurTaskMEntity M_PurTaskM = this.execute<PurTaskMEntity>("com.hnshituo.pur.purplan.service.TaskMService", "findById", new object[] { strTASKID });
  37. if (M_PurTaskM != null)
  38. {
  39. lb_taskId.Text = M_PurTaskM.TaskId;
  40. lb_taskName.Text = M_PurTaskM.TaskName;
  41. if (M_PurTaskM.OfferTimeStart.Value != null)
  42. lb_OFFER_TIME_START.Text = M_PurTaskM.OfferTimeStart.Value.ToShortDateString();
  43. if (M_PurTaskM.OfferTimeEnd.Value != null)
  44. lb_OFFER_TIME_END.Text = M_PurTaskM.OfferTimeEnd.Value.ToShortDateString();
  45. }
  46. }
  47. /// <summary>
  48. /// 初拟最低价格
  49. /// </summary>
  50. /// <param name="dt">竞标价格表</param>
  51. public void GetMinPrice(DataTable dt)
  52. {
  53. Q_dtMinPrice = new DataTable();
  54. DataColumn dcItem = new System.Data.DataColumn();
  55. dcItem.ColumnName = "ITEM";
  56. dcItem.Caption = "物料信息";
  57. Q_dtMinPrice.Columns.Add(dcItem);
  58. DataColumn dcSupp = new System.Data.DataColumn();
  59. dcSupp.ColumnName = "Supp";
  60. dcSupp.Caption = "最低报价供应商";
  61. Q_dtMinPrice.Columns.Add(dcSupp);
  62. int ItemCount = dt.Rows.Count / 6;//供应商个数
  63. for (int i = 0; i < ItemCount; i++)
  64. {
  65. double minPrice = 0;//最小价格供应商单价
  66. string strMinPriceSuppCode = "";//最小价格供应商代码
  67. string strMinPriceSuppName = "";//最小价格供应商名称
  68. for (int j = 1; j < dt.Columns.Count; j++)//比较每个供应商报价
  69. {
  70. if (dt.Rows[i * 6 + 1][j] != null && dt.Rows[i * 6 + 1][j].ToString().Trim() != "")
  71. {
  72. double suppPrice = double.Parse(dt.Rows[i * 6 + 1][j].ToString());
  73. if (minPrice == 0 && suppPrice > 0)
  74. {
  75. minPrice = suppPrice;
  76. }
  77. if (suppPrice <= minPrice)
  78. {
  79. minPrice = suppPrice;
  80. strMinPriceSuppCode = dt.Columns[j].ColumnName;
  81. strMinPriceSuppName = dt.Columns[j].Caption;
  82. }
  83. }
  84. }
  85. for (int k = 0; k < 3; k++)//保存每个物料对应的最低供应商报价信息
  86. {
  87. if (k == 0)
  88. {
  89. DataRow dr = Q_dtMinPrice.NewRow();
  90. dr["ITEM"] = dt.Rows[i * 6 + k]["ITEM"].ToString();//物料名
  91. if (minPrice > 0)
  92. {
  93. dr["Supp"] = strMinPriceSuppName + "(" + strMinPriceSuppCode + ")";//供应商名称
  94. }
  95. else
  96. {
  97. dr["Supp"] = "";//供应商价格
  98. }
  99. Q_dtMinPrice.Rows.Add(dr);
  100. }
  101. else if (k == 1)
  102. {
  103. DataRow dr = Q_dtMinPrice.NewRow();
  104. dr["ITEM"] = dt.Rows[i * 6 + k]["ITEM"].ToString();//物料名价格
  105. if (minPrice > 0)
  106. {
  107. dr["Supp"] = minPrice.ToString();//供应商价格
  108. }
  109. else
  110. {
  111. dr["Supp"] = "";
  112. }
  113. Q_dtMinPrice.Rows.Add(dr);
  114. }
  115. else
  116. {
  117. DataRow dr = Q_dtMinPrice.NewRow();
  118. dr["ITEM"] = dt.Rows[i * 6 + 5]["ITEM"].ToString();//物料名价格
  119. dr["Supp"] = "";
  120. Q_dtMinPrice.Rows.Add(dr);
  121. }
  122. }
  123. }
  124. Q_dtMinPrice = dt;
  125. ultraGrid1.DataSource = dt;
  126. //给物料名称行设置背景颜色
  127. for (int i = 0; i < dt.Rows.Count / 3; i++)
  128. {
  129. for (int j = 0; j < 3; j++)//设置物料信第一列所有单元格背景颜色
  130. {
  131. if (j != 0)
  132. {
  133. ultraGrid1.Rows[i * 3 + j].Cells[0].Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
  134. ultraGrid1.Rows[i * 3 + j].Cells[0].Appearance.BackColor = Color.YellowGreen;
  135. ultraGrid1.Rows[i * 3 + j].Cells[0].Appearance.ForeColor = Color.Black;
  136. }
  137. }
  138. //物料名所在行背景颜色
  139. ultraGrid1.Rows[i * 3].Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
  140. ultraGrid1.Rows[i * 3].Appearance.ForeColor = Color.White;
  141. ultraGrid1.Rows[i * 3].Appearance.BorderColor3DBase = Color.CornflowerBlue;
  142. ultraGrid1.Rows[i * 3].Appearance.BackColor = Color.DodgerBlue;
  143. }
  144. }
  145. /// <summary>
  146. /// 确认操作
  147. /// </summary>
  148. /// <param name="sender"></param>
  149. /// <param name="e"></param>
  150. private void conFirmation()
  151. {
  152. // 查询任务从表
  153. ultraGrid1.UpdateData();
  154. PurTaskCEntity M_PurTaskC = new PurTaskCEntity();
  155. M_PurTaskC.TaskId = Q_strTASKID;
  156. M_PurTaskC.Validflag = "1";
  157. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.purplan.service.TaskCService", "find", new object[] { M_PurTaskC, 0, 0 });
  158. ArrayList al = new ArrayList();
  159. for (int i = 0; i < dt.Rows.Count; i++)
  160. {
  161. for (int j = 0; j < Q_dtMinPrice.Rows.Count; j++)
  162. {
  163. PurTaskCEntity M_PurTaskC_al = new PurTaskCEntity();
  164. M_PurTaskC_al.TaskId = Q_strTASKID;
  165. M_PurTaskC_al.Validflag = "1";
  166. string str = Q_dtMinPrice.Rows[j]["ITEM"].ToString();
  167. if (dt.Rows[i]["ITEMCODE"].ToString() == str.Substring(str.LastIndexOf(":") + 1) && str.IndexOf("备") != 0)//任务单对应物料
  168. {
  169. M_PurTaskC_al.TaskLineId = dt.Rows[i]["TASKLINEID"].ToString();
  170. if (Q_dtMinPrice.Rows[j][1] != null && Q_dtMinPrice.Rows[j][1].ToString() != "")//中标价
  171. {
  172. double db = 0;
  173. double.TryParse(Q_dtMinPrice.Rows[j+1][1].ToString(), out db);
  174. M_PurTaskC_al.BidPrice = db;
  175. }
  176. else
  177. {
  178. M_PurTaskC_al.BidPrice = null;
  179. }
  180. if (Q_dtMinPrice.Rows[j + 2][1] != null)
  181. {
  182. M_PurTaskC_al.BidPriceReason = Q_dtMinPrice.Rows[j + 2][1].ToString();//中标价理由
  183. }
  184. al.Add(M_PurTaskC_al);
  185. break;
  186. }
  187. }
  188. }
  189. if (al.Count > 0)
  190. {
  191. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.purplan.service.TaskCService", "UpdMinPrice", new object[] { al });
  192. if (crt.Resultcode != 0)
  193. {
  194. MessageUtil.ShowTips("提交失败 " + crt.Resultmsg);
  195. return;
  196. }
  197. MessageUtil.ShowTips("提交成功");
  198. this.Close();
  199. }
  200. }
  201. /// <summary>
  202. /// 按钮控件
  203. /// </summary>
  204. /// <param name="sender"></param>
  205. /// <param name="e"></param>
  206. private void barsManagerButon_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  207. {
  208. switch (e.Tool.Key.ToString())
  209. {
  210. case "Query":
  211. {
  212. }
  213. break;
  214. case "conFirmation":
  215. {
  216. conFirmation();
  217. }
  218. break;
  219. case "ESC":
  220. {
  221. this.Close();
  222. }
  223. break;
  224. }
  225. }
  226. }
  227. }