| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- 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;
- 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;
- namespace Pur.Pop_upWindow
- {
- public partial class FrmPop_setPriceOne : FrmPmsBase
- {
- string Q_strTASKID = "";//修改数据库字段PUR_TASK_OFFER_C,PUR_TASK_C
- DataTable Q_dt_getExamineMana = null;
- DataTable Q_dtMinPrice = null;//保存显示最低价格供应商
- public FrmPop_setPriceOne(OpeBase ob, string strTASKID)
- {
- InitializeComponent();
- this.ob = ob;
- Q_strTASKID = strTASKID;
- InitializeComponent();
- }
-
- /// <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();
- }
- }
- /// <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 });
- 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 });
- //DataColumn[] dcs = {dtSupps.Columns["ITEMCODE"]};
- //dtSupps.PrimaryKey = dcs;
- 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++)//几个供应商
- {
- 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())//判断供应商与物料是否有报价权
- {
- for (int n = 1; n < dataTable4.Columns.Count; n++)
- dt.Rows[i * 6 + n][k + 1] = drSupps_dt4[m][n].ToString();//供应商报价信息
- break;
- }
- }
- }
- }
- //给表添加报价参数
- //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]["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;
- }
- /// <summary>
- /// 中标
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraButton1_Click(object sender, EventArgs e)
- {
- // 查询任务从表
- ultraGrid1.UpdateData();
- 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 });
- ArrayList al = new ArrayList();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- for (int j = 0; j < Q_dtMinPrice.Rows.Count; j++)
- {
- PurTaskCEntity M_PurTaskC_al = new PurTaskCEntity();
- M_PurTaskC_al.TaskId = Q_strTASKID;
- M_PurTaskC_al.Validflag = "1";
- string str = Q_dtMinPrice.Rows[j]["ITEM"].ToString();
- if (dt.Rows[i]["ITEMCODE"].ToString() == str.Substring(str.LastIndexOf(":") + 1) && str.IndexOf("备") != 0)
- {
- M_PurTaskC_al.TaskLineId = dt.Rows[i]["TASKLINEID"].ToString();
- if (Q_dtMinPrice.Rows[j][1] != null && Q_dtMinPrice.Rows[j][1].ToString() != "")//中标价
- {
- double db = 0;
- double.TryParse(Q_dtMinPrice.Rows[j + 1][1].ToString(), out db);
- M_PurTaskC_al.BidPrice = db;
- }
- else
- {
- M_PurTaskC_al.BidPrice = null;
- }
- if (Q_dtMinPrice.Rows[j + 2][1] != null)
- {
- M_PurTaskC_al.BidPriceReason = Q_dtMinPrice.Rows[j + 2][1].ToString();//中标价理由
- }
- al.Add(M_PurTaskC_al);
- break;
- }
- }
- }
- if (al.Count > 0)
- {
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.purplan.service.TaskCService", "UpdMinPrice", new object[] { al });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("提交失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("提交成功");
- this.Close();
- }
- }
- private void ultraButton2_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
|