FrmHistory.cs 2.3 KB
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TSA_V
{
    public partial class FrmHistory : FrmBase
    {
        public FrmHistory()
        {
            InitializeComponent();
        }

        private void FrmHistory_Load(object sender, EventArgs e)
        {
            DtpTimeFront.Value = DateTime.Now;
            DtpTimeBack.Value = DateTime.Now;
        }

        private void BtnQuery_Click(object sender, EventArgs e)
        {
            string timeFront = null, timeBack = null;
            if (DtpTimeFront.Checked) timeFront = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DtpTimeFront.Value);
            if (DtpTimeBack.Checked) timeBack = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DtpTimeBack.Value);
            bool rtn = DeviceLibrary.DB.db.QueryHistory(TxtCode.Text, timeFront, timeBack, out string[][] data);
            if (rtn)
            {
                DgvOperateInfo.Rows.Clear();
                if (data.Length == 0)
                    MessageBox.Show("没有找到记录");
                else
                    for (int i = 0; i < data.Length; i++)
                        DgvOperateInfo.Rows.Add(data[i]);
            }
            else
            {
                MessageBox.Show("查询出错", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void DgvOperateInfo_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (DgvOperateInfo.CurrentCell == null) return;
            string id = DgvOperateInfo.Rows[DgvOperateInfo.CurrentCell.RowIndex].Cells[0].Value.ToString();
            bool rtn = DeviceLibrary.DB.db.QueryPointInfo(id, out string[][] data);
            if (rtn)
            {
                DgvPointInfo.Rows.Clear();
                if (data.Length == 0)
                    MessageBox.Show("没有找到记录");
                else
                    for (int i = 0; i < data.Length; i++)
                        DgvPointInfo.Rows.Add(data[i]);
            }
            else
            {
                MessageBox.Show("查询出错", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }


    }
}