private void Button1_Click(object sender, EventArgs e)
        {
            System.Windows.Input.Cursor oldCursor = Mouse.OverrideCursor;
            try
            {
                Mouse.OverrideCursor     = System.Windows.Input.Cursors.Wait;
                tmrCallBgWorker.Interval = 30000;
                GetAttendanceHR getAttendance = new GetAttendanceHR();
                attendanceDepts = getAttendance.GetAttendanceDeptsNew(dtpk_choose.Value);
                DisplayLabelCompany();
                ListAttendance = attendanceDepts.GroupBy(u => u.BigDeptCode)
                                 .Select(grp => grp.ToList())
                                 .ToList();
                ResourceDept1        = new HumanResourceDept(ListAttendance[0]);
                ResourceDept2        = new HumanResourceDept(ListAttendance[1]);
                ResourceDept1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                              | System.Windows.Forms.AnchorStyles.Left)
                                                                             | System.Windows.Forms.AnchorStyles.Right)));
                ResourceDept2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                              | System.Windows.Forms.AnchorStyles.Left)
                                                                             | System.Windows.Forms.AnchorStyles.Right)));
                IntializeforTableLayout(ListAttendance, CurrentStart);
                //pic_loader.Visible = false;

                tmrCallBgWorker.Start();
                hRReport = HRReportStatus.start;
                btn_HRReport.BackColor = Color.Green;
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "", ex.Message);
            }
            finally
            {
                Mouse.OverrideCursor = oldCursor;
            }
        }
        public void IntializeforTableLayout(List <List <AttendanceDept> > attendanceDepts, int Start)
        {
            layoutMain.Visible = false;
            layoutMain.Controls.Clear();
            layoutMain.ColumnStyles.Clear();
            layoutMain.RowStyles.Clear();

            layoutMain.ColumnCount = 1;
            layoutMain.RowCount    = 2;
            float Percerntwidth  = (float)(100 / layoutMain.ColumnCount);
            float Percerntheight = (float)(100 / layoutMain.RowCount);

            for (int i = 0; i < layoutMain.ColumnCount - 1; i++)
            {
                layoutMain.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, Percerntwidth));
            }
            layoutMain.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 - (Percerntwidth * (layoutMain.ColumnCount - 1))));
            for (int i = 0; i < layoutMain.RowCount - 1; i++)
            {
                layoutMain.RowStyles.Add(new RowStyle(SizeType.Percent, Percerntheight));
            }
            layoutMain.RowStyles.Add(new RowStyle(SizeType.Percent, 100 - Percerntheight * (layoutMain.RowCount - 1)));
            if (attendanceDepts == null)
            {
                return;
            }
            int count = Start;

            if (count < ListAttendance.Count)
            {
                ResourceDept1.Dispose();


                GC.SuppressFinalize(ResourceDept1);
                ResourceDept1 = null;
                // HumanResourceDept.attendanceDept = ListAttendance[count];
                ResourceDept1 = new HumanResourceDept(ListAttendance[count]);

                ClearMemory.CleanMemory();
                ResourceDept1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                              | System.Windows.Forms.AnchorStyles.Left)
                                                                             | System.Windows.Forms.AnchorStyles.Right)));
                //   HumanResourceDept.attendanceDept = ListAttendance[count];


                layoutMain.Controls.Add(ResourceDept1, 0, 0);
            }

            count++;
            if (count < ListAttendance.Count)
            {
                ResourceDept2.Dispose();
                GC.SuppressFinalize(ResourceDept2);
                ResourceDept2 = null;

                ClearMemory.CleanMemory();
                ResourceDept2        = new HumanResourceDept(ListAttendance[count]);
                ResourceDept2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                              | System.Windows.Forms.AnchorStyles.Left)
                                                                             | System.Windows.Forms.AnchorStyles.Right)));
                // HumanResourceDept.attendanceDept = ListAttendance[count];

                layoutMain.Controls.Add(ResourceDept2, 0, 1);
            }
            //  count++;
            //for (int i = 0; i < layoutMain.ColumnCount; i++)
            //{
            //    for (int j = 0; j < layoutMain.RowCount; j++)
            //    {

            //        if (count < attendanceDepts.Count)
            //        {

            //            //  ResourceDept = new HumanResourceDept(attendanceDepts[count]);
            //       //     ResourceDept.attendanceDept = attendanceDepts[count];
            //            ResourceDept.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            //    | System.Windows.Forms.AnchorStyles.Left)
            //    | System.Windows.Forms.AnchorStyles.Right)));
            //            layoutMain.Controls.Add(ResourceDept, i, j);


            //        //    count++;
            //        }
            //    }
            //}

            layoutMain.Visible = true;



            ResourceDept = null;
            ClearMemory.CleanMemory();
        }