123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455 |
- using AIRS.usercontrol;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Data;
- using System.Data.SQLite;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace AIRS
- {
- /// <summary>
- /// HistoryGrade.xaml 的交互逻辑
- /// </summary>
- public partial class HistoryGrade : Window
- {
- private int m_Pyte = 0;//打开窗体类型 0历史评级 1检查报告
- #region 分页变量
- /// <summary>
- /// 当前页码
- /// </summary>
- private int m_Page = 1;
- /// <summary>
- /// 总条数
- /// </summary>
- private int m_Total = 0;
- /// <summary>
- /// 总页数
- /// </summary>
- private int m_Count = 1;
- /// <summary>
- /// 每页条数
- /// </summary>
- private int m_Page_Count = 15;
- #endregion
- /// <summary>
- /// 数据库
- /// </summary>
- SQLiteConnection conn = null;
- SQLiteConnectionStringBuilder connstr = null;
- /// <summary>
- /// 程序工作目录
- /// </summary>
- private string path = Directory.GetCurrentDirectory();
- /// <summary>
- /// 构造方法
- /// </summary>
- /// <param name="type">0历史评级 1检查报告</param>
- public HistoryGrade(int type)
- {
- m_Pyte = type;
- InitializeComponent();
- }
- /// <summary>
- /// 关闭窗体事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnCancel_Click(object sender, RoutedEventArgs e)
- {
- this.DialogResult = false;
- }
- /// <summary>
- /// 窗体加载完成后执行事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Window_ContentRendered(object sender, EventArgs e)
- {
- if (m_Pyte == 1)
- {
- //切换到检查报告
- this.HisorReport.Content = "检查报告";
- this.HisGrad.Visibility = Visibility.Collapsed;//隐藏历史评级
- this.CheckReport.Visibility = Visibility.Visible;//显示检查报告
- this.CheckBtnSave.Visibility = Visibility.Visible;//显示报告另存按钮
- this.btn_Query.Visibility = Visibility.Collapsed;//隐藏查询按钮
- this.lable1.Visibility = Visibility.Collapsed;//隐藏lable
- this.startdatePickerCtl.Visibility = Visibility.Collapsed;//隐藏开始时间
- this.enddatePickerCtl.Visibility = Visibility.Collapsed;//隐藏结束时间
- //#region 隐藏分页按钮
- //this.first_btn.Visibility = Visibility.Collapsed;
- //this.last_btn.Visibility = Visibility.Collapsed;
- //this.next_btn.Visibility = Visibility.Collapsed;
- //this.pro_btn.Visibility = Visibility.Collapsed;
- //#endregion
- }
- else if (m_Pyte == 0)
- {
- //切换到历史评级
- this.HisorReport.Content = "历史评级";
- this.HisGrad.Visibility = Visibility.Visible;//显示历史评级
- this.CheckReport.Visibility = Visibility.Collapsed;//隐藏检查报告
- this.CheckBtnSave.Visibility = Visibility.Collapsed;//隐藏报告另存按钮
- this.btn_Query.Visibility = Visibility.Visible;//显示查询按钮
- this.lable1.Visibility = Visibility.Visible;//显示lable
- this.startdatePickerCtl.Visibility = Visibility.Visible;//显示开始时间
- this.enddatePickerCtl.Visibility = Visibility.Visible;//显示结束时间
- //#region 显示分页按钮
- //this.first_btn.Visibility = Visibility.Visible;
- //this.last_btn.Visibility = Visibility.Visible;
- //this.next_btn.Visibility = Visibility.Visible;
- //this.pro_btn.Visibility = Visibility.Visible;
- //#endregion
- GetGrade();
- }
- }
- /// <summary>
- /// 根据路径获取报告
- /// </summary>
- /// <param name="path"></param>
- private void GetReport(string path)
- {
- try
- {
- string strSql = "SELECT * FROM t_grade where \"图像目录\"=='" + path + "'";
- conn = new SQLiteConnection();
- connstr = new SQLiteConnectionStringBuilder();
- connstr.DataSource = path + "\\datas.db";
- conn.ConnectionString = connstr.ToString();
- conn.Open();
- SQLiteDataAdapter da = new SQLiteDataAdapter(strSql, conn);
- DataTable ds = new DataTable();
- da.Fill(ds);
-
- if (ds.Rows.Count > 0)
- {
- }
- else
- {
- MessageBox.Show("没有该图像路径的检查结果!");
- }
- }
- catch (Exception ex)
- {
- }
- finally
- {
- }
- }
- /// <summary>
- /// 获取历史评级数据
- /// </summary>
- /// <returns></returns>
- private void GetGrade()
- {
- try
- {
- string startTime = "";
- string endTime = "";
- try
- {
- startTime = DateTime.Parse(startdatePickerCtl.Text.Trim()).ToString("yyyy-MM-dd 00:00:00");
- endTime = DateTime.Parse(enddatePickerCtl.Text.Trim()).ToString("yyyy-MM-dd 23:59:59");
- }
- catch
- {
- MessageBox.Show("时间格式不正确,请重新填写!");
- return;
- }
- string strSql = "SELECT * FROM t_grade where 1=1";
- string strcountsql = "SELECT count(*) as count FROM t_grade where 1=1";
- if (startTime.Length > 0)
- {
- strSql += " and \"评级时间\">'" + startTime + "'";
- strcountsql += " and \"评级时间\">'" + startTime + "'";
- }
- if (endTime.Length > 0)
- {
- strSql += " and \"评级时间\"<'" + endTime + "'";
- strcountsql += " and \"评级时间\"<'" + endTime + "'";
- }//desc
- strSql += "order by \"评级时间\" desc limit " + ((m_Page - 1) * m_Page_Count) + ","+ m_Page_Count + "";
- conn = new SQLiteConnection();
- connstr = new SQLiteConnectionStringBuilder();
- connstr.DataSource = path + "\\datas.db";
- conn.ConnectionString = connstr.ToString();
- conn.Open();
- SQLiteDataAdapter da = new SQLiteDataAdapter(strSql, conn);
- DataTable ds = new DataTable();
- da.Fill(ds);
- da = new SQLiteDataAdapter(strcountsql, conn);
- DataTable dsCount = new DataTable();
- da.Fill(dsCount);
- m_Total = Convert.ToInt32(dsCount.Rows[0][0]);//总条数
- m_Count = (int)Math.Ceiling(((double)m_Total / (double)m_Page_Count));
- ObservableCollection<HisData> list = new ObservableCollection<HisData>();
- for (int i = 0; i < ds.Rows.Count; i++)
- {
- HisData data = new HisData();
- //data.num = (i + 1);
- data.gradeproject = ds.Rows[i]["评级项目"] == null ? "" : ds.Rows[i]["评级项目"].ToString();
- data.gradetime = ds.Rows[i]["评级时间"] == null ? "" : ds.Rows[i]["评级时间"].ToString(); // ds.Rows[i]["评级时间"].ToString();
- data.operation = ds.Rows[i]["操作员"] == null ? "" : ds.Rows[i]["操作员"].ToString(); //ds.Rows[i]["操作员"].ToString();
- data.checke = ds.Rows[i]["复合员"] == null ? "" : ds.Rows[i]["复合员"].ToString(); //ds.Rows[i]["复合员"].ToString();
- data.imgurl = ds.Rows[i]["图像目录"] == null ? "" : ds.Rows[i]["图像目录"].ToString();
- data.catagory = ds.Rows[i]["catagory"] == null ? "" : ds.Rows[i]["catagory"].ToString();//类别
- data.gangzhong = ds.Rows[i]["钢种"] == null ? "" : ds.Rows[i]["钢种"].ToString();//钢种
- data.imgcount = ds.Rows[i]["图像数量"] == null ? "" : ds.Rows[i]["图像数量"].ToString();//图像数量
- data.pingji = ds.Rows[i]["评级标准"] == null ? "" : ds.Rows[i]["评级标准"].ToString();//评级标准
- data.instrument = ds.Rows[i]["检测仪器"] == null ? "" : ds.Rows[i]["检测仪器"].ToString();//图像数量
- list.Add(data);
- }
- date_grid.DataContext = list;
- //this.pageuser.FontSize = 36;
- this.pageuser.Page = m_Page;
- //this.pageuser.PageCount = m_Count;
- this.pageuser.PageSize = m_Page_Count;
- this.pageuser.RecordCount = m_Total;
- }
- catch (Exception ex)
- {
- }
- finally
- {
- try
- {
- conn.Close();
- }
- catch
- {
- }
- }
- }
- /// <summary>
- /// 序号列
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void date_grid_LoadingRow(object sender, DataGridRowEventArgs e)
- {
- e.Row.Header = e.Row.GetIndex() + 1;
- }
- /// <summary>
- /// 生成/查看报告单击事件(表格内按钮单击事件)
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- //MessageBox.Show(((Button)sender).Tag == null ? "" : ((Button)sender).Tag.ToString());
- try
- {
- string imgUrl = ((Button)sender).Tag == null ? "" : ((Button)sender).Tag.ToString();
- conn = new SQLiteConnection();
- connstr = new SQLiteConnectionStringBuilder();
- connstr.DataSource = path + "\\datas.db";
- conn.ConnectionString = connstr.ToString();
- conn.Open();
- string strSql = "select * from t_grade where \"图像目录\"='" + imgUrl + "'";
- SQLiteDataAdapter da = new SQLiteDataAdapter(strSql, conn);
- DataTable ds = new DataTable();
- da.Fill(ds);
- if (ds.Rows.Count > 0)
- {
- string check_Project = "";// 评级项目/检测项目
- string standard = "";//检测标准及技术文件
- string device = "";//检测使用设备
- string result = "";//结果
- string check_user = "";//检查员
- }
- }
- catch
- {
- }
- finally
- {
- try
- {
- conn.Close();
- }
- catch
- {
- }
- }
- }
- #region 分页事件
- /// <summary>
- /// 上一页
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void pro_btn_Click(object sender, RoutedEventArgs e)
- {
- if (m_Page == 1)
- {
- MessageBox.Show("已经是第一页!");
- return;
- }
- m_Page--;
- GetGrade();
- }
- /// <summary>
- /// 首页
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void first_btn_Click(object sender, RoutedEventArgs e)
- {
- if (m_Page == 1)
- {
- MessageBox.Show("已经是第一页!");
- return;
- }
- m_Page = 1;
- GetGrade();
- }
- /// <summary>
- /// 下一页
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void next_btn_Click(object sender, RoutedEventArgs e)
- {
- if (m_Page >= m_Count)
- {
- MessageBox.Show("已经是最后一页!");
- return;
- }
- m_Page++;
- GetGrade();
- }
- /// <summary>
- /// 尾页
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void last_btn_Click(object sender, RoutedEventArgs e)
- {
- if (m_Page >= m_Count)
- {
- MessageBox.Show("已经是最后一页!");
- return;
- }
- m_Page = m_Count;
- GetGrade();
- }
- #endregion
- /// <summary>
- /// 查询按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_Query_Click(object sender, RoutedEventArgs e)
- {
- m_Page = 1;
- GetGrade();
- }
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- this.pageuser.PageChanged += new EventHandler<PageChangedEventArgs>(Eventpage);
- }
- /// <summary>
- /// 自定义分页事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="a"></param>
- public void Eventpage(object sender, PageChangedEventArgs a)
- {
- m_Page = a.Page;
- GetGrade();
- }
- }
- #region 显示列类
- /// <summary>
- /// 显示列类
- /// </summary>
- public class HisData
- {
- //public int num { get; set; }
- /// <summary>
- /// 评级项目
- /// </summary>
- public string gradeproject { get; set; }
- /// <summary>
- /// 评级时间
- /// </summary>
- public string gradetime { get; set; }
- /// <summary>
- /// 操作员
- /// </summary>
- public string operation { get; set; }
- /// <summary>
- /// 复核员
- /// </summary>
- public string checke { get; set; }
- /// <summary>
- /// 图像目录
- /// </summary>
- public string imgurl { get; set; }
- /// <summary>
- /// 类别
- /// </summary>
- public string catagory { get; set; }
- /// <summary>
- /// 钢种
- /// </summary>
- public string gangzhong { get; set; }
- /// <summary>
- /// 图片数量
- /// </summary>
- public string imgcount { get; set; }
- /// <summary>
- /// 评级标准
- /// </summary>
- public string pingji { get; set; }
- /// <summary>
- /// 检测仪器
- /// </summary>
- public string instrument { get;set;}
- //public string 查看报告 { get; set; }
- }
- #endregion
- }
|