SCLS/SSWCS_JXDL(2019)/SystemConfig/FrmPCSWC.cs
2025-05-19 09:45:29 +08:00

129 lines
4.1 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 FrmPCSWC : Form
{
DBOperator dboM = new DBOperator("ManConnString", "ManDBFactory");
private static FrmPCSWC _formInstance;
string CommomSql="select t.wcid as 加工中心编号,t.decription as 描述,t.wcloc as 入口输送机PCS站地址 from wctab t";
public static FrmPCSWC FormInstance
{
get
{
if (_formInstance == null)
{
_formInstance = new FrmPCSWC();
}
return _formInstance;
}
set { _formInstance = value; }
}
public FrmPCSWC()
{
InitializeComponent();
_formInstance = this;
}
private void btNull_Click(object sender, EventArgs e)
{
this.tbWCID.Text = "";
this.tbDescription.Text = "";
this.nudWCLoc.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 + " where monitor =1 ").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 == "加工中心编号")
{
df = "wcid";
}
else if (this.cbField.Text == "描述")
{
df = "decription";
}
else//
{
df = "wcloc";
}
sql = CommomSql + " where monitor =1 and " + df + "= '" + this.tbContent.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.tbWCID.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString() + "";
this.tbDescription.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString() + "";
this.nudWCLoc.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString() + "";
}
private void btSave_Click(object sender, EventArgs e)
{
if (MessageBox.Show("您确认要修改PCS加工中心/C)站地址信息吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
{
return;
}
if (this.tbWCID.Text.Trim().Length == 0)
{
MessageBox.Show("PCS加工中心/C)编号不允许输入空值!", "误操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.tbWCID.Focus();
return;
}
string sql = "";
try
{
sql = "UPDATE wctab t SET wcloc = " + nudWCLoc.Value + " where t.wcid= '" + this.tbWCID.Text + "'";
dboM.ExceSQL(sql);
MessageBox.Show("PCS加工中心/PCS站地址修改成功", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
sql = CommomSql + " where t.wcid= '"+this.tbWCID.Text+"'" ;
DataSet ds = dboM.ExceSQL(sql);
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
}
catch (Exception ex)
{
throw ex;
}
}
}
}