Files

179 lines
8.2 KiB
C#

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 System.IO;
namespace AGVSystem
{
public partial class SysSet : Form
{
public SysSet()
{
InitializeComponent();
}
private void button4_Click(object sender, EventArgs e)
{
if (Cls.Param.UserName_temp == "")
{
MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
ClsDBConn_sql db = new ClsDBConn_sql();
Cls.Param.map1_path = txt_path1.Text;
Cls.Param.map2_path = txt_path2.Text;
Cls.Param.map3_path = txt_path3.Text;
Cls.Param.map1_status = checkBox1.Checked;
Cls.Param.map2_status = checkBox2.Checked;
Cls.Param.map3_status = checkBox3.Checked;
Cls.Param.Load_Path_His = chk_load_path_his.Checked;
db.Command("UPDATE [SysParam] SET [Col_Value] ='" + Cls.Param.map1_status.ToString() + "' WHERE [Col_Name] ='map1_status'");
db.Command("UPDATE [SysParam] SET [Col_Value] ='" + Cls.Param.map2_status.ToString() + "' WHERE [Col_Name] ='map2_status'");
db.Command("UPDATE [SysParam] SET [Col_Value] ='" + Cls.Param.map3_status.ToString() + "' WHERE [Col_Name] ='map3_status'");
db.Command("UPDATE [SysParam] SET [Col_Value] ='" + numericUpDown2.Value.ToString() + "' WHERE [Col_Name] ='Card1_Interval'");
db.Command("UPDATE [SysParam] SET [Col_Value] ='" + numericUpDown3.Value.ToString() + "' WHERE [Col_Name] ='Card2_Interval'");
db.Command("UPDATE [SysParam] SET [Col_Value] ='" + numericUpDown4.Value.ToString() + "' WHERE [Col_Name] ='Card3_Interval'");
Properties.Settings.Default.Save();
this.Close();
}
private void SysSet_Load(object sender, EventArgs e)
{
checkBox1.Checked = Cls.Param.map1_status;
checkBox2.Checked = Cls.Param.map2_status;
checkBox3.Checked = Cls.Param.map3_status;
chk_auto_control.Checked = Cls.Param.Auto_Control;
chk_load_path_his.Checked = Cls.Param.Load_Path_His;
chk_location_auto_display.Checked = Cls.Param.Agv_Location_Auto_Display;
textBox4.Text = Cls.Param.Pro_id ;
textBox5.Text = Cls.Param.Pro_factory ;
textBox6.Text = Cls.Param.Pro_remark ;
numericUpDown1.Value = Cls.Param.Day_Count;
numericUpDown2.Value = Cls.Param.Card1_Interval;
numericUpDown3.Value = Cls.Param.Card2_Interval;
numericUpDown4.Value = Cls.Param.Card3_Interval;
if (numericUpDown2.Value > 0)
cK_IO1.Checked = true;
if (numericUpDown3.Value > 0)
cK_IO2.Checked = true;
if (numericUpDown4.Value > 0)
cK_IO3.Checked = true;
}
private void button1_Click(object sender, EventArgs e)
{
//System.Windows.Forms.FolderBrowserDialog folder = new FolderBrowserDialog();
//if (folder.ShowDialog() == DialogResult.OK)
//{
// //txt_path1.Text = folder.SelectedPath;
//}
if (Cls.Param.UserName_temp == "")
{
MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
System.Windows.Forms.OpenFileDialog folder = new OpenFileDialog();
folder.Filter = "图片文件png|*.png|图片文件jpg|*.jpg|所有文件(*.*)|*.*";
if (folder.ShowDialog() == DialogResult.OK)
{
txt_path1.Text = folder.FileName;
try
{
File.Copy(folder.FileName, Application.StartupPath + "\\map\\" + Cls.Param.Pro_id + "_1", true);
}
catch (IOException io)
{
if (io.GetType().Name == "IOException")
{
MessageBox.Show("您可能已打开AGV调度监控页面,请重启软件后再设置!","参数设置",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
}
}
private void button2_Click(object sender, EventArgs e)
{
if (Cls.Param.UserName_temp == "")
{
MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
System.Windows.Forms.OpenFileDialog folder = new OpenFileDialog();
folder.Filter = "图片文件png|*.png|图片文件jpg|*.jpg|所有文件(*.*)|*.*";
if (folder.ShowDialog() == DialogResult.OK)
{
txt_path2.Text = folder.FileName;
try
{
File.Copy(folder.FileName, Application.StartupPath + "\\map\\" + Cls.Param.Pro_id + "_2", true);
}
catch (IOException io)
{
if (io.GetType().Name == "IOException")
{
MessageBox.Show("您可能已打开AGV调度监控页面,请重启软件后再设置!", "参数设置", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void button3_Click(object sender, EventArgs e)
{
if (Cls.Param.UserName_temp == "")
{
MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
System.Windows.Forms.OpenFileDialog folder = new OpenFileDialog();
folder.Filter = "图片文件png|*.png|图片文件jpg|*.jpg|所有文件(*.*)|*.*";
if (folder.ShowDialog() == DialogResult.OK)
{
txt_path3.Text = folder.FileName;
try
{
File.Copy(folder.FileName, Application.StartupPath + "\\map\\" + Cls.Param.Pro_id + "_3", true);
}
catch (IOException io)
{
if (io.GetType().Name == "IOException")
{
MessageBox.Show("您可能已打开AGV调度监控页面,请重启软件后再设置!", "参数设置", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void button5_Click(object sender, EventArgs e)
{
if (Cls.Param.UserName_temp == "")
{
MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Cls.Param.Day_Count = (int)numericUpDown1.Value;
Cls.Param.Xj_Time1 = dateTimePicker1.Value.TimeOfDay.ToString();
Cls.Param.Xj_Time2 = dateTimePicker2.Value.TimeOfDay.ToString();
ClsDBConn_sql db = new ClsDBConn_sql();
db.Command("UPDATE [SysParam] SET [Col_Value] ='" + chk_load_path_his.Checked.ToString() + "' WHERE [Col_Name] ='Load_Path_His'");
db.Command("UPDATE [SysParam] SET [Col_Value] ='" + chk_auto_control.Checked.ToString() + "' WHERE [Col_Name] ='Auto_Control'");
db.Command("UPDATE [SysParam] SET [Col_Value] ='" + Cls.Param.Day_Count.ToString() + "' WHERE [Col_Name] ='Day_Count'");
db.Command("UPDATE [SysParam] SET [Col_Value] ='" + chk_location_auto_display.Checked.ToString() + "' WHERE [Col_Name] ='AgvLoc_Dynamic_Display'");
db.Command("UPDATE [SysParam] SET [Col_Value] ='" + Cls.Param.Xj_Time1.ToString() + "' WHERE [Col_Name] ='Xj_Time1'");
db.Command("UPDATE [SysParam] SET [Col_Value] ='" + Cls.Param.Xj_Time2.ToString() + "' WHERE [Col_Name] ='Xj_Time2'");
Properties.Settings.Default.Save();
this.Close();
}
}
}