| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530 |
- using System;
- using System.Data;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using CoreFS.CA06;
- using System.Threading;
- using System.Diagnostics;
- using Infragistics.Win.UltraWinMaskedEdit;
- using Infragistics.Win.UltraWinGrid;
- using Infragistics.Win;
- using System.IO;
- using Core.Mes.Client.Common;
- using Core.LgMes.Client.lgBll.lgReport;
- using Infragistics.Win.UltraWinMaskedEdit;
- namespace Core.LgMes.Client.LgIntegrationQuery
- {
- /// <summary>
- /// FrmIronEleQry 的摘要说明。
- /// </summary>
- public class FrmCcmBilletWgtsamplingReport : Core.Mes.Client.Common.frmStyleBase
- {
- private Infragistics.Win.UltraWinDataSource.UltraDataSource ultraDataSource1;
- private Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid1;
- private Infragistics.Win.Misc.UltraGroupBox ultraGroupBox1;
- private Infragistics.Win.UltraWinEditors.UltraDateTimeEditor uldtEndTime;
- private CheckBox chkTime;
- private Infragistics.Win.UltraWinEditors.UltraDateTimeEditor uldtBeginTime;
- private Label label4;
- private IContainer components;
- string strStartTime = "";
- private Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter GridExcelExporter;
- string strEndTime = "";
- public FrmCcmBilletWgtsamplingReport()
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- }
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- try
- {
- }
- catch { }
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- Infragistics.Win.Appearance appearance70 = new Infragistics.Win.Appearance();
- Infragistics.Win.Appearance appearance71 = new Infragistics.Win.Appearance();
- Infragistics.Win.Appearance appearance72 = new Infragistics.Win.Appearance();
- Infragistics.Win.Appearance appearance73 = new Infragistics.Win.Appearance();
- Infragistics.Win.Appearance appearance74 = new Infragistics.Win.Appearance();
- Infragistics.Win.Appearance appearance75 = new Infragistics.Win.Appearance();
- Infragistics.Win.Appearance appearance76 = new Infragistics.Win.Appearance();
- Infragistics.Win.Appearance appearance77 = new Infragistics.Win.Appearance();
- Infragistics.Win.Appearance appearance78 = new Infragistics.Win.Appearance();
- Infragistics.Win.Appearance appearance79 = new Infragistics.Win.Appearance();
- Infragistics.Win.Appearance appearance80 = new Infragistics.Win.Appearance();
- Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance();
- this.ultraDataSource1 = new Infragistics.Win.UltraWinDataSource.UltraDataSource(this.components);
- this.ultraGrid1 = new Infragistics.Win.UltraWinGrid.UltraGrid();
- this.ultraGroupBox1 = new Infragistics.Win.Misc.UltraGroupBox();
- this.label4 = new System.Windows.Forms.Label();
- this.chkTime = new System.Windows.Forms.CheckBox();
- this.uldtBeginTime = new Infragistics.Win.UltraWinEditors.UltraDateTimeEditor();
- this.uldtEndTime = new Infragistics.Win.UltraWinEditors.UltraDateTimeEditor();
- this.GridExcelExporter = new Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter(this.components);
- ((System.ComponentModel.ISupportInitialize)(this.ultraDataSource1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.ultraGrid1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.ultraGroupBox1)).BeginInit();
- this.ultraGroupBox1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.uldtBeginTime)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.uldtEndTime)).BeginInit();
- this.SuspendLayout();
- //
- // ultraGrid1
- //
- appearance70.TextHAlignAsString = "Left";
- this.ultraGrid1.DisplayLayout.CaptionAppearance = appearance70;
- appearance71.BackColor = System.Drawing.SystemColors.ActiveBorder;
- appearance71.BackColor2 = System.Drawing.SystemColors.ControlDark;
- appearance71.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
- appearance71.BorderColor = System.Drawing.SystemColors.Window;
- this.ultraGrid1.DisplayLayout.GroupByBox.Appearance = appearance71;
- appearance72.ForeColor = System.Drawing.SystemColors.GrayText;
- this.ultraGrid1.DisplayLayout.GroupByBox.BandLabelAppearance = appearance72;
- this.ultraGrid1.DisplayLayout.GroupByBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
- this.ultraGrid1.DisplayLayout.GroupByBox.Hidden = true;
- appearance73.BackColor = System.Drawing.SystemColors.ControlLightLight;
- appearance73.BackColor2 = System.Drawing.SystemColors.Control;
- appearance73.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
- appearance73.ForeColor = System.Drawing.SystemColors.GrayText;
- this.ultraGrid1.DisplayLayout.GroupByBox.PromptAppearance = appearance73;
- this.ultraGrid1.DisplayLayout.MaxColScrollRegions = 1;
- this.ultraGrid1.DisplayLayout.MaxRowScrollRegions = 1;
- appearance74.BackColor = System.Drawing.SystemColors.Window;
- appearance74.ForeColor = System.Drawing.SystemColors.ControlText;
- this.ultraGrid1.DisplayLayout.Override.ActiveCellAppearance = appearance74;
- appearance75.BackColor = System.Drawing.SystemColors.Highlight;
- appearance75.ForeColor = System.Drawing.SystemColors.HighlightText;
- this.ultraGrid1.DisplayLayout.Override.ActiveRowAppearance = appearance75;
- this.ultraGrid1.DisplayLayout.Override.BorderStyleCell = Infragistics.Win.UIElementBorderStyle.RaisedSoft;
- this.ultraGrid1.DisplayLayout.Override.BorderStyleRow = Infragistics.Win.UIElementBorderStyle.None;
- appearance76.BackColor = System.Drawing.SystemColors.Window;
- this.ultraGrid1.DisplayLayout.Override.CardAreaAppearance = appearance76;
- appearance77.FontData.SizeInPoints = 10F;
- appearance77.TextTrimming = Infragistics.Win.TextTrimming.EllipsisCharacter;
- this.ultraGrid1.DisplayLayout.Override.CellAppearance = appearance77;
- this.ultraGrid1.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.EditAndSelectText;
- this.ultraGrid1.DisplayLayout.Override.CellPadding = 0;
- this.ultraGrid1.DisplayLayout.Override.DefaultRowHeight = 25;
- appearance78.BackColor = System.Drawing.SystemColors.Control;
- appearance78.BackColor2 = System.Drawing.SystemColors.ControlDark;
- appearance78.BackGradientAlignment = Infragistics.Win.GradientAlignment.Element;
- appearance78.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
- appearance78.BorderColor = System.Drawing.SystemColors.Window;
- this.ultraGrid1.DisplayLayout.Override.GroupByRowAppearance = appearance78;
- appearance79.TextHAlignAsString = "Left";
- this.ultraGrid1.DisplayLayout.Override.HeaderAppearance = appearance79;
- this.ultraGrid1.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti;
- this.ultraGrid1.DisplayLayout.Override.HeaderStyle = Infragistics.Win.HeaderStyle.Standard;
- this.ultraGrid1.DisplayLayout.Override.RowSelectorNumberStyle = Infragistics.Win.UltraWinGrid.RowSelectorNumberStyle.RowIndex;
- this.ultraGrid1.DisplayLayout.Override.RowSelectorWidth = 25;
- appearance80.BackColor = System.Drawing.SystemColors.ControlLight;
- this.ultraGrid1.DisplayLayout.Override.TemplateAddRowAppearance = appearance80;
- this.ultraGrid1.DisplayLayout.ScrollBounds = Infragistics.Win.UltraWinGrid.ScrollBounds.ScrollToFill;
- this.ultraGrid1.DisplayLayout.ScrollStyle = Infragistics.Win.UltraWinGrid.ScrollStyle.Immediate;
- this.ultraGrid1.DisplayLayout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy;
- this.ultraGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.ultraGrid1.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.ultraGrid1.Location = new System.Drawing.Point(0, 47);
- this.ultraGrid1.Name = "ultraGrid1";
- this.ultraGrid1.Size = new System.Drawing.Size(975, 446);
- this.ultraGrid1.TabIndex = 19;
- //
- // ultraGroupBox1
- //
- this.ultraGroupBox1.Controls.Add(this.label4);
- this.ultraGroupBox1.Controls.Add(this.chkTime);
- this.ultraGroupBox1.Controls.Add(this.uldtBeginTime);
- this.ultraGroupBox1.Controls.Add(this.uldtEndTime);
- this.ultraGroupBox1.Dock = System.Windows.Forms.DockStyle.Top;
- this.ultraGroupBox1.Location = new System.Drawing.Point(0, 0);
- this.ultraGroupBox1.Name = "ultraGroupBox1";
- this.ultraGroupBox1.Size = new System.Drawing.Size(975, 47);
- this.ultraGroupBox1.TabIndex = 21;
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.label4.Location = new System.Drawing.Point(243, 16);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(21, 14);
- this.label4.TabIndex = 284;
- this.label4.Text = "到";
- //
- // chkTime
- //
- this.chkTime.AutoSize = true;
- this.chkTime.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.chkTime.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.chkTime.Location = new System.Drawing.Point(21, 14);
- this.chkTime.Name = "chkTime";
- this.chkTime.Size = new System.Drawing.Size(79, 18);
- this.chkTime.TabIndex = 283;
- this.chkTime.Text = "时间 从";
- this.chkTime.UseVisualStyleBackColor = true;
- this.chkTime.CheckedChanged += new System.EventHandler(this.chkTime_CheckedChanged);
- //
- // uldtBeginTime
- //
- appearance5.BorderAlpha = Infragistics.Win.Alpha.UseAlphaLevel;
- appearance5.BorderColor = System.Drawing.Color.Black;
- this.uldtBeginTime.ButtonAppearance = appearance5;
- this.uldtBeginTime.DateTime = new System.DateTime(2008, 1, 12, 0, 0, 0, 0);
- this.uldtBeginTime.Enabled = false;
- this.uldtBeginTime.FormatProvider = new System.Globalization.CultureInfo("en-US");
- this.uldtBeginTime.FormatString = "yyyy-MM-dd HH:mm";
- this.uldtBeginTime.Location = new System.Drawing.Point(104, 14);
- this.uldtBeginTime.MaskInput = "yyyy-mm-dd hh:mm";
- this.uldtBeginTime.Name = "uldtBeginTime";
- this.uldtBeginTime.Size = new System.Drawing.Size(133, 19);
- this.uldtBeginTime.TabIndex = 282;
- this.uldtBeginTime.UseFlatMode = Infragistics.Win.DefaultableBoolean.True;
- this.uldtBeginTime.Value = new System.DateTime(2008, 1, 12, 0, 0, 0, 0);
- this.uldtBeginTime.ValueChanged += new System.EventHandler(this.uldtBeginTime_ValueChanged);
- //
- // uldtEndTime
- //
- this.uldtEndTime.DateTime = new System.DateTime(2008, 11, 24, 0, 0, 0, 0);
- this.uldtEndTime.FormatProvider = new System.Globalization.CultureInfo("en-US");
- this.uldtEndTime.FormatString = "yyyy-MM-dd HH:mm";
- this.uldtEndTime.Location = new System.Drawing.Point(271, 12);
- this.uldtEndTime.MaskInput = "yyyy-mm-dd hh:mm";
- this.uldtEndTime.Name = "uldtEndTime";
- this.uldtEndTime.Size = new System.Drawing.Size(136, 21);
- this.uldtEndTime.TabIndex = 281;
- this.uldtEndTime.Value = new System.DateTime(2008, 11, 24, 0, 0, 0, 0);
- //
- // FrmCcmBilletWgtsamplingReport
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.ClientSize = new System.Drawing.Size(975, 493);
- this.Controls.Add(this.ultraGrid1);
- this.Controls.Add(this.ultraGroupBox1);
- this.Name = "FrmCcmBilletWgtsamplingReport";
- this.Text = "板坯重量记录表";
- this.Load += new System.EventHandler(this.FrmIronEleQry_Load);
- ((System.ComponentModel.ISupportInitialize)(this.ultraDataSource1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.ultraGrid1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.ultraGroupBox1)).EndInit();
- this.ultraGroupBox1.ResumeLayout(false);
- this.ultraGroupBox1.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.uldtBeginTime)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.uldtEndTime)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- private void FrmIronEleQry_Load(object sender, System.EventArgs e)
- {
- this.uldtBeginTime.Value = DateTime.Today.ToString("yyyy-MM-dd") + " 00:00";
- this.uldtEndTime.Value = DateTime.Today.ToString("yyyy-MM-dd") + " 23:59";
- this.chkTime.Checked = true;
- }
- /// <summary>
- /// ds需要的字段
- /// </summary>
- /// <returns></returns>
- private string[] returnColumnName()
- {
- return new string[] { "SAMPLINGID", "CCMID", "FLOWNO","WEIGHT", "SAMPLINGTIME", "MSG_EXP" };
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- private string[] returnColumnHeaderName()
- {
- return new string[] { "采样ID", "铸机号", "铸流号","重量", "称重时间", "称重序号" };
- }
- private string[] returnColumnDataType()
- {
- return new string[] { "System.String", "System.String", "System.String", "System.Double" , "System.DateTime", "System.String" };
- }
- private Hashtable GetColumnAndType()
- {
- Hashtable hs = new Hashtable();
- for (int i = 0; i < returnColumnName().Length; i++)
- {
- hs.Add(returnColumnName()[i], returnColumnDataType()[i]);
- }
- return hs;
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- this.doQuery();
- break;
- case "Close":
- this.Close();
- break;
- case "Export":
- this.ExportExcel();
- break;
- default:
- break;
- }
- }
- private void chkTime_CheckedChanged(object sender, EventArgs e)
- {
- uldtBeginTime.Enabled = chkTime.Checked;
- uldtEndTime.Enabled = chkTime.Checked;
- }
- private void uldtBeginTime_ValueChanged(object sender, EventArgs e)
- {
- }
- #region "Auto Refresh"
-
- /// <summary>
- /// 获取查询条件
- /// </summary>
- /// <returns></returns>
- private string getSqlCondition()
- {
- string strStartTime = this.uldtBeginTime.DateTime.ToString("yyyy-MM-dd");
- string strEndTime = this.uldtEndTime.DateTime.ToString("yyyy-MM-dd");
- string sqlCondition = string.Format(string.Format(" and samplingtime >= trunc({0}) and samplingtime <= trunc({1} + 1)", "to_date('{0}','yyyy-mm-dd')", "to_date('{1}','yyyy-mm-dd')"), strStartTime, strEndTime);
- return sqlCondition;
- }
- /// <summary>
- /// 将原dataset 中的铸机号和流号进行转换
- /// </summary>
- /// <param name="ds"></param>
- /// <returns></returns>
- private DataSet ChgDataSetByChangeCcmidAndFlow(ref DataSet ds)
- {
- DataSet dsTemp = this.getAllColumn();
- DataRow drs = null;
- foreach (DataRow dr in ds.Tables[0].Rows)
- {
- drs = dsTemp.Tables[0].NewRow();
- foreach (DataColumn dc in ds.Tables[0].Columns)
- {
- if (!dsTemp.Tables[0].Columns.Contains(dc.ColumnName))
- continue;
- if (dc.ColumnName == "CCMID" || dc.ColumnName == "FLOWNO" || dc.ColumnName == "SAMPLINGTIME" || dc.ColumnName == "WEIGHT")
- {
- drs["CCMID"] = dr["CCMID"] + "#";
- drs["FLOWNO"] = dr["FLOWNO"] + "流";
- drs["SAMPLINGTIME"] = Convert.ToDateTime(dr["SAMPLINGTIME"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
- drs["WEIGHT"] = dr["WEIGHT"] + "";
- }
- else
- {
- drs[dc.ColumnName] = dr[dc.ColumnName];
- }
- }
- dsTemp.Tables[0].Rows.Add(drs);
-
- }
- return dsTemp;
-
- }
- private void SetTotalInfo()
- {
- ArrayList alistColumns = new ArrayList();
- ArrayList alistFormat = new ArrayList();
- alistColumns.Add("WEIGHT");
-
- alistFormat.Add(" {0:############0.0}");
- Core.Mes.Client.Common.UltraGridMgt.proc_Statics(ref this.ultraGrid1, alistColumns, true, " {0:############0.0}");
-
-
- }
-
-
- private void doQueryReport()
- {
- if (uldtEndTime.DateTime.Date.Subtract(uldtBeginTime.DateTime.Date).Days > 180)
- {
- MessageBox.Show("查询时间不可超过6个月。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (uldtBeginTime.DateTime.Date > uldtEndTime.DateTime.Date)
- {
- MessageBox.Show("查询开始日期不能大于结束日期!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- DataSet ds = new DataSet();
- ClientParamWithSqlConditionAndOpenBase param = new ClientParamWithSqlConditionAndOpenBase(getSqlCondition(),this.ob);
- try
- {
-
- ds = Core.LgMes.Client.lgBll.lgResMgt.LgStlCcmBilletWgtSamplingMgt.GetStlCcmBilletWgtSamping(param);
- DataSet dsTemp = ChgDataSetByChangeCcmidAndFlow(ref ds);
- if (lgCommon.isNullOrEmptyDataSetCheck(dsTemp))
- {
- DataView dv = new DataView(dsTemp.Tables[0]);
- dv.Sort = "SAMPLINGTIME desc";
- this.ultraGrid1.DataSource = dv.ToTable();
- }
-
- }
- catch(Exception ex)
- {
- }
- initUltraGrid();
- SetTotalInfo();
- }
- /// <summary>
- /// 初始化grid
- /// </summary>
- private void initUltraGrid()
- {
- try
- {
- string[] columnName = returnColumnName();
- string[] columnHeaderName = returnColumnHeaderName();
-
- int columnWidht = 150;
- int otherColumnWidth = 100; // 拉速宽度
- for(int i = 0; i < columnName.Length;i++)
- {
- try
- {
- this.ultraGrid1.DisplayLayout.Bands[0].Columns[columnName[i]].Header.Caption = columnHeaderName[i];
- this.ultraGrid1.DisplayLayout.Bands[0].Columns[columnName[i]].Width = columnWidht;
- }
- catch
- {
- }
-
- }
- for (int i = 0; i < this.ultraGrid1.DisplayLayout.Bands[0].Columns.Count; i++)
- {
- if (i > 8)
- {
- this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].Width = otherColumnWidth;
- }
- }
- //设置列只读
- Core.Mes.Client.Common.UltraGridMgt.SetUltraGridColumnsReadOnly(ref this.ultraGrid1);
- }
- catch
- {
-
- }
- }
- /// <summary>
- /// 构造新的dataset,包含需要显示的字段
- /// </summary>
- /// <returns></returns>
- private DataSet getAllColumn()
- {
- DataSet ds = new DataSet();
- DataTable dt = new DataTable();
- string[] columnName = returnColumnName();
- Hashtable hs = GetColumnAndType();
- foreach (string s in columnName)
- {
- string dbtype = hs[s].ToString();
- dt.Columns.Add(new DataColumn(s, Type.GetType("System.String"))); // 时间
- }
-
- ds.Tables.Add(dt);
- return ds;
- }
- private void doQuery()
- {
- doQueryReport();
- }
- private void ExportExcel()
- {
- try
- {
- string StrfileName = "板坯重量记录表【" + this.uldtBeginTime.DateTime.ToString("yyyy-MM-dd") +"~"+this.uldtEndTime.DateTime.ToString("yyyy-MM-dd")+"】"+ ".xls";
- this.GridExcelExporter.Export(this.ultraGrid1, StrfileName);
- ProcessStartInfo p = new ProcessStartInfo(StrfileName);
- p.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
- p.WorkingDirectory = Path.GetDirectoryName(StrfileName);
- Process.Start(p);
- }
- catch (Exception ex)
- {
-
- }
- }
- #endregion
- }
- }
|