FrmAnalyze.cs 4.0 KB

using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OnlineStore.AutoCountClient
{
    partial class FrmAnalyze : FrmBase
    {
        public FrmAnalyze()
        {
            InitializeComponent();
        }
        public static DateTime PreStartTime = new DateTime(0);
        public static DateTime PreEndTime = new DateTime(0);
        private void FrmAnalyze_Load(object sender, EventArgs e)
        {
            if (PreStartTime.Ticks > 0 && PreEndTime.Ticks > 0)
            {
                dtpStartTime.Value = PreStartTime;
                dtpEndTime.Value = PreEndTime;
            }
            else
            {
                DateTime time1 = DateTime.Now.AddDays(-4);
                dtpStartTime.Value = new DateTime(time1.Year, time1.Month, time1.Day, 0, 0, 0);
                DateTime time = DateTime.Now.AddDays(-1);
                dtpEndTime.Value = new DateTime(time.Year, time.Month, time.Day, 23, 59, 59);
                dtpEndTime.Value = DateTime.Now;
            }
        }


        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (RobotManager.robot.sQLite == null)
            {
                MessageBox.Show("数据未初始化完成,请稍后!");
                return;
            }

            DateTime startTime = dtpStartTime.Value;
            DateTime endTime = dtpEndTime.Value;

            if (startTime < DateTime.Now.AddDays(-30))
            {
                MessageBox.Show("只能查询近30天的日志!");
                dtpStartTime.Focus();
                return;
            }
            if (endTime > DateTime.Now)
            {
                MessageBox.Show("只能查询近今天之前的日志!");
                dtpEndTime.Focus();
                return;
            }

            PreStartTime = startTime;
            PreEndTime = endTime;
            string code = txtCode.Text.Trim();

            string[][] array = null;
            bool result = RobotManager.robot.sQLite.Select(code, startTime.ToString(), endTime.ToString(), out array);
            LogUtil.error("查数据【" + code + "】【" + startTime.ToString() + "】【" + endTime.ToString() + "】结果:" + result + "," + RobotManager.robot.sQLite.ErrInfo);
            if (array != null && array.Length > 0)
            {
                LogUtil.info("共查询到【" + array.Length + "】行数据");

                this.dataGridView1.Rows.Clear();
                foreach (string[] a in array)
                {
                    DataGridViewRow view = new DataGridViewRow();
                    view.CreateCells(dataGridView1);
                   for(int i = 0; i < a.Length; i++)
                    {
                        view.Cells[i].Value = a[i];
                    }
                    //view.Cells[0].Value = point.pointNum.ToString();
                    //view.Cells[1].Value = point.PartNum.ToString();
                    //view.Cells[2].Value = point.pointName;
                    //view.Cells[3].Value = point.PositionX.ToString();
                    //view.Cells[4].Value = point.PositionY.ToString();
                    //view.Cells[5].Value = point.NodePositionX.ToString();
                    //view.Cells[6].Value = point.NodePositionY.ToString();
                    //view.Cells[7].Value = point.PositionNum.ToString();
                    //view.Cells[8].Value = point.NeedSoldering;
                    //view.Cells[9].Value = point.WeldTemp;

                    dataGridView1.Rows.Add(view);
                }
            }
        }
        private void btnBack_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }


    public class XRayHistory
    {
        public string Code = "";

        public int Height = 0;

        public int Width = 0;

        public int Count = 0;

        public string FileName = "";
    }
}