| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653 |
- 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 CoreFS.SA06;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Tool;
- using Infragistics.Win.UltraWinGrid;
- using Infragistics.Win;
- using CoreFS.CA06;
- using System.Net;
- using System.Collections;
- namespace Core.StlMes.Client.BuyBillet
- {
- public partial class RptProduction : FrmBase
- {
- public RptProduction()
- {
- InitializeComponent();
- }
- private void RptProduction_Load(object sender, EventArgs e)
- {
- ForbidSort();
- this.rptdate.Value = DateTime.Today;
- }
- private void getproductions()
- {
- WaitingForm2 wf = new WaitingForm2("正在加载数据,请稍候....");
- try
- {
- string mydate = ((DateTime)this.rptdate.Value).ToString("yyyy-MM-dd");
- DataTable dtqry = ServerHelper.GetData("com.steering.rpt.production.TotalProduction.getQuantity", new object[] { mydate }, this.ob);
- /**分层显示**********/
- //summarytable(dtqry);
- /************/
- /**汇总显示**********/
- summary(dtqry);
- /************/
- GridHelper.CopyDataToDatatable(ref dtqry, ref this.dataTable1, true);
- RefreshSetting(ultraGrid1,((DateTime)this.rptdate.Value).ToString("yyyy年M月d日"));
- wf.Close();
- }
- catch(Exception e)
- {
- MessageBox.Show(e.Message);
- }
- finally
- {
- wf.Close();
- }
- }
- private void summarytable(DataTable dtqry)
- {
- dataTable0.Clear();
- if (dtqry.Rows.Count > 0)
- {
- dtqry.Columns.Add("processcode_area", Type.GetType("System.String"));
- dtqry.Columns.Add("processpline", Type.GetType("System.String"));
- string a = dtqry.Rows[0]["processcode"].ToString();
- decimal outputweight = 0, production = 0, totalproduction = 0,totaloutputweight = 0;
- decimal input = 0, output = 0, firstgood = 0, totalinput = 0, totaloutput = 0, totalfirstgood = 0;
- for (int i = 0; i < dtqry.Rows.Count; i++)
- {
- dtqry.Rows[i]["processcode_area"] = dtqry.Rows[i]["processcode"].ToString() + dtqry.Rows[i]["area"].ToString() ;
- dtqry.Rows[i]["processpline"] = dtqry.Rows[i]["processcode"].ToString() + dtqry.Rows[i]["plinename"].ToString();
- if (dtqry.Rows[i]["production"].ToString() != "")
- production += Convert.ToDecimal(dtqry.Rows[i]["production"].ToString());
- if (dtqry.Rows[i]["input"].ToString() != "")
- input += Convert.ToDecimal(dtqry.Rows[i]["input"].ToString());
- if (dtqry.Rows[i]["output"].ToString() != "")
- output += Convert.ToDecimal(dtqry.Rows[i]["output"].ToString());
- if (dtqry.Rows[i]["outputweight"].ToString() != "")
- outputweight += Convert.ToDecimal(dtqry.Rows[i]["outputweight"].ToString());
- if (dtqry.Rows[i]["firstgood"].ToString() != "")
- firstgood += Convert.ToDecimal(dtqry.Rows[i]["firstgood"].ToString());
- if (dtqry.Rows[i]["totalproduction"].ToString() != "")
- totalproduction += Convert.ToDecimal(dtqry.Rows[i]["totalproduction"].ToString());
- if (dtqry.Rows[i]["totalinput"].ToString() != "")
- totalinput += Convert.ToDecimal(dtqry.Rows[i]["totalinput"].ToString());
- if (dtqry.Rows[i]["totaloutput"].ToString() != "")
- totaloutput += Convert.ToDecimal(dtqry.Rows[i]["totaloutput"].ToString());
- if (dtqry.Rows[i]["totaloutputweight"].ToString() != "")
- totaloutputweight += Convert.ToDecimal(dtqry.Rows[i]["totaloutputweight"].ToString());
- if (dtqry.Rows[i]["totalfirstgood"].ToString() != "")
- totalfirstgood += Convert.ToDecimal(dtqry.Rows[i]["totalfirstgood"].ToString());
- if (i + 1 == dtqry.Rows.Count || i + 1 < dtqry.Rows.Count && dtqry.Rows[i + 1]["processcode"].ToString() != a)
- {
- DataRow myrow = dataTable0.NewRow();
- myrow["processcode_t"] = dtqry.Rows[i]["processcode"].ToString();
- if (production != 0)
- myrow["production_t"] = production.ToString("#,###,##0.000");
- if (outputweight != 0)
- myrow["outputweight_t"] = outputweight.ToString("#,###,##0.000");
-
- if (input != 0)
- myrow["productionrate_t"] = Math.Round(production * 100 / input,2).ToString("##0.00")+"%";
- if (output != 0)
- myrow["firstgoodrate_t"] = Math.Round(firstgood * 100 / output, 2).ToString("##0.00") + "%";
-
- if (totalproduction != 0)
- myrow["totalproduction_t"] = totalproduction.ToString("#,###,##0.000");
- if (totaloutputweight != 0)
- myrow["totaloutputweight_t"] = totaloutputweight.ToString("#,###,##0.000");
-
- if (input != 0)
- myrow["totalproductionrate_t"] = Math.Round(totalproduction * 100 / totalinput, 2).ToString("##0.00") + "%";
- if (output != 0)
- myrow["totalfirstgoodrate_t"] = Math.Round(totalfirstgood * 100 / totaloutput, 2).ToString("##0.00") + "%";
- dataTable0.Rows.Add(myrow);
- if (i + 1 < dtqry.Rows.Count)
- {
- a = dtqry.Rows[i + 1]["processcode"].ToString();
- production = 0;
- outputweight = 0;
- input = 0;
- output = 0;
- firstgood = 0;
-
- totalproduction = 0;
- totaloutputweight = 0;
- totalinput = 0;
- totaloutput = 0;
- totalfirstgood = 0;
- }
- else
- break;
- }
- }
- }
- }
- private void summary(DataTable dtqry)
- {
- if (dtqry.Rows.Count > 0)
- {
- dtqry.Columns.Add("processcode_area", Type.GetType("System.String"));
- dtqry.Columns.Add("processpline", Type.GetType("System.String"));
- string a = dtqry.Rows[0]["processcode"].ToString();
- string b = dtqry.Rows[0]["processcode"].ToString() + dtqry.Rows[0]["dept"].ToString();
- string c = dtqry.Rows[0]["processcode"].ToString() + dtqry.Rows[0]["area"].ToString(); ;
- decimal[] outputweight = { 0, 0, 0 }, production = { 0, 0, 0 }, totalproduction = { 0, 0, 0 }, totaloutputweight = { 0, 0, 0 };
- decimal[] input = { 0, 0, 0 }, output = { 0, 0, 0 }, firstgood = { 0, 0, 0 }, totalinput = { 0, 0, 0 }, totaloutput = { 0, 0, 0 }, totalfirstgood = { 0, 0, 0 };
- int count = 0, count1=0;
- try
- {
- for (int i = 0; i < dtqry.Rows.Count; i++)
- {
- count++;
- count1++;
- dtqry.Rows[i]["processcode_area"] = dtqry.Rows[i]["processcode"].ToString() + dtqry.Rows[i]["area"].ToString() + dtqry.Rows[i]["dept"].ToString();
- dtqry.Rows[i]["processpline"] = dtqry.Rows[i]["processcode"].ToString() + dtqry.Rows[i]["plinename"].ToString();
- if (dtqry.Rows[i]["production"].ToString() != "")
- {
- production[0] += Convert.ToDecimal(dtqry.Rows[i]["production"].ToString());
- production[1] += Convert.ToDecimal(dtqry.Rows[i]["production"].ToString());
- production[2] += Convert.ToDecimal(dtqry.Rows[i]["production"].ToString());
- }
- if (dtqry.Rows[i]["input"].ToString() != "")
- {
- input[0] += Convert.ToDecimal(dtqry.Rows[i]["input"].ToString());
- input[1] += Convert.ToDecimal(dtqry.Rows[i]["input"].ToString());
- input[2] += Convert.ToDecimal(dtqry.Rows[i]["input"].ToString());
- if (dtqry.Rows[i]["production"].ToString() != "" && Convert.ToDecimal(dtqry.Rows[i]["input"].ToString())!=0)
- dtqry.Rows[i]["productionrate"] = Math.Round(Convert.ToDecimal(dtqry.Rows[i]["production"].ToString()) * 100 / Convert.ToDecimal(dtqry.Rows[i]["input"].ToString()), 2).ToString("##0.00") + "%";
- }
- if (dtqry.Rows[i]["output"].ToString() != "")
- {
- output[0] += Convert.ToDecimal(dtqry.Rows[i]["output"].ToString());
- output[1] += Convert.ToDecimal(dtqry.Rows[i]["output"].ToString());
- output[2] += Convert.ToDecimal(dtqry.Rows[i]["output"].ToString());
- if (dtqry.Rows[i]["firstgood"].ToString() != "" && Convert.ToDecimal(dtqry.Rows[i]["output"].ToString())!=0)
- dtqry.Rows[i]["firstgoodrate"] = Math.Round(Convert.ToDecimal(dtqry.Rows[i]["firstgood"].ToString()) * 100 / Convert.ToDecimal(dtqry.Rows[i]["output"].ToString()), 2).ToString("##0.00") + "%";
- }
- if (dtqry.Rows[i]["outputweight"].ToString() != "")
- {
- outputweight[0] += Convert.ToDecimal(dtqry.Rows[i]["outputweight"].ToString());
- outputweight[1] += Convert.ToDecimal(dtqry.Rows[i]["outputweight"].ToString());
- outputweight[2] += Convert.ToDecimal(dtqry.Rows[i]["outputweight"].ToString());
- }
- if (dtqry.Rows[i]["firstgood"].ToString() != "")
- {
- firstgood[0] += Convert.ToDecimal(dtqry.Rows[i]["firstgood"].ToString());
- firstgood[1] += Convert.ToDecimal(dtqry.Rows[i]["firstgood"].ToString());
- firstgood[2] += Convert.ToDecimal(dtqry.Rows[i]["firstgood"].ToString());
- }
- if (dtqry.Rows[i]["totalproduction"].ToString() != "")
- {
- totalproduction[0] += Convert.ToDecimal(dtqry.Rows[i]["totalproduction"].ToString());
- totalproduction[1] += Convert.ToDecimal(dtqry.Rows[i]["totalproduction"].ToString());
- totalproduction[2] += Convert.ToDecimal(dtqry.Rows[i]["totalproduction"].ToString());
- }
- if (dtqry.Rows[i]["totalinput"].ToString() != "")
- {
- totalinput[0] += Convert.ToDecimal(dtqry.Rows[i]["totalinput"].ToString());
- totalinput[1] += Convert.ToDecimal(dtqry.Rows[i]["totalinput"].ToString());
- totalinput[2] += Convert.ToDecimal(dtqry.Rows[i]["totalinput"].ToString());
- if (dtqry.Rows[i]["totalproduction"].ToString() != "" && Convert.ToDecimal(dtqry.Rows[i]["totalinput"].ToString())!=0)
- dtqry.Rows[i]["productionrate_m"] = Math.Round(Convert.ToDecimal(dtqry.Rows[i]["totalproduction"].ToString()) * 100 / Convert.ToDecimal(dtqry.Rows[i]["totalinput"].ToString()), 2).ToString("##0.00") + "%";
- }
- if (dtqry.Rows[i]["totaloutput"].ToString() != "")
- {
- totaloutput[0] += Convert.ToDecimal(dtqry.Rows[i]["totaloutput"].ToString());
- totaloutput[1] += Convert.ToDecimal(dtqry.Rows[i]["totaloutput"].ToString());
- totaloutput[2] += Convert.ToDecimal(dtqry.Rows[i]["totaloutput"].ToString());
- if (dtqry.Rows[i]["totalfirstgood"].ToString() != "" && Convert.ToDecimal(dtqry.Rows[i]["totaloutput"].ToString())!=0)
- dtqry.Rows[i]["firstgoodrate_m"] = Math.Round(Convert.ToDecimal(dtqry.Rows[i]["totalfirstgood"].ToString()) * 100 / Convert.ToDecimal(dtqry.Rows[i]["totaloutput"].ToString()), 2).ToString("##0.00") + "%";
- }
- if (dtqry.Rows[i]["totaloutputweight"].ToString() != "")
- {
- totaloutputweight[0] += Convert.ToDecimal(dtqry.Rows[i]["totaloutputweight"].ToString());
- totaloutputweight[1] += Convert.ToDecimal(dtqry.Rows[i]["totaloutputweight"].ToString());
- totaloutputweight[2] += Convert.ToDecimal(dtqry.Rows[i]["totaloutputweight"].ToString());
- }
- if (dtqry.Rows[i]["totalfirstgood"].ToString() != "")
- {
- totalfirstgood[0] += Convert.ToDecimal(dtqry.Rows[i]["totalfirstgood"].ToString());
- totalfirstgood[1] += Convert.ToDecimal(dtqry.Rows[i]["totalfirstgood"].ToString());
- totalfirstgood[2] += Convert.ToDecimal(dtqry.Rows[i]["totalfirstgood"].ToString());
- }
- string processcode = "", dept = "", area = "";
- if (i + 1 < dtqry.Rows.Count)
- {
- processcode = dtqry.Rows[i + 1]["processcode"].ToString();
- dept = dtqry.Rows[i + 1]["dept"].ToString();
- area = dtqry.Rows[i + 1]["area"].ToString();
- }
- if (i + 1 == dtqry.Rows.Count || i + 1 < dtqry.Rows.Count && processcode + dept != b)
- {
- if (count > 1 && (processcode == a && processcode + dept != b || i + 1 == dtqry.Rows.Count || (processcode != a
- && production[0]<production[1] && outputweight[0]<outputweight[1]
- && totalproduction[0] < totalproduction[1] && totaloutputweight[0] < totaloutputweight[1] && processcode + dept != b)))
- {
- DataRow myrow = dtqry.NewRow();
- myrow["processcode_area"] = dtqry.Rows[i]["processcode_area"].ToString();
- myrow["processcode"] = dtqry.Rows[i]["processcode"].ToString();
- myrow["area"] = dtqry.Rows[i]["area"];
- myrow["dept"] = dtqry.Rows[i]["dept"];
- myrow["plinename"] = "小计";
- myrow["processpline"] = myrow["processcode"].ToString() + dtqry.Rows[i]["dept"].ToString() + myrow["plinename"].ToString();
- if (production[0] != 0)
- myrow["production"] = production[0].ToString("#,###,##0.000");
- if (outputweight[0] != 0)
- myrow["outputweight"] = outputweight[0].ToString("#,###,##0.000");
- if (input[0] != 0)
- myrow["productionrate"] = Math.Round(production[0] * 100 / input[0], 2).ToString("##0.00") + "%";
- if (output[0] != 0)
- myrow["firstgoodrate"] = Math.Round(firstgood[0] * 100 / output[0], 2).ToString("##0.00") + "%";
- if (totalproduction[0] != 0)
- myrow["totalproduction"] = totalproduction[0].ToString("#,###,##0.000");
- if (totaloutputweight[0] != 0)
- myrow["totaloutputweight"] = totaloutputweight[0].ToString("#,###,##0.000");
- if (totalinput[0] != 0)
- myrow["productionrate_m"] = Math.Round(totalproduction[0] * 100 / totalinput[0], 2).ToString("##0.00") + "%";
- if (totaloutput[0] != 0)
- myrow["firstgoodrate_m"] = Math.Round(totalfirstgood[0] * 100 / totaloutput[0], 2).ToString("##0.00") + "%";
- dtqry.Rows.InsertAt(myrow, ++i);
- }
- if (i + 1 < dtqry.Rows.Count && processcode + dept != b)
- {
- b = processcode + dept;
- count = 0;
- production[0] = 0;
- outputweight[0] = 0;
- input[0] = 0;
- output[0] = 0;
- firstgood[0] = 0;
- totalproduction[0] = 0;
- totaloutputweight[0] = 0;
- totalinput[0] = 0;
- totaloutput[0] = 0;
- totalfirstgood[0] = 0;
- }
- if (count1 > 1 && (processcode == a && processcode + area != c || i + 1 == dtqry.Rows.Count || (processcode != a
- && production[2] < production[1] && outputweight[2] < outputweight[1]
- && totalproduction[2] < totalproduction[1] && totaloutputweight[2] < totaloutputweight[1] && processcode + area != c)))
- {
- DataRow myrow = dtqry.NewRow();
- myrow["processcode_area"] = dtqry.Rows[i]["processcode_area"].ToString();
- myrow["processcode"] = dtqry.Rows[i]["processcode"].ToString();
- myrow["area"] = dtqry.Rows[i]["area"];
- myrow["dept"] = "小计";
- myrow["processpline"] = myrow["processcode"].ToString() + dtqry.Rows[i]["dept"].ToString() + myrow["plinename"].ToString();
- if (production[2] != 0)
- myrow["production"] = production[2].ToString("#,###,##0.000");
- if (outputweight[2] != 0)
- myrow["outputweight"] = outputweight[2].ToString("#,###,##0.000");
- if (input[2] != 0)
- myrow["productionrate"] = Math.Round(production[2] * 100 / input[2], 2).ToString("##0.00") + "%";
- if (output[2] != 0)
- myrow["firstgoodrate"] = Math.Round(firstgood[2] * 100 / output[2], 2).ToString("##0.00") + "%";
- if (totalproduction[2] != 0)
- myrow["totalproduction"] = totalproduction[2].ToString("#,###,##0.000");
- if (totaloutputweight[2] != 0)
- myrow["totaloutputweight"] = totaloutputweight[2].ToString("#,###,##0.000");
- if (totalinput[2] != 0)
- myrow["productionrate_m"] = Math.Round(totalproduction[2] * 100 / totalinput[2], 2).ToString("##0.00") + "%";
- if (totaloutput[2] != 0)
- myrow["firstgoodrate_m"] = Math.Round(totalfirstgood[2] * 100 / totaloutput[2], 2).ToString("##0.00") + "%";
- dtqry.Rows.InsertAt(myrow, ++i);
- }
- if (i + 1 < dtqry.Rows.Count && processcode + area != c)
- {
- c = processcode + area;
- count1 = 0;
- production[2] = 0;
- outputweight[2] = 0;
- input[2] = 0;
- output[2] = 0;
- firstgood[2] = 0;
- totalproduction[2] = 0;
- totaloutputweight[2] = 0;
- totalinput[2] = 0;
- totaloutput[2] = 0;
- totalfirstgood[2] = 0;
- }
-
- if (i + 1 == dtqry.Rows.Count || processcode != a)
- {
- DataRow myrow = dtqry.NewRow();
- myrow["processcode_area"] = dtqry.Rows[i]["processcode_area"].ToString();
- myrow["processcode"] = dtqry.Rows[i]["processcode"].ToString();
- myrow["area"] = "合计";
- myrow["processpline"] = myrow["processcode"].ToString() + myrow["area"].ToString();
- if (production[1] != 0)
- myrow["production"] = production[1].ToString("#,###,##0.000");
- if (outputweight[1] != 0)
- myrow["outputweight"] = outputweight[1].ToString("#,###,##0.000");
- if (input[1] != 0)
- myrow["productionrate"] = Math.Round(production[1] * 100 / input[1], 2).ToString("##0.00") + "%";
- if (output[1] != 0)
- myrow["firstgoodrate"] = Math.Round(firstgood[1] * 100 / output[1], 2).ToString("##0.00") + "%";
- if (totalproduction[1] != 0)
- myrow["totalproduction"] = totalproduction[1].ToString("#,###,##0.000");
- if (totaloutputweight[1] != 0)
- myrow["totaloutputweight"] = totaloutputweight[1].ToString("#,###,##0.000");
- if (totalinput[1] != 0)
- myrow["productionrate_m"] = Math.Round(totalproduction[1] * 100 / totalinput[1], 2).ToString("##0.00") + "%";
- if (totaloutput[1] != 0)
- myrow["firstgoodrate_m"] = Math.Round(totalfirstgood[1] * 100 / totaloutput[1], 2).ToString("##0.00") + "%";
- dtqry.Rows.InsertAt(myrow, ++i);
- if (i + 1 < dtqry.Rows.Count)
- {
- a = processcode;
- production[1] = 0;
- outputweight[1] = 0;
- input[1] = 0;
- output[1] = 0;
- firstgood[1] = 0;
- totalproduction[1] = 0;
- totaloutputweight[1] = 0;
- totalinput[1] = 0;
- totaloutput[1] = 0;
- totalfirstgood[1] = 0;
- }
- else if (i + 1 == dtqry.Rows.Count)
- break;
- }
- }
- }
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message);
- }
- finally
- {
-
- }
- }
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- base.ToolBar_Click(sender, ToolbarKey);
- switch (ToolbarKey)
- {
- case "Query":
- getproductions();
- break;
- case "Export":
- Export();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- private void Export()
- {
- GridHelper.ulGridToExcel(ultraGrid1, "产量日报");
- }
-
- /// <summary>
- /// 禁止排序
- /// </summary>
- /// <param name="ugr"></param>
- public void ForbidSort()
- {
- foreach (UltraGridColumn ugc in ultraGrid1.DisplayLayout.Bands[0].Columns)
- {
- ugc.SortIndicator = SortIndicator.Disabled;
- ugc.AllowRowFiltering = DefaultableBoolean.False;
- }
- }
- /// <summary>
- /// 刷新Grid数据并根据数据调整Grid列宽
- /// </summary>
- /// <param name="ultraGrid">需要处理的Grid</param>
- public static void RefreshSetting(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid,string mydate)
- {
- try
- {
- ultraGrid.DataBind();
- foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
- {
- CustomMergedCellEvaluator merge = new CustomMergedCellEvaluator("processcode_area");
- //band.Columns["area"].MergedCellEvaluator = merge;
- band.Columns["dept"].MergedCellEvaluator = merge;
- band.Header.Caption = mydate + "产量日报";
- //band.Columns["production"].Format = "{0:##,###.000}";
- //band.Columns["totalproduction"].Format = "{0:#,##0.000}";
- //band.Columns["firstgoodrate"].Format = "{0:#0.##%}";
- //band.Columns["productionrate"].Format = "{0:#0.##%}";
- //band.Columns["firstgoodrate_m"].Format = "{0:#0.##%}";
- //band.Columns["productionrate_m"].Format = "{0:#0.##%}";
- //band.Columns["plinename"].PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
- foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
- {
- column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
- }
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in band.GetRowEnumerator(GridRowType.DataRow))
- {
- if (row.Cells["area"].Text == "合计")
- {
- row.Cells["area"].Appearance.BackColor = Color.LightYellow;
- row.Cells["dept"].Appearance.BackColor = Color.LightYellow;
- row.Cells["plinename"].Appearance.BackColor = Color.LightYellow;
- row.Cells["production"].Appearance.BackColor = Color.LightYellow;
- row.Cells["totalproduction"].Appearance.BackColor = Color.LightYellow;
- row.Cells["outputweight"].Appearance.BackColor = Color.LightYellow;
- row.Cells["totaloutputweight"].Appearance.BackColor = Color.LightYellow;
- if (row.Cells["processcode"].Text != "A")
- {
- row.Cells["productionrate"].Appearance.BackColor = Color.LightYellow;
- row.Cells["productionrate_m"].Appearance.BackColor = Color.LightYellow;
- row.Cells["firstgoodrate"].Appearance.BackColor = Color.LightYellow;
- row.Cells["firstgoodrate_m"].Appearance.BackColor = Color.LightYellow;
- }
- }
- if (row.Cells["plinename"].Text == "小计")
- {
- row.Cells["plinename"].Appearance.BackColor = Color.LightYellow;
- row.Cells["production"].Appearance.BackColor = Color.LightYellow;
- row.Cells["totalproduction"].Appearance.BackColor = Color.LightYellow;
- row.Cells["outputweight"].Appearance.BackColor = Color.LightYellow;
- row.Cells["totaloutputweight"].Appearance.BackColor = Color.LightYellow;
- if (row.Cells["processcode"].Text != "A")
- {
- row.Cells["productionrate"].Appearance.BackColor = Color.LightYellow;
- row.Cells["productionrate_m"].Appearance.BackColor = Color.LightYellow;
- row.Cells["firstgoodrate"].Appearance.BackColor = Color.LightYellow;
- row.Cells["firstgoodrate_m"].Appearance.BackColor = Color.LightYellow;
- }
- }
- if (row.Cells["dept"].Text == "小计")
- {
- row.Cells["dept"].Appearance.BackColor = Color.LemonChiffon;
- row.Cells["plinename"].Appearance.BackColor = Color.LemonChiffon;
- row.Cells["production"].Appearance.BackColor = Color.LemonChiffon;
- row.Cells["totalproduction"].Appearance.BackColor = Color.LemonChiffon;
- row.Cells["outputweight"].Appearance.BackColor = Color.LemonChiffon;
- row.Cells["totaloutputweight"].Appearance.BackColor = Color.LemonChiffon;
- if (row.Cells["processcode"].Text != "A")
- {
- row.Cells["productionrate"].Appearance.BackColor = Color.LemonChiffon;
- row.Cells["productionrate_m"].Appearance.BackColor = Color.LemonChiffon;
- row.Cells["firstgoodrate"].Appearance.BackColor = Color.LemonChiffon;
- row.Cells["firstgoodrate_m"].Appearance.BackColor = Color.LemonChiffon;
- }
- }
- //if (row.Cells["production"].Text != "")
- //{
- // row.Cells["production"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button;
- // row.Cells["production"].ButtonAppearance.Cursor = Cursors.Hand;
- //}
- //if (row.Cells["outputweight"].Text != "")
- //{
- // row.Cells["outputweight"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button;
- // row.Cells["outputweight"].ButtonAppearance.Cursor = Cursors.Hand;
- //}
- }
- }
- ultraGrid.Refresh();
- }
- catch { }
- }
- public class CustomMergedCellEvaluator : Infragistics.Win.UltraWinGrid.IMergedCellEvaluator
- {
- private string primaryKey;
- ///
- /// 获取或设置合并列的主键列的绑定名称
- ///
- public string PrimaryKey
- {
- get { return primaryKey; }
- set { primaryKey = value; }
- }
- ///
- /// CustomMergedCellEvaluator 的构造函数
- ///
- /// 主键列的绑定名称
- public CustomMergedCellEvaluator(string primaryKey)
- {
- this.primaryKey = primaryKey;
- }
- #region IMergedCellEvaluator 成员
- public bool ShouldCellsBeMerged(Infragistics.Win.UltraWinGrid.UltraGridRow row1, Infragistics.Win.UltraWinGrid.UltraGridRow row2, Infragistics.Win.UltraWinGrid.UltraGridColumn column)
- {
- //确认逻辑:如果是主键列,自动合并,否则通过联合主键来合并
- if (column.MergedCellStyle == Infragistics.Win.UltraWinGrid.MergedCellStyle.Always)
- {
- if (string.IsNullOrEmpty(this.primaryKey))
- {
- return row1.GetCellText(column) == row2.GetCellText(column);
- }
- if ((row1.GetCellValue(row1.Cells[this.primaryKey].Column).ToString() == row2.GetCellValue(row1.Cells[this.primaryKey].Column).ToString()) && (row1.GetCellText(column) == row2.GetCellText(column)))
- {
- return true;
- }
- }
- return false;
- }
- #endregion
- }
- private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
- {
- UltraGridBand band = e.Layout.Bands[0];
- CustomMergedCellEvaluator merge = new CustomMergedCellEvaluator("processcode_area");
- //e.Layout.Bands[1].Columns["OrderCode"].MergedCellStyle = MergedCellStyle.Always;
- band.Columns["area"].MergedCellEvaluator = merge;
- //foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
- //{
- // column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
- //}
- //band.PerformAutoResizeColumns(true, PerformAutoSizeType.VisibleRows);
- band.Columns["production"].Format = "{0:F ##,###.000}";
- band.Columns["totalproduction"].Format = "0:F ##,###.000";
- band.Columns["firstgoodrate"].Format = "0:F #####.00%";
- band.Columns["productionrate"].Format = "{0:F #####.00%}";
- band.Columns["firstgoodrate_m"].Format = "{0:F #####.00%}";
- band.Columns["productionrate_m"].Format = "{0:F #####.00%}";
- }
- private void ultraGrid1_BeforeRowExpanded(object sender, CancelableRowEventArgs e)
- {
- UltraGridBand band = ultraGrid1.DisplayLayout.Bands[0];
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in band.GetRowEnumerator(GridRowType.DataRow))
- {
- if (row.IsExpanded && row.Index != e.Row.Index)
- row.Expanded = false;
- }
- if (e.Row.Cells["plinename"].Text != "")
- getproduction_detail(e.Row.Cells["processcode"].Text, e.Row.Cells["plinename"].Text);
- }
- private void getproduction_detail(string processcode,string plinename)
- {
- WaitingForm2 wf = new WaitingForm2("正在加载数据,请稍候....");
- try
- {
- string mydate = ((DateTime)this.rptdate.Value).ToString("yyyy-MM-dd");
- string sqlid = "com.steering.rpt.production.TotalProduction.getQuantityA_detail";
- switch (processcode)
- {
- case "A":
- sqlid = "com.steering.rpt.production.TotalProduction.getQuantityA_detail";
- break;
- case "B":
- sqlid = "com.steering.rpt.production.TotalProduction.getQuantityB_detail";
- break;
- case "D":
- sqlid = "com.steering.rpt.production.TotalProduction.getQuantityD_detail";
- break;
- case "E":
- sqlid = "com.steering.rpt.production.TotalProduction.getQuantityE_detail";
- break;
- case "F":
- sqlid = "com.steering.rpt.production.TotalProduction.getQuantityF_detail";
- break;
- case "G":
- sqlid = "com.steering.rpt.production.TotalProduction.getQuantityG_detail";
- break;
- }
- DataTable dtqry = ServerHelper.GetData(sqlid, new object[] { mydate, plinename }, this.ob);
- dtqry.Columns.Add("processpline_d", Type.GetType("System.String"));
- foreach (DataRow myrow in dtqry.Rows)
- {
- myrow["processpline_d"] = myrow["processcode_d"].ToString() + myrow["plinename_d"].ToString();
- }
- GridHelper.CopyDataToDatatable(ref dtqry, ref this.dataTable2, true);
- //RefreshSetting(ultraGrid1);
- wf.Close();
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message);
- }
- finally
- {
- wf.Close();
- }
- }
- private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
- {
- }
- }
- }
|