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

132 lines
3.7 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DBUtility;
using gregn6Lib;
namespace PunchAndWeld
{
public partial class FrmTest : Form
{
private string ConnectionString = "";
private GridppReport Report = new GridppReport();
public FrmTest()
{
InitializeComponent();
}
private void FrmTest_Load(object sender, EventArgs e)
{
try
{
ConnectionString = SqlHelper.SqlConnString;
SqlStart();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void SqlStart()
{
try
{
SqlDependency.Start(ConnectionString);//调用SqlDependency.Start(String strConnectionString)方法,在应用程序端启用依赖监听器。
SqlDependencyWatch();
//RefreshTable();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
/* 建立SQL监控 */
private void SqlDependencyWatch()
{
string sSQL = "SELECT [ToVisual] FROM [dbo].[tb_aa]";
using (SqlConnection connection = new SqlConnection(ConnectionString))
{
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();
show();
}
public delegate void Print();
public event Print OnClick;
private void show()
{
try
{
string sSQL = "SELECT top 1 * from [dbo].[tb_aa] where ToVisual=0 order by id";
//DataTable dt = new DataTable();
//using (SqlConnection connection = new SqlConnection(ConnectionString))
//{
// connection.Open();
// using (SqlCommand cmd = new SqlCommand(sSQL, connection))
// {
// using (SqlDataAdapter dr = new SqlDataAdapter(sSQL, connection))
// {
// dr.Fill(dt);
// string aa = dt.Rows[0]["ID"].ToString();
// this.Invoke((EventHandler)(delegate { textBox1.Text = aa; }));
// }
// }
//}
string path = "D:\\aaa.grf";
this.Invoke((EventHandler)(delegate
{
Report.Register("");
Report.LoadFromFile(path);
Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(ReportInitialize);
;
Report.Print(false);
}));
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void ReportInitialize()
{
Report.ParameterByName("zcPartNo").Value = "111";
Report.ParameterByName("zcName").Value = "X247门槛";
}
}
}