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 reportInput : FrmBase { public reportInput() { InitializeComponent(); } ArrayList alistChecked = null; private string[] arr = null;//仓库权限 private string[] belongArr = null;//所属权 private void reportInput_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); dataYearMoth.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; //switch (this.CustomInfo) //{ // case "BELONG_CODE": // this.ultraGrid1.DisplayLayout.Bands[0].Columns["JudgeResultCode"].Hidden = true; // break; //} 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("PonderGrossWt"); CommonMethod.GeneralCheckedListboxItems(ref this.myCheckedListBox1, ref this.ultraGrid1, alist, alistChecked); this.myCheckedListBox1.Controls["SFSP"].Visible = false; } catch { } } /// /// 重写基类方法 /// /// /// 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 judegeNo = ""; string startTim = ""; string endTim = ""; string bathYear = ""; ArrayList list = new ArrayList(); string strSql = ""; string strGroup = ""; string strOut = ""; string strSoureName = ""; string strInstockTypeName = ""; string strStorageName = ""; //if (chkInputTim.Checked) //{ // startTim = this.RegStartTime.Value.ToString(); // endTim = this.RegEndTime.Value.ToString(); // strOut += " and t.INSTOCK_TIME >= to_date('" + startTim + "', 'yyyy-MM-dd HH24:mi:ss') and t.INSTOCK_TIME < to_date('" + endTim + "', 'yyyy-MM-dd HH24:mi:ss')"; //} if (chkJudgeNo.Checked) { judegeNo = this.txtJudgeNo.Text; strOut += " and t.JUDGE_STOVE_NO ='" + judegeNo + "'"; } if (chkStoveNo.Checked) { stoveNo = this.txtStoveNo.Text; strOut += " and t.STOVE_NO ='" + stoveNo + "'"; } if (chkYearMoth.Checked) { bathYear = this.dataYearMoth.Value.ToString("yyyyMM"); strOut += " and t.BAL_YEAR_MONTH ='" + bathYear + "'"; } 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.INSTOCK_TIME >= TO_DATE('" + startTim + "','YYYY-MM-DD HH24:MI:SS') AND T.INSTOCK_TIME <= TO_DATE('" + endTim + "','YYYY-MM-DD HH24:MI:SS')"; } if (chkSoureName.Checked) { strSoureName = this.strSoureName.Text; strOut += " and t.SOURE_NAME like '%" + strSoureName + "%'"; } if (chkInstockTypeName.Checked) { strInstockTypeName = this.strInstockTypeName.Text; strOut += " and t.INSTOCK_TYPE_NAME ='" + strInstockTypeName + "'"; } if (chkStorageName.Checked) { strStorageName = this.strStorageName.Text; strOut += " and s.STORAGE_NAME like '%" + strStorageName + "%'"; } 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("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("JudgeStoveNo")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.JUDGE_STOVE_NO"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.JUDGE_STOVE_NO"; } else if (strKey.Equals("InstockTypeName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.INSTOCK_TYPE_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.INSTOCK_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("Pipmemo")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.PIPMEMO"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.PIPMEMO"; } 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) ? "" : ",") + "s.STORAGE_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "s.STORAGE_NAME"; } else if (strKey.Equals("LocationName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "(SELECT T1.LOCATION_NAME FROM YDM_BS_LOCATION T1 WHERE T1.LOCATION_NO = T.LOCATION_NO)LOCATION_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "T.LOCATION_NO"; } else if (strKey.Equals("SoureName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.SOURE_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.SOURE_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("InstockTime")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "to_char(t.INSTOCK_TIME,'YYYY-MM-DD HH24:MI:SS') as INSTOCK_TIME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.INSTOCK_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("InBc")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "DECODE(t.IN_BC,'1','早','2','中','3','夜')IN_BC"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.IN_BC"; } else if (strKey.Equals("InBz")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "DECODE(t.IN_BZ ,'1','甲','2','乙','3','丙','4','丁')IN_BZ"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.IN_BZ"; } else if (strKey.Equals("OutType")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "DECODE(t.OUT_TYPE ,'0','写卡倒运','1','票据倒运')OUT_TYPE"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.OUT_TYPE"; } else if (strKey.Equals("SoureName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.SOURE_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.SOURE_NAME"; } 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("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("Sfsp")) { } //else if (strKey.Equals("JudgeResultCode")) //{ // strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "MAX((SELECT (SELECT S1.BASENAME FROM COM_BASE_INFO S1 WHERE S1.BASECODE = Q.JUDGE_RESULT_CODE) JUDGE_RESULT_CODE FROM QCM_GP_JUDGE_APPLY Q WHERE Q.STOVE_NO = T.STOVE_NO AND Q.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO AND Q.MULTIPLE_NUM = T.FIX_NUM AND Q.IS_FLAG = '0' AND Q.VALIDFLAG = '20' GROUP BY Q.STOVE_NO,Q.JUDGE_STOVE_NO,Q.MULTIPLE_NUM,Q.JUDGE_RESULT_CODE))JUDGE_RESULT_CODE"; //} 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 = (string.IsNullOrEmpty(strGroup) ? "" : "group by ") + strGroup + " ORDER BY T.IN_TIME_F DESC"; strGroup = (string.IsNullOrEmpty(strGroup) ? "" : "group by ") + strGroup; }else { //strGroup = (string.IsNullOrEmpty(strGroup) ? "" : "group by ") + strGroup + " ,T.IN_TIME_F ORDER BY T.IN_TIME_F DESC"; strGroup = (string.IsNullOrEmpty(strGroup) ? "" : "group by ") + strGroup; } 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.FrmReportBcInput.doQueryData", new object[] { list, arr }, this.ob); break; case"BELONG_CODE": listSource = EntityHelper.GetData( "com.steering.ydm.bc.report.FrmReportBcInput.doQueryDataBelong", new object[] { list, belongArr }, this.ob); break; } YdmBcInlistEntitybindingSource.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("PonderGrossWt"); 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 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.dataYearMoth.Enabled = this.chkYearMoth.Checked; } private void chkSoureName_CheckedChanged(object sender, EventArgs e) { this.strSoureName.Enabled = this.chkSoureName.Checked; } private void chkInstockTypeName_CheckedChanged(object sender, EventArgs e) { this.strInstockTypeName.Enabled = this.chkInstockTypeName.Checked; } private void chkStorageName_CheckedChanged(object sender, EventArgs e) { this.strStorageName.Enabled = this.chkStorageName.Checked; } } }