宜昌华友成品
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.

240 lines
10 KiB

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 FrmLaneFlashInfo : Form
{
bool IfUpdate = false;
DBOperator dbo = CStaticClass.dbo;
private static FrmLaneFlashInfo _formInstance;
public static FrmLaneFlashInfo FormInstance
{
get
{
if (_formInstance == null)
{
_formInstance = new FrmLaneFlashInfo();
}
return _formInstance;
}
set { _formInstance = value; }
}
public FrmLaneFlashInfo()
{
InitializeComponent();
_formInstance = this;
}
private void btSave_Click(object sender, EventArgs e)
{
if (MessageBox.Show("��ȷ��Ҫ���������Ķ�����ʾ��Ϣ����", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
{
return;
}
if (this.tbLaneDeviceIndex.Text.Trim().Length == 0)
{
MessageBox.Show("�������Ų�����������ֵ��", "��������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.tbLaneDeviceIndex.Focus();
return;
}
if (this.tbStartCol.Text.Trim().Length == 0)
{
MessageBox.Show("��ʼ�в�����������ֵ��", "��������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.tbStartCol.Focus();
return;
}
if (this.tbEndCol.Text.Trim().Length == 0)
{
MessageBox.Show("�����в�����������ֵ��", "��������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.tbEndCol.Focus();
return;
}
if (this.tbLeftX.Text.Trim().Length == 0)
{
MessageBox.Show("����X���겻����������ֵ��", "��������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.tbLeftX.Focus();
return;
}
if (this.tbLeftY.Text.Trim().Length == 0)
{
MessageBox.Show("����Y���겻����������ֵ��", "��������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.tbLeftY.Focus();
return;
}
if (this.tbTotalWidth.Text.Trim().Length == 0)
{
MessageBox.Show("��������ͼƬ���Ȳ�����������ֵ��", "��������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.tbTotalWidth.Focus();
return;
}
if (this.tbShelfWidth.Text.Trim().Length == 0)
{
MessageBox.Show("��Ԫ����ͼƬ���Ȳ�����������ֵ��", "��������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.tbShelfWidth.Focus();
return;
}
if (this.tbShelfHeight.Text.Trim().Length == 0)
{
MessageBox.Show("��Ԫ����ͼƬ�߶Ȳ�����������ֵ��", "��������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.tbShelfHeight.Focus();
return;
}
try
{
int ldi, sc, ec, lx, ly, sw, sh, tw;
ldi = Convert.ToInt32(tbLaneDeviceIndex.Text);
sc = Convert.ToInt32(tbStartCol.Text );
ec = Convert.ToInt32(tbEndCol.Text);
lx = Convert.ToInt32(tbLeftX.Text);
ly = Convert.ToInt32(tbLeftY.Text);
sw = Convert.ToInt32(tbShelfWidth.Text);
sh = Convert.ToInt32(tbShelfHeight.Text);
tw = Convert.ToInt32(tbTotalWidth.Text);
string sql = "SELECT F_LaneDeviceIndex AS ��������, F_StartCol AS ��ʼ��, F_EndCol AS ������,"+
" F_LeftX AS ����X����, F_LeftY AS ����Y����, F_TotalWidth AS ��������ͼƬ����, "+
"F_ShelfWidth AS ��Ԫ����ͼƬ����, F_ShelfHeight AS ��Ԫ����ͼƬ�߶� FROM T_Base_LaneInfo "+
" Where F_LaneDeviceIndex='" + tbLaneDeviceIndex.Text + "'";
DataSet ds = dbo.ExceSQL(sql);
if ((ds.Tables[0].DefaultView.Count > 0))
{
if (IfUpdate == false)
{
MessageBox.Show("�������������ݿ��Ѿ����ڣ��벻Ҫ�ظ�¼�����ݣ�", "��������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.tbLaneDeviceIndex.Focus();
return;
}
}
else
{
IfUpdate = false;
}
ds.Clear();
if (IfUpdate == true)
{
sql = "UPDATE T_Base_LaneInfo SET F_StartCol =" + sc + ", F_EndCol =" + ec + ",F_LeftX=" + lx + ",F_LeftY=" + ly + ",F_ShelfWidth=" + sw + ",F_ShelfHeight=" + sh + ",F_TotalWidth=" + tw + " where F_LaneDeviceIndex=" + ldi;
dbo.ExceSQL(sql);
MessageBox.Show("�����Ķ�����ʾ��Ϣ�޸ijɹ���", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Information);
IfUpdate = false;
}
else
{
sql = "INSERT INTO T_Base_LaneInfo(F_LaneDeviceIndex,F_StartCol, F_EndCol, F_LeftX, F_LeftY,F_ShelfWidth,F_ShelfHeight,F_TotalWidth)VALUES" +
" (" + ldi + "," + sc + "," + ec + "," + lx + "," + ly + "," + sw + "," + sh + "," + tw + ")";
dbo.ExceSQL(sql);
MessageBox.Show("�Ѷ����豸��Ϣ¼���ɹ���", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
sql = "SELECT F_LaneDeviceIndex AS ��������, F_StartCol AS ��ʼ��, F_EndCol AS ������," +
" F_LeftX AS ����X����, F_LeftY AS ����Y����, F_TotalWidth AS ��������ͼƬ����, " +
"F_ShelfWidth AS ��Ԫ����ͼƬ����, F_ShelfHeight AS ��Ԫ����ͼƬ�߶� FROM T_Base_LaneInfo " +
" Where F_LaneDeviceIndex='" + tbLaneDeviceIndex.Text + "'";
ds = dbo.ExceSQL(sql);
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
}
catch (Exception ex)
{
throw ex;
}
}
private void button1_Click(object sender, EventArgs e)
{
IfUpdate = false;
}
private void btNull_Click(object sender, EventArgs e)
{
this.tbLaneDeviceIndex.Text = "";
this.tbLeftX.Text = "";
this.tbLeftY.Text = "";
this.tbStartCol.Text = "";
this.tbEndCol.Text = "";
this.tbShelfHeight.Text = "";
this.tbShelfWidth.Text = "";
this.tbTotalWidth.Text = "";
}
private void btQuery_Click(object sender, EventArgs e)
{
if (tbContent.Text.Trim() == "") return;
string sql = "SELECT F_LaneDeviceIndex AS ��������, F_StartCol AS ��ʼ��, F_EndCol AS ������,"+
" F_LeftX AS ����X����, F_LeftY AS ����Y����, F_TotalWidth AS ��������ͼƬ����, "+
"F_ShelfWidth AS ��Ԫ����ͼƬ����, F_ShelfHeight AS ��Ԫ����ͼƬ�߶� FROM T_Base_LaneInfo "+
" Where F_LaneDeviceIndex='"+ tbContent.Text +"'" ;
DataSet ds = dbo.ExceSQL(sql);
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
}
private void btNullQuery_Click(object sender, EventArgs e)
{
this.cbField.Text = "";
this.tbContent.Text = "";
}
private void FrmLaneFlashInfo_Load(object sender, EventArgs e)
{
}
private void tsmEdit_Click(object sender, EventArgs e)
{
if (dataGridView1.RowCount <= 0)
{
return;
}
this.tabControl1.SelectTab("tabPage1");
this.tbLaneDeviceIndex.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString() + "";
this.tbStartCol.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString() + "";
this.tbEndCol.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString() + "";
this.tbLeftX.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString() + "";
this.tbLeftY.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString() + "";
this.tbTotalWidth.Text = this.dataGridView1.CurrentRow.Cells[5].Value.ToString() + "";
this.tbShelfWidth.Text = this.dataGridView1.CurrentRow.Cells[6].Value.ToString() + "";
this.tbShelfHeight.Text = this.dataGridView1.CurrentRow.Cells[7].Value.ToString() + "";
IfUpdate = true;
}
private void tsmDel_Click(object sender, EventArgs e)
{
if (dataGridView1.RowCount <= 0)
{
return;
}
if (MessageBox.Show("��ȷ��Ҫɾ��ѡ���еġ������Ķ�����ʾ��Ϣ��" + this.dataGridView1.CurrentRow.Cells[0].Value.ToString() + "����Ϣ����", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
{
return;
}
dbo.ExceSQL("delete from T_Base_LaneInfo where F_LaneDeviceIndex =" + Convert.ToInt32(this.dataGridView1.CurrentRow.Cells[0].Value));
button2_Click(sender, e);
}
private void button2_Click(object sender, EventArgs e)
{
string sql = "SELECT F_LaneDeviceIndex AS ��������, F_StartCol AS ��ʼ��, F_EndCol AS ������," +
" F_LeftX AS ����X����, F_LeftY AS ����Y����, F_TotalWidth AS ��������ͼƬ����, " +
"F_ShelfWidth AS ��Ԫ����ͼƬ����, F_ShelfHeight AS ��Ԫ����ͼƬ�߶� FROM T_Base_LaneInfo ";
DataSet ds = dbo.ExceSQL(sql);
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
}
}
}