using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using QMAPP.WinForm.Forms.Injection; using QMAPP.WinForm.Forms.Operation; using QMAPP.WinForm.Forms.EquipmentAlarm; using QMAPP.WinForm.Forms.InformationSearch; using QMAPP.WinForm.Forms.Mend; using QMAPP.WinForm.Forms.WarehouseManage; using QMAPP.ServicesAgent.LoginService; using QMAPP.WinForm.Common; using QMAPP.WinForm.Forms.Andon; using QMAPP.WinForm.Forms.Andon.Enum; using QMAPP.WinForm.Forms.SlushPlanForm; using QMAPP.WinForm.Forms.DisPatch; using QMAPP.WinForm.Forms.MachineCheck; using QMAPP.WinForm.Forms.ODS; using QMAPP.ServicesAgent; using QMAPP.WinForm.Forms.ProductIn; using System.Configuration; using System.ServiceModel.Configuration; using QMAPP.WinForm.Forms.RePrint; namespace QMAPP.WinForm { /// /// 主窗体 /// public partial class MainForm : Form { public delegate void InvokeViewCloseHandler(); private bool _isAutoClosed = false; /// /// /// public MainForm() { InitializeComponent(); } public MainForm(LoginInfo login) { InitializeComponent(); SetLoginInfo(login); } /// /// 设置登录信息 /// /// public void SetLoginInfo(LoginInfo login) { ClientContext.AuthList = new Dictionary(); List powerIDList = new List(); XmlReader reader = new XmlReader(); if (login.LoginUserID.ToUpper().Trim() != "ADMIN") { //到菜单配置文件中获取按钮信息 //在web系统中权限配置文件中工控机 List powerIDListTemp = login.Powers.ToList() .Where(o => Convert.ToInt32(o.Substring(2, 2)) >= 80 && Convert.ToInt32(o.Substring(2, 2)) <= 95 ).ToList(); foreach (var item in powerIDListTemp) { powerIDList.Add(item); if (!powerIDList.Contains(item.Substring(0, 6).PadRight(8, '0'))) { powerIDList.Add(item.Substring(0, 6).PadRight(8, '0')); } } List btnIDList = reader.GetMenuBtnFromPower(powerIDList); //btnIDList.Add("btnUserOut");//注销 foreach (ToolStripMenuItem menu in menuStrip1.Items) { //一级菜单. //该模块下按钮总数 int btnSum = menu.DropDownItems.Count; if (btnSum == 0) { continue; } //隐藏按钮数量 int hideSum = 0; foreach (ToolStripDropDownItem subMenu in menu.DropDownItems) { //一级菜单下的子菜单. //对权限不包含的按钮进行隐藏 if (!btnIDList.Contains(subMenu.Name)) { subMenu.Visible = false; hideSum++; } } //隐藏模块按钮 if (btnSum == hideSum) { menu.Visible = false; } } } else { reader.GetMenuBtnFromPower(powerIDList); } //显示登录人信息 string loginInfo = "当前用户:" + login.UserName + " "; if (ClientContext.produceShift != null) { loginInfo += "班次:" + ClientContext.produceShift.PRODUCESHIFTNAME + " "; } this.toolStripStatusLabel1.Text = loginInfo; } private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { Application.Exit(); } private void btnInjectPut_Click(object sender, EventArgs e) { Form f = Application.OpenForms["InjectionMoldingForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { InjectionMoldingForm form = new InjectionMoldingForm(); ClientContext.SetUserAuth(form); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } /// /// /// /// /// private void btnInjectPutNEW_Click(object sender, EventArgs e) { //Form f = Application.OpenForms["InjectionMoldingNEWForm"]; //查找是否打开过Form1窗体 //if (f == null) //没打开过 //{ // InjectionMoldingNEWForm form = new InjectionMoldingNEWForm(); // ClientContext.SetUserAuth(form); // new KeyEvent().SetKeyToTxt(form); // form.MdiParent = this; // form.Show(); //重新new一个Show出来 //} //else //{ // f.WindowState = FormWindowState.Normal; // f.Focus(); //打开过就让其获得焦点 //} } private void btnInjectPrintForm_Click(object sender, EventArgs e) { Form f = Application.OpenForms["InjectPasswordForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { InjectPasswordForm form = new InjectPasswordForm(); ClientContext.SetUserAuth(form); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnInjectionCheck_Click(object sender, EventArgs e) { Form f = Application.OpenForms["InjectionCheckListForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { InjectionCheckListForm form = new InjectionCheckListForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnInjectCodePrint_Click(object sender, EventArgs e) { Form f = Application.OpenForms["InjectionMoldingPrintForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { InjectionMoldingPrintForm form = new InjectionMoldingPrintForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnInjectEquipMaintain_Click(object sender, EventArgs e) { Form f = Application.OpenForms["EquipmentMaintainForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { EquipmentMaintainForm form = new EquipmentMaintainForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnOperateStation_Click(object sender, EventArgs e) { Form f = Application.OpenForms["OperationForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { OperationForm form = new OperationForm(); new KeyEvent().SetKeyToTxt(form); ClientContext.SetUserAuth(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnOperateEquipMaintain_Click(object sender, EventArgs e) { Form f = Application.OpenForms["EquipmentMaintainForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { EquipmentMaintainForm form = new EquipmentMaintainForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnInjectPack_Click(object sender, EventArgs e) { Form f = Application.OpenForms["ProductBundleForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { ProductBundleForm form = new ProductBundleForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnEquipAlarm_Click(object sender, EventArgs e) { Form f = Application.OpenForms["EquipmentAlarmForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { EquipmentAlarmForm form = new EquipmentAlarmForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnFisInfoShow_Click(object sender, EventArgs e) { Form f = Application.OpenForms["FisM100ListForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { FisM100ListForm form = new FisM100ListForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnSPCMonitor_Click(object sender, EventArgs e) { Form f = Application.OpenForms["SPCControlForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { SPCControlForm form = new SPCControlForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnOpeInfoShow_Click(object sender, EventArgs e) { //Form f = Application.OpenForms["MainOperationSearchForm"]; //查找是否打开过Form1窗体 //if (f == null) //没打开过 //{ // MainOperationSearchForm form = new MainOperationSearchForm(); // new KeyEvent().SetKeyToTxt(form); // form.MdiParent = this; // form.Show(); //重新new一个Show出来 //} //else //{ // f.WindowState = FormWindowState.Normal; // f.Focus(); //打开过就让其获得焦点 //} } private void btnMendOperate_Click(object sender, EventArgs e) { Form f = Application.OpenForms["MendRecorderForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { MendRecorderForm form = new MendRecorderForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnOut_Click(object sender, EventArgs e) { Form f = Application.OpenForms["OutWarehouseForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { OutWarehouseForm form = new OutWarehouseForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnIn_Click(object sender, EventArgs e) { Form f = Application.OpenForms["InWarehouseForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { InWarehouseForm form = new InWarehouseForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } public void ThreadProc() { Application.Run(new LoginForm()); } private void 注销ToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show(Resource1.LogOff, Resource1.ConfirmTitle, MessageBoxButtons.OKCancel) != DialogResult.OK) return; this.Close(); System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc)); t.Start(); } private void m135外购件注册ToolStripMenuItem_Click(object sender, EventArgs e) { Form f = Application.OpenForms["ProductAddForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { ProductAddForm form = new ProductAddForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void m181ToolStripMenuItem_Click(object sender, EventArgs e) { Form f = Application.OpenForms["SlushPlanForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { SlushPlanForm form = new SlushPlanForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void tsmiTakeOut_Click(object sender, EventArgs e) { Form f = Application.OpenForms["SendFinalForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { SendFinalForm form = new SendFinalForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBox.Show("是否关闭窗口", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No) e.Cancel = true; } private void MainForm_Load(object sender, EventArgs e) { LoadServerHost(); var startup = Common.LocalSetting.Settings["StartUp", ""]; if (!string.IsNullOrWhiteSpace(startup)) { var formtype = Type.GetType(startup); if (formtype != null) { Form startupform = (Form)Activator.CreateInstance(formtype); ClientContext.SetUserAuth(startupform); if (startupform != null) { //ClientContext.SetUserAuth(((ToolStripMenuItem)sender).Name, startupform); startupform.MdiParent = this; startupform.WindowState = FormWindowState.Maximized; startupform.Show(); } } } } private void LoadServerHost() { Configuration cfg = ConfigurationManager.OpenExeConfiguration(""); var clientSecion = cfg.GetSection("system.serviceModel/client") as ClientSection; tslServerHost.Text = "WCF服务器:" + GetEndointByName(clientSecion, "BasicHttpBinding_IGeneralService").Address.Host; } private ChannelEndpointElement GetEndointByName(ClientSection section, string endpointname) { foreach (ChannelEndpointElement endpoint in section.Endpoints) { if (string.Equals(endpoint.Name, endpointname)) { return endpoint; } } return null; } private void PrintCodeToolStripMenuItem_Click(object sender, EventArgs e) { //Form f = Application.OpenForms["PrintForm"]; //查找是否打开过Form1窗体 //if (f == null) //没打开过 //{ // PrintForm form = new PrintForm(); // ClientContext.SetUserAuth(form); // //new KeyEvent().SetKeyToTxt(form); // form.MdiParent = this; // form.Show(); //重新new一个Show出来 //} //else //{ // f.WindowState = FormWindowState.Normal; // f.Focus(); //打开过就让其获得焦点 //} return; } private void FrmPlace_Click(object sender, EventArgs e) { Form f = Application.OpenForms["FrmPlace"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { FrmPlace form = new FrmPlace(); //new KeyEvent().SetKeyToTxt(form); ClientContext.SetUserAuth(form); form.MdiParent = this; form.WindowState = FormWindowState.Maximized; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void VedioToolStripMenuItem1_Click(object sender, EventArgs e) { Form f = Application.OpenForms["MediaPlayerForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { MediaPlayerForm form = new MediaPlayerForm(); //new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.WindowState = FormWindowState.Maximized; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void TypeToolStripMenuItem_Click(object sender, EventArgs e) { Form f = Application.OpenForms["VideoTypeForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { VideoTypeForm form = new VideoTypeForm(); //new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.WindowState = FormWindowState.Maximized; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void AodonToolStripMenuItem_Click(object sender, EventArgs e) { Form f = Application.OpenForms["CallManageForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { CallManageForm form = new CallManageForm(); form.MdiParent = this; form.WindowState = FormWindowState.Maximized; form.mainForm = this; form.Show(); //重新new一个Show出来 } else { //先关闭 f.Close(); //重新打开 CallManageForm form = new CallManageForm(); form.MdiParent = this; form.WindowState = FormWindowState.Maximized; form.Show(); //重新new一个Show出来 } } //private void tsmiCallReason_Click(object sender, EventArgs e) //{ // Form f = Application.OpenForms["CallReasonForm"]; //查找是否打开过Form1窗体 // if (f == null) //没打开过 // { // CallReasonForm form = new CallReasonForm(); // form.MdiParent = this; // form.WindowState = FormWindowState.Maximized; // form.Show(); //重新new一个Show出来 // } // else // { // //先关闭 // f.Close(); // //重新打开 // CallReasonForm form = new CallReasonForm(); // form.MdiParent = this; // form.WindowState = FormWindowState.Maximized; // form.Show(); //重新new一个Show出来 // } //} private void EquipToolStripMenuItem1_Click(object sender, EventArgs e) { Form f = Application.OpenForms["MachineCheckForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { MachineCheckForm form = new MachineCheckForm(); form.MdiParent = this; form.WindowState = FormWindowState.Maximized; form.Show(); //重新new一个Show出来 } else { //先关闭 f.Close(); //重新打开 MachineCheckForm form = new MachineCheckForm(); form.MdiParent = this; form.WindowState = FormWindowState.Maximized; form.Show(); //重新new一个Show出来 } } private void tsmiFISBreak_Click(object sender, EventArgs e) { QMAPP.WinForm.Forms.PlanSearch.frmFISBreakConfirm form = new QMAPP.WinForm.Forms.PlanSearch.frmFISBreakConfirm(); //form.MdiParent = this; //form.WindowState = FormWindowState.Maximized; form.ShowDialog(); //重新new一个Show出来 } private void timer1_Tick(object sender, EventArgs e) { QMAPP.ServicesAgent.ServiceAgent agent1 = ClientContext.GetServiceAgent(); var shift = agent1.InvokeServiceFunction(B9BasicService.ProduceShiftBLL_GetWorkingShift.ToString(), ClientContext.MachineInfo != null ? ClientContext.MachineInfo.WORKCENTER_CODE : ""); if (shift != null) { ClientContext.produceShift = shift; } //显示登录人信息 string loginInfo = this.toolStripStatusLabel1.Text.Substring(0, this.toolStripStatusLabel1.Text.LastIndexOf(':') + 1); if (ClientContext.produceShift != null) { loginInfo += ClientContext.produceShift.PRODUCESHIFTNAME + " "; } this.toolStripStatusLabel1.Text = loginInfo; tsslblIps.Text = "本机IP:" + string.Join(",", System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()).Where(p => p.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).Select(p => p.ToString())); if (ClientContext.OpcState > 0) { tsslblOPCStatus.Visible = true; string statetext = ""; switch (ClientContext.OpcState) { case 1: { statetext = "连接正常"; break; } case 2: { statetext = "连接断开"; break; } case 3: { statetext = "连接断开"; break; } case 4: { statetext = "正在连接"; break; } } tsslblOPCStatus.Text = "OPC服务状态:" + statetext; } else { tsslblOPCStatus.Visible = false; } } private void tsmiSetStartUp_Click(object sender, EventArgs e) { if (this.ActiveMdiChild != null) { Common.LocalSetting.Settings["StartUp"] = this.ActiveMdiChild.GetType().FullName; MessageBox.Show(string.Format("已将\"{0}\"设置未启动页!\r\n当登录成功时将自动开启此界面。", this.ActiveMdiChild.Text)); } } private void toolStripMenuItem2_Click(object sender, EventArgs e) { Form f = Application.OpenForms["ProductInForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { ProductInForm form = new ProductInForm(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.WindowState = FormWindowState.Maximized; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void tsmiPrintPlanlabel_Click(object sender, EventArgs e) { Form f = Application.OpenForms["PrintPlanLabel"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { PrintPlanLabel form = new PrintPlanLabel(); //new KeyEvent().SetKeyToTxt(form); ClientContext.SetUserAuth(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void tsmiInspectSkipping_Click(object sender, EventArgs e) { Form f = Application.OpenForms["frmInspectSkipping"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { frmInspectSkipping form = new frmInspectSkipping(); //new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void 替换操作ToolStripMenuItem_Click(object sender, EventArgs e) { Form f = Application.OpenForms["ReplaceForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { ReplaceForm form = new ReplaceForm(); //new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void 抽检操作ToolStripMenuItem_Click(object sender, EventArgs e) { Form f = Application.OpenForms["ProductCheckForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { ProductCheckForm form = new ProductCheckForm(); //new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void 总成条码替换ToolStripMenuItem_Click(object sender, EventArgs e) { Form f = Application.OpenForms["ProductCheckForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { MainCodeChangeForm form = new MainCodeChangeForm(); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void tsmiProductInfo_Click(object sender, EventArgs e) { Form f = Application.OpenForms["ProductInfo"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { QMAPP.WinForm.Forms.Query.ProductInfo form = new Forms.Query.ProductInfo(); form.WindowState = FormWindowState.Maximized; //new KeyEvent().SetKeyToTxt(form); ClientContext.SetUserAuth(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Maximized; f.Focus(); //打开过就让其获得焦点 } } private void 投料平台ToolStripMenuItem_Click(object sender, EventArgs e) { Form f = Application.OpenForms["InjectPlat"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { InjectPlat form = new InjectPlat(); new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnvVWSinglePrint_Click(object sender, EventArgs e) { Form f = Application.OpenForms["SlushMoldingPrintForOldForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { SlushMoldingPrintForOldForm form = new SlushMoldingPrintForOldForm(); //new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnSlushCodePrint_Click(object sender, EventArgs e) { Form f = Application.OpenForms["SlushMoldingPrintForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { SlushMoldingPrintForm form = new SlushMoldingPrintForm(); //new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnInjectPrint_Click(object sender, EventArgs e) { Form f = Application.OpenForms["InjectionCodePrint"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { InjectionCodePrint form = new InjectionCodePrint(); //new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void tsmDPAssmblyItem_Click(object sender, EventArgs e) { Form f = Application.OpenForms["DPAssemblyCodePrint"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { DPAssemblyCodePrintForm form = new DPAssemblyCodePrintForm(); //new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void tsmiFoamingFeed_Click(object sender, EventArgs e) { Form f = Application.OpenForms["PouringMoldingForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { PouringMoldingForm form = new PouringMoldingForm(); new KeyEvent().SetKeyToTxt(form); ClientContext.SetUserAuth(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void btnSlushPut_Click(object sender, EventArgs e) { Form f = Application.OpenForms["SlushMoldingForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { SlushMoldingForm form = new SlushMoldingForm(); ClientContext.SetUserAuth(form); //new KeyEvent().SetKeyToTxt(form); form.MdiParent = this; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void tsmiDPShipment_Click(object sender, EventArgs e) { Form f = Application.OpenForms["DPShipment"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { DPShipment form = new DPShipment(); //new KeyEvent().SetKeyToTxt(form); ClientContext.SetUserAuth(form); form.MdiParent = this; form.WindowState = FormWindowState.Maximized; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void tsmiUserManage_Click(object sender, EventArgs e) { Form f = Application.OpenForms["ManageUserForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { Forms.Sys.ManageUserForm form = new QMAPP.WinForm.Forms.Sys.ManageUserForm(); //new KeyEvent().SetKeyToTxt(form); ClientContext.SetUserAuth(form); form.MdiParent = this; form.WindowState = FormWindowState.Maximized; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } private void tsmiDefectRecording_Click(object sender, EventArgs e) { Form f = Application.OpenForms["MendRecorderReasonForm"]; //查找是否打开过Form1窗体 if (f == null) //没打开过 { MendRecorderReasonForm form = new QMAPP.WinForm.Forms.Mend.MendRecorderReasonForm(); //new KeyEvent().SetKeyToTxt(form); ClientContext.SetUserAuth(form); form.MdiParent = this; form.WindowState = FormWindowState.Maximized; form.Show(); //重新new一个Show出来 } else { f.WindowState = FormWindowState.Normal; f.Focus(); //打开过就让其获得焦点 } } } }