270 lines
10 KiB
C#
270 lines
10 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
using Microsoft.VisualBasic;
|
||
using DBFactory;
|
||
namespace SystemConfig
|
||
{
|
||
public partial class FrmLaneGateEdit : Form
|
||
{
|
||
bool IfUpdate = false;
|
||
DBOperator dbo = CStaticClass.dbo;
|
||
private static FrmLaneGateEdit _formInstance;
|
||
|
||
public static FrmLaneGateEdit FormInstance
|
||
{
|
||
get
|
||
{
|
||
if (_formInstance == null)
|
||
{
|
||
_formInstance = new FrmLaneGateEdit();
|
||
|
||
}
|
||
return _formInstance;
|
||
}
|
||
set {_formInstance = value; }
|
||
}
|
||
public FrmLaneGateEdit()
|
||
{
|
||
InitializeComponent();
|
||
_formInstance =this;
|
||
dbo.Open();
|
||
}
|
||
|
||
private void FrmLaneGateEdit_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void btLaneGateDeviceIndex_Click(object sender, EventArgs e)
|
||
{
|
||
FrmDeviceEdit.FormInstance.LaneGateDeviceIndex = true;
|
||
FrmDeviceEdit.FormInstance.LaneIndex = false;
|
||
FrmDeviceEdit.FormInstance.IsSelected = true;
|
||
FrmDeviceEdit.FormInstance.ShowDialog();
|
||
}
|
||
|
||
private void btLaneIndex_Click(object sender, EventArgs e)
|
||
{
|
||
FrmDeviceEdit.FormInstance.LaneIndex= true;
|
||
FrmDeviceEdit.FormInstance.LaneGateDeviceIndex = false;
|
||
FrmDeviceEdit.FormInstance.IsSelected = true;
|
||
FrmDeviceEdit.FormInstance.ShowDialog();
|
||
}
|
||
|
||
private void btNull_Click(object sender, EventArgs e)
|
||
{
|
||
this.tbLaneGateDeviceIndex.Text = "";
|
||
this.tbLaneIndex.Text = "";
|
||
this.tbX.Text = "";
|
||
this.tbY.Text = "";
|
||
this.tbZ.Text = "";
|
||
this.chbInput.Checked = false;
|
||
this.chbOutput.Checked = false;
|
||
|
||
}
|
||
|
||
private void btBack_Click(object sender, EventArgs e)
|
||
{
|
||
this.Close();
|
||
}
|
||
|
||
private void btSave_Click(object sender, EventArgs e)
|
||
{
|
||
if (MessageBox.Show("<22><>ȷ<EFBFBD><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (Information.IsNumeric(this.tbLaneGateDeviceIndex.Text) == false)
|
||
{
|
||
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
tbLaneGateDeviceIndex.Focus();
|
||
return;
|
||
}
|
||
if (Information.IsNumeric(this.tbLaneIndex.Text) == false)
|
||
{
|
||
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
this.tbLaneIndex.Focus();
|
||
return;
|
||
}
|
||
if (Information.IsNumeric(this.tbX.Text) == false)
|
||
{
|
||
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
this.tbX.Focus();
|
||
return;
|
||
}
|
||
if (Information.IsNumeric(this.tbY.Text) == false)
|
||
{
|
||
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Y<EFBFBD><59><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
this.tbY.Focus();
|
||
return;
|
||
}
|
||
if (Information.IsNumeric(this.tbZ.Text) == false)
|
||
{
|
||
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD><5A><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
this.tbZ.Focus();
|
||
return;
|
||
}
|
||
if ((this.chbInput.Checked == false) && (this.chbOutput.Checked == false))
|
||
{
|
||
MessageBox.Show("<22><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>dz<EFBFBD><C7B3><EFBFBD><EFBFBD>ڡ<EFBFBD><DAA1>͡<EFBFBD><CDA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD><DAA1><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
try
|
||
{
|
||
DataSet ds;
|
||
string sql;
|
||
char inp, outp;
|
||
if (this.chbInput.Checked == true)
|
||
{
|
||
inp = '1';
|
||
}
|
||
else
|
||
{
|
||
inp = '0';
|
||
}
|
||
if (this.chbOutput.Checked == true)
|
||
{
|
||
outp = '1';
|
||
}
|
||
else
|
||
{
|
||
outp = '0';
|
||
}
|
||
if (IfUpdate == true)
|
||
{
|
||
sql = "UPDATE T_Base_Lane_Gate SET F_LaneIndex =" + Convert.ToInt32(this.tbLaneIndex.Text)
|
||
+ ", F_ZXY ='" + tbZ.Text+ "-" +tbX.Text + "-" + tbY.Text + "', F_Input =" + inp +
|
||
", F_Output =" + outp + " where F_LaneGateDeviceIndex=" + Convert.ToInt32(this.tbLaneGateDeviceIndex.Text);
|
||
dbo.ExceSQL(sql);
|
||
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ijɹ<C4B3><C9B9><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
IfUpdate = false;
|
||
}
|
||
else
|
||
{
|
||
sql = "SELECT F_LaneGateDeviceIndex FROM T_Base_Lane_Gate where F_LaneGateDeviceIndex=" + Convert.ToInt32(this.tbLaneGateDeviceIndex.Text);
|
||
ds = dbo.ExceSQL(sql);
|
||
if (ds.Tables[0].DefaultView.Count > 0)
|
||
{
|
||
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3>벻Ҫ<EBB2BB>ظ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
tbLaneGateDeviceIndex.Focus();
|
||
return;
|
||
}
|
||
ds.Clear();
|
||
//20100305
|
||
sql = "INSERT INTO T_Base_Lane_Gate(F_LaneGateDeviceIndex, F_LaneIndex, F_ZXY, F_Input, F_Output)VALUES" +
|
||
" (" + Convert.ToInt32(this.tbLaneGateDeviceIndex.Text) + "," + Convert.ToInt32(this.tbLaneIndex.Text)
|
||
+ ",'" + tbZ.Text + "-" + tbX.Text + "-" + tbY.Text + "'," + inp + "," + outp + ")";
|
||
dbo.ExceSQL(sql);
|
||
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ¼<CFA2><C2BC><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
}
|
||
sql = "SELECT F_LaneGateDeviceIndex AS <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>,F_LaneIndex AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>, F_ZXY AS " +
|
||
" [<5B><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>-<2D><>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>], F_Input AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, F_Output AS <20>dz<EFBFBD><C7B3><EFBFBD><EFBFBD><EFBFBD> FROM T_Base_Lane_Gate where "+
|
||
" F_LaneGateDeviceIndex="+Convert.ToInt32(this.tbLaneGateDeviceIndex.Text );
|
||
//20100305
|
||
ds = dbo.ExceSQL(sql);
|
||
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
private void btNullQuery_Click(object sender, EventArgs e)
|
||
{
|
||
this.tbContent.Text = "";
|
||
this.cbField.Text = "";
|
||
}
|
||
|
||
private void btQuery_Click(object sender, EventArgs e)
|
||
|
||
{
|
||
if (tbContent.Text.Trim() == "") return;
|
||
string df,sql;
|
||
if (this.cbField.Text == "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>")
|
||
{
|
||
df = "F_LaneIndex";
|
||
}
|
||
else
|
||
{
|
||
df = "F_LaneGateDeviceIndex";
|
||
}
|
||
//20100305
|
||
sql = "SELECT F_LaneGateDeviceIndex AS <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>,F_LaneIndex AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>, F_ZXY AS " +
|
||
" [<5B><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>-<2D><>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>], F_Input AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, F_Output AS <20>dz<EFBFBD><C7B3><EFBFBD><EFBFBD><EFBFBD> FROM T_Base_Lane_Gate where " +
|
||
" " + df + "='" + Convert.ToInt32(this.tbContent.Text) +"'";
|
||
DataSet ds = dbo.ExceSQL(sql);
|
||
this.dataGridView1.DataSource = ds.Tables[0].DefaultView ;
|
||
}
|
||
|
||
private void tsmEdit_Click(object sender, EventArgs e)
|
||
{
|
||
if (dataGridView1.RowCount <= 0)
|
||
{
|
||
return;
|
||
}
|
||
char[] cc = new char[1] { ';'};
|
||
string[] spl;
|
||
spl = this.dataGridView1.CurrentRow.Cells[2].Value.ToString().Split(cc);
|
||
this.tabControl1.SelectTab("tabPage1");
|
||
this.tbLaneIndex.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString() + "";
|
||
this.tbLaneGateDeviceIndex.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString() + "";
|
||
this.tbX.Text = spl[0];
|
||
this.tbY.Text = spl[1];
|
||
this.tbZ.Text = spl[2];
|
||
if (this.dataGridView1.CurrentRow.Cells[3].Value.ToString() == "1")
|
||
{
|
||
this.chbInput.Checked = true;
|
||
}
|
||
else
|
||
{
|
||
this.chbInput.Checked = false;
|
||
}
|
||
if (this.dataGridView1.CurrentRow.Cells[4].Value.ToString() == "1")
|
||
{
|
||
this.chbOutput.Checked = true;
|
||
}
|
||
else
|
||
{
|
||
this.chbOutput.Checked = false;
|
||
}
|
||
IfUpdate = true;
|
||
}
|
||
|
||
private void tsmDel_Click(object sender, EventArgs e)
|
||
{
|
||
if (dataGridView1.RowCount <= 0)
|
||
{
|
||
return;
|
||
}
|
||
if (MessageBox.Show("<22><>ȷ<EFBFBD><C8B7>Ҫɾ<D2AA><C9BE>ѡ<EFBFBD><D1A1><EFBFBD>еġ<D0B5><C4A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>" + this.dataGridView1.CurrentRow.Cells[0].Value.ToString() + "<22><><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||
{
|
||
return;
|
||
}
|
||
dbo.ExceSQL("delete from T_Base_Lane_Gate where F_LaneGateDeviceIndex =" + Convert.ToInt32(this.dataGridView1.CurrentRow.Cells[0].Value));
|
||
button2_Click(sender, e);
|
||
}
|
||
|
||
private void button1_Click(object sender, EventArgs e)
|
||
{
|
||
IfUpdate = false;
|
||
}
|
||
|
||
private void button2_Click(object sender, EventArgs e)
|
||
{//20100305
|
||
string sql = "SELECT F_LaneGateDeviceIndex AS <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>,F_LaneIndex AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>, F_ZXY AS " +
|
||
" [<5B><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>-<2D><>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>], F_Input AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, F_Output AS <20>dz<EFBFBD><C7B3><EFBFBD><EFBFBD><EFBFBD> FROM T_Base_Lane_Gate";
|
||
DataSet ds = dbo.ExceSQL(sql);
|
||
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
|
||
}
|
||
|
||
|
||
|
||
}
|
||
} |