frmInto_Examine.cs 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832
  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 Core.Mes.Client.Comm.Control;
  10. using Core.Mes.Client.Comm.Tool;
  11. using CoreFS.CA06;
  12. using Pur.Entity;
  13. using Pur.Entity.pur_planEntity;
  14. using System.Collections;
  15. using Pur.configure;
  16. using Pur.Entity.configureEntity;
  17. using Pur.Pop_upWindow;
  18. using Infragistics.Win.UltraWinGrid;
  19. using com.hnshituo.pur.vo;
  20. using Infragistics.Win;
  21. namespace Pur.pur_plan
  22. {
  23. public partial class frmInto_Examine : FrmPmsBase
  24. {
  25. //int Q_ChitChatOld = 0;
  26. //string QstrChating = "";//用户选择的聊天对象
  27. Color QtabColor;
  28. string Q_strTASKID = "";
  29. DataTable Q_dt_TaskOfferC = null;//供应商报价信息
  30. int[] Q_ChatcCount = null;//保存各供应商聊天记录条数
  31. DataTable Q_dt_getExamineMana = null;
  32. public frmInto_Examine(OpeBase ob, string strTASKID)
  33. {
  34. InitializeComponent();
  35. timer1.Stop();
  36. timer2.Stop();//计时器停止防止程序出现异常而计时器继续进行
  37. this.ob = ob;
  38. Q_strTASKID = strTASKID;
  39. //Q_ChitChatOld = this.execute<int>("com.hnshituo.pur.purplan.service.ReviewBillMService", "count", new object[] { null });
  40. GetTaskM();
  41. GetTaskC();
  42. GetSupp();
  43. getExamineMana();
  44. setChitChatDt();
  45. Q_ChatcCount = new int[dataTable3.Rows.Count];//定义保存供应商聊天记录个数
  46. for (int i = 0; i < Q_ChatcCount.Length; i++)//首先将数据数组数据置为0
  47. {
  48. Q_ChatcCount[i] = 0;
  49. }
  50. getChitChatMessege();//显示聊天记录
  51. timer1.Start();
  52. timer2.Start();
  53. timer3.Start();
  54. }
  55. protected override void OnLoad(EventArgs e)
  56. {
  57. base.OnLoad(e);
  58. ultraGrid1.DisplayLayout.Override.RowSelectorNumberStyle = RowSelectorNumberStyle.None;//去掉grid序号显示
  59. GridHelper.ClearUlGridFilter(ultraGrid1);
  60. ultraGrid3.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  61. ultraGrid4.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  62. ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  63. //ultraGrid1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);//自适应列宽
  64. for (int i = 0; i < ultraGrid1.DisplayLayout.Bands[0].Columns.Count; i++)
  65. {
  66. ultraGrid1.DisplayLayout.Bands[0].Columns[i].SortIndicator = SortIndicator.Disabled;//是否允许排序
  67. }
  68. //ultraGrid1.DisplayLayout.Bands[0].Columns["JUDGE_STOVE_NO"].SortIndicator = SortIndicator.Disabled;//是否允许排序
  69. ultraGrid1.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;//是否允许过滤
  70. //rollingInfomation1.UltraGrid4.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
  71. //rollingCard2.UltraGrid4.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
  72. //ultraGridPlan.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);//自适应列宽
  73. //ultraGridMatSeq.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
  74. //ultraGrid1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
  75. //e.Layout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.Vertical;
  76. //e.Layout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.Select;
  77. }
  78. /// <summary>
  79. /// 按钮控件
  80. /// </summary>
  81. /// <param name="sender"></param>
  82. /// <param name="e"></param>
  83. private void barsManagerButon_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  84. {
  85. switch (e.Tool.Key.ToString())
  86. {
  87. /// <summary>
  88. /// 初拟中标价格
  89. /// </summary>
  90. case "GetMinPrice":
  91. {
  92. //将每个供应商对应的最低报价显示
  93. //FrmPop_GetMinPrice FrmGetMinPrice = new FrmPop_GetMinPrice(this.ob, lb_taskId.Text, setPriceMin());
  94. //FrmGetMinPrice.ShowDialog();
  95. }
  96. break;
  97. case "SetSuppGrade":
  98. {
  99. //SetSuppGrade();
  100. }
  101. break;
  102. case "ESC":
  103. {
  104. this.Close();
  105. }
  106. break;
  107. }
  108. }
  109. /// <summary>
  110. /// 查询任务主表
  111. /// </summary>
  112. public void GetTaskM()
  113. {
  114. PurTaskMEntity M_PurTaskM = this.execute<PurTaskMEntity>("com.hnshituo.pur.purplan.service.TaskMService", "findById", new object[] { Q_strTASKID });
  115. if (M_PurTaskM != null)
  116. {
  117. lb_taskId.Text = M_PurTaskM.TaskId;
  118. lb_taskName.Text = M_PurTaskM.TaskName;
  119. if (M_PurTaskM.OfferTimeStart != null && M_PurTaskM.OfferTimeStart.Value != null)
  120. lb_OFFER_TIME_START.Text = M_PurTaskM.OfferTimeStart.Value.ToShortDateString();
  121. if (M_PurTaskM.OfferTimeEnd != null && M_PurTaskM.OfferTimeEnd.Value != null)
  122. lb_OFFER_TIME_END.Text = M_PurTaskM.OfferTimeEnd.Value.ToShortDateString();
  123. if (M_PurTaskM.BidOpenTime != null && M_PurTaskM.BidOpenTime.Value != null)
  124. lb_BID_OPEN_TIME.Text = M_PurTaskM.BidOpenTime.Value.ToShortDateString();
  125. switch (M_PurTaskM.Status)
  126. {
  127. case "1":
  128. lb_Status.Text = "未竞标";
  129. break;
  130. case "2":
  131. lb_Status.Text = "报价中";
  132. break;
  133. case "3":
  134. lb_Status.Text = "待开标";
  135. break;
  136. case "4":
  137. lb_Status.Text = "评标中";
  138. break;
  139. case "5":
  140. lb_Status.Text = "待供应商确认";
  141. break;
  142. case "6":
  143. lb_Status.Text = "待供应部确认";
  144. break;
  145. case "7":
  146. lb_Status.Text = "已确认";
  147. break;
  148. case "8":
  149. lb_Status.Text = "已关闭";
  150. break;
  151. case "9":
  152. lb_Status.Text = "已生成采购纪要";
  153. break;
  154. }
  155. }
  156. }
  157. /// <summary>
  158. /// 查询任务从表
  159. /// </summary>
  160. public void GetTaskC()
  161. {
  162. if (Q_strTASKID != "")
  163. {
  164. // 查询任务从表
  165. PurTaskCEntity M_PurTaskC = new PurTaskCEntity();
  166. M_PurTaskC.TaskId = Q_strTASKID;
  167. M_PurTaskC.Validflag = "1";
  168. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.purplan.service.TaskCService", "find", new object[] { M_PurTaskC, 0, 0 });
  169. if (dt.Rows.Count > 0)
  170. {
  171. dt.DefaultView.Sort = "ITEMUNIQUE";
  172. dt = dt.DefaultView.ToTable();
  173. }
  174. //将空属性的值置为""
  175. for (int i = 0; i < dt.Rows.Count; i++)
  176. {
  177. if (dt.Rows[i]["ITEMATTRID"] == null || dt.Rows[i]["ITEMATTRID"].ToString() == "")
  178. {
  179. dt.Rows[i]["ITEMATTRID"] = " ";
  180. }
  181. }
  182. GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);//绑定物料分类表
  183. }
  184. }
  185. /// <summary>
  186. /// 查询供应商
  187. /// </summary>
  188. public void GetSupp()
  189. {
  190. if (Q_strTASKID != "")
  191. {
  192. // 查询供应商
  193. PurTaskSuppsEntity M_PurTaskSupps = new PurTaskSuppsEntity();
  194. M_PurTaskSupps.TaskId = Q_strTASKID;
  195. M_PurTaskSupps.Validflag = "1";
  196. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.purplan.service.TaskSuppsService", "find", new object[] { M_PurTaskSupps, 0, 0 });
  197. GridHelper.CopyDataToDatatable(ref dt, ref dataTable3, true);//绑定物料分类表
  198. }
  199. }
  200. /// <summary>
  201. /// 供应商报价
  202. /// </summary>
  203. private void getExamineMana()
  204. {
  205. if (Q_strTASKID == "")
  206. {
  207. MessageUtil.ShowTips("未找到任务单号");
  208. return;
  209. }
  210. DataTable dtItem = this.execute<DataTable>("com.hnshituo.pur.purplan.service.TaskCService", "getTaskItem", new object[] { Q_strTASKID });//任务单对应的物料信息
  211. DataTable dtSupps = this.execute<DataTable>("com.hnshituo.pur.purplan.service.TaskOfferCService", "getSuppRes", new object[] { Q_strTASKID });//供应商报价信息
  212. if (dtItem.Rows.Count > 0)
  213. {
  214. dtItem.DefaultView.Sort = "ITEMUNIQUE";
  215. dtItem = dtItem.DefaultView.ToTable();
  216. }
  217. //有新的供应商报价
  218. if (Q_dt_TaskOfferC!=null)
  219. {
  220. string str = "";
  221. bool bl = true;//是否新增报价
  222. foreach (DataRow dr in dtSupps.Rows)
  223. {
  224. bl = true;
  225. foreach (DataRow dr1 in Q_dt_TaskOfferC.Rows)
  226. {
  227. //if (dr["SUPPCODE"].ToString() == dr1["SUPPCODE"].ToString() && dr["ITEMCODE"].ToString() == dr1["ITEMCODE"].ToString() && dr["ITEMATTRID"].ToString() == dr1["ITEMATTRID"].ToString())
  228. if (dr["ITEMUNIQUE"].ToString() == dr1["ITEMUNIQUE"].ToString())
  229. {
  230. bl = false;
  231. break;
  232. }
  233. }
  234. if (bl)
  235. {
  236. str += "供应商【"+dr["SUPPNAME"].ToString()+"】对物料"+dr["ITEMNAME"].ToString()+"报价啦!\n";
  237. }
  238. }
  239. if (str != "")
  240. {
  241. MessageUtil.ShowTips(str);
  242. }
  243. }
  244. //DataColumn[] dcs = {dtSupps.Columns["ITEMCODE"]};
  245. //dtSupps.PrimaryKey = dcs;
  246. Q_dt_TaskOfferC = dtSupps;
  247. GridHelper.CopyDataToDatatable(ref dtItem, ref dataTable1, true);//绑定物料分类表
  248. GridHelper.CopyDataToDatatable(ref dtSupps, ref dataTable4, true);//绑定物料分类表
  249. //设置显示表的表结构
  250. DataTable dt = new DataTable();
  251. DataColumn dc = new System.Data.DataColumn();
  252. dc.ColumnName = "ITEM";
  253. dc.Caption = "物料信息";
  254. dt.Columns.Add(dc);
  255. for (int k = 0; k < dataTable3.Rows.Count; k++)
  256. {
  257. DataColumn dc_Supp = new System.Data.DataColumn();
  258. //dc_Supp.ColumnName = "SUPP" + (k + 1);
  259. //dc_Supp.Caption = "供应商信息" + (k + 1);
  260. dc_Supp.ColumnName = dataTable3.Rows[k]["SUPPCODE"].ToString();
  261. dc_Supp.Caption = dataTable3.Rows[k]["SUPPNAME"].ToString();
  262. dt.Columns.Add(dc_Supp);
  263. }
  264. //给设计表赋值
  265. for (int i = 0; i < dataTable1.Rows.Count; i++)//循环物料表
  266. {
  267. for (int j = 0; j < dataTable1.Columns.Count; j++)//循环每行物料表的列(只需6列)
  268. {
  269. DataRow dr = dt.NewRow();
  270. dr[0] = dataTable1.Rows[i][j].ToString();//物料报价信息
  271. dt.Rows.Add(dr);
  272. }
  273. //循环供应商
  274. for (int k = 0; k < dataTable3.Rows.Count; k++)//几个供应商
  275. {
  276. if (dtSupps.Rows.Count > 0)
  277. {
  278. DataRow[] drSupps = dtSupps.Select("SUPPCODE='" + dataTable3.Rows[k]["SUPPCODE"].ToString() + "'");//寻找当前供应商的对应物料报价信息
  279. DataRow[] drSupps_dt4 = dataTable4.Select("SUPPCODE='" + dataTable3.Rows[k]["SUPPCODE"].ToString() + "'");//寻找当前供应商的对应物料报价信息
  280. for (int m = 0; m < drSupps_dt4.Length; m++)//供应商与物料报价关系为多对多,可能有相同的供应商报价,但对应的物料是不同
  281. {
  282. //if (drSupps[m]["ITEMCODE"].ToString() == dtItem.Rows[i]["ITEMCODE"].ToString() && drSupps[m]["ITEMATTRID"].ToString().Trim() == dtItem.Rows[i]["ITEMATTRID"].ToString().Trim())//判断供应商与物料是否有报价权
  283. if (drSupps[m]["ITEMUNIQUE"].ToString() == dtItem.Rows[i]["ITEMUNIQUE"].ToString())
  284. {
  285. for (int n = 1; n < dataTable4.Columns.Count; n++)
  286. {
  287. dt.Rows[i * 6 + n][k + 1] = drSupps_dt4[m][n].ToString();//供应商报价信息
  288. }
  289. }
  290. }
  291. }
  292. }
  293. }
  294. //给表添加报价参数
  295. //DataColumn dc_Item_Args = new System.Data.DataColumn();
  296. //dc_Item_Args.ColumnName = "dc_Item_Args";
  297. //dc_Item_Args.Caption = "参数信息";
  298. //dt.Columns.Add(dc_Item_Args);
  299. //dc_Item_Args.SetOrdinal(0);
  300. for (int i = 0; i < dataTable1.Rows.Count; i++)
  301. {
  302. string[] str_Item_Args = { "", "单 价", "数 量", "金 额", "交货日期", "备 注" };
  303. for (int j = 0; j < 6; j++)
  304. {
  305. if ((i + 1) % 6 != 0)//物料名下一个循环设置
  306. {
  307. dt.Rows[i * 6 + j][0] = str_Item_Args[j] + "(" + dt.Rows[i * 6 + j][0].ToString() + ")";
  308. }
  309. }
  310. }
  311. ultraGrid1.DataSource = dt;
  312. //给物料名称行设置背景颜色
  313. for (int i = 0; i < dataTable1.Rows.Count; i++)
  314. {
  315. for (int j = 0; j < 6; j++)//设置物料信息字段背景颜色
  316. {
  317. if (j != 0)
  318. {
  319. ultraGrid1.Rows[i * 6 + j].Cells[0].Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
  320. ultraGrid1.Rows[i * 6 + j].Cells[0].Appearance.BackColor = Color.YellowGreen;
  321. ultraGrid1.Rows[i * 6 + j].Cells[0].Appearance.ForeColor = Color.Black;
  322. }
  323. }
  324. //设置每行第一列背景颜色,并显示第一行的物料信息
  325. dt.Rows[i * 6][0] = (i + 1) + "﹑物料名:" + dt.Rows[i * 6][0].ToString() + " 物料编码:" + dtItem.Rows[i]["ITEMCODE"].ToString();//设置物料显示
  326. if (dt.Columns.Count > 1)//显示物料描述信息
  327. {
  328. dt.Rows[i * 6][1] = "属性:" + dtItem.Rows[i]["ITEMATTR"].ToString() + "属性编码:" + dtItem.Rows[i]["ITEMATTRID"].ToString();
  329. }
  330. if (dt.Columns.Count > 2)//显示物料描述信息
  331. {
  332. //dt.Rows[i * 6][2] = "物料描述:" + dtItem.Rows[i]["ITEMDESC"].ToString();
  333. }
  334. //物料名所在列颜色
  335. ultraGrid1.Rows[i * 6].Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
  336. ultraGrid1.Rows[i * 6].Appearance.ForeColor = Color.White;
  337. ultraGrid1.Rows[i * 6].Appearance.BorderColor3DBase = Color.CornflowerBlue;
  338. ultraGrid1.Rows[i * 6].Appearance.BackColor = Color.DodgerBlue;
  339. }
  340. Q_dt_getExamineMana = dt;
  341. //设置填写日期单元格类型为日期类型
  342. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  343. {
  344. if (ultraGrid1.Rows[i].Cells[0].Value.ToString().IndexOf("交货日期") == 0)
  345. {
  346. for (int j = 1; j < ultraGrid1.DisplayLayout.Bands[0].Columns.Count; j++)
  347. {
  348. ultraGrid1.Rows[i].Cells[j].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Date;
  349. ultraGrid1.Rows[i].Cells[j].Band.Columns[j].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.OnCellActivate;
  350. ultraGrid1.Rows[i].Cells[j].Band.Columns[j].CellActivation = Activation.NoEdit;
  351. }
  352. }
  353. }
  354. //标记价格最低颜色的供应商
  355. //价格所在行索引为1,7,13...,备注所在列的索引分别为5,11,17...
  356. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  357. {
  358. if (ultraGrid1.DisplayLayout.Bands[0].Columns.Count > 1)
  359. {
  360. if (ultraGrid1.Rows[i].Cells[0].Value.ToString().IndexOf("单") == 0)
  361. {
  362. int num = 1;//默认为第一个供应商报价为最低
  363. Double MinPrice = 0;
  364. if (ultraGrid1.Rows[i].Cells[1].Value.ToString() != "" && StringUtil.IsNumber(ultraGrid1.Rows[i].Cells[1].Value.ToString()))
  365. {
  366. MinPrice = Convert.ToDouble(ultraGrid1.Rows[i].Cells[1].Value.ToString());
  367. }
  368. for (int j = 1; j < ultraGrid1.DisplayLayout.Bands[0].Columns.Count; j++)
  369. {
  370. string strMinPrice = ultraGrid1.Rows[i].Cells[j].Value.ToString();
  371. if (strMinPrice != "" && StringUtil.IsNumber(strMinPrice))//是否为数字
  372. {
  373. if (MinPrice > Convert.ToDouble(strMinPrice))//比较
  374. {
  375. MinPrice = Convert.ToDouble(strMinPrice);//保存最小报价
  376. num = j;//保存最小报价所在的列
  377. }
  378. }
  379. }
  380. //将最小报价所在的位置标记颜色
  381. ultraGrid1.Rows[i].Cells[num].Appearance.BackColor = Color.Yellow;
  382. }
  383. }
  384. }
  385. }
  386. /// <summary>
  387. /// 聊天信息
  388. /// </summary>
  389. /// <param name="dt"></param>
  390. private void getChitChatMessege()
  391. {
  392. for (int i = 0; i < dataTable3.Rows.Count; i++)//循环供应商
  393. {
  394. PurTaskChatEntity ReviewBillMEntity = new PurTaskChatEntity();
  395. ReviewBillMEntity.TaskId = lb_taskId.Text;
  396. //ReviewBillMEntity.ReceiverUserid = UserInfo.GetUserID();//ReceiverUserid属性传采购商代码
  397. ReviewBillMEntity.SenderUserid = dataTable3.Rows[i]["SUPPCODE"].ToString();//SenderUserid属性传供应商代码
  398. DataTable dt_ChitChatNew = this.execute<DataTable>("com.hnshituo.pur.purplan.service.TaskChatService", "getChitChatMessege", new object[] { ReviewBillMEntity });
  399. int count = dt_ChitChatNew.Rows.Count;
  400. Control[] ctrs = ultraTabControl1.Controls.Find(dataTable3.Rows[i]["SUPPCODE"].ToString(), true);
  401. if (count > Q_ChatcCount[i])//有新的聊天记录
  402. {
  403. //循环聊天框tab中的文本框,将聊天记录读取
  404. foreach (Control ctr in ctrs)
  405. {
  406. if (ctr is RichTextBox)
  407. {
  408. RichTextBox rtb = (RichTextBox)ctr;//找到对应的富文本框
  409. int[,] MassageColor = new int[(dt_ChitChatNew.Rows.Count - Q_ChatcCount[i]) * 2, 3];//二位数组,保存聊天记录,字体显示颜色
  410. //判断是否有信息输入,有信息输入则增加,没有信息记录则不增加信息
  411. for (int j = Q_ChatcCount[i]; j < dt_ChitChatNew.Rows.Count; j++)
  412. {
  413. if (dt_ChitChatNew.Rows[j]["SENDERTYPE"].ToString() == "2")
  414. {
  415. MassageColor[j - Q_ChatcCount[i], 2] = 2;
  416. }
  417. else
  418. {
  419. MassageColor[j - Q_ChatcCount[i], 2] = 1;
  420. }
  421. string str = "\n" + dt_ChitChatNew.Rows[j]["SENDERUSERNAME"].ToString() + "(" + dt_ChitChatNew.Rows[j]["SENDERUSERID"].ToString() + ")" + dt_ChitChatNew.Rows[j]["CREATETIME"].ToString() + "\n";
  422. MassageColor[j - Q_ChatcCount[i], 0] = rtb.Text.Length; ;//标记颜色起始位置
  423. rtb.AppendText(str);
  424. MassageColor[j - Q_ChatcCount[i], 1] = str.Length;//标记颜色结束位置
  425. MassageColor[(j - Q_ChatcCount[i]) + 1, 0] = rtb.Text.Length; ;//标记颜色起始位置
  426. rtb.AppendText(" " + dt_ChitChatNew.Rows[j]["MESSAGE"].ToString() + "\n");
  427. MassageColor[(j - Q_ChatcCount[i]) + 1, 1] = (" " + dt_ChitChatNew.Rows[j]["MESSAGE"].ToString() + "\n").Length;//标记颜色结束位置
  428. MassageColor[(j - Q_ChatcCount[i]) + 1, 2] = 3;//标记发送信息的颜色
  429. //rtb.SelectionStart = rtb.TextLength;//设置滚动条的位置
  430. //rtb.ScrollToCaret();//必须设置滚动起始标记位置
  431. }
  432. Q_ChatcCount[i] = count;//保存当前供应商聊天记录条数
  433. //rtb.SelectionStart = rtb.TextLength;//设置滚动条的位置
  434. //rtb.ScrollToCaret();//必须设置滚动起始标记位置
  435. setChatColor(rtb, MassageColor);
  436. //rtb.ScrollToCaret();//必须设置滚动起始标记位置
  437. changTabcolor(rtb);//有新的聊天记录时,设置聊天背景颜色
  438. break;//找到相应供应商聊天记录页面,退出循环,进入下一个供应商,直到结束
  439. }
  440. }
  441. }
  442. }
  443. }
  444. /// <summary>
  445. /// 设置聊天发送人显示颜色
  446. /// </summary>
  447. /// <param name="rtb">改变颜色RichTextBox控件</param>
  448. /// <param name="rows">聊天记录</param>
  449. protected void setChatColor(RichTextBox rtb, int[,] MassageColor)
  450. {
  451. for (int i = 0; i < MassageColor.GetLength(0); i++)
  452. {
  453. rtb.SelectionStart = MassageColor[i, 0];
  454. rtb.SelectionLength = MassageColor[i, 1];
  455. if (MassageColor[i, 2] == 1)
  456. {
  457. rtb.SelectionColor = Color.Red;
  458. }
  459. else if (MassageColor[i, 2] == 2)
  460. {
  461. rtb.SelectionColor = Color.Blue;
  462. }
  463. else
  464. {
  465. rtb.SelectionColor = Color.Black;
  466. }
  467. }
  468. }
  469. /// <summary>
  470. /// 设置文本控件滚动条
  471. /// </summary>
  472. /// <param name="sender"></param>
  473. /// <param name="e"></param>
  474. private void rtbLog_TextChanged(object sender, EventArgs e){
  475. RichTextBox rtb = (RichTextBox)sender;
  476. rtb.SelectionStart = rtb.Text.Length; //Set the current caret position at the end
  477. rtb.ScrollToCaret(); //Now scroll it automatically
  478. }
  479. public void LogAppend(Color color, string text, RichTextBox rtb)
  480. {
  481. rtb.SelectionColor = color;
  482. if (text.IndexOf(" ") != 0)
  483. {
  484. rtb.SelectedText = text;
  485. }
  486. else
  487. {
  488. rtb.SelectedText = text;
  489. }
  490. rtb.SelectedText = System.Environment.NewLine;
  491. rtb.ScrollToCaret();
  492. }
  493. /// <summary>
  494. /// 聊天表结构
  495. /// </summary>
  496. /// <param name="dt_supps"></param>
  497. private void setChitChatDt()
  498. {
  499. //设置tab聊天框
  500. for (int i = 0; i < dataTable3.Rows.Count; i++)
  501. {
  502. RichTextBox tb = new RichTextBox();
  503. tb.Name = dataTable3.Rows[i]["SUPPCODE"].ToString();
  504. tb.Dock = DockStyle.Fill;
  505. tb.Multiline = true;
  506. tb.ReadOnly = true;
  507. tb.TextChanged += new EventHandler(rtbLog_TextChanged);
  508. Infragistics.Win.UltraWinTabControl.UltraTab ultb = ultraTabControl1.Tabs.Add(dataTable3.Rows[i]["SUPPCODE"].ToString(), dataTable3.Rows[i]["SUPPNAME"].ToString() + "(" + dataTable3.Rows[i]["SUPPCODE"].ToString() + ")");
  509. //ultb.TabPage = ult_tpc;
  510. ultb.TabPage.Controls.Add(tb);
  511. QtabColor = ultb.TabPage.Tab.Appearance.BackColor;
  512. }
  513. //显示供应商聊天复选框
  514. int widthScreen_top = 0;//计算显示的供应商长度是否超出发送文本框的高度
  515. int widthScreen_left = 0;//计算显示的供应商长度是否超出发送文本框的宽度
  516. for (int i = 0; i < dataTable3.Rows.Count; i++)
  517. {
  518. CheckBox rb = new CheckBox();
  519. rb.Text = dataTable3.Rows[i]["SUPPNAME"].ToString() + "(" + dataTable3.Rows[i]["SUPPCODE"].ToString() + ")";
  520. rb.Name = dataTable3.Rows[i]["SUPPCODE"].ToString();
  521. rb.AutoSize = true;
  522. rb.Left = textBox1.Left + widthScreen_left;
  523. rb.Top = textBox1.Top - rb.Height * (widthScreen_top / textBox1.Width + 1);
  524. ultraGroupBox6.Controls.Add(rb);
  525. widthScreen_top += rb.Width + 5;
  526. widthScreen_left += rb.Width + 5;
  527. if (widthScreen_left > textBox1.Width)
  528. {
  529. widthScreen_left = 0;
  530. }
  531. if (i == dataTable3.Rows.Count - 1)
  532. {
  533. checkBox1.Left = textBox1.Left + widthScreen_left;//设置全选复选框的位置
  534. checkBox1.Top = rb.Top;
  535. }
  536. }
  537. }
  538. //刷新聊天记录
  539. private void timer1_Tick(object sender, EventArgs e)
  540. {
  541. timer1.Stop();
  542. timer3.Stop();
  543. getChitChatMessege();//刷新聊天信息
  544. timer1.Start();
  545. timer3.Start();
  546. }
  547. /// <summary>
  548. /// 刷新供应商报价
  549. /// </summary>
  550. /// <param name="sender"></param>
  551. /// <param name="e"></param>
  552. private void timer2_Tick(object sender, EventArgs e)
  553. {
  554. //timer1.Stop();
  555. //timer2.Stop();
  556. //getExamineMana();
  557. for (int i = 0; i < dataTable3.Rows.Count; i++)//循环供应商
  558. {
  559. Control[] ctrs = ultraTabControl1.Controls.Find(dataTable3.Rows[i]["SUPPCODE"].ToString(), true);
  560. //循环聊天框tab中的文本框,将聊天记录读取
  561. foreach (Control ctr in ctrs)
  562. {
  563. RichTextBox rtb = (RichTextBox)ctr;
  564. rtb.SelectionStart = rtb.Text.Length; //Set the current caret position at the end
  565. rtb.ScrollToCaret(); //Now scroll it automatically
  566. }
  567. }
  568. timer2.Stop();
  569. //timer1.Start();
  570. //timer2.Start();
  571. }
  572. /// <summary>
  573. /// 发送信息按钮
  574. /// </summary>
  575. /// <param name="sender"></param>
  576. /// <param name="e"></param>
  577. private void btn_SendMessage_Click(object sender, EventArgs e)
  578. {
  579. sendMessage();
  580. }
  581. /// <summary>
  582. /// 发送信息
  583. /// </summary>
  584. private void sendMessage()
  585. {
  586. if (textBox1.Text.Trim() == "")
  587. {
  588. MessageUtil.ShowTips("发送类容不能为空");
  589. return;
  590. }
  591. textBox1.Text = textBox1.Text.Replace("\n", "\n ");
  592. ArrayList al = new ArrayList();
  593. foreach (Control ctr in ultraGroupBox6.Controls)
  594. {
  595. if (ctr is CheckBox)
  596. {
  597. CheckBox ckb = (CheckBox)ctr;
  598. if (ckb.Checked && ckb.Name != "checkBox1")
  599. {
  600. PurTaskChatEntity ReviewBillMEntity = new PurTaskChatEntity();
  601. ReviewBillMEntity.Id = Guid.NewGuid().ToString();
  602. ReviewBillMEntity.TaskId = lb_taskId.Text;
  603. ReviewBillMEntity.SenderType = "2";
  604. ReviewBillMEntity.SenderUsername = UserInfo.GetUserName();
  605. ReviewBillMEntity.SenderUserid = UserInfo.GetUserID();
  606. ReviewBillMEntity.ReceiverType = "1";
  607. ReviewBillMEntity.ReceiverUserid = ckb.Name;
  608. ReviewBillMEntity.ReceiverUsername = ckb.Text.Substring(0, ckb.Text.LastIndexOf(ckb.Name) - 1);
  609. ReviewBillMEntity.CreateName = UserInfo.GetUserName();
  610. ReviewBillMEntity.CreateUserid = UserInfo.GetUserID();
  611. //ReviewBillMEntity.CreateTime = System.DateTime.Now;
  612. ReviewBillMEntity.Message = textBox1.Text;
  613. ReviewBillMEntity.Isread = "0";
  614. al.Add(ReviewBillMEntity);
  615. }
  616. }
  617. }
  618. if (al.Count < 1)
  619. {
  620. MessageUtil.ShowTips("请选择发送的供应商");
  621. }
  622. else
  623. {
  624. Boolean bl = true;
  625. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.purplan.service.TaskChatService", "sendChatMessage", new object[] { al });
  626. if (bl)
  627. {
  628. timer1.Stop();
  629. //timer2.Stop();
  630. getChitChatMessege();//刷新聊天信息
  631. timer1.Start();
  632. //timer2.Start();
  633. textBox1.Text = "";
  634. }
  635. else
  636. {
  637. MessageUtil.ShowTips("发送失败,请重新发送");
  638. }
  639. if (crt.Resultcode != 0)
  640. {
  641. MessageUtil.ShowTips("发送失败 " + crt.Resultmsg);
  642. return;
  643. }
  644. }
  645. }
  646. /// <summary>
  647. /// 关闭窗体是时间计时器停止
  648. /// </summary>
  649. /// <param name="sender"></param>
  650. /// <param name="e"></param>
  651. private void frmInto_Examine_FormClosing(object sender, FormClosingEventArgs e)
  652. {
  653. if (timer1 != null)
  654. timer1.Dispose();
  655. if (timer2 != null)
  656. timer2.Dispose();
  657. if (timer3 != null)
  658. timer3.Dispose();
  659. }
  660. /// <summary>
  661. /// 全选所有的供应商复选框
  662. /// </summary>
  663. /// <param name="sender"></param>
  664. /// <param name="e"></param>
  665. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  666. {
  667. foreach (Control ctr in ultraGroupBox6.Controls)
  668. {
  669. if (ctr is CheckBox)
  670. {
  671. CheckBox cb = (CheckBox)ctr;
  672. cb.Checked = checkBox1.Checked;
  673. }
  674. }
  675. }
  676. //打包询价
  677. private void button5_Click(object sender, EventArgs e)
  678. {
  679. }
  680. /// <summary>
  681. /// 有新的聊天记录时,设置聊天背景颜色
  682. /// </summary>
  683. private void changTabcolor(Control ctr)
  684. {
  685. if (ctr.Parent is Infragistics.Win.UltraWinTabControl.UltraTabPageControl)
  686. {
  687. Infragistics.Win.UltraWinTabControl.UltraTabPageControl ultb = (Infragistics.Win.UltraWinTabControl.UltraTabPageControl)ctr.Parent;
  688. if (!ultraTabControl1.ActiveTab.TabPage.Equals(ultb))//如果tab页面已经是打开状态则不用变换颜色,否则变换
  689. {
  690. ctr.Parent.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
  691. }
  692. }
  693. }
  694. //信息已经阅读,背景颜色变回原来的颜色
  695. private void ultraTabControl1_ActiveTabChanged(object sender, Infragistics.Win.UltraWinTabControl.ActiveTabChangedEventArgs e)
  696. {
  697. if (QtabColor != null)
  698. {
  699. ultraTabControl1.ActiveTab.TabPage.Tab.Appearance.BackColor = QtabColor;
  700. }
  701. }
  702. /// <summary>
  703. /// 初拟中标价格
  704. /// </summary>
  705. /// <returns></returns>
  706. private DataTable setPriceMin()
  707. {
  708. ultraGrid1.UpdateData();
  709. DataTable dt = Q_dt_getExamineMana.Copy();
  710. if (dt.Columns.Count < 2)
  711. {
  712. MessageUtil.ShowTips("没有供应商报价,不能进行初拟中标价格");
  713. return null;
  714. }
  715. //清楚数量,金额,交货日期所在行
  716. for (int i = 0; i < dt.Rows.Count; )
  717. {
  718. if (dt.Rows[i][0].ToString().IndexOf("数") == 0)
  719. {
  720. dt.Rows.RemoveAt(i);
  721. continue;
  722. }
  723. else if (dt.Rows[i][0].ToString().IndexOf("金") == 0)
  724. {
  725. dt.Rows.RemoveAt(i);
  726. continue;
  727. }
  728. else if (dt.Rows[i][0].ToString().IndexOf("交") == 0)
  729. {
  730. dt.Rows.RemoveAt(i);
  731. continue;
  732. }
  733. i++;
  734. }
  735. for (int i = 0; i < dt.Rows.Count; i++)
  736. {
  737. if (dt.Rows[i][0].ToString().IndexOf("单") == 0)
  738. {
  739. int num = 1;//默认为第一个供应商报价为最低
  740. int MinPrice = 0;
  741. if (dt.Rows[i][1].ToString() != "" && StringUtil.IsNumber(dt.Rows[i][1].ToString()))
  742. {
  743. MinPrice = Convert.ToInt32(dt.Rows[i][1].ToString());
  744. }
  745. for (int j = 1; j < dt.Columns.Count; j++)
  746. {
  747. string strMinPrice = dt.Rows[i][j].ToString();
  748. if (strMinPrice != "" && StringUtil.IsNumber(strMinPrice))//是否为数字
  749. {
  750. if (MinPrice > Convert.ToInt32(strMinPrice))//比较
  751. {
  752. MinPrice = Convert.ToInt32(strMinPrice);//保存最小报价
  753. num = j;//保存最小报价所在的列
  754. }
  755. }
  756. }
  757. //将最小报价赋值到第二列
  758. dt.Rows[i][1] = dt.Rows[i][num];
  759. //将供应商名称赋值到供应商报价上一列
  760. dt.Rows[i - 1][1] = dt.Columns[num].Caption;
  761. }
  762. }
  763. //保留dt前两列
  764. for (int i = 2; i < dt.Columns.Count; )
  765. {
  766. dt.Columns.RemoveAt(i);
  767. }
  768. dt.Columns[1].Caption = "最低报价供应商";
  769. return dt;
  770. }
  771. /// <summary>
  772. /// 刷新评标报价
  773. /// </summary>
  774. /// <param name="sender"></param>
  775. /// <param name="e"></param>
  776. private void timer3_Tick(object sender, EventArgs e)
  777. {
  778. timer1.Stop();
  779. timer3.Stop();
  780. getExamineMana();
  781. timer1.Start();
  782. timer3.Start();
  783. }
  784. /// <summary>
  785. /// 添加快捷键功能
  786. /// </summary>
  787. /// <param name="sender"></param>
  788. /// <param name="e"></param>
  789. private void textBox1_KeyDown(object sender, KeyEventArgs e)
  790. {
  791. if (e.KeyCode == Keys.A && e.Control)
  792. {
  793. textBox1.SelectAll();//全选功能
  794. e.Handled = true; //将Handled设置为true,指示已经处理过KeyPress事件,输入的值无效 button1.PerformClick();
  795. }
  796. else if (e.Shift && e.KeyCode == Keys.Enter)
  797. {
  798. //textBox1.Text += Environment.NewLine;//按回车键和shift键换行
  799. //e.Handled = true; //将Handled设置为true,指示已经处理过KeyPress事件,输入的值无效
  800. }
  801. else if (e.Control && e.KeyCode == Keys.Enter)
  802. {
  803. //textBox1.Text += Environment.NewLine;//按回车键和Control键换行
  804. //e.Handled = true; //将Handled设置为true,指示已经处理过KeyPress事件,输入的值无效
  805. }
  806. else if(e.KeyCode == Keys.Enter)
  807. {
  808. sendMessage();//按回车键发送信息
  809. e.Handled = true; //将Handled设置为true,指示已经处理过KeyPress事件,输入的值无效
  810. }
  811. }
  812. }
  813. }