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.CA06; using System.Collections; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Tool; using Core.Mes.Client.Comm.Server; using Core.StlMes.Client.YdmBcPipeManage.Entity; namespace Core.StlMes.Client.YdmBcPipeManage { public partial class reportOutput : FrmBase { public reportOutput() { InitializeComponent(); } ArrayList alistChecked = null; private string[] arr = null; private string[] belongArr = null; private void reportOutput_Load(object sender, EventArgs e) { DateTime now = DateTime.Now; DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天 DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天 this.RegStartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00"); this.RegEndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59"); DateTime d1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); dateYearMoth.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM")); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); ultraGrid1.DisplayLayout.Bands[0].Columns["OrderTypDesc"].Hidden = false; arr = BaseMethod.WarehousePermissionsStore(this.ValidDataPurviewIds,ob); belongArr = this.ValidDataPurviewIds; try { alistChecked = new ArrayList(); alistChecked.Add("StoveNo"); alistChecked.Add("JudgeStoveNo"); alistChecked.Add("MaterialName"); //alistChecked.Add("FixNum"); //alistChecked.Add("FixLen"); } catch { } try { ArrayList alist = new ArrayList(); alist.Add("ActCount"); alist.Add("ActWeight"); alist.Add("PtWeight"); alist.Add("ActLen"); CommonMethod.GeneralCheckedListboxItems(ref this.myCheckedListBox1, ref this.ultraGrid1, alist, alistChecked); } catch { } switch (this.CustomInfo) { case "BELONG_CODE": this.ultraOptionSet1.Visible = false; break; } } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": QueryData(); break; case "Export": ExportData(); break; case "Close": this.Close(); break; } } /// /// 查询 /// private void QueryData() { List listSource = null; if (this.chkStoveNo.Checked && string.IsNullOrEmpty(this.txtStoveNo.Text)) { MessageUtil.ShowTips("请输入炉号!"); this.txtStoveNo.Focus(); return; } string stoveNo = ""; string judgeNo = ""; string startTim = ""; string endTim = ""; string bathYearMoth = ""; ArrayList list = new ArrayList(); string strSql = ""; string strGroup = ""; string strOut = ""; string strPlnSql = ""; //if (chkInputTim.Checked) //{ // startTim = this.RegStartTime.Value.ToString(); // endTim = this.RegEndTime.Value.ToString(); // strOut += " and t.OUTSTOCK_TIME >= to_date('" + startTim + "', 'yyyy-MM-dd HH24:mi:ss') and t.OUTSTOCK_TIME < to_date('" + endTim + "', 'yyyy-MM-dd HH24:mi:ss')"; //} if (chkStoveNo.Checked) { stoveNo = this.txtStoveNo.Text; strOut += " and t.STOVE_NO = '" + stoveNo + "'"; } if (chkJudgeNo.Checked) { judgeNo = this.txtJudgeNo.Text; strOut += " and t.JUDGE_STOVE_NO ='" + judgeNo + "'"; } if(chkYearMoth.Checked) { bathYearMoth = this.dateYearMoth.Value.ToString("yyyyMM"); strOut += " and t.BAL_YEAR_MONTH ='" + bathYearMoth + "'"; } if (chkRegTime.Checked) { startTim = this.RegStartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTim = this.RegEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); strOut += " AND T.OUTSTOCK_TIME >= TO_DATE('" + startTim + "','YYYY-MM-DD HH24:MI:SS') AND T.OUTSTOCK_TIME <= TO_DATE('" + endTim + "','YYYY-MM-DD HH24:MI:SS')"; } string strKey = ""; CheckBox item; for (int i = 0; i < this.myCheckedListBox1.Controls.Count; i++) { try { item = this.myCheckedListBox1.Controls[i] as CheckBox; if (item != null && item.Checked) { strKey = item.Name; if (strKey.Equals("StoveNo")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.STOVE_NO"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.STOVE_NO"; } else if (strKey.Equals("FlagStoveNoZg")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.FLAG_STOVE_NO_ZG"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.FLAG_STOVE_NO_ZG"; } else if (strKey.Equals("JudgeStoveNo")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.JUDGE_STOVE_NO"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.JUDGE_STOVE_NO"; //strPlnSql += " AND F.JUDGE_STOVE_NO = D.JUDGE_STOVE_NO"; } else if (strKey.Equals("BatchNo")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.BATCH_NO"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.BATCH_NO"; } else if (strKey.Equals("BatchGroudNo")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.Batch_Groud_No"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.Batch_Groud_No"; } else if (strKey.Equals("OutstockTypeName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.OUTSTOCK_TYPE_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.OUTSTOCK_TYPE_NAME"; } else if (strKey.Equals("MaterialName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.MATERIAL_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.MATERIAL_NAME"; } else if (strKey.Equals("Producname")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.PRODUCNAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.PRODUCNAME"; } else if (strKey.Equals("Gradename")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.GRADENAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.GRADENAME"; } else if (strKey.Equals("Steelname")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.STEELNAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.STEELNAME"; } else if (strKey.Equals("StdName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.STD_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.STD_NAME"; } else if (strKey.Equals("StdStyleDesc")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.STD_STYLE_DESC"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.STD_STYLE_DESC"; } else if (strKey.Equals("SpecName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.SPEC_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.SPEC_NAME"; } else if (strKey.Equals("ModelDesc")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.MODEL_DESC"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.MODEL_DESC"; } else if (strKey.Equals("LoadPlineName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.LOAD_PLINE_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.LOAD_PLINE_NAME"; } else if (strKey.Equals("OutType")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "DECODE(t.OUT_TYPE,'0','写卡倒运','1','票据倒运','2','纠错倒运','3','外委倒运','4','装车皮倒运')OUT_TYPE"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.OUT_TYPE"; } else if (strKey.Equals("ProOrderNo")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.PRO_ORDER_NO"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.PRO_ORDER_NO"; } else if (strKey.Equals("ActDimater")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.ACT_DIMATER"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.ACT_DIMATER"; } else if (strKey.Equals("ActHeight")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.ACT_HEIGHT"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.ACT_HEIGHT"; } //else if (strKey.Equals("ActLen")) //{ // strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.ACT_LEN"; // strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.ACT_LEN"; //} else if (strKey.Equals("StorageName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "(SELECT M.STORAGE_NAME FROM YDM_BS_STORAGE M WHERE M.STORAGE_NO = T.STORAGE_NO)STORAGE_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "T.STORAGE_NO"; } else if (strKey.Equals("LocationNo")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "(SELECT M1.LOCATION_NAME FROM YDM_BS_LOCATION M1 WHERE M1.LOCATION_NO = T.LOCATION_NO)LOCATION_NO"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "T.LOCATION_NO"; } else if (strKey.Equals("TarStorageName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "s.STORAGE_NAME as TAR_STORAGE_NAME "; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "s.STORAGE_NAME"; } else if (strKey.Equals("BelongName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.BELONG_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.BELONG_NAME"; } else if (strKey.Equals("PlineName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.PLINE_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.PLINE_NAME"; } else if (strKey.Equals("ProcessName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.PROCESS_DESC AS Process_Name"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.PROCESS_DESC"; } else if (strKey.Equals("OutstockTime")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "to_char(t.OUTSTOCK_TIME,'YYYY-MM-DD HH24:MI:SS') as OUTSTOCK_TIME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.OUTSTOCK_TIME"; } else if (strKey.Equals("BalYearMonth")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.BAL_YEAR_MONTH"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.BAL_YEAR_MONTH"; } else if (strKey.Equals("Memo")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.MEMO"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.MEMO"; } else if (strKey.Equals("ProductFlag")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "(SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T.PRODUCT_FLAG AND ROWNUM = 1)PRODUCT_FLAG"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.PRODUCT_FLAG"; } else if (strKey.Equals("OrderTypDesc")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "( SELECT ORDER_TYP_DESC FROM SLM_ORDER_HEAD WHERE ORDER_NO = T.ORDER_NO and VALIDFLAG = '1' AND ROWNUM = 1 )ORDER_TYP_DESC"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.ORDER_NO"; } else if (strKey.Equals("OutBc")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "( CASE WHEN T.OUT_BC ='1' THEN '白班' WHEN T.OUT_BC ='2' THEN '中班' WHEN T.OUT_BC ='3' THEN '晚班' end) OUT_BC "; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.OUT_BC"; } else if (strKey.Equals("OutBz")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + " (CASE WHEN T.OUT_BZ ='1' THEN '甲' WHEN T.OUT_BZ ='2' THEN '乙' WHEN T.OUT_BZ ='3' THEN '丙' WHEN T.OUT_BZ ='4' THEN '丁' end) OUT_BZ "; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.OUT_BZ"; } //else if (strKey.Equals("OutBz")) //{ // strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "DECODE(t.OUT_BZ,'1','甲','2','乙','3','丙','4','丁')OUT_BZ"; // strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.OUT_BZ"; //} //else if (strKey.Equals("Gptype")) //{ // strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + " CASE WHEN T.MATERIAL_NAME LIKE 'PA%' then '铸坯'WHEN T.MATERIAL_NAME LIKE 'PB%' then'锻坯'WHEN T.MATERIAL_NAME LIKE 'PC%' then'轧坯'WHEN T.MATERIAL_NAME LIKE 'PD%' then'钢锭'END GPTYPE"; //} else { strSql += (string.IsNullOrEmpty(strSql) ? "t." : ",t.") + strKey; strGroup += (string.IsNullOrEmpty(strGroup) ? "t." : ",t.") + strKey; } } } catch { } } strSql += (string.IsNullOrEmpty(strSql) ? "" : ","); if (string.IsNullOrEmpty(strGroup)) { strGroup = strOut + (string.IsNullOrEmpty(strGroup) ? "" : "group by ") + strGroup + " ORDER BY T.OUTSTOCK_TIME DESC"; } else { strGroup = strOut + (string.IsNullOrEmpty(strGroup) ? "" : "group by ") + strGroup + " ,T.OUTSTOCK_TIME ORDER BY T.OUTSTOCK_TIME DESC"; } switch (this.CustomInfo) { case "STORAGE_NO": if (this.ultraOptionSet1.CheckedItem.DataValue.ToString().Equals("0")) { strOut = " AND t.TAR_REC_FLAG = '0'AND T.OUTSTOCK_TYPE_CODE = '800803'"; } else { strOut = " and ((T.OUTSTOCK_TYPE_CODE = '800803' and t.TAR_REC_FLAG = '1') OR T.OUTSTOCK_TYPE_CODE IN ('800801', '800802','800804','800805'))"; } break; } string _sql = strOut + strGroup; list.Add(strSql); list.Add(strOut); list.Add(strGroup); switch(this.CustomInfo) { case"STORAGE_NO": listSource = EntityHelper.GetData( "com.steering.ydm.bc.report.FrmReportBcOutput.doQueryData", new object[] { list, arr, strPlnSql, bathYearMoth }, this.ob); break; case"BELONG_CODE": listSource = EntityHelper.GetData( "com.steering.ydm.bc.report.FrmReportBcOutput.doQueryDataBelong", new object[] { list, belongArr }, this.ob); break; } YdmBcOutlistEntitybindingSource.DataSource = listSource; bool bContains = false, bChecked = false; for (int i = 0; i < this.ultraGrid1.DisplayLayout.Bands[0].Columns.Count; i++) { try { bContains = false; strKey = this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].Key; for (int j = 0; j < this.myCheckedListBox1.Controls.Count; j++) { try { item = this.myCheckedListBox1.Controls[j] as CheckBox; if (item.Name.Equals(strKey)) { bContains = true; bChecked = item.Checked; break; } } catch { } } if (bContains) { this.ultraGrid1.DisplayLayout.Bands[0].Columns[i].Hidden = !bChecked; } } catch { } } this.SetStaticsInfo(); CommonMethod.SetGridSumArea(this.ultraGrid1); } private void SetStaticsInfo() { try { if (this.ultraGrid1.Rows.Count == 0) { this.ultraGrid1.DisplayLayout.Bands[0].Summaries.Clear(); } else { ArrayList alist = new ArrayList(); alist.Add("ActCount"); alist.Add("ActWeight"); alist.Add("PtWeight"); alist.Add("ActLen"); CommonMethod.SetStaticsInfoSum(ref this.ultraGrid1, alist, true); } } catch { } } /// /// 导出 /// private void ExportData() { GridHelper.ulGridToExcel(ultraGrid1, "出库实绩总汇"); } /// /// 全选 /// /// /// private void myLinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { this.myCheckedListBox1.CheckAll(); } /// /// 清除 /// /// /// private void myLinkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { this.myCheckedListBox1.UnCheckAll(); } /// /// 默认 /// /// /// private void myLinkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { CheckBox items; for (int i = 0; i < this.myCheckedListBox1.Controls.Count; i++) { try { items = this.myCheckedListBox1.Controls[i] as CheckBox; if (alistChecked.Contains(items.Name)) { items.Checked = true; } else { items.Checked = false; } } catch { } } } private void chkInputTim_CheckedChanged(object sender, EventArgs e) { //this.RegStartTime.Enabled = this.chkInputTim.Checked; //this.RegEndTime.Enabled = this.chkInputTim.Checked; } private void chkStoveNo_CheckedChanged(object sender, EventArgs e) { this.txtStoveNo.Enabled = this.chkStoveNo.Checked; } private void chkJudgeNo_CheckedChanged(object sender, EventArgs e) { this.txtJudgeNo.Enabled = this.chkJudgeNo.Checked; } private void chkGroup_CheckedChanged(object sender, EventArgs e) { CommonMethod.SetGridGroupBy(ref this.ultraGrid1, this.chkGroup.Checked); CommonMethod.SetGridSumArea(this.ultraGrid1); } private void txtStoveNo_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { QueryData(); } } private void txtJudgeNo_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { QueryData(); } } private void chkYearMoth_CheckedChanged(object sender, EventArgs e) { this.dateYearMoth.Enabled = this.chkYearMoth.Checked; } } }