using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.ZGMil.Entity;
using CoreFS.CA06;
using Infragistics.Win.UltraWinGrid;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.IO;
namespace Core.StlMes.Client.ZGMil.Report
{
public partial class FrmProcessFlowCard : FrmBase
{
private string departm = "";
//private string plineCode = "";
private string[] plineCode = null;
public FrmProcessFlowCard()
{
InitializeComponent();
this.IsLoadUserView = true;
}
private void FrmProcessFlowCard_Load(object sender, EventArgs e)
{
NativeMethodNew na = new NativeMethodNew(this.ob);
departm = UserInfo.GetDepartment();
//plineCode = na.GetPCode(departm);//获取 用户 对应的产线
plineCode = na.GetPCodePline(this.ValidDataPurviewIds);
/* try
{
//20250828 获取本地打印机
// 清空ComboBox现有项
comboBox1.Items.Clear();
// 获取所有已安装的打印机
foreach (string printer in PrinterSettings.InstalledPrinters)
{
comboBox1.Items.Add(printer);
}
// 如果有打印机,选择第一项
if (comboBox1.Items.Count > 0)
{
comboBox1.SelectedIndex = 0;
}
}
catch (Exception ex)
{
MessageBox.Show($"加载打印机列表时出错: {ex.Message}");
}*/
}
///
/// 重写基类方法
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
doQuery();
break;
case "Close":
this.Close();
break;
case "Excel":
doExcel();
break;
}
}
private void chkDate_CheckedChanged(object sender, EventArgs e)
{
if (chkScph.Checked) { txtLotNo.Enabled = true; } else { txtLotNo.Enabled = false; }
if (chkLh.Checked) { txtJutNo.Enabled = true; } else { txtJutNo.Enabled = false; }
}
private void doQuery()
{
ArrayList list = new ArrayList();
string strLotNo = "";
string strJuNo = "";
if (chkScph.Checked)
{
if (txtLotNo.Text.Trim() == "")
{
MessageUtil.ShowTips("请输入生产批号!");
return;
}
else
{
strLotNo = txtLotNo.Text.ToString();
}
}
if (chkLh.Checked)
{
if (txtJutNo.Text.Trim() == "")
{
MessageUtil.ShowTips("请输入炉号!");
return;
}
else
{
strJuNo = txtJutNo.Text.ToString();
}
}
System.Data.DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmProcessFlowCard.queryMinResult", new Object[] { strLotNo, strJuNo, plineCode }, this.ob);
GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
}
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
e.Row.Cells["CARD"].Value = "打印";
}
private void ultraGrid1_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
{
UltraGridRow row = ultraGrid1.ActiveRow;
if (row == null) return;
string plineNo = row.Cells["PLINE_CODE"].Value.ToString();//产线
string plineName = row.Cells["PLINE_NAME"].Value.ToString();//产线
string juNo = row.Cells["JUDGE_STOVE_NO"].Value.ToString();
string url = "";
//if (plineNo == "C009" || plineNo == "C017")
//{
// url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMobileCardSon.cpt&__bypagesize__=false&JudgeStoveNo=" + juNo + "";
//}
//else if (plineNo == "C008" || plineNo == "C010")
//{
// MessageUtil.ShowTips(plineName+"暂无模板!"); return;
//}
//else
//{
// MessageUtil.ShowTips("无产线!"); return;
//}
if (plineNo.Equals("C072"))
{
url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMobileCardSon.cpt&op=view&JudgeStoveNo=" + juNo + "";
}
else
{
url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMobileCardSon.cpt&op=view&JudgeStoveNo=" + juNo + "";
}
FrmRepExcel fre = new FrmRepExcel(this.ob, url);
//fre.AutoSize = true;
fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
fre.Text = "工艺流动卡";
fre.ShowDialog();
}
private void card_pathT_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{
if (ultraGrid1.ActiveRow == null) return;
UltraGridRow row = ultraGrid1.ActiveRow;
if (e.Button.Key.Equals("CK"))
{
FormFileDown down = new FormFileDown(this.ob, row.Cells["CARD_PATH"].Text);
down.ShowDialog();
}
else
{
string filePath = "MESServer/" + "CARD" + "/" + row.Cells["PLINE_CODE"].Text + "/" + row.Cells["JUDGE_STOVE_NO"].Text + "/";
FormFileDown down = new FormFileDown(this.ob, filePath);
down.CtrlFileDown1.FilePath = filePath;
List list = new List();
FileBean bean = new FileBean();
OpenFileDialog file = new OpenFileDialog();
file.Multiselect = true;
DialogResult drStat;
drStat = file.ShowDialog();
if (drStat == DialogResult.OK)
{
foreach (string fileName in file.FileNames)
{
bean = new FileBean();
string filena = System.IO.Path.GetFileName(fileName);
bean.setFileName(filena);
bean.setPathName(filePath);
bean.setFile(FileHelper.FileToArray(fileName));
list.Add(bean);
}
bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
if (isSuccess)
{
Thread.Sleep(100); //等待一下下
DoUpdateFilePath(filePath, true);
}
else
{
MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
}
}
}
}
private void DoUpdateFilePath(string filePath, bool showTips)
{
var ccp = new CoreClientParam
{
ServerName = "com.steering.mes.zgmil.report.FrmProcessFlowCard",
MethodName = "DoUpdateFilePath",
ServerParams = new object[]
{
ultraGrid1.ActiveRow.Cells["JUDGE_STOVE_NO"].Text,
filePath
}
};
ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1 && showTips)
{
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Contains("成功!"))
doQuery();
}
else if (!showTips)
{
doQuery();
}
}
//批量打印
private void button1_Click(object sender, EventArgs e)
{
try
{
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (Convert.ToBoolean(row.Cells["CHC"].Text) == true)
{
string plineNo = row.Cells["PLINE_CODE"].Value.ToString();//产线
string plineName = row.Cells["PLINE_NAME"].Value.ToString();//产线
string juNo = row.Cells["JUDGE_STOVE_NO"].Value.ToString();
string url = "";
if (plineNo.Equals("C072"))
{
url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMobileCardSon.cpt&op=view&JudgeStoveNo=" + juNo + "";
}
else
{
url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilMobileCardSon.cpt&op=view&JudgeStoveNo=" + juNo + "";
}
FrmRepExcel fre = new FrmRepExcel(this.ob, url);
fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
fre.Text = "工艺流动卡";
fre.ShowDialog();
}
}
}
catch (Exception ex)
{
MessageBox.Show($"打印时出错: {ex.Message}");
}
}
private void doExcel()
{
}
}
}