SCLS/SSWCS_JXDL(2019)/SystemConfig/FrmPCSLocation.cs

126 lines
4.1 KiB
C#
Raw Normal View History

2025-05-19 09:45:29 +08:00
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<43><53><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>,areano <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,agvloc as PCSվ<53><D5BE>ַ 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<43><53><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>")
{
df = "location";
}
else if (this.cbField.Text == "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
{
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("<22><>ȷ<EFBFBD><C8B7>Ҫ<EFBFBD>޸<EFBFBD>ѡ<EFBFBD>л<EFBFBD><D0BB>ܱ<EFBFBD><DCB1><EFBFBD>PCSվ<53><D5BE>ַ<EFBFBD><D6B7>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
{
return;
}
if (this.tbLocation.Text.Trim().Length == 0)
{
MessageBox.Show("PCS<43><53><EFBFBD>ܱ<EFBFBD><DCB1>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", 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<43><53><EFBFBD><EFBFBD>վ<EFBFBD><D5BE>ַ<EFBFBD>޸ijɹ<C4B3><C9B9><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>", 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() + "";
}
}
}