using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Judge.Commons; using Core.StlMes.Client.Judge.Controls; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Linq; using System.Net; using System.Windows.Forms; namespace Core.StlMes.Client.Judge.Forms { public partial class SteelMakingColligateQueryFrm : FrmBase { private SteelMakingColligateQueryCtrl _colligateQueryCtrl; private StlIncisionDtlCtrl _stlDtlCtrl; private QcmJhyElementsCtrl _jhyElementsCtrl; private QcmJhyPhyDbResultCtrl _jhyPhyDbResultCtrl; private FaceFileCtrl _faceFileCtrl; private DetectFileCtrl _detectFileCtrl; private Dal _d; public SteelMakingColligateQueryFrm() { InitializeComponent(); _colligateQueryCtrl = new SteelMakingColligateQueryCtrl(splitContainer1.Panel1, ob); _colligateQueryCtrl.SteelMakingColligateQueryGrid.AfterRowActivate += colligateQueryCtrl_AfterRowActivate; _colligateQueryCtrl.SteelMakingColligateQueryGrid.ClickCell += colligateQueryCtrl_ClickCell; this.IsLoadUserView = true; } public override void ToolBar_Click(object sender, string ToolbarKey) { base.ToolBar_Click(sender, ToolbarKey); switch (ToolbarKey) { case "Query": Query(); break; case "ReviewGpCertificate": ReviewGpCertificate(); break; case "Export": Export(); break; case "BatchDownload": BatchDownload(); break; } } private void SteelMakingColligateQueryFrm_Load(object sender, EventArgs e) { _d = new Dal(ob); _colligateQueryCtrl.D.Ob = ob; _stlDtlCtrl = new StlIncisionDtlCtrl(splitContainer1.Panel2, ob); _jhyElementsCtrl = new QcmJhyElementsCtrl(ultraTabPageControl1, ob, false); _jhyPhyDbResultCtrl = new QcmJhyPhyDbResultCtrl(ultraTabPageControl2, ob); _faceFileCtrl = new FaceFileCtrl(ultraTabPageControl4, ob, false); _detectFileCtrl = new DetectFileCtrl(ultraTabPageControl3, ob, false); JudgeBaseInfo.LoadPlineName(labelComboBox1.ComboBox, ob, false, "A"); JudgeBaseInfo.LoadPlineName(labelComboBox5.ComboBox, ob, false, "B", "C"); ClsBaseInfo.FillComBaseInfo(labelComboBox2.ComboBox, "407407", ob, false); //判定结果只显示内控合格和不合格。 40740101内控合格 40740102内控不合格 DataTable dt = (DataTable)labelComboBox2.ComboBox.DataSource; DataRow dr = dt.NewRow(); dr["BASECODE"] = "1"; dr["BASENAME"] = "已判"; dt.Rows.InsertAt(dr, 0); dr = dt.NewRow(); dr["BASECODE"] = "0"; dr["BASENAME"] = "未判"; dt.Rows.InsertAt(dr, 0); dt.AcceptChanges(); dt.DefaultView.RowFilter = "BASECODE NOT IN ('40740703', '40740706')"; ClsBaseInfo.SetComboItemHeight(labelComboBox2.ComboBox); labelDateTimePicker1.Checked = true; labelDateTimePicker1.DateTimePicker.Value = DateTime.Now.Date.AddDays(-3); labelDateTimePicker2.DateTimePicker.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1); labelDateTimePicker3.DateTimePicker.Value = DateTime.Now.Date.AddDays(-3); labelDateTimePicker4.DateTimePicker.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1); for (int i = DateTime.Now.Year - 10; i <= DateTime.Now.Year + 10; i++) { ultraComboEditor1.Items.Add(i); } ultraComboEditor1.Value = DateTime.Now.Year; ultraComboEditor2.Value = DateTime.Now.Month.ToString().PadLeft(2, '0'); } private void Export() { GridHelper.ulGridToExcel(_colligateQueryCtrl.SteelMakingColligateQueryGrid, "炼钢综合判定查询"); } void colligateQueryCtrl_ClickCell(object sender, ClickCellEventArgs e) { if(e.Cell.Column.Key.Equals("chk")){ _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow.Cells["chk"].Value = !Boolean.Parse(_colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow.Cells["chk"].Value.ToString()); } } void colligateQueryCtrl_AfterRowActivate(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; //查询倍尺、长度、重量等信息 var row = _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow; DataRow craftDbCnt = _d.GetRowByXmlId("QcmJhyPhyDbResultDAL.queryJhyDbCnt", row.GetValue("judgeStoveNo")); if (craftDbCnt["COUNT"].ToString() == "0" && !row.GetValue("steelStandrad").Contains("PIC")) { ultraTabControl1.Tabs[1].Visible = false; } else { ultraTabControl1.Tabs[1].Visible = true; } DataRow drGpApply; if (row.GetValue("jugdeApplyCode") == "") { drGpApply = _d.GetRowByXmlId("QcmGpJugdeApplyDAL.queryGpApplyByJudgeStoveNo2", row.GetValue("judgeStoveNo")); } else { drGpApply = _d.GetRowByXmlId("QcmGpJugdeApplyDAL.queryGpApplyByJudgeStoveNo", row.GetValue("jugdeApplyCode"), row.GetValue("jugdeApplySqe"), row.GetValue("JudgeStoveNo")); } if (drGpApply != null && drGpApply["DetectResultPath"].ToString() != "") { ultraTabControl1.Tabs[2].Visible = true; } else { ultraTabControl1.Tabs[2].Visible = false; } //查询倍尺 if (row.GetValue("jugdeApplyCode") == "") { _stlDtlCtrl.QueryStl(row.GetValue("judgeStoveNo")); } else { _stlDtlCtrl.QueryApply(row.GetValue("jugdeApplyCode"), row.GetValue("jugdeApplySqe"), row.GetValue("judgeStoveNo")); } QueryGpJudgeApplyDown(drGpApply); } finally { this.Cursor = Cursors.Default; } } //private string[] GetGpJudgeApplyZgPlanId() //{ // if (_colligateQueryCtrl == null) return new string[] { "", "" }; // var row = _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow; // if (row == null) return new string[] { "", "" }; // DataTable dtGpApply = _d.GetTableByXmlId("QcmGpJugdeApplyDAL.getApplyPlnIdByJudgeStoveNo", row.GetValue("JudgeStoveNo")); // List zgProPlanIds = new List(); // foreach (DataRow gpJudgeApply in dtGpApply.Rows) // { // string proPlanIdNext = gpJudgeApply["proPlanIdNext"].ToString(); // string proPlanId = gpJudgeApply["proPlanId"].ToString(); // if (proPlanIdNext != "" && proPlanIdNext.StartsWith("ZG")) // { // zgProPlanIds.Add(proPlanIdNext); // } // else // { // string zzProPlanId = ""; // if (proPlanIdNext != "") // { // zzProPlanId = proPlanIdNext; // } // else // { // zzProPlanId = proPlanId; // } // DataTable dtZgProPlanIds = _d.GetTableByXmlId("JdgPlnOrderZgS.queryByGpreqId", zzProPlanId); // foreach (DataRow drZgProPlanId in dtZgProPlanIds.Rows) // { // zgProPlanIds.Add(drZgProPlanId["proPlanId"].ToString()); // } // } // } // return zgProPlanIds.ToArray(); //} private void QueryGpJudgeApplyDown(DataRow drGpApply) { if (_colligateQueryCtrl == null) return; var row = _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow; if (row == null) return; switch (ultraTabControl1.SelectedTab.Text) { case "成分信息": _jhyElementsCtrl.ClearData(); string[] zgProPlanIds; if (row.GetValue("jugdeApplyCode") == "") { zgProPlanIds = SteelMakingChemJudgeFrm.GetStlInsitionZgPlanId(row.GetValue("judgeStoveNo"), row.GetValue("stoveNo"), _d.Ob); } else { zgProPlanIds = SteelMakingChemJudgeFrm.GetGpJudgeApplyZgPlanId(row.GetValue("jugdeApplyCode"), row.GetValue("jugdeApplySqe"), row.GetValue("judgeStoveNo"), row.GetValue("stoveNo"), _d.Ob); } DataRow drPlnCic = _d.GetRowByXmlId("PlnSteelforOrdDAL.getCicByJudgeStoveNo", row.GetValue("judgeStoveNo")); string[] cics = new string[1]; if (drPlnCic != null) { cics = drPlnCic["cic"].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } else if (drGpApply != null) { cics[0] = drGpApply["cic"].ToString(); } DataTable dtCraftCic = _d.GetTableByXmlId("JdgPlnOrderZgS.queryCraftCicByZgProPlanId", new object[] { zgProPlanIds, cics.Length, cics }); //增加余材获取成分 if (dtCraftCic.Rows.Count <= 0) { drPlnCic = _d.GetRowByXmlId("PlnSteelforOrdDAL.getCicByProPlanId", new object[] { zgProPlanIds }); cics = new string[1]; if (drPlnCic != null) { cics = drPlnCic["cic"].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } else if (drGpApply != null) { cics[0] = drGpApply["cic"].ToString(); } if (cics.Length != 0 && cics[0] == null) { break; } dtCraftCic = _d.GetTableByXmlId("JdgPlnOrderZgS.queryCraftCicByZgProPlanId", new object[] { zgProPlanIds, cics.Length, cics }); if (dtCraftCic.Rows.Count <= 0) { dtCraftCic = _d.GetTableByXmlId("JdgPlnOrderZgS.queryCraftCicByZgProPlanIdNew", new object[] { zgProPlanIds }); } } //FillLkCic(drGpApply, dtCraftCic); _jhyElementsCtrl.QueryCraftResultByStoveNo(row.GetValue("stoveNo"), row.GetValue("judgeStoveNo"), dtCraftCic, "A",zgProPlanIds); break; case "低倍信息": _jhyPhyDbResultCtrl.ClearData(); string lgJudgeStoveNo = row.GetValue("judgeStoveNo"); if (drGpApply != null && drGpApply["judgeStoveNoLg"].ToString() != "") { lgJudgeStoveNo = drGpApply["judgeStoveNoLg"].ToString(); } _jhyPhyDbResultCtrl.Query(lgJudgeStoveNo); break; case "探伤信息": _detectFileCtrl.Query(row.GetValue("judgeStoveNo")); break; case "表检尺寸": _faceFileCtrl.Query(row.GetValue("judgeStoveNo")); break; } } private void FillLkCic(DataRow drGpApply, DataTable dtCraftCic) { if (drGpApply != null && drGpApply["Cic"].ToString() != "" && drGpApply["lkFlag"].ToString() == "1") { bool sameCic = false; foreach (DataRow drCraftCic in dtCraftCic.Rows) { if (drCraftCic["cic"].ToString() == drGpApply["cic"].ToString()) { sameCic = true; } } if (!sameCic) { foreach (DataRow drCraftCic in dtCraftCic.Rows) { drCraftCic["cic"] = drGpApply["cic"].ToString(); } } } } private void Query() { try { this.Cursor = Cursors.WaitCursor; string judgeStoveNo = labelTextBox4.Checked ? labelTextBox4.Text.Trim() : ""; string judgeState = labelComboBox2.Checked ? labelComboBox2.SelecteValue.ToString2() : ""; string orderNo = labelTextBox9.Checked ? labelTextBox9.Text.Trim() : ""; string[] plines; if (labelComboBox1.ComboBox.Value == null || !labelComboBox1.Checked) { plines = new string[0]; } else { plines = ((List)labelComboBox1.ComboBox.Value).Select(a => a.ToString()).ToArray(); } string timeB = labelDateTimePicker1.Checked ? labelDateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; string timeE = labelDateTimePicker1.Checked ? labelDateTimePicker2.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; string proTimeB = labelDateTimePicker3.Checked ? labelDateTimePicker3.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; string proTimeE = labelDateTimePicker3.Checked ? labelDateTimePicker4.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; string chemType = ultraOptionSet2.Value.ToString2(); string gpSource = ultraOptionSet1.Value.ToString2(); string[] plinesGp; if (labelComboBox5.ComboBox.Value == null || !labelComboBox5.Checked) { plinesGp = new string[0]; } else { plinesGp = ((List)labelComboBox5.ComboBox.Value).Select(a => a.ToString()).ToArray(); } string balYearMonth = ultraCheckEditor1.Checked ? ultraComboEditor1.Value.ToString2() + ultraComboEditor2.Value.ToString() : ""; _colligateQueryCtrl.Query(judgeStoveNo, judgeState, plines, timeB, timeE, chemType, gpSource, plinesGp, balYearMonth, proTimeB, proTimeE, orderNo); } finally { this.Cursor = Cursors.Default; } } private void ReviewGpCertificate() { try { this.Cursor = Cursors.WaitCursor; var row = _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow; if (row == null) { MessageUtil.ShowWarning("请选择一行记录!"); return; } string judgeApplyCode = row.Cells["jugdeApplyCode"].Value.ToString(); string judgeApplySeq = row.Cells["jugdeApplySqe"].Value.ToString(); string judgeStoveNo = row.Cells["judgeStoveNo"].Value.ToString(); if (judgeApplyCode == "") { MessageUtil.ShowWarning("该记录还未进行综合判定,无法查看判定书!", _colligateQueryCtrl.SteelMakingColligateQueryGrid, _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow); return; } string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepGpCertificate.cpt&_bypagesize__=false" + "&JUGDE_APPLY_CODE=" + judgeApplyCode + judgeApplySeq + "&JUDGE_STOVE_NO=" + judgeStoveNo; FrmOrderRepExcel fBug = new FrmOrderRepExcel(ob, strurl); fBug.AutoSize = true; fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fBug.WindowState = FormWindowState.Maximized; fBug.Text = "管坯判定书"; fBug.Show(); } finally { this.Cursor = Cursors.Default; } } private void BatchDownload() { //int count = _colligateQueryCtrl.SteelMakingColligateQueryGrid.Selected.Rows.Count; IQueryable ugrs = _colligateQueryCtrl.SteelMakingColligateQueryGrid.Rows.AsQueryable().Where(" CHK = 'True'"); if (ugrs.Count() <= 0) { MessageUtil.ShowWarning("请选择您要批量下载的报告!"); return; } if (ugrs.Count() > 50) { MessageUtil.ShowWarning("导出数量不能大于50条!"); return; } //if (count > 50 && MessageUtil.ShowYesNoAndQuestion("是否确定添加?") == DialogResult.No) //{ // return; //} WaitingForm2 wf = new WaitingForm2("系统生成PDF中...."); List pathList = new List(); foreach (UltraGridRow row in ugrs) { string judgeApplyCode = row.Cells["jugdeApplyCode"].Value.ToString(); string judgeApplySeq = row.Cells["jugdeApplySqe"].Value.ToString(); string judgeStoveNo = row.Cells["judgeStoveNo"].Value.ToString(); if (judgeApplyCode == "") { wf.Close(); MessageUtil.ShowWarning(judgeStoveNo+"该记录还未进行综合判定,无法生成判定书!"); return; } string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepGpCertificate.cpt&bypagesize=false&format=pdf&embed=true" + "&JUGDE_APPLY_CODE=" + judgeApplyCode + judgeApplySeq + "&JUDGE_STOVE_NO=" + judgeStoveNo; string savePath = "judge/PipeMaterialJudgment/A/" + judgeApplyCode + judgeApplySeq + "/"; if (!FlileUploadcomm.CreatePdfToFtp(strurl, savePath, judgeStoveNo)) { wf.Close(); MessageUtil.ShowError("系统生成PDF失败,请稍后再试!"); return; } pathList.Add(savePath); } wf.Close(); dlgOrderAskDown down = new dlgOrderAskDown(this.ob, pathList); down.DeleteButton.Visible = false; down.ShowDialog(); //打开下载后的文件夹 if (down.Pic != "") System.Diagnostics.Process.Start("Explorer.exe", down.Pic); } private void labelDateTimePicker1_CheckBox_CheckedChanged(object sender, EventArgs e) { labelDateTimePicker2.DateTimeEnabled = labelDateTimePicker1.Checked; } private void labelTextBox4_TextBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter) { Query(); } } private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (_colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow == null) return; var row = _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow; DataRow drGpApply = _d.GetRowByXmlId("QcmGpJugdeApplyDAL.queryGpApplyByJudgeStoveNo2", row.GetValue("judgeStoveNo")); QueryGpJudgeApplyDown(drGpApply); } finally { this.Cursor = Cursors.Default; } } private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e) { ultraComboEditor1.Enabled = ultraComboEditor2.Enabled = ultraCheckEditor1.Checked; } private void labelDateTimePicker3_CheckBox_CheckedChanged(object sender, EventArgs e) { labelDateTimePicker4.DateTimeEnabled = labelDateTimePicker3.DateTimeEnabled; } } }