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] 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, "产量日报"); } /// /// 禁止排序 /// /// public void ForbidSort() { foreach (UltraGridColumn ugc in ultraGrid1.DisplayLayout.Bands[0].Columns) { ugc.SortIndicator = SortIndicator.Disabled; ugc.AllowRowFiltering = DefaultableBoolean.False; } } /// /// 刷新Grid数据并根据数据调整Grid列宽 /// /// 需要处理的Grid 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) { } } }