using ButcherFactory.BO;
using ButcherFactory.Controls;
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 IdentifySelectionDialog : Form
  {
    ClientGoodsSet_Detail set;
    public IdentifySelectionDialog(ClientGoodsSet_Detail clientGoodsSet)
    {
      this.set = clientGoodsSet;
      InitializeComponent();
      goodsNameLbl.Text = set.Goods_Name;
      identityRemark.Text = set.SelectedIdentify == null ? "" : set.SelectedIdentify.Remark;
      foreach (var item in set.Identify)
      {
        var btn = new ColorButton() { Width = 100, Height = 62, Text = item.Identify, Font = new Font("宋体", 15), Margin = new Padding(15, 3, 15, 0), EnableGroup = true };
        btn.Tag = item;
        if (set.SelectedIdentify != null && set.SelectedIdentify.Identify == item.Identify)
          btn.Selected = true;
        btn.Click += delegate
        {
          var obj = btn.Tag as GoodsIdentify;
          identityRemark.Text = obj.Remark;
          set.SelectedIdentify = obj;
        };
        flowLayoutPanel1.Controls.Add(btn);
      }
    }

    private void okBtn_Click(object sender, EventArgs e)
    {
      this.Close();
    }

    private void clearBtn_Click(object sender, EventArgs e)
    {
      set.SelectedIdentify = null;
      this.Close();
    }
  }
}
