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 NurseRosterProb
{
    public partial class Form_N50 : Form
    {
        public Form_N50()
        {
            InitializeComponent();
        }

        Cls_N50 OBJ_MainTab = new Cls_N50();
        string[,] MainTab = new string[50, 15];

        public void PrintSchedule()
        {
            textBox_N1_D1.Text = MainTab[0, 1]; textBox_N1_D2.Text = MainTab[0, 2]; textBox_N1_D3.Text = MainTab[0, 3];
            textBox_N1_D4.Text = MainTab[0, 4]; textBox_N1_D5.Text = MainTab[0, 5]; textBox_N1_D6.Text = MainTab[0, 6];
            textBox_N1_D7.Text = MainTab[0, 7]; textBox_N1_D8.Text = MainTab[0, 8]; textBox_N1_D9.Text = MainTab[0, 9];
            textBox_N1_D10.Text = MainTab[0, 10]; textBox_N1_D11.Text = MainTab[0, 11]; textBox_N1_D12.Text = MainTab[0, 12];
            textBox_N1_D13.Text = MainTab[0, 13]; textBox_N1_D14.Text = MainTab[0, 14];

            textBox_N2_D1.Text = MainTab[1, 1]; textBox_N2_D2.Text = MainTab[1, 2]; textBox_N2_D3.Text = MainTab[1, 3];
            textBox_N2_D4.Text = MainTab[1, 4]; textBox_N2_D5.Text = MainTab[1, 5]; textBox_N2_D6.Text = MainTab[1, 6];
            textBox_N2_D7.Text = MainTab[1, 7]; textBox_N2_D8.Text = MainTab[1, 8]; textBox_N2_D9.Text = MainTab[1, 9];
            textBox_N2_D10.Text = MainTab[1, 10]; textBox_N2_D11.Text = MainTab[1, 11]; textBox_N2_D12.Text = MainTab[1, 12];
            textBox_N2_D13.Text = MainTab[1, 13]; textBox_N2_D14.Text = MainTab[1, 14];

            textBox_N3_D1.Text = MainTab[2, 1]; textBox_N3_D2.Text = MainTab[2, 2]; textBox_N3_D3.Text = MainTab[2, 3];
            textBox_N3_D4.Text = MainTab[2, 4]; textBox_N3_D5.Text = MainTab[2, 5]; textBox_N3_D6.Text = MainTab[2, 6];
            textBox_N3_D7.Text = MainTab[2, 7]; textBox_N3_D8.Text = MainTab[2, 8]; textBox_N3_D9.Text = MainTab[2, 9];
            textBox_N3_D10.Text = MainTab[2, 10]; textBox_N3_D11.Text = MainTab[2, 11]; textBox_N3_D12.Text = MainTab[2, 12];
            textBox_N3_D13.Text = MainTab[2, 13]; textBox_N3_D14.Text = MainTab[2, 14];

            textBox_N4_D1.Text = MainTab[3, 1]; textBox_N4_D2.Text = MainTab[3, 2]; textBox_N4_D3.Text = MainTab[3, 3];
            textBox_N4_D4.Text = MainTab[3, 4]; textBox_N4_D5.Text = MainTab[3, 5]; textBox_N4_D6.Text = MainTab[3, 6];
            textBox_N4_D7.Text = MainTab[3, 7]; textBox_N4_D8.Text = MainTab[3, 8]; textBox_N4_D9.Text = MainTab[3, 9];
            textBox_N4_D10.Text = MainTab[3, 10]; textBox_N4_D11.Text = MainTab[3, 11]; textBox_N4_D12.Text = MainTab[3, 12];
            textBox_N4_D13.Text = MainTab[3, 13]; textBox_N4_D14.Text = MainTab[3, 14];

            textBox_N5_D1.Text = MainTab[4, 1]; textBox_N5_D2.Text = MainTab[4, 2]; textBox_N5_D3.Text = MainTab[4, 3];
            textBox_N5_D4.Text = MainTab[4, 4]; textBox_N5_D5.Text = MainTab[4, 5]; textBox_N5_D6.Text = MainTab[4, 6];
            textBox_N5_D7.Text = MainTab[4, 7]; textBox_N5_D8.Text = MainTab[4, 8]; textBox_N5_D9.Text = MainTab[4, 9];
            textBox_N5_D10.Text = MainTab[4, 10]; textBox_N5_D11.Text = MainTab[4, 11]; textBox_N5_D12.Text = MainTab[4, 12];
            textBox_N5_D13.Text = MainTab[4, 13]; textBox_N5_D14.Text = MainTab[4, 14];

            textBox_N6_D1.Text = MainTab[5, 1]; textBox_N6_D2.Text = MainTab[5, 2]; textBox_N6_D3.Text = MainTab[5, 3];
            textBox_N6_D4.Text = MainTab[5, 4]; textBox_N6_D5.Text = MainTab[5, 5]; textBox_N6_D6.Text = MainTab[5, 6];
            textBox_N6_D7.Text = MainTab[5, 7]; textBox_N6_D8.Text = MainTab[5, 8]; textBox_N6_D9.Text = MainTab[5, 9];
            textBox_N6_D10.Text = MainTab[5, 10]; textBox_N6_D11.Text = MainTab[5, 11]; textBox_N6_D12.Text = MainTab[5, 12];
            textBox_N6_D13.Text = MainTab[5, 13]; textBox_N6_D14.Text = MainTab[5, 14];

            textBox_N7_D1.Text = MainTab[6, 1]; textBox_N7_D2.Text = MainTab[6, 2]; textBox_N7_D3.Text = MainTab[6, 3];
            textBox_N7_D4.Text = MainTab[6, 4]; textBox_N7_D5.Text = MainTab[6, 5]; textBox_N7_D6.Text = MainTab[6, 6];
            textBox_N7_D7.Text = MainTab[6, 7]; textBox_N7_D8.Text = MainTab[6, 8]; textBox_N7_D9.Text = MainTab[6, 9];
            textBox_N7_D10.Text = MainTab[6, 10]; textBox_N7_D11.Text = MainTab[6, 11]; textBox_N7_D12.Text = MainTab[6, 12];
            textBox_N7_D13.Text = MainTab[6, 13]; textBox_N7_D14.Text = MainTab[6, 14];

            textBox_N8_D1.Text = MainTab[7, 1]; textBox_N8_D2.Text = MainTab[7, 2]; textBox_N8_D3.Text = MainTab[7, 3];
            textBox_N8_D4.Text = MainTab[7, 4]; textBox_N8_D5.Text = MainTab[7, 5]; textBox_N8_D6.Text = MainTab[7, 6];
            textBox_N8_D7.Text = MainTab[7, 7]; textBox_N8_D8.Text = MainTab[7, 8]; textBox_N8_D9.Text = MainTab[7, 9];
            textBox_N8_D10.Text = MainTab[7, 10]; textBox_N8_D11.Text = MainTab[7, 11]; textBox_N8_D12.Text = MainTab[7, 12];
            textBox_N8_D13.Text = MainTab[7, 13]; textBox_N8_D14.Text = MainTab[7, 14];

            textBox_N9_D1.Text = MainTab[8, 1]; textBox_N9_D2.Text = MainTab[8, 2]; textBox_N9_D3.Text = MainTab[8, 3];
            textBox_N9_D4.Text = MainTab[8, 4]; textBox_N9_D5.Text = MainTab[8, 5]; textBox_N9_D6.Text = MainTab[8, 6];
            textBox_N9_D7.Text = MainTab[8, 7]; textBox_N9_D8.Text = MainTab[8, 8]; textBox_N9_D9.Text = MainTab[8, 9];
            textBox_N9_D10.Text = MainTab[8, 10]; textBox_N9_D11.Text = MainTab[8, 11]; textBox_N9_D12.Text = MainTab[8, 12];
            textBox_N9_D13.Text = MainTab[8, 13]; textBox_N9_D14.Text = MainTab[8, 14];

            textBox_N10_D1.Text = MainTab[9, 1]; textBox_N10_D2.Text = MainTab[9, 2]; textBox_N10_D3.Text = MainTab[9, 3];
            textBox_N10_D4.Text = MainTab[9, 4]; textBox_N10_D5.Text = MainTab[9, 5]; textBox_N10_D6.Text = MainTab[9, 6];
            textBox_N10_D7.Text = MainTab[9, 7]; textBox_N10_D8.Text = MainTab[9, 8]; textBox_N10_D9.Text = MainTab[9, 9];
            textBox_N10_D10.Text = MainTab[9, 10]; textBox_N10_D11.Text = MainTab[9, 11]; textBox_N10_D12.Text = MainTab[9, 12];
            textBox_N10_D13.Text = MainTab[9, 13]; textBox_N10_D14.Text = MainTab[9, 14];

            textBox_N11_D1.Text = MainTab[10, 1]; textBox_N11_D2.Text = MainTab[10, 2]; textBox_N11_D3.Text = MainTab[10, 3];
            textBox_N11_D4.Text = MainTab[10, 4]; textBox_N11_D5.Text = MainTab[10, 5]; textBox_N11_D6.Text = MainTab[10, 6];
            textBox_N11_D7.Text = MainTab[10, 7]; textBox_N11_D8.Text = MainTab[10, 8]; textBox_N11_D9.Text = MainTab[10, 9];
            textBox_N11_D10.Text = MainTab[10, 10]; textBox_N11_D11.Text = MainTab[10, 11]; textBox_N11_D12.Text = MainTab[10, 12];
            textBox_N11_D13.Text = MainTab[10, 13]; textBox_N11_D14.Text = MainTab[10, 14];

            textBox_N12_D1.Text = MainTab[11, 1]; textBox_N12_D2.Text = MainTab[11, 2]; textBox_N12_D3.Text = MainTab[11, 3];
            textBox_N12_D4.Text = MainTab[11, 4]; textBox_N12_D5.Text = MainTab[11, 5]; textBox_N12_D6.Text = MainTab[11, 6];
            textBox_N12_D7.Text = MainTab[11, 7]; textBox_N12_D8.Text = MainTab[11, 8]; textBox_N12_D9.Text = MainTab[11, 9];
            textBox_N12_D10.Text = MainTab[11, 10]; textBox_N12_D11.Text = MainTab[11, 11]; textBox_N12_D12.Text = MainTab[11, 12];
            textBox_N12_D13.Text = MainTab[11, 13]; textBox_N12_D14.Text = MainTab[11, 14];

            textBox_N13_D1.Text = MainTab[12, 1]; textBox_N13_D2.Text = MainTab[12, 2]; textBox_N13_D3.Text = MainTab[12, 3];
            textBox_N13_D4.Text = MainTab[12, 4]; textBox_N13_D5.Text = MainTab[12, 5]; textBox_N13_D6.Text = MainTab[12, 6];
            textBox_N13_D7.Text = MainTab[12, 7]; textBox_N13_D8.Text = MainTab[12, 8]; textBox_N13_D9.Text = MainTab[12, 9];
            textBox_N13_D10.Text = MainTab[12, 10]; textBox_N13_D11.Text = MainTab[12, 11]; textBox_N13_D12.Text = MainTab[12, 12];
            textBox_N13_D13.Text = MainTab[12, 13]; textBox_N13_D14.Text = MainTab[12, 14];

            textBox_N14_D1.Text = MainTab[13, 1]; textBox_N14_D2.Text = MainTab[13, 2]; textBox_N14_D3.Text = MainTab[13, 3];
            textBox_N14_D4.Text = MainTab[13, 4]; textBox_N14_D5.Text = MainTab[13, 5]; textBox_N14_D6.Text = MainTab[13, 6];
            textBox_N14_D7.Text = MainTab[13, 7]; textBox_N14_D8.Text = MainTab[13, 8]; textBox_N14_D9.Text = MainTab[13, 9];
            textBox_N14_D10.Text = MainTab[13, 10]; textBox_N14_D11.Text = MainTab[13, 11]; textBox_N14_D12.Text = MainTab[13, 12];
            textBox_N14_D13.Text = MainTab[13, 13]; textBox_N14_D14.Text = MainTab[13, 14];

            textBox_N15_D1.Text = MainTab[14, 1]; textBox_N15_D2.Text = MainTab[14, 2]; textBox_N15_D3.Text = MainTab[14, 3];
            textBox_N15_D4.Text = MainTab[14, 4]; textBox_N15_D5.Text = MainTab[14, 5]; textBox_N15_D6.Text = MainTab[14, 6];
            textBox_N15_D7.Text = MainTab[14, 7]; textBox_N15_D8.Text = MainTab[14, 8]; textBox_N15_D9.Text = MainTab[14, 9];
            textBox_N15_D10.Text = MainTab[14, 10]; textBox_N15_D11.Text = MainTab[14, 11]; textBox_N15_D12.Text = MainTab[14, 12];
            textBox_N15_D13.Text = MainTab[14, 13]; textBox_N15_D14.Text = MainTab[14, 14];

            textBox_N16_D1.Text = MainTab[15, 1]; textBox_N16_D2.Text = MainTab[15, 2]; textBox_N16_D3.Text = MainTab[15, 3];
            textBox_N16_D4.Text = MainTab[15, 4]; textBox_N16_D5.Text = MainTab[15, 5]; textBox_N16_D6.Text = MainTab[15, 6];
            textBox_N16_D7.Text = MainTab[15, 7]; textBox_N16_D8.Text = MainTab[15, 8]; textBox_N16_D9.Text = MainTab[15, 9];
            textBox_N16_D10.Text = MainTab[15, 10]; textBox_N16_D11.Text = MainTab[15, 11]; textBox_N16_D12.Text = MainTab[15, 12];
            textBox_N16_D13.Text = MainTab[15, 13]; textBox_N16_D14.Text = MainTab[15, 14];

            textBox_N17_D1.Text = MainTab[16, 1]; textBox_N17_D2.Text = MainTab[16, 2]; textBox_N17_D3.Text = MainTab[16, 3];
            textBox_N17_D4.Text = MainTab[16, 4]; textBox_N17_D5.Text = MainTab[16, 5]; textBox_N17_D6.Text = MainTab[16, 6];
            textBox_N17_D7.Text = MainTab[16, 7]; textBox_N17_D8.Text = MainTab[16, 8]; textBox_N17_D9.Text = MainTab[16, 9];
            textBox_N17_D10.Text = MainTab[16, 10]; textBox_N17_D11.Text = MainTab[16, 11]; textBox_N17_D12.Text = MainTab[16, 12];
            textBox_N17_D13.Text = MainTab[16, 13]; textBox_N17_D14.Text = MainTab[16, 14];

            textBox_N18_D1.Text = MainTab[17, 1]; textBox_N18_D2.Text = MainTab[17, 2]; textBox_N18_D3.Text = MainTab[17, 3];
            textBox_N18_D4.Text = MainTab[17, 4]; textBox_N18_D5.Text = MainTab[17, 5]; textBox_N18_D6.Text = MainTab[17, 6];
            textBox_N18_D7.Text = MainTab[17, 7]; textBox_N18_D8.Text = MainTab[17, 8]; textBox_N18_D9.Text = MainTab[17, 9];
            textBox_N18_D10.Text = MainTab[17, 10]; textBox_N18_D11.Text = MainTab[17, 11]; textBox_N18_D12.Text = MainTab[17, 12];
            textBox_N18_D13.Text = MainTab[17, 13]; textBox_N18_D14.Text = MainTab[17, 14];

            textBox_N19_D1.Text = MainTab[18, 1]; textBox_N19_D2.Text = MainTab[18, 2]; textBox_N19_D3.Text = MainTab[18, 3];
            textBox_N19_D4.Text = MainTab[18, 4]; textBox_N19_D5.Text = MainTab[18, 5]; textBox_N19_D6.Text = MainTab[18, 6];
            textBox_N19_D7.Text = MainTab[18, 7]; textBox_N19_D8.Text = MainTab[18, 8]; textBox_N19_D9.Text = MainTab[18, 9];
            textBox_N19_D10.Text = MainTab[18, 10]; textBox_N19_D11.Text = MainTab[18, 11]; textBox_N19_D12.Text = MainTab[18, 12];
            textBox_N19_D13.Text = MainTab[18, 13]; textBox_N19_D14.Text = MainTab[18, 14];

            textBox_N20_D1.Text = MainTab[19, 1]; textBox_N20_D2.Text = MainTab[19, 2]; textBox_N20_D3.Text = MainTab[19, 3];
            textBox_N20_D4.Text = MainTab[19, 4]; textBox_N20_D5.Text = MainTab[19, 5]; textBox_N20_D6.Text = MainTab[19, 6];
            textBox_N20_D7.Text = MainTab[19, 7]; textBox_N20_D8.Text = MainTab[19, 8]; textBox_N20_D9.Text = MainTab[19, 9];
            textBox_N20_D10.Text = MainTab[19, 10]; textBox_N20_D11.Text = MainTab[19, 11]; textBox_N20_D12.Text = MainTab[19, 12];
            textBox_N20_D13.Text = MainTab[19, 13]; textBox_N20_D14.Text = MainTab[19, 14];

            textBox_N21_D1.Text = MainTab[20, 1]; textBox_N21_D2.Text = MainTab[20, 2]; textBox_N21_D3.Text = MainTab[20, 3];
            textBox_N21_D4.Text = MainTab[20, 4]; textBox_N21_D5.Text = MainTab[20, 5]; textBox_N21_D6.Text = MainTab[20, 6];
            textBox_N21_D7.Text = MainTab[20, 7]; textBox_N21_D8.Text = MainTab[20, 8]; textBox_N21_D9.Text = MainTab[20, 9];
            textBox_N21_D10.Text = MainTab[20, 10]; textBox_N21_D11.Text = MainTab[20, 11]; textBox_N21_D12.Text = MainTab[20, 12];
            textBox_N21_D13.Text = MainTab[20, 13]; textBox_N21_D14.Text = MainTab[20, 14];

            textBox_N22_D1.Text = MainTab[21, 1]; textBox_N22_D2.Text = MainTab[21, 2]; textBox_N22_D3.Text = MainTab[21, 3];
            textBox_N22_D4.Text = MainTab[21, 4]; textBox_N22_D5.Text = MainTab[21, 5]; textBox_N22_D6.Text = MainTab[21, 6];
            textBox_N22_D7.Text = MainTab[21, 7]; textBox_N22_D8.Text = MainTab[21, 8]; textBox_N22_D9.Text = MainTab[21, 9];
            textBox_N22_D10.Text = MainTab[21, 10]; textBox_N22_D11.Text = MainTab[21, 11]; textBox_N22_D12.Text = MainTab[21, 12];
            textBox_N22_D13.Text = MainTab[21, 13]; textBox_N22_D14.Text = MainTab[21, 14];

            textBox_N23_D1.Text = MainTab[22, 1]; textBox_N23_D2.Text = MainTab[22, 2]; textBox_N23_D3.Text = MainTab[22, 3];
            textBox_N23_D4.Text = MainTab[22, 4]; textBox_N23_D5.Text = MainTab[22, 5]; textBox_N23_D6.Text = MainTab[22, 6];
            textBox_N23_D7.Text = MainTab[22, 7]; textBox_N23_D8.Text = MainTab[22, 8]; textBox_N23_D9.Text = MainTab[22, 9];
            textBox_N23_D10.Text = MainTab[22, 10]; textBox_N23_D11.Text = MainTab[22, 11]; textBox_N23_D12.Text = MainTab[22, 12];
            textBox_N23_D13.Text = MainTab[22, 13]; textBox_N23_D14.Text = MainTab[22, 14];

            textBox_N24_D1.Text = MainTab[23, 1]; textBox_N24_D2.Text = MainTab[23, 2]; textBox_N24_D3.Text = MainTab[23, 3];
            textBox_N24_D4.Text = MainTab[23, 4]; textBox_N24_D5.Text = MainTab[23, 5]; textBox_N24_D6.Text = MainTab[23, 6];
            textBox_N24_D7.Text = MainTab[23, 7]; textBox_N24_D8.Text = MainTab[23, 8]; textBox_N24_D9.Text = MainTab[23, 9];
            textBox_N24_D10.Text = MainTab[23, 10]; textBox_N24_D11.Text = MainTab[23, 11]; textBox_N24_D12.Text = MainTab[23, 12];
            textBox_N24_D13.Text = MainTab[23, 13]; textBox_N24_D14.Text = MainTab[23, 14];

            textBox_N25_D1.Text = MainTab[24, 1]; textBox_N25_D2.Text = MainTab[24, 2]; textBox_N25_D3.Text = MainTab[24, 3];
            textBox_N25_D4.Text = MainTab[24, 4]; textBox_N25_D5.Text = MainTab[24, 5]; textBox_N25_D6.Text = MainTab[24, 6];
            textBox_N25_D7.Text = MainTab[24, 7]; textBox_N25_D8.Text = MainTab[24, 8]; textBox_N25_D9.Text = MainTab[24, 9];
            textBox_N25_D10.Text = MainTab[24, 10]; textBox_N25_D11.Text = MainTab[24, 11]; textBox_N25_D12.Text = MainTab[24, 12];
            textBox_N25_D13.Text = MainTab[24, 13]; textBox_N25_D14.Text = MainTab[24, 14];

            textBox_N26_D1.Text = MainTab[25, 1]; textBox_N26_D2.Text = MainTab[25, 2]; textBox_N26_D3.Text = MainTab[25, 3];
            textBox_N26_D4.Text = MainTab[25, 4]; textBox_N26_D5.Text = MainTab[25, 5]; textBox_N26_D6.Text = MainTab[25, 6];
            textBox_N26_D7.Text = MainTab[25, 7]; textBox_N26_D8.Text = MainTab[25, 8]; textBox_N26_D9.Text = MainTab[25, 9];
            textBox_N26_D10.Text = MainTab[25, 10]; textBox_N26_D11.Text = MainTab[25, 11]; textBox_N26_D12.Text = MainTab[25, 12];
            textBox_N26_D13.Text = MainTab[25, 13]; textBox_N26_D14.Text = MainTab[25, 14];

            textBox_N27_D1.Text = MainTab[26, 1]; textBox_N27_D2.Text = MainTab[26, 2]; textBox_N27_D3.Text = MainTab[26, 3];
            textBox_N27_D4.Text = MainTab[26, 4]; textBox_N27_D5.Text = MainTab[26, 5]; textBox_N27_D6.Text = MainTab[26, 6];
            textBox_N27_D7.Text = MainTab[26, 7]; textBox_N27_D8.Text = MainTab[26, 8]; textBox_N27_D9.Text = MainTab[26, 9];
            textBox_N27_D10.Text = MainTab[26, 10]; textBox_N27_D11.Text = MainTab[26, 11]; textBox_N27_D12.Text = MainTab[26, 12];
            textBox_N27_D13.Text = MainTab[26, 13]; textBox_N27_D14.Text = MainTab[26, 14];

            textBox_N28_D1.Text = MainTab[27, 1]; textBox_N28_D2.Text = MainTab[27, 2]; textBox_N28_D3.Text = MainTab[27, 3];
            textBox_N28_D4.Text = MainTab[27, 4]; textBox_N28_D5.Text = MainTab[27, 5]; textBox_N28_D6.Text = MainTab[27, 6];
            textBox_N28_D7.Text = MainTab[27, 7]; textBox_N28_D8.Text = MainTab[27, 8]; textBox_N28_D9.Text = MainTab[27, 9];
            textBox_N28_D10.Text = MainTab[27, 10]; textBox_N28_D11.Text = MainTab[27, 11]; textBox_N28_D12.Text = MainTab[27, 12];
            textBox_N28_D13.Text = MainTab[27, 13]; textBox_N28_D14.Text = MainTab[27, 14];

            textBox_N29_D1.Text = MainTab[28, 1]; textBox_N29_D2.Text = MainTab[28, 2]; textBox_N29_D3.Text = MainTab[28, 3];
            textBox_N29_D4.Text = MainTab[28, 4]; textBox_N29_D5.Text = MainTab[28, 5]; textBox_N29_D6.Text = MainTab[28, 6];
            textBox_N29_D7.Text = MainTab[28, 7]; textBox_N29_D8.Text = MainTab[28, 8]; textBox_N29_D9.Text = MainTab[28, 9];
            textBox_N29_D10.Text = MainTab[28, 10]; textBox_N29_D11.Text = MainTab[28, 11]; textBox_N29_D12.Text = MainTab[28, 12];
            textBox_N29_D13.Text = MainTab[28, 13]; textBox_N29_D14.Text = MainTab[28, 14];

            textBox_N30_D1.Text = MainTab[29, 1]; textBox_N30_D2.Text = MainTab[29, 2]; textBox_N30_D3.Text = MainTab[29, 3];
            textBox_N30_D4.Text = MainTab[29, 4]; textBox_N30_D5.Text = MainTab[29, 5]; textBox_N30_D6.Text = MainTab[29, 6];
            textBox_N30_D7.Text = MainTab[29, 7]; textBox_N30_D8.Text = MainTab[29, 8]; textBox_N30_D9.Text = MainTab[29, 9];
            textBox_N30_D10.Text = MainTab[29, 10]; textBox_N30_D11.Text = MainTab[29, 11]; textBox_N30_D12.Text = MainTab[29, 12];
            textBox_N30_D13.Text = MainTab[29, 13]; textBox_N30_D14.Text = MainTab[29, 14];

            textBox_N31_D1.Text = MainTab[30, 1]; textBox_N31_D2.Text = MainTab[30, 2]; textBox_N31_D3.Text = MainTab[30, 3];
            textBox_N31_D4.Text = MainTab[30, 4]; textBox_N31_D5.Text = MainTab[30, 5]; textBox_N31_D6.Text = MainTab[30, 6];
            textBox_N31_D7.Text = MainTab[30, 7]; textBox_N31_D8.Text = MainTab[30, 8]; textBox_N31_D9.Text = MainTab[30, 9];
            textBox_N31_D10.Text = MainTab[30, 10]; textBox_N31_D11.Text = MainTab[30, 11]; textBox_N31_D12.Text = MainTab[30, 12];
            textBox_N31_D13.Text = MainTab[30, 13]; textBox_N31_D14.Text = MainTab[30, 14];

            textBox_N32_D1.Text = MainTab[31, 1]; textBox_N32_D2.Text = MainTab[31, 2]; textBox_N32_D3.Text = MainTab[31, 3];
            textBox_N32_D4.Text = MainTab[31, 4]; textBox_N32_D5.Text = MainTab[31, 5]; textBox_N32_D6.Text = MainTab[31, 6];
            textBox_N32_D7.Text = MainTab[31, 7]; textBox_N32_D8.Text = MainTab[31, 8]; textBox_N32_D9.Text = MainTab[31, 9];
            textBox_N32_D10.Text = MainTab[31, 10]; textBox_N32_D11.Text = MainTab[31, 11]; textBox_N32_D12.Text = MainTab[31, 12];
            textBox_N32_D13.Text = MainTab[31, 13]; textBox_N32_D14.Text = MainTab[31, 14];

            textBox_N33_D1.Text = MainTab[32, 1]; textBox_N33_D2.Text = MainTab[32, 2]; textBox_N33_D3.Text = MainTab[32, 3];
            textBox_N33_D4.Text = MainTab[32, 4]; textBox_N33_D5.Text = MainTab[32, 5]; textBox_N33_D6.Text = MainTab[32, 6];
            textBox_N33_D7.Text = MainTab[32, 7]; textBox_N33_D8.Text = MainTab[32, 8]; textBox_N33_D9.Text = MainTab[32, 9];
            textBox_N33_D10.Text = MainTab[32, 10]; textBox_N33_D11.Text = MainTab[32, 11]; textBox_N33_D12.Text = MainTab[32, 12];
            textBox_N33_D13.Text = MainTab[32, 13]; textBox_N33_D14.Text = MainTab[32, 14];

            textBox_N34_D1.Text = MainTab[33, 1]; textBox_N34_D2.Text = MainTab[33, 2]; textBox_N34_D3.Text = MainTab[33, 3];
            textBox_N34_D4.Text = MainTab[33, 4]; textBox_N34_D5.Text = MainTab[33, 5]; textBox_N34_D6.Text = MainTab[33, 6];
            textBox_N34_D7.Text = MainTab[33, 7]; textBox_N34_D8.Text = MainTab[33, 8]; textBox_N34_D9.Text = MainTab[33, 9];
            textBox_N34_D10.Text = MainTab[33, 10]; textBox_N34_D11.Text = MainTab[33, 11]; textBox_N34_D12.Text = MainTab[33, 12];
            textBox_N34_D13.Text = MainTab[33, 13]; textBox_N34_D14.Text = MainTab[33, 14];

            textBox_N35_D1.Text = MainTab[34, 1]; textBox_N35_D2.Text = MainTab[34, 2]; textBox_N35_D3.Text = MainTab[34, 3];
            textBox_N35_D4.Text = MainTab[34, 4]; textBox_N35_D5.Text = MainTab[34, 5]; textBox_N35_D6.Text = MainTab[34, 6];
            textBox_N35_D7.Text = MainTab[34, 7]; textBox_N35_D8.Text = MainTab[34, 8]; textBox_N35_D9.Text = MainTab[34, 9];
            textBox_N35_D10.Text = MainTab[34, 10]; textBox_N35_D11.Text = MainTab[34, 11]; textBox_N35_D12.Text = MainTab[34, 12];
            textBox_N35_D13.Text = MainTab[34, 13]; textBox_N35_D14.Text = MainTab[34, 14];

            textBox_N36_D1.Text = MainTab[35, 1]; textBox_N36_D2.Text = MainTab[35, 2]; textBox_N36_D3.Text = MainTab[35, 3];
            textBox_N36_D4.Text = MainTab[35, 4]; textBox_N36_D5.Text = MainTab[35, 5]; textBox_N36_D6.Text = MainTab[35, 6];
            textBox_N36_D7.Text = MainTab[35, 7]; textBox_N36_D8.Text = MainTab[35, 8]; textBox_N36_D9.Text = MainTab[35, 9];
            textBox_N36_D10.Text = MainTab[35, 10]; textBox_N36_D11.Text = MainTab[35, 11]; textBox_N36_D12.Text = MainTab[35, 12];
            textBox_N36_D13.Text = MainTab[35, 13]; textBox_N36_D14.Text = MainTab[35, 14];

            textBox_N37_D1.Text = MainTab[36, 1]; textBox_N37_D2.Text = MainTab[36, 2]; textBox_N37_D3.Text = MainTab[36, 3];
            textBox_N37_D4.Text = MainTab[36, 4]; textBox_N37_D5.Text = MainTab[36, 5]; textBox_N37_D6.Text = MainTab[36, 6];
            textBox_N37_D7.Text = MainTab[36, 7]; textBox_N37_D8.Text = MainTab[36, 8]; textBox_N37_D9.Text = MainTab[36, 9];
            textBox_N37_D10.Text = MainTab[36, 10]; textBox_N37_D11.Text = MainTab[36, 11]; textBox_N37_D12.Text = MainTab[36, 12];
            textBox_N37_D13.Text = MainTab[36, 13]; textBox_N37_D14.Text = MainTab[36, 14];

            textBox_N38_D1.Text = MainTab[37, 1]; textBox_N38_D2.Text = MainTab[37, 2]; textBox_N38_D3.Text = MainTab[37, 3];
            textBox_N38_D4.Text = MainTab[37, 4]; textBox_N38_D5.Text = MainTab[37, 5]; textBox_N38_D6.Text = MainTab[37, 6];
            textBox_N38_D7.Text = MainTab[37, 7]; textBox_N38_D8.Text = MainTab[37, 8]; textBox_N38_D9.Text = MainTab[37, 9];
            textBox_N38_D10.Text = MainTab[37, 10]; textBox_N38_D11.Text = MainTab[37, 11]; textBox_N38_D12.Text = MainTab[37, 12];
            textBox_N38_D13.Text = MainTab[37, 13]; textBox_N38_D14.Text = MainTab[37, 14];

            textBox_N39_D1.Text = MainTab[38, 1]; textBox_N39_D2.Text = MainTab[38, 2]; textBox_N39_D3.Text = MainTab[38, 3];
            textBox_N39_D4.Text = MainTab[38, 4]; textBox_N39_D5.Text = MainTab[38, 5]; textBox_N39_D6.Text = MainTab[38, 6];
            textBox_N39_D7.Text = MainTab[38, 7]; textBox_N39_D8.Text = MainTab[38, 8]; textBox_N39_D9.Text = MainTab[38, 9];
            textBox_N39_D10.Text = MainTab[38, 10]; textBox_N39_D11.Text = MainTab[38, 11]; textBox_N39_D12.Text = MainTab[38, 12];
            textBox_N39_D13.Text = MainTab[38, 13]; textBox_N39_D14.Text = MainTab[38, 14];

            textBox_N40_D1.Text = MainTab[39, 1]; textBox_N40_D2.Text = MainTab[39, 2]; textBox_N40_D3.Text = MainTab[39, 3];
            textBox_N40_D4.Text = MainTab[39, 4]; textBox_N40_D5.Text = MainTab[39, 5]; textBox_N40_D6.Text = MainTab[39, 6];
            textBox_N40_D7.Text = MainTab[39, 7]; textBox_N40_D8.Text = MainTab[39, 8]; textBox_N40_D9.Text = MainTab[39, 9];
            textBox_N40_D10.Text = MainTab[39, 10]; textBox_N40_D11.Text = MainTab[39, 11]; textBox_N40_D12.Text = MainTab[39, 12];
            textBox_N40_D13.Text = MainTab[39, 13]; textBox_N40_D14.Text = MainTab[39, 14];

            textBox_N41_D1.Text = MainTab[40, 1]; textBox_N41_D2.Text = MainTab[40, 2]; textBox_N41_D3.Text = MainTab[40, 3];
            textBox_N41_D4.Text = MainTab[40, 4]; textBox_N41_D5.Text = MainTab[40, 5]; textBox_N41_D6.Text = MainTab[40, 6];
            textBox_N41_D7.Text = MainTab[40, 7]; textBox_N41_D8.Text = MainTab[40, 8]; textBox_N41_D9.Text = MainTab[40, 9];
            textBox_N41_D10.Text = MainTab[40, 10]; textBox_N41_D11.Text = MainTab[40, 11]; textBox_N41_D12.Text = MainTab[40, 12];
            textBox_N41_D13.Text = MainTab[40, 13]; textBox_N41_D14.Text = MainTab[40, 14];

            textBox_N42_D1.Text = MainTab[41, 1]; textBox_N42_D2.Text = MainTab[41, 2]; textBox_N42_D3.Text = MainTab[41, 3];
            textBox_N42_D4.Text = MainTab[41, 4]; textBox_N42_D5.Text = MainTab[41, 5]; textBox_N42_D6.Text = MainTab[41, 6];
            textBox_N42_D7.Text = MainTab[41, 7]; textBox_N42_D8.Text = MainTab[41, 8]; textBox_N42_D9.Text = MainTab[41, 9];
            textBox_N42_D10.Text = MainTab[41, 10]; textBox_N42_D11.Text = MainTab[41, 11]; textBox_N42_D12.Text = MainTab[41, 12];
            textBox_N42_D13.Text = MainTab[41, 13]; textBox_N42_D14.Text = MainTab[41, 14];

            textBox_N43_D1.Text = MainTab[42, 1]; textBox_N43_D2.Text = MainTab[42, 2]; textBox_N43_D3.Text = MainTab[42, 3];
            textBox_N43_D4.Text = MainTab[42, 4]; textBox_N43_D5.Text = MainTab[42, 5]; textBox_N43_D6.Text = MainTab[42, 6];
            textBox_N43_D7.Text = MainTab[42, 7]; textBox_N43_D8.Text = MainTab[42, 8]; textBox_N43_D9.Text = MainTab[42, 9];
            textBox_N43_D10.Text = MainTab[42, 10]; textBox_N43_D11.Text = MainTab[42, 11]; textBox_N43_D12.Text = MainTab[42, 12];
            textBox_N43_D13.Text = MainTab[42, 13]; textBox_N43_D14.Text = MainTab[42, 14];

            textBox_N44_D1.Text = MainTab[43, 1]; textBox_N44_D2.Text = MainTab[43, 2]; textBox_N44_D3.Text = MainTab[43, 3];
            textBox_N44_D4.Text = MainTab[43, 4]; textBox_N44_D5.Text = MainTab[43, 5]; textBox_N44_D6.Text = MainTab[43, 6];
            textBox_N44_D7.Text = MainTab[43, 7]; textBox_N44_D8.Text = MainTab[43, 8]; textBox_N44_D9.Text = MainTab[43, 9];
            textBox_N44_D10.Text = MainTab[43, 10]; textBox_N44_D11.Text = MainTab[43, 11]; textBox_N44_D12.Text = MainTab[43, 12];
            textBox_N44_D13.Text = MainTab[43, 13]; textBox_N44_D14.Text = MainTab[43, 14];

            textBox_N45_D1.Text = MainTab[44, 1]; textBox_N45_D2.Text = MainTab[44, 2]; textBox_N45_D3.Text = MainTab[44, 3];
            textBox_N45_D4.Text = MainTab[44, 4]; textBox_N45_D5.Text = MainTab[44, 5]; textBox_N45_D6.Text = MainTab[44, 6];
            textBox_N45_D7.Text = MainTab[44, 7]; textBox_N45_D8.Text = MainTab[44, 8]; textBox_N45_D9.Text = MainTab[44, 9];
            textBox_N45_D10.Text = MainTab[44, 10]; textBox_N45_D11.Text = MainTab[44, 11]; textBox_N45_D12.Text = MainTab[44, 12];
            textBox_N45_D13.Text = MainTab[44, 13]; textBox_N45_D14.Text = MainTab[44, 14];

            textBox_N46_D1.Text = MainTab[45, 1]; textBox_N46_D2.Text = MainTab[45, 2]; textBox_N46_D3.Text = MainTab[45, 3];
            textBox_N46_D4.Text = MainTab[45, 4]; textBox_N46_D5.Text = MainTab[45, 5]; textBox_N46_D6.Text = MainTab[45, 6];
            textBox_N46_D7.Text = MainTab[45, 7]; textBox_N46_D8.Text = MainTab[45, 8]; textBox_N46_D9.Text = MainTab[45, 9];
            textBox_N46_D10.Text = MainTab[45, 10]; textBox_N46_D11.Text = MainTab[45, 11]; textBox_N46_D12.Text = MainTab[45, 12];
            textBox_N46_D13.Text = MainTab[45, 13]; textBox_N46_D14.Text = MainTab[45, 14];

            textBox_N47_D1.Text = MainTab[46, 1]; textBox_N47_D2.Text = MainTab[46, 2]; textBox_N47_D3.Text = MainTab[46, 3];
            textBox_N47_D4.Text = MainTab[46, 4]; textBox_N47_D5.Text = MainTab[46, 5]; textBox_N47_D6.Text = MainTab[46, 6];
            textBox_N47_D7.Text = MainTab[46, 7]; textBox_N47_D8.Text = MainTab[46, 8]; textBox_N47_D9.Text = MainTab[46, 9];
            textBox_N47_D10.Text = MainTab[46, 10]; textBox_N47_D11.Text = MainTab[46, 11]; textBox_N47_D12.Text = MainTab[46, 12];
            textBox_N47_D13.Text = MainTab[46, 13]; textBox_N47_D14.Text = MainTab[46, 14];

            textBox_N48_D1.Text = MainTab[47, 1]; textBox_N48_D2.Text = MainTab[47, 2]; textBox_N48_D3.Text = MainTab[47, 3];
            textBox_N48_D4.Text = MainTab[47, 4]; textBox_N48_D5.Text = MainTab[47, 5]; textBox_N48_D6.Text = MainTab[47, 6];
            textBox_N48_D7.Text = MainTab[47, 7]; textBox_N48_D8.Text = MainTab[47, 8]; textBox_N48_D9.Text = MainTab[47, 9];
            textBox_N48_D10.Text = MainTab[47, 10]; textBox_N48_D11.Text = MainTab[47, 11]; textBox_N48_D12.Text = MainTab[47, 12];
            textBox_N48_D13.Text = MainTab[47, 13]; textBox_N48_D14.Text = MainTab[47, 14];

            textBox_N49_D1.Text = MainTab[48, 1]; textBox_N49_D2.Text = MainTab[48, 2]; textBox_N49_D3.Text = MainTab[48, 3];
            textBox_N49_D4.Text = MainTab[48, 4]; textBox_N49_D5.Text = MainTab[48, 5]; textBox_N49_D6.Text = MainTab[48, 6];
            textBox_N49_D7.Text = MainTab[48, 7]; textBox_N49_D8.Text = MainTab[48, 8]; textBox_N49_D9.Text = MainTab[48, 9];
            textBox_N49_D10.Text = MainTab[48, 10]; textBox_N49_D11.Text = MainTab[48, 11]; textBox_N49_D12.Text = MainTab[48, 12];
            textBox_N49_D13.Text = MainTab[48, 13]; textBox_N49_D14.Text = MainTab[48, 14];

            textBox_N50_D1.Text = MainTab[49, 1]; textBox_N50_D2.Text = MainTab[49, 2]; textBox_N50_D3.Text = MainTab[49, 3];
            textBox_N50_D4.Text = MainTab[49, 4]; textBox_N50_D5.Text = MainTab[49, 5]; textBox_N50_D6.Text = MainTab[49, 6];
            textBox_N50_D7.Text = MainTab[49, 7]; textBox_N50_D8.Text = MainTab[49, 8]; textBox_N50_D9.Text = MainTab[49, 9];
            textBox_N50_D10.Text = MainTab[49, 10]; textBox_N50_D11.Text = MainTab[49, 11]; textBox_N50_D12.Text = MainTab[49, 12];
            textBox_N50_D13.Text = MainTab[49, 13]; textBox_N50_D14.Text = MainTab[49, 14];
        }

        private void Form_N50_Load(object sender, EventArgs e)
        {
            btn_Reset.PerformClick();
        }

        private void btn_Reset_Click(object sender, EventArgs e)
        {
            label_Elapse.Text = "- . - - - s";
            label_Penalty.Text = "----";
            for (int i = 0; i < 50; i++)
                for (int j = 0; j < 15; j++)
                    if (j == 0)
                    {
                        MainTab[i, j] = "N" + (i + 1);
                    }
                    else
                        MainTab[i, j] = null;
            PrintSchedule();
            richTextBox1.Clear();
        }

        private void btn_Generate_Click(object sender, EventArgs e)
        {
            btn_Reset.PerformClick();
            int R_Nurse = 0;
            MainTab = OBJ_MainTab.Function_MainTab(MainTab, R_Nurse);
            var watch = System.Diagnostics.Stopwatch.StartNew();
            int Day_C = 1;
            int C_OffDays;
            string CheckTillOff = null;
            int Cell_OffD_Nurse_ptr;
            int SumNurWorkDay;
            int TotalOffRow;
            int[,] DB_nurse_poss_off = new int[30, 3];
            int DB_NextRow;
            int M_C, E_C;
            int C_OffDays_NOW;
            while (Day_C <= 14)
            {
                for (int i = 0; i < 30; i++)
                    for (int j = 0; j < 3; j++)
                        DB_nurse_poss_off[i, j] = -1;
                DB_NextRow = 0;

                C_OffDays_NOW = 0;
                M_C = 0;
                E_C = 0;
                for (int i = 0; i < 50; i++) ///////
                {
                    if (MainTab[i, Day_C] == "O")
                        C_OffDays_NOW++;
                    if (MainTab[i, Day_C] == "M")
                        M_C++;
                    if (MainTab[i, Day_C] == "E")
                        E_C++;
                }
                if (C_OffDays_NOW == 0)
                    C_OffDays = 20;
                else
                    C_OffDays = 20 - C_OffDays_NOW;

                for (int Nurse_Loop = 0; Nurse_Loop < 50; Nurse_Loop++)
                {
                    SumNurWorkDay = 0;
                    Cell_OffD_Nurse_ptr = Day_C - 1;
                    CheckTillOff = MainTab[Nurse_Loop, Cell_OffD_Nurse_ptr];
                    if (MainTab[Nurse_Loop, Day_C] != null)
                        continue;
                    else
                        while (CheckTillOff != "O")
                        {
                            if (Cell_OffD_Nurse_ptr <= 0)
                                break;
                            else
                                if (MainTab[Nurse_Loop, Cell_OffD_Nurse_ptr] == "M" || MainTab[Nurse_Loop, Cell_OffD_Nurse_ptr] == "E" || MainTab[Nurse_Loop, Cell_OffD_Nurse_ptr] == "W")
                                    SumNurWorkDay++;
                            Cell_OffD_Nurse_ptr--;
                            CheckTillOff = MainTab[Nurse_Loop, Cell_OffD_Nurse_ptr];
                        }

                    if (SumNurWorkDay >= 2)
                    {
                        TotalOffRow = 0;
                        for (int NurDays_Loop = 0; NurDays_Loop < 14; NurDays_Loop++)
                            if (MainTab[Nurse_Loop, NurDays_Loop] == "O")
                                TotalOffRow++;
                    }
                    else
                        continue;

                    if (TotalOffRow < 3 && Day_C <= 9)
                    {
                        DB_nurse_poss_off[DB_NextRow, 0] = Nurse_Loop;
                        DB_nurse_poss_off[DB_NextRow, 1] = SumNurWorkDay;
                        DB_nurse_poss_off[DB_NextRow, 2] = TotalOffRow;
                        DB_NextRow++;
                    }
                    else
                        if (TotalOffRow < 4 && Day_C >= 10)
                        {
                            DB_nurse_poss_off[DB_NextRow, 0] = Nurse_Loop;
                            DB_nurse_poss_off[DB_NextRow, 1] = SumNurWorkDay;
                            DB_nurse_poss_off[DB_NextRow, 2] = TotalOffRow;
                            DB_NextRow++;
                        }
                }
                if (DB_NextRow != 0)
                {
                    if (C_OffDays == DB_NextRow) // or == 10 bcz it's fixed value normally !!
                    {
                        for (int i = 0; i < DB_NextRow; i++)
                            MainTab[DB_nurse_poss_off[i, 0], Day_C] = "O";
                    }
                    else
                        if (C_OffDays == 1 && DB_NextRow == 1)
                            MainTab[DB_nurse_poss_off[0, 0], Day_C] = "O";
                        else
                            if (C_OffDays == 2 && DB_NextRow == 2)
                            {
                                // -- (till now no use)
                            }
                            else
                                if (C_OffDays == 3 && DB_NextRow == 3)
                                {
                                    MainTab[DB_nurse_poss_off[0, 0], Day_C] = "O";
                                    MainTab[DB_nurse_poss_off[1, 0], Day_C] = "O";
                                    MainTab[DB_nurse_poss_off[2, 0], Day_C] = "O";
                                }
                                else
                                    if (C_OffDays < DB_NextRow)
                                    {
                                        switch (C_OffDays)
                                        {
                                            case 1:
                                                int Max_Work = 0;
                                                int NO_Nurse = 0;
                                                for (int i = 0; i < DB_NextRow; i++)
                                                {
                                                    if (DB_nurse_poss_off[i, 1] > Max_Work)
                                                    {
                                                        Max_Work = DB_nurse_poss_off[i, 1];
                                                        NO_Nurse = DB_nurse_poss_off[i, 0];
                                                    }
                                                }
                                                MainTab[NO_Nurse, Day_C] = "O";
                                                break;
                                            case 2:
                                                // Finding the 2-max nurse2 (till now no use)
                                                int Max1WorkNurse = 0;
                                                int NO_MaxNurse1 = 0;
                                                for (int i = 0; i < DB_NextRow; i++)
                                                {
                                                    if (DB_nurse_poss_off[i, 1] > Max1WorkNurse)
                                                    {
                                                        Max1WorkNurse = DB_nurse_poss_off[i, 1];
                                                        NO_MaxNurse1 = DB_nurse_poss_off[i, 0];
                                                    }
                                                }
                                                int Max2WorkNurse = Max1WorkNurse;
                                                int NO_MaxNurse2 = 0;
                                                for (int i = 0; i < DB_NextRow; i++)
                                                {
                                                    if (DB_nurse_poss_off[i, 1] > Max2WorkNurse && DB_nurse_poss_off[i, 0] != NO_MaxNurse1)
                                                    {
                                                        Max2WorkNurse = DB_nurse_poss_off[i, 1];
                                                        NO_MaxNurse2 = DB_nurse_poss_off[i, 0];
                                                    }
                                                }
                                                MainTab[NO_MaxNurse1, Day_C] = "O";
                                                MainTab[NO_MaxNurse2, Day_C] = "O";
                                                break;
                                            case 3:
                                                // Finding the 3-max nurse2 (till now no use)
                                                int Mx1WorkNurse = DB_nurse_poss_off[0, 1];
                                                int N_MaxNurse1 = DB_nurse_poss_off[0, 0];
                                                for (int i = 1; i < DB_NextRow; i++)
                                                {
                                                    if (DB_nurse_poss_off[i, 1] > Mx1WorkNurse)
                                                    {
                                                        Mx1WorkNurse = DB_nurse_poss_off[i, 1];
                                                        N_MaxNurse1 = DB_nurse_poss_off[i, 0];
                                                    }
                                                }
                                                int Mx2WorkNurse = 0;
                                                int N_MaxNurse2 = 0;
                                                for (int i = 0; i < DB_NextRow; i++)
                                                {
                                                    if (DB_nurse_poss_off[i, 0] == N_MaxNurse1)
                                                        continue;
                                                    else
                                                        if (DB_nurse_poss_off[i, 1] > Mx2WorkNurse)
                                                        {
                                                            Mx2WorkNurse = DB_nurse_poss_off[i, 1];
                                                            N_MaxNurse2 = DB_nurse_poss_off[i, 0];
                                                        }
                                                }
                                                int Mx3WorkNurse = 0;
                                                int N_MaxNurse3 = 0;
                                                for (int i = 1; i < DB_NextRow; i++)
                                                {
                                                    if (DB_nurse_poss_off[i, 0] == N_MaxNurse1 || DB_nurse_poss_off[i, 0] == N_MaxNurse2)
                                                        continue;
                                                    else
                                                        if (DB_nurse_poss_off[i, 1] > Mx3WorkNurse)
                                                        {
                                                            Mx3WorkNurse = DB_nurse_poss_off[i, 1];
                                                            N_MaxNurse3 = DB_nurse_poss_off[i, 0];
                                                        }
                                                }
                                                MainTab[N_MaxNurse1, Day_C] = "O";
                                                MainTab[N_MaxNurse2, Day_C] = "O";
                                                MainTab[N_MaxNurse3, Day_C] = "O";
                                                break;
                                            case 4:
                                                // Finding the 4-max nurse2 (till now no use)
                                                int Mx1WrkNurse = DB_nurse_poss_off[0, 1];
                                                int N_MxNurse1 = DB_nurse_poss_off[0, 0];
                                                for (int i = 1; i < DB_NextRow; i++)
                                                {
                                                    if (DB_nurse_poss_off[i, 1] > Mx1WrkNurse)
                                                    {
                                                        Mx1WrkNurse = DB_nurse_poss_off[i, 1];
                                                        N_MxNurse1 = DB_nurse_poss_off[i, 0];
                                                    }
                                                }
                                                int Mx2WrkNurse = 0;
                                                int N_MxNurse2 = 0;
                                                for (int i = 0; i < DB_NextRow; i++)
                                                {
                                                    if (DB_nurse_poss_off[i, 0] == N_MxNurse1)
                                                        continue;
                                                    else
                                                        if (DB_nurse_poss_off[i, 1] > Mx2WrkNurse)
                                                        {
                                                            Mx2WrkNurse = DB_nurse_poss_off[i, 1];
                                                            N_MxNurse2 = DB_nurse_poss_off[i, 0];
                                                        }
                                                }
                                                int Mx3WrkNurse = 0;
                                                int N_MxNurse3 = 0;
                                                for (int i = 0; i < DB_NextRow; i++)
                                                {
                                                    if (DB_nurse_poss_off[i, 0] == N_MxNurse1 || DB_nurse_poss_off[i, 0] == N_MxNurse2)
                                                        continue;
                                                    else
                                                        if (DB_nurse_poss_off[i, 1] > Mx3WrkNurse)
                                                        {
                                                            Mx3WrkNurse = DB_nurse_poss_off[i, 1];
                                                            N_MxNurse3 = DB_nurse_poss_off[i, 0];
                                                        }
                                                }
                                                int Mx4WrkNurse = 0;
                                                int N_MxNurse4 = 0;
                                                for (int i = 0; i < DB_NextRow; i++)
                                                {
                                                    if (DB_nurse_poss_off[i, 0] == N_MxNurse1 || DB_nurse_poss_off[i, 0] == N_MxNurse2 || DB_nurse_poss_off[i, 0] == N_MxNurse3)
                                                        continue;
                                                    else
                                                        if (DB_nurse_poss_off[i, 1] > Mx4WrkNurse)
                                                        {
                                                            Mx4WrkNurse = DB_nurse_poss_off[i, 1];
                                                            N_MxNurse4 = DB_nurse_poss_off[i, 0];
                                                        }
                                                }
                                                MainTab[N_MxNurse1, Day_C] = "O";
                                                MainTab[N_MxNurse2, Day_C] = "O";
                                                MainTab[N_MxNurse3, Day_C] = "O";
                                                MainTab[N_MxNurse4, Day_C] = "O";
                                                break;
                                            default:
                                                MessageBox.Show("You need to add another case ;)");
                                                break;
                                        }
                                    }
                                    else
                                    {
                                        // this when have less poss-nurse than what we need from/of Off-Days
                                        for (int i = 0; i < DB_NextRow; i++)
                                            MainTab[DB_nurse_poss_off[i, 0], Day_C] = "O";
                                    }
                }
                M_C = 0;
                for (int i = 0; i < 50; i++)
                {
                    if (M_C == 10)
                        break;
                    else
                        if (MainTab[i, Day_C] == null)
                        {
                            MainTab[i, Day_C] = "M";
                            M_C++;
                        }
                }
                E_C = 0;
                for (int i = 0; i < 50; i++)
                {
                    if (E_C == 10)
                        break;
                    else
                        if (MainTab[i, Day_C] == null)
                        {
                            MainTab[i, Day_C] = "E";
                            E_C++;
                        }
                }
                for (int i = 0; i < 50; i++)
                    if (MainTab[i, Day_C] == null)
                        MainTab[i, Day_C] = "W";
                Day_C++;
                C_OffDays = 0;
            }

            for (int i = 0; i < 50; i++)
                if (MainTab[i, 6] == "W" && MainTab[i, 2] == "O")
                {
                    MainTab[i, 6] = "O";
                    MainTab[i, 2] = "E";
                }
            for (int i = 0; i < 50; i++)
                for (int j = 0; j < 15; j++)
                    if (MainTab[i, j] == "W")
                        MainTab[i, j] = "E";
            PrintSchedule();
            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;
            Double ELAPSE = Convert.ToDouble(elapsedMs);
            ELAPSE = ELAPSE / 1000;
            label_Elapse.Text = ELAPSE.ToString() + " s";
            // Calculate Penalty
            Cls_Penalty OBJ_Penalty = new Cls_Penalty();
            int N_Max = 50;
            int[,] Res_Pena = new int[N_Max, 2];
            Res_Pena = OBJ_Penalty.Function_Calculate_Penalty(MainTab, N_Max);
            label_Penalty.Text = Res_Pena[0, 0].ToString();
            for (int INC = 1; INC <= N_Max; INC++)
                richTextBox1.AppendText(Res_Pena[INC, 0].ToString() + " -> " + Res_Pena[INC, 1].ToString() + Environment.NewLine);
        }

    }
}
