using ButcherFactory.BO.LocalBL;
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 ButcherFactory.SegmentProductionAuto_
{
  public partial class LogForm : Form
  {
    public LogForm()
    {
      InitializeComponent();
      this.Load += LogForm_Load;
    }

    void LogForm_Load(object sender, EventArgs e)
    {
      BindListView(null);
    }

    void BindListView(string type)
    {
      listView1.Items.Clear();
      var list = SegmentProductionBL.GetLog(type);
      foreach (var u in list)
      {
        ListViewItem lv = new ListViewItem();
        lv.Text = u.BarCode;
        lv.SubItems.Add(u.Action);
        lv.SubItems.Add(u.Message);
        lv.SubItems.Add(u.Time.ToString("yyyy/MM/dd HH:mm"));
        listView1.Items.Add(lv);
      }
      listView1.Refresh();
    }

    private void colorButton1_Click(object sender, EventArgs e)
    {
      var tag = (sender as Button).Tag;
      if (tag == null)
        BindListView(null);
      else
        BindListView(tag.ToString());
    }
  }
}
