private void create_default(AxfpSpread arg_grid)
        {
            try
            {
                int    iRowHeight, iFontSize;
                double iColWidth;

                if (_status == "DMC")
                {
                    iRowHeight = 18;
                    iColWidth  = 6.5;
                    iFontSize  = 12;
                }
                else
                {
                    iRowHeight = 20;
                    iColWidth  = 9.8;
                    iFontSize  = 12;
                }

                axGrid.Reset();
                axGrid.DisplayColHeaders        = false;
                axGrid.DisplayRowHeaders        = false;
                axGrid.ActiveCellHighlightStyle = ActiveCellHighlightStyleConstants.ActiveCellHighlightStyleOff;
                axGrid.ColHeaderRows            = 0;
                axGrid.ScrollBars  = ScrollBarsConstants.ScrollBarsNone;
                axGrid.Font        = new System.Drawing.Font("Calibri", iFontSize);
                axGrid.BorderStyle = BorderStyleConstants.BorderStyleNone;

                // axGrid.BorderStyle = BorderStyleConstants.BorderStyleNone;
                axGrid.set_RowHeight(1, 0.5);
                //axGrid.set_RowHeight(20, 9);
                //axGrid.set_ColWidth((int)G.S1_Blank, 5.37);
                axGrid.set_ColWidth(1, 0.5);
                //axGrid.set_ColWidth((int)G.S3_Blank, 5.37);
                //axGrid.set_ColWidth((int)G.Blank1, 13.62);
                //axGrid.set_ColWidth((int)G.Blank2, 13.62);
                axGrid.TypeHAlign = TypeHAlignConstants.TypeHAlignCenter;
                axGrid.TypeVAlign = TypeVAlignConstants.TypeVAlignCenter;
                axGrid.SetCellBorder(1, 1, 150, axGrid.MaxRows, CellBorderIndexConstants.CellBorderIndexLeft, 0, CellBorderStyleConstants.CellBorderStyleBlank);
                axGrid.SetCellBorder(1, 1, 150, axGrid.MaxRows, CellBorderIndexConstants.CellBorderIndexBottom, 0, CellBorderStyleConstants.CellBorderStyleBlank);
                //  axGrid.SetCellBorder((int)G.S1_M1_L_Plan, 1, (int)G.S3_M2_R_Act, axGrid.MaxRows, CellBorderIndexConstants.CellBorderIndexTop, 0, CellBorderStyleConstants.CellBorderStyleBlank);


                //  axGrid.SetCellBorder((int)G.S1_M1_L_Tar, 1, (int)G.S3_M2_R_Cur, axGrid.MaxRows, CellBorderIndexConstants.CellBorderIndexOutline, 0, CellBorderStyleConstants.CellBorderStyleBlank);


                for (int irow = 2; irow <= 50; irow++)
                {
                    axGrid.set_RowHeight(irow, iRowHeight);
                }

                for (int icol = 2; icol <= 150; icol++)
                {
                    axGrid.set_ColWidth(icol, iColWidth);
                }
            }
            catch (Exception)
            { }
        }
        private void DisplayGridDMP(DataTable arg_dt, AxfpSpread arg_grid)
        {
            try
            {
                _countN  = 0;
                _countNU = 0;
                _countP  = 0;
                _countR  = 0;
                if (arg_dt == null || arg_dt.Rows.Count == 0)
                {
                    return;
                }
                // axGrid.ClearRange(0, 0, 50, 50, true);
                create_default(arg_grid);
                _Loc_plan_DMP.Clear();
                //_row1 = Convert.ToInt32(arg_dt.Rows[0]["Row1"]);
                //_row2 = Convert.ToInt32(arg_dt.Rows[0]["Row2"]);
                //_row3 = Convert.ToInt32(arg_dt.Rows[0]["Row3"]);
                int row_s = 3;
                int irow  = row_s;
                int icol  = 2;
                lbl_plan.Text   = arg_dt.Rows[0]["TOT_PLAN"].ToString();
                lbl_actual.Text = arg_dt.Rows[0]["TOT_ACT"].ToString();

                arg_grid.set_ColWidth(icol, 5);
                MachineHeadDMP(icol, irow, 0, arg_dt, arg_grid);
                irow += 2;
                MachineBodyDMP(icol, irow, 0, arg_dt, arg_grid);
                irow++;

                for (int i = 1; i < arg_dt.Rows.Count; i++)
                {
                    if (arg_dt.Rows[i]["MACHINE_NAME"].ToString() == arg_dt.Rows[i - 1]["MACHINE_NAME"].ToString())
                    {
                        MachineBodyDMP(icol, irow, i, arg_dt, arg_grid);
                        irow++;
                    }
                    else
                    {
                        icol += 4;
                        arg_grid.set_ColWidth(icol, 5);
                        irow = row_s;
                        MachineHeadDMP(icol, irow, i, arg_dt, arg_grid);
                        irow += 2;
                        MachineBodyDMP(icol, irow, i, arg_dt, arg_grid);
                        irow++;
                    }
                }
                set_qty();
                // if (_Loc_yellow.Count > 0) tmr_blind.Start();
                // else tmr_blind.Stop();
            }
            catch
            {
            }
        }
        private void blind(List <string> arg_list, AxfpSpread arg_grid)
        {
            try
            {
                if (arg_list.Count <= 0)
                {
                    return;
                }
                string[] str;

                for (int i = _iColor; i < arg_list.Count; i += 3)
                {
                    str        = arg_list[i].Split(' ');
                    axGrid.Col = Convert.ToInt32(str[0].ToString());
                    axGrid.Row = Convert.ToInt32(str[1].ToString());
                    if (axGrid.BackColor == Color.Yellow)
                    {
                        if (axGrid.Text == "")
                        {
                            axGrid.BackColor = Color.Red;
                        }
                        else
                        {
                            axGrid.BackColor = Color.Green;
                        }

                        axGrid.ForeColor = Color.White;
                    }
                    else
                    {
                        axGrid.BackColor = Color.Yellow;
                        axGrid.ForeColor = Color.Black;
                    }
                }
                if (_iColor == 3)
                {
                    _iColor = 0;
                }
                else
                {
                    _iColor++;
                }
            }
            catch (Exception)
            { }
        }
        public void MachineBodyDMP(int arg_icol, int arg_irow, int arg_idt, DataTable arg_dt, AxfpSpread arg_grid)
        {
            try
            {
                arg_grid.SetCellBorder(arg_icol, arg_irow, arg_icol + 2, arg_irow, CellBorderIndexConstants.CellBorderIndexLeft, 0, CellBorderStyleConstants.CellBorderStyleSolid);
                arg_grid.SetCellBorder(arg_icol, arg_irow, arg_icol + 3, arg_irow, CellBorderIndexConstants.CellBorderIndexLeft, 0, CellBorderStyleConstants.CellBorderStyleSolid);
                arg_grid.SetCellBorder(arg_icol, arg_irow, arg_icol + 2, arg_irow, CellBorderIndexConstants.CellBorderIndexBottom, 0, CellBorderStyleConstants.CellBorderStyleSolid);

                arg_grid.set_RowHeight(arg_irow, 30);


                arg_grid.Col  = arg_icol;
                arg_grid.Row  = arg_irow;
                arg_grid.Text = arg_dt.Rows[arg_idt]["STA"].ToString();

                arg_grid.Col  = arg_icol + 1;
                arg_grid.Text = arg_dt.Rows[arg_idt]["PLAN_L"].ToString();
                if (arg_dt.Rows[arg_idt]["USE_L"].ToString() == "Y")
                {
                    if (arg_dt.Rows[arg_idt]["L_color_B_value"].ToString() == "LIME")
                    {
                        arg_grid.BackColor = Color.Lime;
                        _countP++;
                    }
                    else if (arg_dt.Rows[arg_idt]["L_color_B_value"].ToString() == "RED")
                    {
                        arg_grid.BackColor = Color.Red;
                        _countN++;
                    }
                    else
                    {
                        arg_grid.BackColor = Color.Yellow;
                        _countR++;
                    }

                    // arg_grid.BackColor = Color.FromName(arg_dt.Rows[arg_idt]["L_color_B_value"].ToString());
                }
                else
                {
                    arg_grid.BackColor = Color.LightGray;
                    _countNU++;
                }
                arg_grid.ForeColor = Color.FromName(arg_dt.Rows[arg_idt]["L_color_F_value"].ToString());

                arg_grid.Col  = arg_icol + 2;
                arg_grid.Text = arg_dt.Rows[arg_idt]["PLAN_R"].ToString();
                if (arg_dt.Rows[arg_idt]["USE_R"].ToString() == "Y")
                {
                    if (arg_dt.Rows[arg_idt]["R_color_B_value"].ToString() == "LIME")
                    {
                        arg_grid.BackColor = Color.Lime;
                        _countP++;
                    }
                    else if (arg_dt.Rows[arg_idt]["R_color_B_value"].ToString() == "RED")
                    {
                        arg_grid.BackColor = Color.Red;
                        _countN++;
                    }
                    else
                    {
                        arg_grid.BackColor = Color.Yellow;
                        _countR++;
                    }

                    // arg_grid.BackColor = Color.FromName(arg_dt.Rows[arg_idt]["L_color_B_value"].ToString());
                }
                else
                {
                    arg_grid.BackColor = Color.LightGray;
                    _countNU++;
                }
                // arg_grid.BackColor = Color.FromName(arg_dt.Rows[arg_idt]["R_color_B_value"].ToString());
                arg_grid.ForeColor = Color.FromName(arg_dt.Rows[arg_idt]["R_color_F_value"].ToString());


                if (arg_dt.Rows[arg_idt]["L_Status"].ToString() == "1")
                {
                    _Loc_plan_DMP.Add((arg_icol + 1) + " " + arg_irow + " " + arg_dt.Rows[arg_idt]["machine_cd"].ToString());
                }
                if (arg_dt.Rows[arg_idt]["R_Status"].ToString() == "1")
                {
                    _Loc_plan_DMP.Add((arg_icol + 2) + " " + arg_irow + " " + arg_dt.Rows[arg_idt]["machine_cd"].ToString());
                }

                if (arg_dt.Rows[arg_idt]["L_Status"].ToString() == "2")
                {
                    _Loc_change_DMP.Add((arg_icol + 1) + " " + arg_irow + " " + arg_dt.Rows[arg_idt]["machine_cd"].ToString());
                }
                if (arg_dt.Rows[arg_idt]["R_Status"].ToString() == "2")
                {
                    _Loc_change_DMP.Add((arg_icol + 2) + " " + arg_irow + " " + arg_dt.Rows[arg_idt]["machine_cd"].ToString());
                }
            }
            catch (Exception)
            { }
        }
        private void MachineHeadDMP(int arg_icol, int arg_irow, int arg_idt, DataTable arg_dt, AxfpSpread arg_grid)
        {
            try
            {
                arg_grid.Col        = arg_icol;
                arg_grid.Row        = arg_irow;
                arg_grid.Text       = arg_dt.Rows[arg_idt]["MACHINE_NAME"].ToString();
                arg_grid.Font       = new System.Drawing.Font("Calibri", 20, FontStyle.Bold);
                arg_grid.BackColor  = Color.DodgerBlue;
                arg_grid.ForeColor  = Color.White;
                arg_grid.TypeVAlign = TypeVAlignConstants.TypeVAlignCenter;
                arg_grid.AddCellSpan(arg_icol, arg_irow, 3, 1);

                //arg_grid.SetCellBorder(icol, irow, icol + 2, irow + 1, CellBorderIndexConstants.CellBorderIndexOutline, 0, CellBorderStyleConstants.CellBorderStyleSolid);
                // arg_grid.SetCellBorder(icol, irow, icol + 3, irow + 1, CellBorderIndexConstants.CellBorderIndexLeft, 0, CellBorderStyleConstants.CellBorderStyleSolid);
                //arg_grid.SetCellBorder(icol, irow, icol + 2, irow +1, CellBorderIndexConstants.CellBorderIndexBottom, 0, CellBorderStyleConstants.CellBorderStyleSolid);
                //arg_grid.SetCellBorder(icol, irow, icol + 2, irow, CellBorderIndexConstants.CellBorderIndexTop, 0, CellBorderStyleConstants.CellBorderStyleSolid);


                arg_irow++;
                arg_grid.Row       = arg_irow;
                arg_grid.Col       = arg_icol;
                arg_grid.Text      = "STA";
                arg_grid.BackColor = Color.LightSkyBlue;
                //  arg_grid.ForeColor = Color.White;
                arg_grid.Font = new System.Drawing.Font("Calibri", 15, FontStyle.Bold);

                arg_grid.Col       = arg_icol + 1;
                arg_grid.Text      = "L";
                arg_grid.BackColor = Color.LightSkyBlue;
                //  arg_grid.ForeColor = Color.White;
                arg_grid.Font = new System.Drawing.Font("Calibri", 15, FontStyle.Bold);

                arg_grid.Col       = arg_icol + 2;
                arg_grid.Text      = "R";
                arg_grid.BackColor = Color.LightSkyBlue;
                //  arg_grid.ForeColor = Color.White;
                arg_grid.Font = new System.Drawing.Font("Calibri", 15, FontStyle.Bold);
            }
            catch
            { }
        }
        private void DisplayGridDMC(DataTable arg_dt, AxfpSpread arg_grid)
        {
            try
            {
                _countP  = 0;
                _countN  = 0;
                _countNU = 0;
                _countR  = 0;

                axGrid.ClearRange(0, 0, 50, 50, true);
                create_default(arg_grid);
                if (arg_dt == null || arg_dt.Rows.Count == 0)
                {
                    return;
                }


                _Loc_change_DMC.Clear();
                int row_s2 = 15;
                int row_s1 = 7;
                int row_s3 = 23;
                int col_s3 = 6;
                int irow   = row_s2;
                int icol   = 2;

                MachineBodyDMC(icol, irow, 0, arg_dt, arg_grid);
                MachineCenterText(icol, irow, 0, arg_dt, arg_grid);
                //MachineCenterBG(icol, irow, 0, arg_dt, arg_grid);
                lbl_plan.Text   = arg_dt.Rows[0]["TOT_PLAN"].ToString();
                lbl_actual.Text = arg_dt.Rows[0]["TOT_ACT"].ToString();
                for (int i = 1; i < arg_dt.Rows.Count; i++)
                {
                    if (arg_dt.Rows[i]["machine_cd"].ToString() == arg_dt.Rows[i - 1]["machine_cd"].ToString())
                    {
                        if (arg_dt.Rows[i]["direction"].ToString() == arg_dt.Rows[i - 1]["direction"].ToString())
                        {
                            if (arg_dt.Rows[i]["direction"].ToString() == "1")
                            {
                                irow--;
                                //   MachineCenterBG(icol, irow, i, arg_dt, arg_grid);
                            }
                            else if (arg_dt.Rows[i]["direction"].ToString() == "2")
                            {
                                icol++;
                            }
                            else if (arg_dt.Rows[i]["direction"].ToString() == "3")
                            {
                                irow++;
                            }
                            else
                            {
                                icol--;
                            }
                            MachineBodyDMC(icol, irow, i, arg_dt, arg_grid);
                        }
                        else
                        {
                            if (arg_dt.Rows[i]["direction"].ToString() == "2")
                            {
                                irow--;
                                icol++;
                                MachineHeadDMC(icol, irow - 1, i, arg_dt, arg_grid);
                            }
                            else if (arg_dt.Rows[i]["direction"].ToString() == "3")
                            {
                                icol++;
                                irow++;
                            }
                            else if (arg_dt.Rows[i]["direction"].ToString() == "4")
                            {
                                irow++;
                                icol--;
                            }
                            MachineBodyDMC(icol, irow, i, arg_dt, arg_grid);
                        }
                    }
                    else
                    {
                        if (arg_dt.Rows[i]["line_id"].ToString() == "2")
                        {
                            irow = row_s2;
                            icol = icol + 6;
                            //  axGrid.SetText(icol, irow, "2");
                        }
                        else if (arg_dt.Rows[i]["line_id"].ToString() == "1")
                        {
                            irow = row_s1;
                            icol--;
                            //   axGrid.SetText(icol, irow,"1");
                        }
                        else
                        {
                            irow    = row_s3;
                            col_s3 += 8;
                            icol    = col_s3;
                        }
                        MachineBodyDMC(icol, irow, i, arg_dt, arg_grid);
                        MachineCenterText(icol, irow, i, arg_dt, arg_grid);
                        //  MachineCenterBG(icol, irow, i, arg_dt, arg_grid);
                    }
                }
                set_qty();

                // if (_Loc_change.Count > 0) tmr_blind.Start();
                // else tmr_blind.Stop();
            }
            catch
            { }
        }
        public void MachineBodyDMC(int arg_col, int arg_row, int arg_idt, DataTable arg_dt, AxfpSpread arg_grid)
        {
            try
            {
                arg_grid.SetCellBorder(arg_col, arg_row, arg_col, arg_row, CellBorderIndexConstants.CellBorderIndexLeft, 0, CellBorderStyleConstants.CellBorderStyleSolid);
                arg_grid.SetCellBorder(arg_col + 1, arg_row, arg_col + 1, arg_row, CellBorderIndexConstants.CellBorderIndexLeft, 0, CellBorderStyleConstants.CellBorderStyleSolid);
                arg_grid.SetCellBorder(arg_col, arg_row, arg_col, arg_row, CellBorderIndexConstants.CellBorderIndexBottom, 0, CellBorderStyleConstants.CellBorderStyleSolid);
                arg_grid.SetCellBorder(arg_col, arg_row, arg_col, arg_row, CellBorderIndexConstants.CellBorderIndexTop, 0, CellBorderStyleConstants.CellBorderStyleSolid);

                arg_grid.Row  = arg_row;
                arg_grid.Col  = arg_col;
                arg_grid.Text = _dt_layout_DMC.Rows[arg_idt]["size_plan"].ToString();
                if (arg_dt.Rows[arg_idt]["USE_YN"].ToString() == "Y")
                {
                    if (arg_dt.Rows[arg_idt]["color_B_value"].ToString() == "LIME")
                    {
                        arg_grid.BackColor = Color.Lime;
                        _countP++;
                    }
                    else if (arg_dt.Rows[arg_idt]["color_B_value"].ToString() == "RED")
                    {
                        arg_grid.BackColor = Color.Red;
                        _countN++;
                    }
                    else
                    {
                        arg_grid.BackColor = Color.Yellow;
                        _countR++;
                    }

                    // arg_grid.BackColor = Color.FromName(arg_dt.Rows[arg_idt]["L_color_B_value"].ToString());
                }
                else
                {
                    arg_grid.BackColor = Color.LightGray;
                    _countNU++;
                }
                //  arg_grid.BackColor = Color.FromName(arg_dt.Rows[arg_idt]["color_B_value"].ToString());
                arg_grid.ForeColor = Color.FromName(arg_dt.Rows[arg_idt]["color_F_value"].ToString());


                //if (arg_dt.Rows[arg_idt]["Status"].ToString() == "1")
                //    _Loc_plan_DMC.Add(arg_col + " " + arg_row + " " + arg_dt.Rows[arg_idt]["machine_id"].ToString());
                //if (arg_dt.Rows[arg_idt]["Status"].ToString() == "2")
                //    _Loc_change_DMC.Add(arg_col  + " " + arg_row + " " + arg_dt.Rows[arg_idt]["machine_id"].ToString());

                //if (arg_dt.Rows[arg_idt]["direction"].ToString() == "1")
                //{
                //    arg_col++;
                //}
                //else if (arg_dt.Rows[arg_idt]["direction"].ToString() == "2")
                //{
                //    arg_row++;
                //}
                //else if (arg_dt.Rows[arg_idt]["direction"].ToString() == "3")
                //{
                //    arg_col--;
                //}
                //else if (arg_dt.Rows[arg_idt]["direction"].ToString() == "4")
                //{
                //    arg_row--;
                //}

                //arg_grid.Row = arg_row;
                //arg_grid.Col = arg_col;

                //switch (_dt_layout_DMC.Rows[arg_idt]["STATION_CD"].ToString())
                //{
                //    case "05":
                //    case "09":
                //    case "13":
                //    case "16":
                //        arg_grid.Text += "/" + _dt_layout_DMC.Rows[arg_idt]["STATION_CD"].ToString();
                //        break;
                //    default:
                //        arg_grid.Text = _dt_layout_DMC.Rows[arg_idt]["STATION_CD"].ToString();
                //        break;
                //}
            }
            catch (Exception)
            { }
        }
        //private void MachineCenterBG(int arg_col, int arg_row, int arg_idt, DataTable arg_dt, AxfpSpread arg_grid)
        //{
        //    int c = Convert.ToInt32(arg_dt.Rows[arg_idt]["line"].ToString());

        //    for (int i = 1; i <= c; i++)
        //    {

        //        arg_grid.Row = arg_row;
        //        arg_grid.Col = arg_col + i;
        //        arg_grid.BackColor = Color.FromArgb(242, 226, 213);
        //    }

        //    arg_grid.SetCellBorder(arg_col + 1, arg_row, arg_col + c, arg_row
        //                              , CellBorderIndexConstants.CellBorderIndexLeft, 0xd5e2f2
        //                              , CellBorderStyleConstants.CellBorderStyleSolid);
        //    arg_grid.SetCellBorder(arg_col + 1, arg_row, arg_col + c, arg_row
        //                          , CellBorderIndexConstants.CellBorderIndexBottom, 0xd5e2f2
        //                          , CellBorderStyleConstants.CellBorderStyleSolid);

        //}


        private void MachineHeadDMC(int arg_col, int arg_row, int arg_idt, DataTable arg_dt, AxfpSpread arg_grid)
        {
            try
            {
                //axGrid.AddCellSpan(icol, irow
                //                    , Convert.ToInt32(_dt_layout.Rows[idt]["line"].ToString()) * 2
                //                    , 1);
                arg_grid.Col = arg_col;
                arg_grid.Row = arg_row;
                arg_grid.set_RowHeight(arg_row, 20);
                arg_grid.Text       = arg_dt.Rows[arg_idt]["MACHINE_NAME"].ToString();
                arg_grid.Font       = new System.Drawing.Font("Calibri", 15, FontStyle.Bold);
                arg_grid.BackColor  = Color.DodgerBlue;
                arg_grid.ForeColor  = Color.White;
                arg_grid.TypeVAlign = TypeVAlignConstants.TypeVAlignCenter;

                arg_grid.AddCellSpan(arg_col, arg_row
                                     , Convert.ToInt32(arg_dt.Rows[arg_idt]["line"].ToString())
                                     , 1);
            }
            catch
            {
            }
        }
        private void MachineCenterText(int arg_col, int arg_row, int arg_idt, DataTable arg_dt, AxfpSpread arg_grid)
        {
            int iColPlus = Convert.ToInt32(arg_dt.Rows[arg_idt]["col_cen"]);
            int iRowPlus = Convert.ToInt32(arg_dt.Rows[arg_idt]["row_cen"]);

            //arg_grid.AddCellSpan(arg_col + (iColPlus - 1), arg_row + (iRowPlus - 1), iColPlus, iRowPlus);
            arg_grid.AddCellSpan(arg_col + 1, arg_row - (iRowPlus - 1), iColPlus, iRowPlus);
            arg_grid.Col = arg_col + 1;
            arg_grid.Row = arg_row - (iRowPlus - 1);
            arg_grid.TypeEditMultiLine = true;
            arg_grid.FontBold          = true;
            arg_grid.FontSize          = 18f;
            arg_grid.BackColor         = Color.FromArgb(242, 226, 213);

            arg_grid.SetText(arg_col + 1, arg_row - (iRowPlus - 1),
                             arg_dt.Rows[arg_idt]["text_cen"].ToString().Replace("-", "\n"));


            //int c = Convert.ToInt32(arg_dt.Rows[arg_idt]["line"].ToString());

            //for (int i = 1; i <= c; i++)
            //{

            //    arg_grid.Row = arg_row;
            //    arg_grid.Col = arg_col + i;
            //    arg_grid.BackColor = Color.FromArgb(244, 140, 65);
            //}

            //arg_grid.SetCellBorder(arg_col + 1, arg_row, arg_col + c, arg_row
            //                          , CellBorderIndexConstants.CellBorderIndexLeft, 0x418cf4
            //                          , CellBorderStyleConstants.CellBorderStyleSolid);
            //arg_grid.SetCellBorder(arg_col + 1, arg_row, arg_col + c, arg_row
            //                      , CellBorderIndexConstants.CellBorderIndexBottom, 0x418cf4
            //                      , CellBorderStyleConstants.CellBorderStyleSolid);
        }