using ButcherFactory.BO;
|
|
using ButcherFactory.BO.LocalBL;
|
|
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.Dialogs
|
|
{
|
|
public partial class ClientGoodsSetDialog : Form
|
|
{
|
|
Dictionary<string, IEnumerable<ClientGoodsSet_Detail>> goodsSetDic;
|
|
public ClientGoodsSetDialog()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
goodsSetDic = FormClientGoodsSetBL.GetGoodsSetDic();
|
|
|
|
foreach (var item in goodsSetDic)
|
|
{
|
|
var btn = new ColorButton() { Width = 100, Height = 62, Text = item.Key, Font = new Font("宋体", 15), Margin = new Padding(15, 5, 15, 5), EnableGroup = true };
|
|
btn.Click += GroupBtnClick;
|
|
flowLayoutPanel1.Controls.Add(btn);
|
|
}
|
|
}
|
|
|
|
Color goodsColor = Color.FromArgb(250, 120, 24);
|
|
void GroupBtnClick(object sender, EventArgs e)
|
|
{
|
|
flowLayoutPanel2.Controls.Clear();
|
|
var groupBtn = sender as ColorButton;
|
|
var arr = goodsSetDic[groupBtn.Text];
|
|
foreach (var item in arr)
|
|
{
|
|
var btn = new ColorButton() { Width = 127, Height = 75, Text = item.Goods_Name, Tag = item, Font = new Font("宋体", 15), BackColor = goodsColor, Margin = new Padding(20, 10, 20, 35), PlaySound = true, StateHold = true };
|
|
if (item.Selected)
|
|
btn.Selected = true;
|
|
btn.Click += GoodsBtnClick;
|
|
flowLayoutPanel2.Controls.Add(btn);
|
|
}
|
|
}
|
|
|
|
void GoodsBtnClick(object sender, EventArgs e)
|
|
{
|
|
var btn = sender as ColorButton;
|
|
var detail = btn.Tag as ClientGoodsSet_Detail;
|
|
if (detail.Selected)
|
|
FormClientGoodsSetBL.DeleteWorkGoodsSet(detail.ID);
|
|
else
|
|
FormClientGoodsSetBL.InsertWorkerGoodsSet(detail.ID);
|
|
detail.Selected = !detail.Selected;
|
|
}
|
|
|
|
private void closeBtn_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|