| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Tool;
- using CoreFS.CA06;
- using Pur.Entity;
- using Pur.Entity.pur_planEntity;
- using System.Collections;
- using Pur.configure;
- using Pur.Entity.configureEntity;
- using Pur.Pop_upWindow;
- using Infragistics.Win.UltraWinGrid;
- using com.hnshituo.pur.vo;
- using Infragistics.Win;
- namespace Pur.pur_plan
- {
- public partial class frmInto_Examine : FrmPmsBase
- {
- //int Q_ChitChatOld = 0;
- //string QstrChating = "";//用户选择的聊天对象
- Color QtabColor;
- string Q_strTASKID = "";
- DataTable Q_dt_TaskOfferC = null;//供应商报价信息
- int[] Q_ChatcCount = null;//保存各供应商聊天记录条数
- DataTable Q_dt_getExamineMana = null;
- public frmInto_Examine(OpeBase ob, string strTASKID)
- {
- InitializeComponent();
- timer1.Stop();
- timer2.Stop();//计时器停止防止程序出现异常而计时器继续进行
- this.ob = ob;
- Q_strTASKID = strTASKID;
- //Q_ChitChatOld = this.execute<int>("com.hnshituo.pur.purplan.service.ReviewBillMService", "count", new object[] { null });
- GetTaskM();
- GetTaskC();
- GetSupp();
- getExamineMana();
- setChitChatDt();
- Q_ChatcCount = new int[dataTable3.Rows.Count];//定义保存供应商聊天记录个数
- for (int i = 0; i < Q_ChatcCount.Length; i++)//首先将数据数组数据置为0
- {
- Q_ChatcCount[i] = 0;
- }
- getChitChatMessege();//显示聊天记录
- timer1.Start();
- timer2.Start();
- timer3.Start();
- }
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- ultraGrid1.DisplayLayout.Override.RowSelectorNumberStyle = RowSelectorNumberStyle.None;//去掉grid序号显示
- GridHelper.ClearUlGridFilter(ultraGrid1);
- ultraGrid3.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- ultraGrid4.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- //ultraGrid1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);//自适应列宽
- for (int i = 0; i < ultraGrid1.DisplayLayout.Bands[0].Columns.Count; i++)
- {
- ultraGrid1.DisplayLayout.Bands[0].Columns[i].SortIndicator = SortIndicator.Disabled;//是否允许排序
- }
- //ultraGrid1.DisplayLayout.Bands[0].Columns["JUDGE_STOVE_NO"].SortIndicator = SortIndicator.Disabled;//是否允许排序
- ultraGrid1.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;//是否允许过滤
- //rollingInfomation1.UltraGrid4.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
- //rollingCard2.UltraGrid4.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
- //ultraGridPlan.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);//自适应列宽
- //ultraGridMatSeq.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
- //ultraGrid1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
- //e.Layout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.Vertical;
- //e.Layout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.Select;
- }
- /// <summary>
- /// 按钮控件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void barsManagerButon_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key.ToString())
- {
- /// <summary>
- /// 初拟中标价格
- /// </summary>
- case "GetMinPrice":
- {
- //将每个供应商对应的最低报价显示
- //FrmPop_GetMinPrice FrmGetMinPrice = new FrmPop_GetMinPrice(this.ob, lb_taskId.Text, setPriceMin());
- //FrmGetMinPrice.ShowDialog();
- }
- break;
- case "SetSuppGrade":
- {
- //SetSuppGrade();
- }
- break;
- case "ESC":
- {
- this.Close();
- }
- break;
- }
- }
- /// <summary>
- /// 查询任务主表
- /// </summary>
- public void GetTaskM()
- {
- PurTaskMEntity M_PurTaskM = this.execute<PurTaskMEntity>("com.hnshituo.pur.purplan.service.TaskMService", "findById", new object[] { Q_strTASKID });
- if (M_PurTaskM != null)
- {
- lb_taskId.Text = M_PurTaskM.TaskId;
- lb_taskName.Text = M_PurTaskM.TaskName;
- if (M_PurTaskM.OfferTimeStart != null && M_PurTaskM.OfferTimeStart.Value != null)
- lb_OFFER_TIME_START.Text = M_PurTaskM.OfferTimeStart.Value.ToShortDateString();
- if (M_PurTaskM.OfferTimeEnd != null && M_PurTaskM.OfferTimeEnd.Value != null)
- lb_OFFER_TIME_END.Text = M_PurTaskM.OfferTimeEnd.Value.ToShortDateString();
- if (M_PurTaskM.BidOpenTime != null && M_PurTaskM.BidOpenTime.Value != null)
- lb_BID_OPEN_TIME.Text = M_PurTaskM.BidOpenTime.Value.ToShortDateString();
- switch (M_PurTaskM.Status)
- {
- case "1":
- lb_Status.Text = "未竞标";
- break;
- case "2":
- lb_Status.Text = "报价中";
- break;
- case "3":
- lb_Status.Text = "待开标";
- break;
- case "4":
- lb_Status.Text = "评标中";
- break;
- case "5":
- lb_Status.Text = "待供应商确认";
- break;
- case "6":
- lb_Status.Text = "待供应部确认";
- break;
- case "7":
- lb_Status.Text = "已确认";
- break;
- case "8":
- lb_Status.Text = "已关闭";
- break;
- case "9":
- lb_Status.Text = "已生成采购纪要";
- break;
- }
- }
- }
- /// <summary>
- /// 查询任务从表
- /// </summary>
- public void GetTaskC()
- {
- if (Q_strTASKID != "")
- {
- // 查询任务从表
- PurTaskCEntity M_PurTaskC = new PurTaskCEntity();
- M_PurTaskC.TaskId = Q_strTASKID;
- M_PurTaskC.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.purplan.service.TaskCService", "find", new object[] { M_PurTaskC, 0, 0 });
- if (dt.Rows.Count > 0)
- {
- dt.DefaultView.Sort = "ITEMUNIQUE";
- dt = dt.DefaultView.ToTable();
- }
- //将空属性的值置为""
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dt.Rows[i]["ITEMATTRID"] == null || dt.Rows[i]["ITEMATTRID"].ToString() == "")
- {
- dt.Rows[i]["ITEMATTRID"] = " ";
- }
- }
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);//绑定物料分类表
- }
- }
- /// <summary>
- /// 查询供应商
- /// </summary>
- public void GetSupp()
- {
- if (Q_strTASKID != "")
- {
- // 查询供应商
- PurTaskSuppsEntity M_PurTaskSupps = new PurTaskSuppsEntity();
- M_PurTaskSupps.TaskId = Q_strTASKID;
- M_PurTaskSupps.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.purplan.service.TaskSuppsService", "find", new object[] { M_PurTaskSupps, 0, 0 });
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable3, true);//绑定物料分类表
- }
- }
- /// <summary>
- /// 供应商报价
- /// </summary>
- private void getExamineMana()
- {
- if (Q_strTASKID == "")
- {
- MessageUtil.ShowTips("未找到任务单号");
- return;
- }
- DataTable dtItem = this.execute<DataTable>("com.hnshituo.pur.purplan.service.TaskCService", "getTaskItem", new object[] { Q_strTASKID });//任务单对应的物料信息
- DataTable dtSupps = this.execute<DataTable>("com.hnshituo.pur.purplan.service.TaskOfferCService", "getSuppRes", new object[] { Q_strTASKID });//供应商报价信息
- if (dtItem.Rows.Count > 0)
- {
- dtItem.DefaultView.Sort = "ITEMUNIQUE";
- dtItem = dtItem.DefaultView.ToTable();
- }
- //有新的供应商报价
- if (Q_dt_TaskOfferC!=null)
- {
- string str = "";
- bool bl = true;//是否新增报价
- foreach (DataRow dr in dtSupps.Rows)
- {
- bl = true;
- foreach (DataRow dr1 in Q_dt_TaskOfferC.Rows)
- {
- //if (dr["SUPPCODE"].ToString() == dr1["SUPPCODE"].ToString() && dr["ITEMCODE"].ToString() == dr1["ITEMCODE"].ToString() && dr["ITEMATTRID"].ToString() == dr1["ITEMATTRID"].ToString())
- if (dr["ITEMUNIQUE"].ToString() == dr1["ITEMUNIQUE"].ToString())
- {
- bl = false;
- break;
- }
- }
- if (bl)
- {
- str += "供应商【"+dr["SUPPNAME"].ToString()+"】对物料"+dr["ITEMNAME"].ToString()+"报价啦!\n";
- }
- }
- if (str != "")
- {
- MessageUtil.ShowTips(str);
- }
- }
- //DataColumn[] dcs = {dtSupps.Columns["ITEMCODE"]};
- //dtSupps.PrimaryKey = dcs;
- Q_dt_TaskOfferC = dtSupps;
- GridHelper.CopyDataToDatatable(ref dtItem, ref dataTable1, true);//绑定物料分类表
- GridHelper.CopyDataToDatatable(ref dtSupps, ref dataTable4, true);//绑定物料分类表
- //设置显示表的表结构
- DataTable dt = new DataTable();
- DataColumn dc = new System.Data.DataColumn();
- dc.ColumnName = "ITEM";
- dc.Caption = "物料信息";
- dt.Columns.Add(dc);
- for (int k = 0; k < dataTable3.Rows.Count; k++)
- {
- DataColumn dc_Supp = new System.Data.DataColumn();
- //dc_Supp.ColumnName = "SUPP" + (k + 1);
- //dc_Supp.Caption = "供应商信息" + (k + 1);
- dc_Supp.ColumnName = dataTable3.Rows[k]["SUPPCODE"].ToString();
- dc_Supp.Caption = dataTable3.Rows[k]["SUPPNAME"].ToString();
- dt.Columns.Add(dc_Supp);
- }
- //给设计表赋值
- for (int i = 0; i < dataTable1.Rows.Count; i++)//循环物料表
- {
- for (int j = 0; j < dataTable1.Columns.Count; j++)//循环每行物料表的列(只需6列)
- {
- DataRow dr = dt.NewRow();
- dr[0] = dataTable1.Rows[i][j].ToString();//物料报价信息
- dt.Rows.Add(dr);
- }
- //循环供应商
- for (int k = 0; k < dataTable3.Rows.Count; k++)//几个供应商
- {
- if (dtSupps.Rows.Count > 0)
- {
- DataRow[] drSupps = dtSupps.Select("SUPPCODE='" + dataTable3.Rows[k]["SUPPCODE"].ToString() + "'");//寻找当前供应商的对应物料报价信息
- DataRow[] drSupps_dt4 = dataTable4.Select("SUPPCODE='" + dataTable3.Rows[k]["SUPPCODE"].ToString() + "'");//寻找当前供应商的对应物料报价信息
- for (int m = 0; m < drSupps_dt4.Length; m++)//供应商与物料报价关系为多对多,可能有相同的供应商报价,但对应的物料是不同
- {
- //if (drSupps[m]["ITEMCODE"].ToString() == dtItem.Rows[i]["ITEMCODE"].ToString() && drSupps[m]["ITEMATTRID"].ToString().Trim() == dtItem.Rows[i]["ITEMATTRID"].ToString().Trim())//判断供应商与物料是否有报价权
- if (drSupps[m]["ITEMUNIQUE"].ToString() == dtItem.Rows[i]["ITEMUNIQUE"].ToString())
- {
- for (int n = 1; n < dataTable4.Columns.Count; n++)
- {
- dt.Rows[i * 6 + n][k + 1] = drSupps_dt4[m][n].ToString();//供应商报价信息
- }
- }
- }
- }
- }
- }
- //给表添加报价参数
- //DataColumn dc_Item_Args = new System.Data.DataColumn();
- //dc_Item_Args.ColumnName = "dc_Item_Args";
- //dc_Item_Args.Caption = "参数信息";
- //dt.Columns.Add(dc_Item_Args);
- //dc_Item_Args.SetOrdinal(0);
- for (int i = 0; i < dataTable1.Rows.Count; i++)
- {
- string[] str_Item_Args = { "", "单 价", "数 量", "金 额", "交货日期", "备 注" };
- for (int j = 0; j < 6; j++)
- {
- if ((i + 1) % 6 != 0)//物料名下一个循环设置
- {
- dt.Rows[i * 6 + j][0] = str_Item_Args[j] + "(" + dt.Rows[i * 6 + j][0].ToString() + ")";
- }
- }
- }
- ultraGrid1.DataSource = dt;
- //给物料名称行设置背景颜色
- for (int i = 0; i < dataTable1.Rows.Count; i++)
- {
- for (int j = 0; j < 6; j++)//设置物料信息字段背景颜色
- {
- if (j != 0)
- {
- ultraGrid1.Rows[i * 6 + j].Cells[0].Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
- ultraGrid1.Rows[i * 6 + j].Cells[0].Appearance.BackColor = Color.YellowGreen;
- ultraGrid1.Rows[i * 6 + j].Cells[0].Appearance.ForeColor = Color.Black;
- }
- }
- //设置每行第一列背景颜色,并显示第一行的物料信息
- dt.Rows[i * 6][0] = (i + 1) + "﹑物料名:" + dt.Rows[i * 6][0].ToString() + " 物料编码:" + dtItem.Rows[i]["ITEMCODE"].ToString();//设置物料显示
- if (dt.Columns.Count > 1)//显示物料描述信息
- {
- dt.Rows[i * 6][1] = "属性:" + dtItem.Rows[i]["ITEMATTR"].ToString() + "属性编码:" + dtItem.Rows[i]["ITEMATTRID"].ToString();
- }
- if (dt.Columns.Count > 2)//显示物料描述信息
- {
- //dt.Rows[i * 6][2] = "物料描述:" + dtItem.Rows[i]["ITEMDESC"].ToString();
- }
- //物料名所在列颜色
- ultraGrid1.Rows[i * 6].Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
- ultraGrid1.Rows[i * 6].Appearance.ForeColor = Color.White;
- ultraGrid1.Rows[i * 6].Appearance.BorderColor3DBase = Color.CornflowerBlue;
- ultraGrid1.Rows[i * 6].Appearance.BackColor = Color.DodgerBlue;
- }
- Q_dt_getExamineMana = dt;
- //设置填写日期单元格类型为日期类型
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.Rows[i].Cells[0].Value.ToString().IndexOf("交货日期") == 0)
- {
- for (int j = 1; j < ultraGrid1.DisplayLayout.Bands[0].Columns.Count; j++)
- {
- ultraGrid1.Rows[i].Cells[j].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Date;
- ultraGrid1.Rows[i].Cells[j].Band.Columns[j].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.OnCellActivate;
- ultraGrid1.Rows[i].Cells[j].Band.Columns[j].CellActivation = Activation.NoEdit;
- }
- }
- }
- //标记价格最低颜色的供应商
- //价格所在行索引为1,7,13...,备注所在列的索引分别为5,11,17...
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (ultraGrid1.DisplayLayout.Bands[0].Columns.Count > 1)
- {
- if (ultraGrid1.Rows[i].Cells[0].Value.ToString().IndexOf("单") == 0)
- {
- int num = 1;//默认为第一个供应商报价为最低
- Double MinPrice = 0;
- if (ultraGrid1.Rows[i].Cells[1].Value.ToString() != "" && StringUtil.IsNumber(ultraGrid1.Rows[i].Cells[1].Value.ToString()))
- {
- MinPrice = Convert.ToDouble(ultraGrid1.Rows[i].Cells[1].Value.ToString());
- }
- for (int j = 1; j < ultraGrid1.DisplayLayout.Bands[0].Columns.Count; j++)
- {
- string strMinPrice = ultraGrid1.Rows[i].Cells[j].Value.ToString();
- if (strMinPrice != "" && StringUtil.IsNumber(strMinPrice))//是否为数字
- {
- if (MinPrice > Convert.ToDouble(strMinPrice))//比较
- {
- MinPrice = Convert.ToDouble(strMinPrice);//保存最小报价
- num = j;//保存最小报价所在的列
- }
- }
- }
- //将最小报价所在的位置标记颜色
- ultraGrid1.Rows[i].Cells[num].Appearance.BackColor = Color.Yellow;
- }
- }
- }
- }
- /// <summary>
- /// 聊天信息
- /// </summary>
- /// <param name="dt"></param>
- private void getChitChatMessege()
- {
- for (int i = 0; i < dataTable3.Rows.Count; i++)//循环供应商
- {
- PurTaskChatEntity ReviewBillMEntity = new PurTaskChatEntity();
- ReviewBillMEntity.TaskId = lb_taskId.Text;
- //ReviewBillMEntity.ReceiverUserid = UserInfo.GetUserID();//ReceiverUserid属性传采购商代码
- ReviewBillMEntity.SenderUserid = dataTable3.Rows[i]["SUPPCODE"].ToString();//SenderUserid属性传供应商代码
- DataTable dt_ChitChatNew = this.execute<DataTable>("com.hnshituo.pur.purplan.service.TaskChatService", "getChitChatMessege", new object[] { ReviewBillMEntity });
- int count = dt_ChitChatNew.Rows.Count;
- Control[] ctrs = ultraTabControl1.Controls.Find(dataTable3.Rows[i]["SUPPCODE"].ToString(), true);
- if (count > Q_ChatcCount[i])//有新的聊天记录
- {
- //循环聊天框tab中的文本框,将聊天记录读取
- foreach (Control ctr in ctrs)
- {
- if (ctr is RichTextBox)
- {
- RichTextBox rtb = (RichTextBox)ctr;//找到对应的富文本框
- int[,] MassageColor = new int[(dt_ChitChatNew.Rows.Count - Q_ChatcCount[i]) * 2, 3];//二位数组,保存聊天记录,字体显示颜色
- //判断是否有信息输入,有信息输入则增加,没有信息记录则不增加信息
- for (int j = Q_ChatcCount[i]; j < dt_ChitChatNew.Rows.Count; j++)
- {
- if (dt_ChitChatNew.Rows[j]["SENDERTYPE"].ToString() == "2")
- {
- MassageColor[j - Q_ChatcCount[i], 2] = 2;
- }
- else
- {
- MassageColor[j - Q_ChatcCount[i], 2] = 1;
- }
- string str = "\n" + dt_ChitChatNew.Rows[j]["SENDERUSERNAME"].ToString() + "(" + dt_ChitChatNew.Rows[j]["SENDERUSERID"].ToString() + ")" + dt_ChitChatNew.Rows[j]["CREATETIME"].ToString() + "\n";
- MassageColor[j - Q_ChatcCount[i], 0] = rtb.Text.Length; ;//标记颜色起始位置
- rtb.AppendText(str);
- MassageColor[j - Q_ChatcCount[i], 1] = str.Length;//标记颜色结束位置
- MassageColor[(j - Q_ChatcCount[i]) + 1, 0] = rtb.Text.Length; ;//标记颜色起始位置
- rtb.AppendText(" " + dt_ChitChatNew.Rows[j]["MESSAGE"].ToString() + "\n");
- MassageColor[(j - Q_ChatcCount[i]) + 1, 1] = (" " + dt_ChitChatNew.Rows[j]["MESSAGE"].ToString() + "\n").Length;//标记颜色结束位置
- MassageColor[(j - Q_ChatcCount[i]) + 1, 2] = 3;//标记发送信息的颜色
- //rtb.SelectionStart = rtb.TextLength;//设置滚动条的位置
- //rtb.ScrollToCaret();//必须设置滚动起始标记位置
- }
- Q_ChatcCount[i] = count;//保存当前供应商聊天记录条数
- //rtb.SelectionStart = rtb.TextLength;//设置滚动条的位置
- //rtb.ScrollToCaret();//必须设置滚动起始标记位置
- setChatColor(rtb, MassageColor);
- //rtb.ScrollToCaret();//必须设置滚动起始标记位置
- changTabcolor(rtb);//有新的聊天记录时,设置聊天背景颜色
- break;//找到相应供应商聊天记录页面,退出循环,进入下一个供应商,直到结束
- }
- }
- }
- }
- }
- /// <summary>
- /// 设置聊天发送人显示颜色
- /// </summary>
- /// <param name="rtb">改变颜色RichTextBox控件</param>
- /// <param name="rows">聊天记录</param>
- protected void setChatColor(RichTextBox rtb, int[,] MassageColor)
- {
- for (int i = 0; i < MassageColor.GetLength(0); i++)
- {
- rtb.SelectionStart = MassageColor[i, 0];
- rtb.SelectionLength = MassageColor[i, 1];
-
- if (MassageColor[i, 2] == 1)
- {
- rtb.SelectionColor = Color.Red;
- }
- else if (MassageColor[i, 2] == 2)
- {
- rtb.SelectionColor = Color.Blue;
- }
- else
- {
- rtb.SelectionColor = Color.Black;
- }
- }
- }
- /// <summary>
- /// 设置文本控件滚动条
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void rtbLog_TextChanged(object sender, EventArgs e){
- RichTextBox rtb = (RichTextBox)sender;
- rtb.SelectionStart = rtb.Text.Length; //Set the current caret position at the end
- rtb.ScrollToCaret(); //Now scroll it automatically
- }
- public void LogAppend(Color color, string text, RichTextBox rtb)
- {
- rtb.SelectionColor = color;
- if (text.IndexOf(" ") != 0)
- {
- rtb.SelectedText = text;
- }
- else
- {
- rtb.SelectedText = text;
- }
- rtb.SelectedText = System.Environment.NewLine;
- rtb.ScrollToCaret();
- }
- /// <summary>
- /// 聊天表结构
- /// </summary>
- /// <param name="dt_supps"></param>
- private void setChitChatDt()
- {
- //设置tab聊天框
- for (int i = 0; i < dataTable3.Rows.Count; i++)
- {
- RichTextBox tb = new RichTextBox();
- tb.Name = dataTable3.Rows[i]["SUPPCODE"].ToString();
- tb.Dock = DockStyle.Fill;
- tb.Multiline = true;
- tb.ReadOnly = true;
- tb.TextChanged += new EventHandler(rtbLog_TextChanged);
- Infragistics.Win.UltraWinTabControl.UltraTab ultb = ultraTabControl1.Tabs.Add(dataTable3.Rows[i]["SUPPCODE"].ToString(), dataTable3.Rows[i]["SUPPNAME"].ToString() + "(" + dataTable3.Rows[i]["SUPPCODE"].ToString() + ")");
- //ultb.TabPage = ult_tpc;
- ultb.TabPage.Controls.Add(tb);
- QtabColor = ultb.TabPage.Tab.Appearance.BackColor;
- }
- //显示供应商聊天复选框
- int widthScreen_top = 0;//计算显示的供应商长度是否超出发送文本框的高度
- int widthScreen_left = 0;//计算显示的供应商长度是否超出发送文本框的宽度
- for (int i = 0; i < dataTable3.Rows.Count; i++)
- {
- CheckBox rb = new CheckBox();
- rb.Text = dataTable3.Rows[i]["SUPPNAME"].ToString() + "(" + dataTable3.Rows[i]["SUPPCODE"].ToString() + ")";
- rb.Name = dataTable3.Rows[i]["SUPPCODE"].ToString();
- rb.AutoSize = true;
- rb.Left = textBox1.Left + widthScreen_left;
- rb.Top = textBox1.Top - rb.Height * (widthScreen_top / textBox1.Width + 1);
- ultraGroupBox6.Controls.Add(rb);
- widthScreen_top += rb.Width + 5;
- widthScreen_left += rb.Width + 5;
- if (widthScreen_left > textBox1.Width)
- {
- widthScreen_left = 0;
- }
- if (i == dataTable3.Rows.Count - 1)
- {
- checkBox1.Left = textBox1.Left + widthScreen_left;//设置全选复选框的位置
- checkBox1.Top = rb.Top;
- }
- }
- }
- //刷新聊天记录
- private void timer1_Tick(object sender, EventArgs e)
- {
- timer1.Stop();
- timer3.Stop();
- getChitChatMessege();//刷新聊天信息
- timer1.Start();
- timer3.Start();
- }
- /// <summary>
- /// 刷新供应商报价
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void timer2_Tick(object sender, EventArgs e)
- {
- //timer1.Stop();
- //timer2.Stop();
- //getExamineMana();
- for (int i = 0; i < dataTable3.Rows.Count; i++)//循环供应商
- {
- Control[] ctrs = ultraTabControl1.Controls.Find(dataTable3.Rows[i]["SUPPCODE"].ToString(), true);
- //循环聊天框tab中的文本框,将聊天记录读取
- foreach (Control ctr in ctrs)
- {
- RichTextBox rtb = (RichTextBox)ctr;
- rtb.SelectionStart = rtb.Text.Length; //Set the current caret position at the end
- rtb.ScrollToCaret(); //Now scroll it automatically
- }
- }
- timer2.Stop();
- //timer1.Start();
- //timer2.Start();
- }
- /// <summary>
- /// 发送信息按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_SendMessage_Click(object sender, EventArgs e)
- {
- sendMessage();
- }
- /// <summary>
- /// 发送信息
- /// </summary>
- private void sendMessage()
- {
- if (textBox1.Text.Trim() == "")
- {
- MessageUtil.ShowTips("发送类容不能为空");
- return;
- }
- textBox1.Text = textBox1.Text.Replace("\n", "\n ");
- ArrayList al = new ArrayList();
- foreach (Control ctr in ultraGroupBox6.Controls)
- {
- if (ctr is CheckBox)
- {
- CheckBox ckb = (CheckBox)ctr;
- if (ckb.Checked && ckb.Name != "checkBox1")
- {
- PurTaskChatEntity ReviewBillMEntity = new PurTaskChatEntity();
- ReviewBillMEntity.Id = Guid.NewGuid().ToString();
- ReviewBillMEntity.TaskId = lb_taskId.Text;
- ReviewBillMEntity.SenderType = "2";
- ReviewBillMEntity.SenderUsername = UserInfo.GetUserName();
- ReviewBillMEntity.SenderUserid = UserInfo.GetUserID();
- ReviewBillMEntity.ReceiverType = "1";
- ReviewBillMEntity.ReceiverUserid = ckb.Name;
- ReviewBillMEntity.ReceiverUsername = ckb.Text.Substring(0, ckb.Text.LastIndexOf(ckb.Name) - 1);
- ReviewBillMEntity.CreateName = UserInfo.GetUserName();
- ReviewBillMEntity.CreateUserid = UserInfo.GetUserID();
- //ReviewBillMEntity.CreateTime = System.DateTime.Now;
- ReviewBillMEntity.Message = textBox1.Text;
- ReviewBillMEntity.Isread = "0";
- al.Add(ReviewBillMEntity);
- }
- }
- }
- if (al.Count < 1)
- {
- MessageUtil.ShowTips("请选择发送的供应商");
- }
- else
- {
- Boolean bl = true;
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.purplan.service.TaskChatService", "sendChatMessage", new object[] { al });
- if (bl)
- {
- timer1.Stop();
- //timer2.Stop();
- getChitChatMessege();//刷新聊天信息
- timer1.Start();
- //timer2.Start();
- textBox1.Text = "";
- }
- else
- {
- MessageUtil.ShowTips("发送失败,请重新发送");
- }
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("发送失败 " + crt.Resultmsg);
- return;
- }
- }
- }
- /// <summary>
- /// 关闭窗体是时间计时器停止
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void frmInto_Examine_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (timer1 != null)
- timer1.Dispose();
- if (timer2 != null)
- timer2.Dispose();
- if (timer3 != null)
- timer3.Dispose();
- }
- /// <summary>
- /// 全选所有的供应商复选框
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- foreach (Control ctr in ultraGroupBox6.Controls)
- {
- if (ctr is CheckBox)
- {
- CheckBox cb = (CheckBox)ctr;
- cb.Checked = checkBox1.Checked;
- }
- }
- }
- //打包询价
- private void button5_Click(object sender, EventArgs e)
- {
- }
- /// <summary>
- /// 有新的聊天记录时,设置聊天背景颜色
- /// </summary>
- private void changTabcolor(Control ctr)
- {
- if (ctr.Parent is Infragistics.Win.UltraWinTabControl.UltraTabPageControl)
- {
- Infragistics.Win.UltraWinTabControl.UltraTabPageControl ultb = (Infragistics.Win.UltraWinTabControl.UltraTabPageControl)ctr.Parent;
- if (!ultraTabControl1.ActiveTab.TabPage.Equals(ultb))//如果tab页面已经是打开状态则不用变换颜色,否则变换
- {
- ctr.Parent.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
- }
- }
- }
- //信息已经阅读,背景颜色变回原来的颜色
- private void ultraTabControl1_ActiveTabChanged(object sender, Infragistics.Win.UltraWinTabControl.ActiveTabChangedEventArgs e)
- {
- if (QtabColor != null)
- {
- ultraTabControl1.ActiveTab.TabPage.Tab.Appearance.BackColor = QtabColor;
- }
- }
- /// <summary>
- /// 初拟中标价格
- /// </summary>
- /// <returns></returns>
- private DataTable setPriceMin()
- {
- ultraGrid1.UpdateData();
- DataTable dt = Q_dt_getExamineMana.Copy();
- if (dt.Columns.Count < 2)
- {
- MessageUtil.ShowTips("没有供应商报价,不能进行初拟中标价格");
- return null;
- }
- //清楚数量,金额,交货日期所在行
- for (int i = 0; i < dt.Rows.Count; )
- {
- if (dt.Rows[i][0].ToString().IndexOf("数") == 0)
- {
- dt.Rows.RemoveAt(i);
- continue;
- }
- else if (dt.Rows[i][0].ToString().IndexOf("金") == 0)
- {
- dt.Rows.RemoveAt(i);
- continue;
- }
- else if (dt.Rows[i][0].ToString().IndexOf("交") == 0)
- {
- dt.Rows.RemoveAt(i);
- continue;
- }
- i++;
- }
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dt.Rows[i][0].ToString().IndexOf("单") == 0)
- {
- int num = 1;//默认为第一个供应商报价为最低
- int MinPrice = 0;
- if (dt.Rows[i][1].ToString() != "" && StringUtil.IsNumber(dt.Rows[i][1].ToString()))
- {
- MinPrice = Convert.ToInt32(dt.Rows[i][1].ToString());
- }
- for (int j = 1; j < dt.Columns.Count; j++)
- {
- string strMinPrice = dt.Rows[i][j].ToString();
- if (strMinPrice != "" && StringUtil.IsNumber(strMinPrice))//是否为数字
- {
- if (MinPrice > Convert.ToInt32(strMinPrice))//比较
- {
- MinPrice = Convert.ToInt32(strMinPrice);//保存最小报价
- num = j;//保存最小报价所在的列
- }
- }
- }
- //将最小报价赋值到第二列
- dt.Rows[i][1] = dt.Rows[i][num];
- //将供应商名称赋值到供应商报价上一列
- dt.Rows[i - 1][1] = dt.Columns[num].Caption;
- }
- }
- //保留dt前两列
- for (int i = 2; i < dt.Columns.Count; )
- {
- dt.Columns.RemoveAt(i);
- }
- dt.Columns[1].Caption = "最低报价供应商";
- return dt;
- }
- /// <summary>
- /// 刷新评标报价
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void timer3_Tick(object sender, EventArgs e)
- {
- timer1.Stop();
- timer3.Stop();
- getExamineMana();
- timer1.Start();
- timer3.Start();
- }
- /// <summary>
- /// 添加快捷键功能
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void textBox1_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.A && e.Control)
- {
- textBox1.SelectAll();//全选功能
- e.Handled = true; //将Handled设置为true,指示已经处理过KeyPress事件,输入的值无效 button1.PerformClick();
- }
- else if (e.Shift && e.KeyCode == Keys.Enter)
- {
- //textBox1.Text += Environment.NewLine;//按回车键和shift键换行
- //e.Handled = true; //将Handled设置为true,指示已经处理过KeyPress事件,输入的值无效
- }
- else if (e.Control && e.KeyCode == Keys.Enter)
- {
- //textBox1.Text += Environment.NewLine;//按回车键和Control键换行
- //e.Handled = true; //将Handled设置为true,指示已经处理过KeyPress事件,输入的值无效
- }
- else if(e.KeyCode == Keys.Enter)
- {
- sendMessage();//按回车键发送信息
- e.Handled = true; //将Handled设置为true,指示已经处理过KeyPress事件,输入的值无效
- }
-
- }
- }
- }
|