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;
using System.Text.RegularExpressions;

namespace WindowsFormsApp1.Convenience
{
    public partial class Quick_menu : Form
    {
        Main main;
        Helper_DB db = new Helper_DB();
        string compidx;
        public Quick_menu(Main _main)
        {
            InitializeComponent();
            main = _main;
            compidx = main.com_idx;
        }
        private void Quick_menu_Load(object sender, EventArgs e)
        {
            db.DBcon();
            base_setting();
        }
        private void base_setting()
        {
            rb_home1.Checked = true;
            rb_home2.Checked = true;
            rb_home3.Checked = true;
            rb_home4.Checked = true;
            rb_home5.Checked = true;
            rb_home6.Checked = true;
            rb_home7.Checked = true;
            rb_home8.Checked = true;
            rb_home9.Checked = true;
            rb_home10.Checked = true;

            string[] list_home = { "사용자 관리", "납품/거래처 관리", "주문처 관리", "도서정보 관리", "사용대장" };
            string[] list_div = { "물품등록", "목록조회", "목록집계", "주문입력", "예가조회", 
                                  "견적서", "입고작업", "매입/반품입력", "재고입력/조회" };
            string[] list_pay = { "송금내역조회", "매입집계", "매입장부", "매입미결제", "매출입력", 
                                  "매출입금", "매출장부", "매출미수금", "계산서관리" };

            
            cb_home1.Items.AddRange(list_home);
            cb_home2.Items.AddRange(list_home);
            cb_home3.Items.AddRange(list_home);
            cb_home4.Items.AddRange(list_home);
            cb_home5.Items.AddRange(list_home);
            cb_home6.Items.AddRange(list_home);
            cb_home7.Items.AddRange(list_home);
            cb_home8.Items.AddRange(list_home);
            cb_home9.Items.AddRange(list_home);
            cb_home10.Items.AddRange(list_home);

            cb_div1.Items.AddRange(list_div);
            cb_div2.Items.AddRange(list_div);
            cb_div3.Items.AddRange(list_div);
            cb_div4.Items.AddRange(list_div);
            cb_div5.Items.AddRange(list_div);
            cb_div6.Items.AddRange(list_div);
            cb_div7.Items.AddRange(list_div);
            cb_div8.Items.AddRange(list_div);
            cb_div9.Items.AddRange(list_div);
            cb_div10.Items.AddRange(list_div);

            cb_pay1.Items.AddRange(list_pay);
            cb_pay2.Items.AddRange(list_pay);
            cb_pay3.Items.AddRange(list_pay);
            cb_pay4.Items.AddRange(list_pay);
            cb_pay5.Items.AddRange(list_pay);
            cb_pay6.Items.AddRange(list_pay);
            cb_pay7.Items.AddRange(list_pay);
            cb_pay8.Items.AddRange(list_pay);
            cb_pay9.Items.AddRange(list_pay);
            cb_pay10.Items.AddRange(list_pay);
        }
        private void radio_Checked(object sender)
        {
            string tmp_name = Regex.Replace(((RadioButton)sender).Name, @"\D", "");
            int num = 0;
            num = Convert.ToInt32(tmp_name);
            combo_Enabled(((RadioButton)sender).Name, num);
        }
        private void combo_Enabled(string name, int num)
        {
            if (name.Contains("rb_home") == true) {
                switch (num) {
                    case 1:
                        cb_home1.Enabled = true;
                        cb_div1.Enabled = false;
                        cb_pay1.Enabled = false;
                        cb_marc1.Enabled = false;
                        cb_work1.Enabled = false;
                        cb_conv1.Enabled = false;
                        break;
                    case 2:
                        cb_home2.Enabled = true;
                        cb_div2.Enabled = false;
                        cb_pay2.Enabled = false;
                        cb_marc2.Enabled = false;
                        cb_work2.Enabled = false;
                        cb_conv2.Enabled = false;
                        break;
                    case 3:
                        cb_home3.Enabled = true;
                        cb_div3.Enabled = false;
                        cb_pay3.Enabled = false;
                        cb_marc3.Enabled = false;
                        cb_work3.Enabled = false;
                        cb_conv3.Enabled = false;
                        break;
                    case 4:
                        cb_home4.Enabled = true;
                        cb_div4.Enabled = false;
                        cb_pay4.Enabled = false;
                        cb_marc4.Enabled = false;
                        cb_work4.Enabled = false;
                        cb_conv4.Enabled = false;
                        break;
                    case 5:
                        cb_home5.Enabled = true;
                        cb_div5.Enabled = false;
                        cb_pay5.Enabled = false;
                        cb_marc5.Enabled = false;
                        cb_work5.Enabled = false;
                        cb_conv5.Enabled = false;
                        break;
                    case 6:
                        cb_home6.Enabled = true;
                        cb_div6.Enabled = false;
                        cb_pay6.Enabled = false;
                        cb_marc6.Enabled = false;
                        cb_work6.Enabled = false;
                        cb_conv6.Enabled = false;
                        break;
                    case 7:
                        cb_home7.Enabled = true;
                        cb_div7.Enabled = false;
                        cb_pay7.Enabled = false;
                        cb_marc7.Enabled = false;
                        cb_work7.Enabled = false;
                        cb_conv7.Enabled = false;
                        break;
                    case 8:
                        cb_home8.Enabled = true;
                        cb_div8.Enabled = false;
                        cb_pay8.Enabled = false;
                        cb_marc8.Enabled = false;
                        cb_work8.Enabled = false;
                        cb_conv8.Enabled = false;
                        break;
                    case 9:
                        cb_home9.Enabled = true;
                         cb_div9.Enabled = false;
                         cb_pay9.Enabled = false;
                        cb_marc9.Enabled = false;
                        cb_work9.Enabled = false;
                        cb_conv9.Enabled = false;
                        break;
                    case 10:
                        cb_home10.Enabled = true;
                        cb_div10.Enabled = false;
                        cb_pay10.Enabled = false;
                        cb_marc10.Enabled = false;
                        cb_work10.Enabled = false;
                        cb_conv10.Enabled = false;
                        break;
                    default:
                        break;
                }
            }
            else if (name.Contains("rb_div") == true) {
                switch (num) {
                    case 1:
                        cb_home1.Enabled = false;
                        cb_div1.Enabled = true;
                        cb_pay1.Enabled = false;
                        cb_marc1.Enabled = false;
                        cb_work1.Enabled = false;
                        cb_conv1.Enabled = false;
                        break;
                    case 2:
                        cb_home2.Enabled = false;
                        cb_div2.Enabled = true;
                        cb_pay2.Enabled = false;
                        cb_marc2.Enabled = false;
                        cb_work2.Enabled = false;
                        cb_conv2.Enabled = false;
                        break;
                    case 3:
                        cb_home3.Enabled = false;
                        cb_div3.Enabled = true;
                        cb_pay3.Enabled = false;
                        cb_marc3.Enabled = false;
                        cb_work3.Enabled = false;
                        cb_conv3.Enabled = false;
                        break;
                    case 4:
                        cb_home4.Enabled = false;
                        cb_div4.Enabled = true;
                        cb_pay4.Enabled = false;
                        cb_marc4.Enabled = false;
                        cb_work4.Enabled = false;
                        cb_conv4.Enabled = false;
                        break;
                    case 5:
                        cb_home5.Enabled = false;
                        cb_div5.Enabled = true;
                        cb_pay5.Enabled = false;
                        cb_marc5.Enabled = false;
                        cb_work5.Enabled = false;
                        cb_conv5.Enabled = false;
                        break;
                    case 6:
                        cb_home6.Enabled = false;
                        cb_div6.Enabled = true;
                        cb_pay6.Enabled = false;
                        cb_marc6.Enabled = false;
                        cb_work6.Enabled = false;
                        cb_conv6.Enabled = false;
                        break;
                    case 7:
                        cb_home7.Enabled = false;
                        cb_div7.Enabled = true;
                        cb_pay7.Enabled = false;
                        cb_marc7.Enabled = false;
                        cb_work7.Enabled = false;
                        cb_conv7.Enabled = false;
                        break;
                    case 8:
                        cb_home8.Enabled = false;
                        cb_div8.Enabled = true;
                        cb_pay8.Enabled = false;
                        cb_marc8.Enabled = false;
                        cb_work8.Enabled = false;
                        cb_conv8.Enabled = false;
                        break;
                    case 9:
                        cb_home9.Enabled = false;
                        cb_div9.Enabled = true;
                        cb_pay9.Enabled = false;
                        cb_marc9.Enabled = false;
                        cb_work9.Enabled = false;
                        cb_conv9.Enabled = false;
                        break;
                    case 10:
                        cb_home10.Enabled = false;
                        cb_div10.Enabled = true;
                        cb_pay10.Enabled = false;
                        cb_marc10.Enabled = false;
                        cb_work10.Enabled = false;
                        cb_conv10.Enabled = false;
                        break;
                    default:
                        break;
                }
            }
            else if (name.Contains("rb_pay") == true) {
                switch (num) {
                    case 1:
                        cb_home1.Enabled = false;
                        cb_div1.Enabled = false;
                        cb_pay1.Enabled = true;
                        cb_marc1.Enabled = false;
                        cb_work1.Enabled = false;
                        cb_conv1.Enabled = false;
                        break;
                    case 2:
                        cb_home2.Enabled = false;
                        cb_div2.Enabled = false;
                        cb_pay2.Enabled = true;
                        cb_marc2.Enabled = false;
                        cb_work2.Enabled = false;
                        cb_conv2.Enabled = false;
                        break;
                    case 3:
                        cb_home3.Enabled = false;
                        cb_div3.Enabled = false;
                        cb_pay3.Enabled = true;
                        cb_marc3.Enabled = false;
                        cb_work3.Enabled = false;
                        cb_conv3.Enabled = false;
                        break;
                    case 4:
                        cb_home4.Enabled = false;
                        cb_div4.Enabled = false;
                        cb_pay4.Enabled = true;
                        cb_marc4.Enabled = false;
                        cb_work4.Enabled = false;
                        cb_conv4.Enabled = false;
                        break;
                    case 5:
                        cb_home5.Enabled = false;
                        cb_div5.Enabled = false;
                        cb_pay5.Enabled = true;
                        cb_marc5.Enabled = false;
                        cb_work5.Enabled = false;
                        cb_conv5.Enabled = false;
                        break;
                    case 6:
                        cb_home6.Enabled = false;
                        cb_div6.Enabled = false;
                        cb_pay6.Enabled = true;
                        cb_marc6.Enabled = false;
                        cb_work6.Enabled = false;
                        cb_conv6.Enabled = false;
                        break;
                    case 7:
                        cb_home7.Enabled = false;
                        cb_div7.Enabled = false;
                        cb_pay7.Enabled = true;
                        cb_marc7.Enabled = false;
                        cb_work7.Enabled = false;
                        cb_conv7.Enabled = false;
                        break;
                    case 8:
                        cb_home8.Enabled = false;
                        cb_div8.Enabled = false;
                        cb_pay8.Enabled = true;
                        cb_marc8.Enabled = false;
                        cb_work8.Enabled = false;
                        cb_conv8.Enabled = false;
                        break;
                    case 9:
                        cb_home9.Enabled = false;
                        cb_div9.Enabled = false;
                        cb_pay9.Enabled = true;
                        cb_marc9.Enabled = false;
                        cb_work9.Enabled = false;
                        cb_conv9.Enabled = false;
                        break;
                    case 10:
                        cb_home10.Enabled = false;
                        cb_div10.Enabled = false;
                        cb_pay10.Enabled = true;
                        cb_marc10.Enabled = false;
                        cb_work10.Enabled = false;
                        cb_conv10.Enabled = false;
                        break;
                    default:
                        break;
                }
            }
            else if (name.Contains("rb_marc") == true) {
                switch (num) {
                    case 1:
                        cb_home1.Enabled = false;
                        cb_div1.Enabled = false;
                        cb_pay1.Enabled = false;
                        cb_marc1.Enabled = true;
                        cb_work1.Enabled = false;
                        cb_conv1.Enabled = false;
                        break;
                    case 2:
                        cb_home2.Enabled = false;
                        cb_div2.Enabled = false;
                        cb_pay2.Enabled = false;
                        cb_marc2.Enabled = true;
                        cb_work2.Enabled = false;
                        cb_conv2.Enabled = false;
                        break;
                    case 3:
                        cb_home3.Enabled = false;
                        cb_div3.Enabled = false;
                        cb_pay3.Enabled = false;
                        cb_marc3.Enabled = true;
                        cb_work3.Enabled = false;
                        cb_conv3.Enabled = false;
                        break;
                    case 4:
                        cb_home4.Enabled = false;
                        cb_div4.Enabled = false;
                        cb_pay4.Enabled = false;
                        cb_marc4.Enabled = true;
                        cb_work4.Enabled = false;
                        cb_conv4.Enabled = false;
                        break;
                    case 5:
                        cb_home5.Enabled = false;
                        cb_div5.Enabled = false;
                        cb_pay5.Enabled = false;
                        cb_marc5.Enabled = true;
                        cb_work5.Enabled = false;
                        cb_conv5.Enabled = false;
                        break;
                    case 6:
                        cb_home6.Enabled = false;
                        cb_div6.Enabled = false;
                        cb_pay6.Enabled = false;
                        cb_marc6.Enabled = true;
                        cb_work6.Enabled = false;
                        cb_conv6.Enabled = false;
                        break;
                    case 7:
                        cb_home7.Enabled = false;
                        cb_div7.Enabled = false;
                        cb_pay7.Enabled = false;
                        cb_marc7.Enabled = true;
                        cb_work7.Enabled = false;
                        cb_conv7.Enabled = false;
                        break;
                    case 8:
                        cb_home8.Enabled = false;
                        cb_div8.Enabled = false;
                        cb_pay8.Enabled = false;
                        cb_marc8.Enabled = true;
                        cb_work8.Enabled = false;
                        cb_conv8.Enabled = false;
                        break;
                    case 9:
                        cb_home9.Enabled = false;
                        cb_div9.Enabled = false;
                        cb_pay9.Enabled = false;
                        cb_marc9.Enabled = true;
                        cb_work9.Enabled = false;
                        cb_conv9.Enabled = false;
                        break;
                    case 10:
                        cb_home10.Enabled = false;
                        cb_div10.Enabled = false;
                        cb_pay10.Enabled = false;
                        cb_marc10.Enabled = true;
                        cb_work10.Enabled = false;
                        cb_conv10.Enabled = false;
                        break;
                    default:
                        break;
                }
            }
            else if (name.Contains("rb_work") == true) {
                switch (num)
                {
                    case 1:
                        cb_home1.Enabled = false;
                        cb_div1.Enabled = false;
                        cb_pay1.Enabled = false;
                        cb_marc1.Enabled = false;
                        cb_work1.Enabled = true;
                        cb_conv1.Enabled = false;
                        break;
                    case 2:
                        cb_home2.Enabled = false;
                        cb_div2.Enabled = false;
                        cb_pay2.Enabled = false;
                        cb_marc2.Enabled = false;
                        cb_work2.Enabled = true;
                        cb_conv2.Enabled = false;
                        break;
                    case 3:
                        cb_home3.Enabled = false;
                        cb_div3.Enabled = false;
                        cb_pay3.Enabled = false;
                        cb_marc3.Enabled = false;
                        cb_work3.Enabled = true;
                        cb_conv3.Enabled = false;
                        break;
                    case 4:
                        cb_home4.Enabled = false;
                        cb_div4.Enabled = false;
                        cb_pay4.Enabled = false;
                        cb_marc4.Enabled = false;
                        cb_work4.Enabled = true;
                        cb_conv4.Enabled = false;
                        break;
                    case 5:
                        cb_home5.Enabled = false;
                        cb_div5.Enabled = false;
                        cb_pay5.Enabled = false;
                        cb_marc5.Enabled = false;
                        cb_work5.Enabled = true;
                        cb_conv5.Enabled = false;
                        break;
                    case 6:
                        cb_home6.Enabled = false;
                        cb_div6.Enabled = false;
                        cb_pay6.Enabled = false;
                        cb_marc6.Enabled = false;
                        cb_work6.Enabled = true;
                        cb_conv6.Enabled = false;
                        break;
                    case 7:
                        cb_home7.Enabled = false;
                        cb_div7.Enabled = false;
                        cb_pay7.Enabled = false;
                        cb_marc7.Enabled = false;
                        cb_work7.Enabled = true;
                        cb_conv7.Enabled = false;
                        break;
                    case 8:
                        cb_home8.Enabled = false;
                        cb_div8.Enabled = false;
                        cb_pay8.Enabled = false;
                        cb_marc8.Enabled = false;
                        cb_work8.Enabled = true;
                        cb_conv8.Enabled = false;
                        break;
                    case 9:
                        cb_home9.Enabled = false;
                        cb_div9.Enabled = false;
                        cb_pay9.Enabled = false;
                        cb_marc9.Enabled = false;
                        cb_work9.Enabled = true;
                        cb_conv9.Enabled = false;
                        break;
                    case 10:
                        cb_home10.Enabled = false;
                        cb_div10.Enabled = false;
                        cb_pay10.Enabled = false;
                        cb_marc10.Enabled = false;
                        cb_work10.Enabled = true;
                        cb_conv10.Enabled = false;
                        break;
                    default:
                        break;
                }
            }
            else if (name.Contains("rb_conv") == true) {
                switch (num)
                {
                    case 1:
                        cb_home1.Enabled = false;
                        cb_div1.Enabled = false;
                        cb_pay1.Enabled = false;
                        cb_marc1.Enabled = false;
                        cb_work1.Enabled = false;
                        cb_conv1.Enabled = true;
                        break;
                    case 2:
                        cb_home2.Enabled = false;
                        cb_div2.Enabled = false;
                        cb_pay2.Enabled = false;
                        cb_marc2.Enabled = false;
                        cb_work2.Enabled = false;
                        cb_conv2.Enabled = true;
                        break;
                    case 3:
                        cb_home3.Enabled = false;
                        cb_div3.Enabled = false;
                        cb_pay3.Enabled = false;
                        cb_marc3.Enabled = false;
                        cb_work3.Enabled = false;
                        cb_conv3.Enabled = true;
                        break;
                    case 4:
                        cb_home4.Enabled = false;
                        cb_div4.Enabled = false;
                        cb_pay4.Enabled = false;
                        cb_marc4.Enabled = false;
                        cb_work4.Enabled = false;
                        cb_conv4.Enabled = true;
                        break;
                    case 5:
                        cb_home5.Enabled = false;
                        cb_div5.Enabled = false;
                        cb_pay5.Enabled = false;
                        cb_marc5.Enabled = false;
                        cb_work5.Enabled = false;
                        cb_conv5.Enabled = true;
                        break;
                    case 6:
                        cb_home6.Enabled = false;
                        cb_div6.Enabled = false;
                        cb_pay6.Enabled = false;
                        cb_marc6.Enabled = false;
                        cb_work6.Enabled = false;
                        cb_conv6.Enabled = true;
                        break;
                    case 7:
                        cb_home7.Enabled = false;
                        cb_div7.Enabled = false;
                        cb_pay7.Enabled = false;
                        cb_marc7.Enabled = false;
                        cb_work7.Enabled = false;
                        cb_conv7.Enabled = true;
                        break;
                    case 8:
                        cb_home8.Enabled = false;
                        cb_div8.Enabled = false;
                        cb_pay8.Enabled = false;
                        cb_marc8.Enabled = false;
                        cb_work8.Enabled = false;
                        cb_conv8.Enabled = true;
                        break;
                    case 9:
                        cb_home9.Enabled = false;
                        cb_div9.Enabled = false;
                        cb_pay9.Enabled = false;
                        cb_marc9.Enabled = false;
                        cb_work9.Enabled = false;
                        cb_conv9.Enabled = true;
                        break;
                    case 10:
                        cb_home10.Enabled = false;
                        cb_div10.Enabled = false;
                        cb_pay10.Enabled = false;
                        cb_marc10.Enabled = false;
                        cb_work10.Enabled = false;
                        cb_conv10.Enabled = true;
                        break;
                    default:
                        break;
                }
            }
        }
        private void btn_save_Click(object sender, EventArgs e)
        {
            /* TODO: 
             * 1. DB에 자료 저장할 리스트 구상할 것.
             * 2. main폼과 연동하여 버튼이벤트를 활성화시킬 것.
             * 3. 저장하는 즉시 퀵메뉴가 적용이 되어야함. (아니면 재접속하는 방법)
             */
        }
        private void btn_close_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void rb_home1_CheckedChanged(object sender, EventArgs e)
        {
            radio_Checked(sender);
        }
    }
}
