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.YdmStuffManage; using Core.StlMes.Client.YdmStuffReport.Entity; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.YdmStuffReport { 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) { RegStartTime.Value = DateTime.Parse(new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToString()); DateTime d1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); RegEndTime.Value = DateTime.Parse(d1.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd") + " 23:59:59"); dataYearMoth.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM")); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); arr = BaseMethod.WarehousePermissionsStore(this.ValidDataPurviewIds,ob); belongArr = this.ValidDataPurviewIds; switch (this.CustomInfo) { case "BELONG_CODE": this.ultraGrid1.DisplayLayout.Bands[0].Columns["JudgeResultCode"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["OrderNo"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["CHK"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["InstockDoc"].Hidden = true; break; case "STORAGE_NO": ultraGrid1.DisplayLayout.Bands[0].Columns["ProOrderNo"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["Producname"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["Steelname"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["IsDealer"].Hidden = true; break; } try { alistChecked = new ArrayList(); alistChecked.Add("StoveNo"); alistChecked.Add("JudgeStoveNo"); alistChecked.Add("MaterialName"); alistChecked.Add("ActLen"); alistChecked.Add("JudgeResultCode"); alistChecked.Add("SoureName"); alistChecked.Add("Dimater"); alistChecked.Add("Gradename"); alistChecked.Add("ProOrderNo"); alistChecked.Add("StorageName"); alistChecked.Add("LocationName"); alistChecked.Add("InBc"); alistChecked.Add("InBz"); alistChecked.Add("InTimeF"); alistChecked.Add("BelongName"); alistChecked.Add("CreateName"); } catch { } try { ArrayList alist = new ArrayList(); alist.Add("ActCount"); alist.Add("ActWeight"); CommonMethod.GeneralCheckedListboxItems(ref this.myCheckedListBox1, ref this.ultraGrid1, alist, alistChecked); } catch { } } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": QueryData(); break; case "Print": print(); 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 = ""; 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 + "'"; } 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("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("Gradename")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.GRADENAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.GRADENAME"; } else if (strKey.Equals("StdName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.STD_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.STD_NAME"; } else if (strKey.Equals("Dimater")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.DIMATER"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.DIMATER"; } else if (strKey.Equals("FixNum")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.FIX_NUM"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.FIX_NUM"; } else if (strKey.Equals("FixLen")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.FIX_LEN"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.FIX_LEN"; } 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("CreateName")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.CREATE_NAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.CREATE_NAME"; } 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("InTimeF")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "to_char(t.IN_TIME_F,'YYYY-MM-DD HH24:MI:SS') as IN_TIME_F"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.IN_TIME_F"; } else if (strKey.Equals("InstockTimeS")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "MAX(to_char(t.IN_TIME_F,'YYYY-MM-DD')) as INSTOCK_TIME_S"; } 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("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 if (strKey.Equals("ProOrderNo")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.PRO_ORDER_NO"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.PRO_ORDER_NO"; } else if (strKey.Equals("Producname")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "S1.PRODUCNAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "S1.PRODUCNAME"; } else if (strKey.Equals("Steelname")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "S1.STEELNAME"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "S1.STEELNAME"; } 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("OrderNo")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.ORDER_NO"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.ORDER_NO"; }else if(strKey.Equals("IsDealer")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "DECODE(T.IS_DEALER,'0','自用','1','双经销','2','来料加工','3','定销订购','4','库存商备坯')IS_DEALER"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "T.IS_DEALER"; } else if (strKey.Equals("InstockDoc")) { strSql += (string.IsNullOrEmpty(strSql) ? "" : ",") + "t.INSTOCK_DOC"; strGroup += (string.IsNullOrEmpty(strGroup) ? "" : ",") + "t.INSTOCK_DOC"; } else if (strKey.Equals("CHK")) { } else if (strKey.Equals("CgHtTh")) { } 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( "Core.LgMes.Server.Stuffmanage.Report.FrmReportInput.doQueryData", new object[] { list, arr }, this.ob); break; case"BELONG_CODE": listSource = EntityHelper.GetData( "Core.LgMes.Server.Stuffmanage.Report.FrmReportInput.doQueryDataBelong", new object[] { list, belongArr }, this.ob); break; } YdmGpInlistEntitybindingSource.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"); 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.dataYearMoth.Enabled = this.chkYearMoth.Checked; } /// /// 打印管坯库入库台账 /// private void print() { this.ultraGrid1.UpdateData(); int m = 0; int n = 0; string InstockDoc = ""; IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要打印的信息!"); return; } foreach (UltraGridRow row in checkMagRows) { if (n == 0) { InstockDoc = row.Cells["InstockDoc"].Text ; } else { InstockDoc = InstockDoc + "','" + row.Cells["InstockDoc"].Text ; } n = n + 1; } string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepGpInListTH.cpt&INSTOCK_DOC=" + InstockDoc + "&BC=" + this.UserInfo.GetUserOrder() + "&BZ=" + this.UserInfo.GetUserGroup(); FrmExcel fre = new FrmExcel(this.ob, strurl); fre.AutoSize = true; fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fre.WindowState = FormWindowState.Maximized; fre.Show(); } } }