//核对客户端名称 public void CheckTerminal() { try { if (System.IO.File.Exists(MainWindow.configPath)) { using (StreamReader sr = new StreamReader(MainWindow.configPath, Encoding.UTF8)) //读取配置文件内容 { String nextLine = null; String terminalNumber = null; while ((nextLine = sr.ReadLine()) != null) { if (nextLine.Contains("[TerminalNumber]")) { terminalNumber = sr.ReadLine(); } } sr.Close(); if (String.IsNullOrEmpty(terminalNumber)) //配置文件中无客户端记录 { ClientManage cm = new ClientManage(); cm.ShowDialog(); } else //有客户端记录 { MainWindow.TerminalNumber = terminalNumber; DBConnection connection = new DBConnection(); String sql = "select * from terminal where terminal = '" + terminalNumber + "';"; DataSet ds = connection.Select(sql); if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0) { sql = "insert into terminal (terminal) values ('" + terminalNumber + "');"; connection.Insert(sql); } } Program.mw.statusStripStatusLabel_client.Text = MainWindow.TerminalNumber; } } else { MessageBox.Show("配置文件不存在!"); Program.mw.Close(); Application.Exit(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/************************************ 第一个按钮 **************************************/ public void toolStripButton1_Click() //按下工具栏处第一个按钮(更改终端、新购入库、工装方式、工装上架、工装数据) { Program.mw.toolStripButton1.BackColor = System.Drawing.Color.Aqua; Program.mw.toolStripButton2.BackColor = System.Drawing.Color.LightSteelBlue; Program.mw.toolStripButton3.BackColor = System.Drawing.Color.LightSteelBlue; if (Program.mw.toolStripButton1.Text == "更改终端") { ClientManage clientWindow = new ClientManage(); clientWindow.ShowDialog(); } if (Program.mw.toolStripButton1.Text == "新购入库") { CommonFunction.HideAllPanelsExcept(Program.mw.panel21_newToolsIn); if (Program.mw.checkBox_newToolsIn_batch.Checked == false) //非批量入库 { Program.mw.textBox_newToolsIn_endCode.BackColor = System.Drawing.Color.LightGray; //结尾编码变灰 Program.mw.textBox_newToolsIn_endCode.Enabled = false; //结尾编码只读 } Program.mw.textBox_newToolsIn_code.Focus(); //默认焦点置于二维码输入框 } if (Program.mw.toolStripButton1.Text == "工装方式") { CommonFunction.HideAllPanelsExcept(Program.mw.panel31_outByTools); Program.mw.textBox_outByTools_code.Focus(); } if (Program.mw.toolStripButton1.Text == "工装上架") { CommonFunction.HideAllPanelsExcept(Program.mw.panel41_putOnShelf); Program.mw.textBox_putOnShelf_code.Focus(); } if (Program.mw.toolStripButton1.Text == "工装数据") { CommonFunction.HideAllPanelsExcept(Program.mw.panel51_toolsData); Program.mw.textBox_toolsData_code.Focus(); } if (Program.mw.toolStripButton1.Text == "预警设置") { CommonFunction.HideAllPanelsExcept(Program.mw.panel71_warningSetUp); Program.mw.textBox_warningSetUp_materialNumber.Focus(); } }
public void toolStripButton1_Click() //按下工具栏处第一个按钮(更改终端、新购入库、工装方式、工装上架、工装数据) { Program.mw.toolStripButton1.BackColor = System.Drawing.Color.LightSkyBlue; Program.mw.toolStripButton2.BackColor = System.Drawing.SystemColors.ActiveCaption; Program.mw.toolStripButton3.BackColor = System.Drawing.SystemColors.ActiveCaption; if (Program.mw.toolStripButton1.Text == "更改终端") { ClientManage clientWindow = new ClientManage(); clientWindow.ShowDialog(); } if (Program.mw.toolStripButton1.Text == "新购入库") { Program.mw.panel_newtoolsIn.Visible = true; Program.mw.panel_toolsReturn.Visible = false; Program.mw.panel_repairtoolsIn.Visible = false; Program.mw.panel_outByTools.Visible = false; if (Program.mw.checkBox_newToolsIn_batch.Checked == false) //非批量入库 { Program.mw.textBox_newToolsIn_endCode.BackColor = System.Drawing.Color.LightGray; //结尾编码变灰 Program.mw.textBox_newToolsIn_endCode.ReadOnly = true; //结尾编码只读 } Program.mw.textBox_newToolsIn_code.Focus(); //默认焦点置于二维码输入框 ToolsIn ti = new ToolsIn(); ti.drawListView_newToolsIn(Program.mw.listView_newToolsIn); ti.fillListView_newToolsIn(Program.mw.listView_newToolsIn); } if (Program.mw.toolStripButton1.Text == "工装方式") { Program.mw.panel_newtoolsIn.Visible = false; Program.mw.panel_toolsReturn.Visible = false; Program.mw.panel_repairtoolsIn.Visible = false; Program.mw.panel_outByTools.Visible = true; int listViewWidth = Screen.PrimaryScreen.Bounds.Width - Program.mw.listView_repairtoolsIn.Location.X * 2 - Program.mw.toolStrip1.Width; int listViewHeight = Screen.PrimaryScreen.Bounds.Height - Program.mw.listView_repairtoolsIn.Location.Y - Program.mw.statusStrip1.Height - Program.mw.menuStrip1.Height - 85; int listViewColumnWidth = listViewWidth / 15; Program.mw.listView_outByTools.Size = new System.Drawing.Size(listViewWidth, listViewHeight); Program.mw.listView_outByTools.Font = new System.Drawing.Font("微软雅黑", 8F); Program.mw.listView_outByTools.GridLines = true; Program.mw.listView_outByTools.View = View.Details; Program.mw.listView_outByTools.HeaderStyle = ColumnHeaderStyle.Clickable; //表头样式 Program.mw.listView_outByTools.FullRowSelect = true; //表示在控件上,是否可以选择一整行 Program.mw.listView_outByTools.Columns.Add("", 0, HorizontalAlignment.Center); //添加(列宽度、列的对齐方式) Program.mw.listView_outByTools.Columns.Add("工装编码", listViewColumnWidth, HorizontalAlignment.Center); //添加(列宽度、列的对齐方式) Program.mw.listView_outByTools.Columns.Add("工装名称", listViewColumnWidth, HorizontalAlignment.Center); //添加 Program.mw.listView_outByTools.Columns.Add("物料号", listViewColumnWidth, HorizontalAlignment.Center); //添加 Program.mw.listView_outByTools.Columns.Add("功能状态", listViewColumnWidth, HorizontalAlignment.Center); //添加(列宽度、列的对齐方式) Program.mw.listView_outByTools.Columns.Add("领用线体", listViewColumnWidth, HorizontalAlignment.Center); //添加(列宽度、列的对齐方式) Program.mw.listView_outByTools.Columns.Add("领用工位", listViewColumnWidth, HorizontalAlignment.Center); //添加 Program.mw.listView_outByTools.Columns.Add("用途", listViewColumnWidth, HorizontalAlignment.Center); //添加 Program.mw.listView_outByTools.Columns.Add("库位", listViewColumnWidth, HorizontalAlignment.Center); //添加 Program.mw.listView_outByTools.Columns.Add("架位", listViewColumnWidth, HorizontalAlignment.Center); //添加(列宽度、列的对齐方式) Program.mw.listView_outByTools.Columns.Add("层位", listViewColumnWidth, HorizontalAlignment.Center); //添加(列宽度、列的对齐方式) Program.mw.listView_outByTools.Columns.Add("领用人", listViewColumnWidth, HorizontalAlignment.Center); //添加 Program.mw.listView_outByTools.Columns.Add("领用人姓名", listViewColumnWidth, HorizontalAlignment.Center); //添加 Program.mw.listView_outByTools.Columns.Add("领用人联系方式", listViewColumnWidth, HorizontalAlignment.Center); //添加 Program.mw.listView_outByTools.Columns.Add("厂家", listViewColumnWidth, HorizontalAlignment.Center); //添加(列宽度、列的对齐方式) Program.mw.listView_outByTools.Columns.Add("备注", listViewWidth - listViewColumnWidth * 14, HorizontalAlignment.Center); } }