添加项目文件。
This commit is contained in:
@@ -0,0 +1,153 @@
|
||||
using JY.DAL;
|
||||
using JY.Model;
|
||||
using JY.Utility;
|
||||
using MetroFramework.Forms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace JY.Inspection.Frm
|
||||
{
|
||||
public partial class FrmCCDQuery : MetroForm
|
||||
{
|
||||
public delegate void myDelegate(DataTable dt);
|
||||
public delegate void PDelegate();
|
||||
Thread tSo;
|
||||
string strWorkerNum;
|
||||
private string selectDate = "";
|
||||
private DataTable dataTable = null;
|
||||
/// <summary>
|
||||
/// 数据库访问接口
|
||||
/// </summary>
|
||||
private IDbHelper dbHelper = new OpSqlDataBase();
|
||||
public FrmCCDQuery()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
private void FrmAlamQuery_Load(object sender, EventArgs e)
|
||||
{
|
||||
dtStartTime.Value = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 08:00"));
|
||||
dtEndTime.Value = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59"));
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询报警日志
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnSelect_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
//if (txtOrderNum.Text == "")
|
||||
//{
|
||||
// MessageBox.Show("工单号未输入","系统提示");
|
||||
// return;
|
||||
//}
|
||||
|
||||
strWorkerNum = txtOrderNum.Text.Trim();
|
||||
try
|
||||
{
|
||||
tSo = new Thread(new ThreadStart(ThreadWork));
|
||||
tSo.IsBackground = true;
|
||||
tSo.Start();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message.ToString() + ",数据查询失败", "查询提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ThreadWork()
|
||||
{
|
||||
lblSelectStures.BeginInvoke(new PDelegate(aa));
|
||||
string strDate1 = dtStartTime.Value.ToString("yyyy-MM-dd ") + "00:00:01";
|
||||
string strDate2 = dtEndTime.Value.ToString("yyyy-MM-dd ") + "23:59:59";
|
||||
selectDate = dtStartTime.Value.ToString("yyyy-MM-dd ");
|
||||
|
||||
if (dtEndTime.Value.Year != dtStartTime.Value.Year)
|
||||
{
|
||||
MessageBox.Show("请选择日期必须在同一年份内!");
|
||||
lblSelectStures.BeginInvoke(new PDelegate(bb));
|
||||
return;
|
||||
}
|
||||
|
||||
var result = dbHelper.GetCCDData(strWorkerNum, selectDate, selectDate);
|
||||
if (result == null)
|
||||
{
|
||||
MessageBox.Show("此时间段无数据或无此条码数据", "系统提示");
|
||||
lblSelectStures.BeginInvoke(new PDelegate(bb));
|
||||
return;
|
||||
}
|
||||
this.dgvData.BeginInvoke(new myDelegate(FillData), new object[] { result });//异步调用(来填充)
|
||||
lblSelectStures.BeginInvoke(new PDelegate(bb));
|
||||
}
|
||||
|
||||
private void FillData(DataTable dt)
|
||||
{
|
||||
dataTable = dt;
|
||||
this.dgvData.DataSource = dt.DefaultView;
|
||||
}
|
||||
|
||||
private void aa()
|
||||
{
|
||||
this.lblSelectStures.Text = "正在查询数据...";
|
||||
}
|
||||
private void bb()
|
||||
{
|
||||
this.lblSelectStures.Text = "查询结束";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出数据
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnExcel_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string strErr = "";
|
||||
DataTable dt = dataTable;
|
||||
int b = OpenOfficeXML.ExportExcel(dt, selectDate, ref strErr);
|
||||
switch (b)
|
||||
{
|
||||
case 0:
|
||||
MessageBox.Show(strErr, "系统错误");
|
||||
break;
|
||||
case 1:
|
||||
MessageBox.Show(strErr, "系统错误");
|
||||
break;
|
||||
case 2:
|
||||
MessageBox.Show(strErr, "系统错误");
|
||||
break;
|
||||
case 3:
|
||||
MessageBox.Show(strErr, "系统错误");
|
||||
break;
|
||||
case 4:
|
||||
if (MessageBox.Show("导出成功,是否打开文件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
|
||||
{
|
||||
System.Diagnostics.Process.Start(strErr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user