| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428 |
- 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.Common;
- using Infragistics.Win.UltraWinGrid;
- using System.Collections;
- using Infragistics.Win;
- using System.Diagnostics;
- using System.IO;
- using CoreFS.CA06;
- using Core.LgMes.Client.Comm;
- namespace Core.LgMes.Client.lgIntegrationQuery
- {
- public partial class FrmCcmWeightReport : frmStyleBase
- {
- public FrmCcmWeightReport()
- {
- InitializeComponent();
- }
- private UltraGridRow currRow = null;
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- {
- proc_Query();
- break;
- }
- case "Save":
- {
- proc_Add("Edit");
- proc_Query();
- break;
- }
- case "Export":
- {
- try
- {
- if (ultraGrid1.Rows.Count == 0) return;
- string strFileName = "合金验收记录" + DateTime.Now.ToString("yyyyMMdd");
- SaveFileDialog dlg = new SaveFileDialog();
- dlg.Title = "保存";
- dlg.OverwritePrompt = true;
- dlg.Filter = "Excel文件(*.xls)|*.xls";
- dlg.AddExtension = true;
- dlg.FileName = strFileName;
- if (dlg.ShowDialog() == DialogResult.OK)
- {
- strFileName = dlg.FileName;
- ultraGridExcelExporter1.Export(ultraGrid1, strFileName);
- if (MessageBox.Show("数据导出成功!\r\n需要打开所导出文件吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- ultraGridExcelExporter1.Export(ultraGrid1, strFileName);
- ProcessStartInfo p = new ProcessStartInfo(strFileName);
- p.WorkingDirectory = Path.GetDirectoryName(strFileName);
- Process.Start(p);
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- break;
- }
- case "Close":
- {
- this.Close();
- break;
- }
- }
- }
- public void proc_Query()
- {
- if (ultraDateTimeEditor2.DateTime.Date.Subtract(ultraDateTimeEditor1.DateTime.Date).Days > 60)
- {
- MessageBox.Show("查询时间不可超过2个月。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (ultraDateTimeEditor1.DateTime.Date > ultraDateTimeEditor2.DateTime.Date)
- {
- MessageBox.Show("查询开始日期不能大于结束日期!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- Cursor oldCursor = this.Cursor;
- this.Cursor = Cursors.WaitCursor;
- try
- {
- this.dataTable1.Clear();
- string sqlStr = @"SELECT TO_CHAR(T.OPTDATE, 'YYYY-MM-DD HH24:MI:SS') OPTDATE,
- DECODE(SUBSTR(T.SHIFTCODE, 1, 1), '1', '早', '2', '中', '3', '晚') SHIFTGROUP,
- DECODE(SUBSTR(T.SHIFTCODE, 1, 1),
- '1',
- '甲',
- '2',
- '乙',
- '3',
- '丙',
- '丁') SHIFTCLASS,
- DECODE(T.STATIONCODE,'01','6#','02','5#','7#') STATIONCODE,
- T.HEATNO,
- T.PLANSTEEL,
- T1.PLAN_LINES FACT_ROUTE,
- T.BILLETSECTION,
- T.BILLETSECTION2,
- NVL(T.PFBALEWGT, 0) - NVL(T.BALELEAVEWGT, 0) JGWGT,
- T2.WEIGHT,
- SENDSMPOPTOR1,
- SENDSMPOPTOR2,
- SENDSMPOPTOR3,
- CONFIRMOPTOR
- FROM (SELECT * FROM STL_CCM_OPTINFO UNION SELECT * FROM J#STL_CCM_OPTINFO) T
- LEFT JOIN PPC_STEEL_HEAT T1
- ON T.HEATNO = T1.HEATNO
- LEFT JOIN (SELECT SUBSTR(SLAB_NO, 1, 9) || 'A' HEATNO,
- SUM(NVL(WEIGHT_WGT, SLAB_WGT / 1000)) WEIGHT
- FROM STL_INCISION_VIEW
- GROUP BY SUBSTR(SLAB_NO, 1, 9) || 'A') T2
- ON T.HEATNO = T2.HEATNO
- WHERE NVL(T.BALESTARTTIME, T.OPTDATE) BETWEEN TO_DATE('{0}','YYYY-MM-DD HH24:MI:SS') AND TO_DATE('{1}','YYYY-MM-DD HH24:MI:SS')
- AND DISPOSALTIME = '01'
- ORDER BY T.STATIONCODE,NVL(T.BALESTARTTIME, T.OPTDATE)";
- if (ultraDateTimeEditor1.DateTime.Date > ultraDateTimeEditor2.DateTime.Date)
- {
- MessageBox.Show("查询开始日期不能大于结束日期!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- string strFrom = ultraDateTimeEditor1.DateTime.ToString("yyyy-MM-dd") + " 00:00:00";
- string strTo = ultraDateTimeEditor2.DateTime.ToString("yyyy-MM-dd") + " 23:59:59";
- sqlStr = string.Format(sqlStr, strFrom, strTo);
- //调用服务端方法
- CoreClientParam CCP_LgEts = new CoreClientParam();
- DataTable dt = new DataTable();
- CCP_LgEts.ServerName = "Core.LgMes.Server.Common.ComDBExecute";
- CCP_LgEts.MethodName = "doSimpleQuery";
- CCP_LgEts.ServerParams = new object[] { sqlStr };
- CCP_LgEts.SourceDataTable = dt;
- this.ExecuteQueryToDataTable(CCP_LgEts, CoreInvokeType.Internal);
- DataSet ds = new DataSet();
- if (dt != null && dt.Rows.Count > 0)
- {
- this.dataTable1.Rows.Clear();
- DataRow dr;
- for (int iRow = 0; iRow < dt.Rows.Count; iRow++)
- {
- dr = this.dataTable1.NewRow();
- for (int jCol = 0; jCol < dt.Columns.Count; jCol++)
- {
- if (dt.Columns[jCol].ColumnName == "FACT_ROUTE")
- {
- dr[dt.Columns[jCol].ColumnName] = CStaticMethod.analysPlan_Lines(dt.Rows[iRow][jCol].ToString());
- }
- else
- {
- dr[dt.Columns[jCol].ColumnName] = dt.Rows[iRow][jCol];
- }
- }
- this.dataTable1.Rows.Add(dr);
- }
- }
- ultraGrid1.UpdateData();
- if (ultraGrid1.Rows.Count > 0)
- {
- ultraGrid1.ActiveCell = ultraGrid1.Rows[0].Cells["STATIONCODE"];
- ultraGrid1.Rows[0].Cells["STATIONCODE"].Selected = false;
- }
- //this.proc_SetUltraGridReadOnly(ultraGrid1);
- ArrayList alistColumns = new ArrayList();
- alistColumns.Add("JGWGT");
- alistColumns.Add("WEIGHT");
- alistColumns.Add("SENDSMPOPTOR1");
- alistColumns.Add("SENDSMPOPTOR2");
- alistColumns.Add("SENDSMPOPTOR3");
- proc_Statics(ref ultraGrid1, alistColumns, true, " {0:############0.0}");
- }
- catch
- { }
- finally
- {
- this.Cursor = oldCursor;
- }
- }
- public void proc_Add(string flag)
- {
- try
- {
- this.ultraGrid1.UpdateData();
- if (dataTable1.Rows.Count > 0)
- {
- string strErr = "";
- string strMess = "";
- if (flag == "Add")
- {
- ArrayList arry = new ArrayList();
- arry.Add("frmAlloy.Insert");
- string str1 = ultraGrid1.ActiveRow.Cells["STATIONCODE"].Text;
- string str2 = ultraGrid1.ActiveRow.Cells["LK"].Text;
- string str3 = ultraGrid1.ActiveRow.Cells["GGM"].Text;
- string str4 = ultraGrid1.ActiveRow.Cells["GT"].Text;
- string str5 = ultraGrid1.ActiveRow.Cells["GM"].Text;
- string str6 = ultraGrid1.ActiveRow.Cells["ZTJ"].Text;
- string str7 = ultraGrid1.ActiveRow.Cells["ZTMT"].Text;
- string str8 = ultraGrid1.ActiveRow.Cells["TT"].Text;
- string str9 = ultraGrid1.ActiveRow.Cells["JSMK"].Text;
- string str10 = ultraGrid1.ActiveRow.Cells["ZTGT"].Text;
- string str11 = ultraGrid1.ActiveRow.Cells["MT"].Text;
- string str12 = ultraGrid1.ActiveRow.Cells["GTGT"].Text;
- string str13 = ultraGrid1.ActiveRow.Cells["JLZ"].Text;
- string str14 = ultraGrid1.ActiveRow.Cells["RHGZJ"].Text;
- string str15 = ultraGrid1.ActiveRow.Cells["DGYSQ"].Text;
- string str16 = ultraGrid1.ActiveRow.Cells["HZYSH"].Text;
- string str17 = this.UserInfo.GetUserName();
- arry.Add(str1);
- arry.Add(str2);
- arry.Add(str3);
- arry.Add(str4);
- arry.Add(str5);
- arry.Add(str6);
- arry.Add(str7);
- arry.Add(str8);
- arry.Add(str9);
- arry.Add(str10);
- arry.Add(str11);
- arry.Add(str12);
- arry.Add(str13);
- arry.Add(str14);
- arry.Add(str15);
- arry.Add(str16);
- arry.Add(str17);
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = this.ob;
- cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
- "doSimpleSave", arry, out strErr);
- this.proc_setCellReadOnly(currRow, true);
- currRow = null;
- }
- else if (flag == "Edit")
- {
- ArrayList arry = new ArrayList();
- arry.Add("frmCcmWeight1.Update");
- string str1 = ultraGrid1.ActiveRow.Cells["SENDSMPOPTOR1"].Text;
- string str2 = ultraGrid1.ActiveRow.Cells["SENDSMPOPTOR2"].Text;
- string str3 = ultraGrid1.ActiveRow.Cells["SENDSMPOPTOR3"].Text;
- string str4 = ultraGrid1.ActiveRow.Cells["CONFIRMOPTOR"].Text;
- string str5 = ultraGrid1.ActiveRow.Cells["HEATNO"].Text;
- arry.Add(str1);
- arry.Add(str2);
- arry.Add(str3);
- arry.Add(str4);
- arry.Add(str5);
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = this.ob;
- cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
- "doSimpleSave", arry, out strErr);
- arry.Clear();
- arry.Add("frmCcmWeight2.Update");
- arry.Add(str1);
- arry.Add(str2);
- arry.Add(str3);
- arry.Add(str4);
- arry.Add(str5);
- cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
- "doSimpleSave", arry, out strErr);
- this.proc_setCellReadOnly(currRow, true);
- currRow = null;
- }
- if (strErr == "")
- {
- dataTable1.AcceptChanges();
- //JJBStaticFunction.SetRowEdit(ultraGrid1);
- if (!string.IsNullOrEmpty(strMess))
- MessageBox.Show(strMess, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- else
- {
- MessageBox.Show("保存失败!输入信息已经存在或数据无效。", "错误");
- }
- if (ultraGrid1.ActiveCell != null)
- ultraGrid1.ActiveCell.Activated = false;
- }
- }
- catch (System.Exception ex)
- {
- Console.WriteLine(ex.ToString());
- }
- }
- private void proc_setCellReadOnly(UltraGridRow row, bool bReadOnly)
- {
- try
- {
- if (row == null)
- return;
- if (bReadOnly)
- {
- row.Activation = Activation.ActivateOnly;
- row.CellAppearance.BackColor = Color.White;
- foreach (Infragistics.Win.UltraWinGrid.UltraGridCell cell in row.Cells)
- {
- cell.CancelUpdate();
- }
- }
- else
- {
- row.Activation = Activation.AllowEdit;
- row.CellAppearance.BackColor = Color.Khaki;
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void proc_SetUltraGridReadOnly(Infragistics.Win.UltraWinGrid.UltraGridBase ultGrid)
- {
- foreach (UltraGridRow row in ultGrid.Rows)
- {
- row.Activation = Activation.ActivateOnly;
- }
- }
- public void proc_Statics(ref UltraGrid ultraGrid, ArrayList alistColumns, bool clearExists, string strFormat)
- {
- try
- {
- if (alistColumns == null)
- {
- return;
- }
- UltraGridBand band = ultraGrid.DisplayLayout.Bands[0];
- if (clearExists)
- band.Summaries.Clear();
- SummarySettings summary = null;
- UltraGridColumn cl = null;
- foreach (UltraGridColumn column in ultraGrid.DisplayLayout.Bands[0].Columns)
- {
- if (column.RowLayoutColumnInfo.OriginX == 0)
- {
- cl = column;
- break;
- }
- }
- summary = band.Summaries.Add(SummaryType.Count, cl);
- summary.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
- summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
- summary.DisplayFormat = "合计:";
- summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Center;
- summary.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
- summary.Appearance.FontData.Bold = DefaultableBoolean.True;
- if (string.IsNullOrEmpty(strFormat.Trim()))
- {
- strFormat = " {0:############0.00}";
- }
- for (int i = 0; i < alistColumns.Count; i++)
- {
- try
- {
- summary = band.Summaries.Add(SummaryType.Sum, band.Columns[alistColumns[i].ToString()]);
- summary.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
- summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
- summary.DisplayFormat = strFormat;
- summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Right;
- summary.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
- summary.Appearance.FontData.Bold = DefaultableBoolean.True;
- summary.Appearance.ForeColor = Color.DarkBlue;
- summary.Appearance.BackColor = Color.White;
- }
- catch { }
- }
- band.Override.SummaryFooterCaptionVisible = Infragistics.Win.DefaultableBoolean.False;
- }
- catch { }
- }
- private void FrmCcmWeightReport_Load(object sender, EventArgs e)
- {
- ultraDateTimeEditor1.DateTime = DateTime.Today;
- ultraDateTimeEditor2.DateTime = DateTime.Today;
- }
- }
- }
|