using FCOMMON;
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 FPJ0000.JobReport_
{
    public partial class fSelectProcess : fBase
    {
        public List<string> values = new List<string>();
        public fSelectProcess(string[] list)
        {
            InitializeComponent();
            values.AddRange(list);
        }

        private void fSelectProcess_Load(object sender, EventArgs e)
        {
            EnsureVisibleAndUsableSize();
            //공정목록

            var prclist = FCOMMON.DBM.GroupUserProcessList();
            //var taProc = new dsReportTableAdapters.ProcessListTableAdapter();
            //var dtProcList = taProc.GetData(FCOMMON.info.Login.gcode);
            cmbProcess.Items.Clear();
            //cmbProcess.Items.Add("--전체--");

            foreach (var dr in prclist)
            {
                cmbProcess.Items.Add(dr);
                if (values.Contains(dr))
                {
                    this.cmbProcess.SetItemChecked(cmbProcess.Items.Count - 1, true);
                }
            }
            //cmbProcess.Text = FCOMMON.info.Login.process;
            //if (cmbProcess.SelectedIndex < 0) cmbProcess.SelectedIndex = 0; //공정이 없는 사람은 전체보기로 함
        }

        private void button1_Click(object sender, EventArgs e)
        {
            values.Clear();
            for (int i = 0; i <= (cmbProcess.Items.Count - 1); i++)
            {
                if (cmbProcess.GetItemChecked(i))
                {
                    values.Add(cmbProcess.Items[i].ToString());
                }
            }
            if (values.Count < 1)
            {
                FCOMMON.Util.MsgE("공정선택이 필요 합니다");
                return;
            }
            DialogResult = DialogResult.OK;
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i <= (cmbProcess.Items.Count - 1); i++)
            {
                cmbProcess.SetItemChecked(i, true);
            }
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            for (int i = 0; i <= (cmbProcess.Items.Count - 1); i++)
            {
                cmbProcess.SetItemChecked(i, false);
            }
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            for (int i = 0; i <= (cmbProcess.Items.Count - 1); i++)
            {
                var cur = cmbProcess.GetItemChecked(i);
                cmbProcess.SetItemChecked(i, !cur);
            }
        }
    }
}
