using HKHelper;
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 HKCardManager.Message
{
    public partial class MessageShow : Form
    {
        public MessageShow(Dictionary<string, List<UserDtoModel>> RrrorUser)
        {
            InitializeComponent();
            string message = string.Empty;
            string sucess=string.Empty;
            string message1=string.Empty;
            foreach (var item in RrrorUser)
            {
                if (item.Value.Count > 0)
                {
                    if (item.Key == "成功")
                    {
                        (item.Value as List<UserDtoModel>)?.ForEach(par =>
                        {
                            sucess += "[" + par.OrgId + "-" + "" + par.Name + "],";
                        });
                    }
                    else
                    {
                        message += item.Key + "列表：\r\n";
                        message1 += "\r\n\r\n姓名集合:\r\n";
                        (item.Value as List<UserDtoModel>)?.ForEach(par =>
                        {
                            message += "[" + par.OrgId + "-" + "" + par.Name + "],";
                            message1 += par.Name + ",";
                        });
                    }
                }
            }
            label1.Text = $"批量录入成功！成功:{RrrorUser["成功"].Count} 条 失败:{(RrrorUser["名字重复"].Count + RrrorUser["机构不存在"].Count + RrrorUser["添加出错"].Count)} 条";
            textBox1.Text= sucess.TrimEnd(',');
            textBox3.Text = message.TrimEnd(',')+ message1.TrimEnd(',');

        }

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

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