159 lines
5.0 KiB
C#
159 lines
5.0 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;
|
|
|
|
namespace AGVSystem
|
|
{
|
|
public partial class Linemanage : Form
|
|
{
|
|
private ClsDBConn_sql db = new ClsDBConn_sql();
|
|
System.Data.DataSet ds = new System.Data.DataSet();
|
|
public Linemanage( )
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Linemanage_Load(object sender, EventArgs e)
|
|
{
|
|
ds = db.connDt("select id as 线体编号 , line_name as 线体名称 , area as 所属地图 from Assembly_Line");
|
|
if (ds.Tables.Count > 0)
|
|
{
|
|
dataGridView1.DataSource = ds.Tables[0];
|
|
}
|
|
this.WindowState = FormWindowState.Maximized;
|
|
}
|
|
|
|
|
|
private void dataGridView1_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
if (dataGridView1.RowCount > 0)
|
|
{
|
|
txt_id.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["线体编号"].Value.ToString();
|
|
txt_line_name.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["线体名称"].Value.ToString();
|
|
comboBox1.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["所属地图"].Value.ToString());
|
|
}
|
|
}
|
|
|
|
private int Delete_Assembly_Line(string id)
|
|
{
|
|
int rowcount = 0;
|
|
try
|
|
{
|
|
rowcount = Convert.ToInt16(db.Command("delete from Assembly_Line where id = " + id));
|
|
}
|
|
catch
|
|
{ }
|
|
return rowcount;
|
|
}
|
|
|
|
private int Update_Assembly_Line(string id, string name,int map)
|
|
{
|
|
int rowcount = 0;
|
|
try
|
|
{
|
|
rowcount = Convert.ToInt16(db.Command("update Assembly_Line set line_name='" + name + "' , area = "+ map+" where id = " + id));
|
|
}
|
|
catch
|
|
{ }
|
|
return rowcount;
|
|
}
|
|
private int Add_Assembly_Line(string id , string name,int map)
|
|
{
|
|
int rowcount = 0;
|
|
try
|
|
{
|
|
rowcount = Convert.ToInt16(db.Command("insert into Assembly_Line (id , line_name,area ) values (" + id + ",'" + name +"',"+map+ ") "));
|
|
}
|
|
catch
|
|
{ }
|
|
return rowcount;
|
|
}
|
|
|
|
|
|
|
|
private void toolStripButton1_Click(object sender, EventArgs e)
|
|
{
|
|
txt_id.Text = "";
|
|
txt_line_name.Text = "";
|
|
comboBox1.SelectedIndex = 0;
|
|
}
|
|
|
|
private void toolStripButton3_Click(object sender, EventArgs e)
|
|
{
|
|
if (Cls.Param.UserName_temp == "")
|
|
{
|
|
MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
if (txt_id.Text.Trim() == "" || txt_line_name.Text.Trim() == "")
|
|
{
|
|
return;
|
|
}
|
|
if (Add_Assembly_Line(txt_id.Text, txt_line_name.Text, comboBox1.SelectedIndex ) > 0)
|
|
{
|
|
MessageBox.Show("添加成功!");
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
Linemanage_Load(null, null);
|
|
txt_id.Text = "";
|
|
txt_line_name.Text = "";
|
|
}
|
|
|
|
private void toolStripButton4_Click(object sender, EventArgs e)
|
|
{
|
|
if (Cls.Param.UserName_temp == "")
|
|
{
|
|
MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
if (txt_id.Text.Trim() == "" || txt_line_name.Text.Trim() == "")
|
|
{
|
|
return;
|
|
}
|
|
if (Delete_Assembly_Line(txt_id.Text.Trim()) > 0)
|
|
{
|
|
MessageBox.Show("删除成功!");
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
Linemanage_Load(null, null);
|
|
txt_id.Text = "";
|
|
txt_line_name.Text = "";
|
|
}
|
|
|
|
private void toolStripButton6_Click(object sender, EventArgs e)
|
|
{
|
|
if (Cls.Param.UserName_temp == "")
|
|
{
|
|
MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
if (txt_id.Text.Trim() == "" || txt_line_name.Text.Trim() == "")
|
|
{
|
|
return;
|
|
}
|
|
if (Update_Assembly_Line(txt_id.Text, txt_line_name.Text, comboBox1.SelectedIndex + 1) > 0)
|
|
{
|
|
MessageBox.Show("修改成功!");
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
Linemanage_Load(null, null);
|
|
txt_id.Text = "";
|
|
txt_line_name.Text = "";
|
|
}
|
|
}
|
|
}
|