注塑喷涂
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.
 
 
 
 
 

155 lines
4.6 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.BLL.Mistake247;
using MESClassLibrary.DAL;
namespace PurchingMistakeNew
{
public partial class FrmScan_247 : Form
{
private int count = 1;
private int scanCount = 0;
public FrmScan_247()
{
InitializeComponent();
}
private void textBox2_KeyDown(object sender, KeyEventArgs e)
{
try
{
RecordBLL rbll = new RecordBLL();
ToVisualBLL bll=new ToVisualBLL();
#region 校验是否扫描过、是否已入库、是否已报废
if (string.IsNullOrWhiteSpace(textBox2.Text))
{
MessageBox.Show("总成条码不能为空!", "提示", MessageBoxButtons.OK);
textBox2.Focus();
return;
}
DataTable recorddt = rbll.SearchByPartNo2(textBox2.Text.Trim());
if (recorddt != null && recorddt.Rows.Count > 0)
{
if (recorddt.Rows[0]["BoxNo"].ToString() != "")
{
MessageBox.Show("此总成已入箱!", "提示", MessageBoxButtons.OK);
textBox2.SelectAll();
textBox2.Focus();
return;
}
if (Convert.ToInt32(recorddt.Rows[0]["Flag"].ToString()) == 2)
{
MessageBox.Show("此总成已报废!", "提示", MessageBoxButtons.OK);
textBox2.SelectAll();
textBox2.Focus();
return;
}
}
else
{
MessageBox.Show("此总成不存在!", "提示", MessageBoxButtons.OK);
textBox2.SelectAll();
textBox2.Focus();
return;
}
#endregion
#region 传递给视觉
bll.AddInfo(textBox2.Text.Trim(), "tb_ToVisual_WheelBrow_247");
#endregion
scanCount += 1;
if (scanCount == count)
{
this.Hide();
scanCount = 0;
Form5 frm=new Form5();
frm.Show();
}
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
}
}
private void SqlStart()
{
try
{
SqlDependency.Start(ConfigurationManager.AppSettings["SqlConnString"]);
SqlDependencyWatch();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
}
}
private void SqlDependencyWatch()
{
string sSQL = "SELECT [ToVisual] FROM [dbo].[tb_ToVisual_WheelBrow_247]";
using (SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["SqlConnString"]))
{
using (SqlCommand command = new SqlCommand(sSQL, connection))
{
command.CommandType = CommandType.Text;
connection.Open();
SqlDependency dependency = new SqlDependency(command);
dependency.OnChange += new OnChangeEventHandler(SQLTableOnChange);
SqlDataReader sdr = command.ExecuteReader();
}
}
}
private void SQLTableOnChange(object sender, SqlNotificationEventArgs e)
{
SqlDependencyWatch();
//AfterScanBarcode();
}
private void FrmScan_247_Load(object sender, EventArgs e)
{
//SqlStart();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (!checkBox1.Checked)
{
count = 2;
}
else
{
count = 1;
}
}
private void FrmScan_247_FormClosed(object sender, FormClosedEventArgs e)
{
Environment.Exit(0);
}
}
}