You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
4.1 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DBFactory;
namespace SystemConfig
{
public partial class FrmPCSLocation : Form
{
DBOperator dboM = new DBOperator("ManConnString", "ManDBFactory");
private static FrmPCSLocation _formInstance;
string CommomSql = "select location as PCS���ܱ���,areano ��������,agvloc as PCSվ��ַ from locationtab ";
public static FrmPCSLocation FormInstance
{
get
{
if (_formInstance == null)
{
_formInstance = new FrmPCSLocation();
}
return _formInstance;
}
set { _formInstance = value; }
}
public FrmPCSLocation()
{
InitializeComponent();
_formInstance = this;
}
private void btNull_Click(object sender, EventArgs e)
{
this.tbAreano.Text = "";
this.tbLocation.Text = "";
this.nudAgvloc.Value = 0;
}
private void btNullQuery_Click(object sender, EventArgs e)
{
this.tbContent.Text = "";
this.cbField.Text = "";
}
private void button2_Click(object sender, EventArgs e)
{
DataView dv = dboM.ExceSQL(CommomSql ).Tables[0].DefaultView;
dataGridView1.DataSource = dv;
}
private void btQuery_Click(object sender, EventArgs e)
{
try
{
string df, sql;
if ((this.tbContent.Text.Trim() == "") ||(this.cbField.Text.Trim()=="")) return;
if (this.cbField.Text == "PCS���ܱ���")
{
df = "location";
}
else if (this.cbField.Text == "��������")
{
df = "areano";
}
else//
{
df = "agvloc";
}
sql = CommomSql + " where " + df + "= '" + this.tbContent.Text + "'";
DataSet ds = dboM.ExceSQL(sql);
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
}
catch (Exception ex)
{
throw ex;
}
}
private void btSave_Click(object sender, EventArgs e)
{
if (MessageBox.Show("��ȷ��Ҫ�޸�ѡ�л��ܱ���PCSվ��ַ��Ϣ����", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
{
return;
}
if (this.tbLocation.Text.Trim().Length == 0)
{
MessageBox.Show("PCS���ܱ��Ų�����������ֵ��", "��������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.tbLocation.Focus();
return;
}
string sql = "";
try
{
sql = "UPDATE locationtab t SET agvloc = " + nudAgvloc.Value + " where t.location= '" + this.tbLocation.Text + "'";
dboM.ExceSQL(sql);
MessageBox.Show("PCS����վ��ַ�޸ijɹ���", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Information);
sql = CommomSql + " where location= '" + this.tbLocation.Text + "'";
DataSet ds = dboM.ExceSQL(sql);
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
}
catch (Exception ex)
{
throw ex;
}
}
private void tsmEdit_Click(object sender, EventArgs e)
{
if (dataGridView1.RowCount <= 0)
{
return;
}
this.tabControl1.SelectTab("tabPage1");
this.tbLocation.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString() + "";
this.tbAreano.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString() + "";
this.nudAgvloc.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString() + "";
}
}
}