public static bool GetShopDocData(ComboBoxEx Op1Combobox, out Dictionary <DB_TEMain, IList <Com_ShopDoc> > DicShopDocData)
        {
            DicShopDocData = new Dictionary <DB_TEMain, IList <Com_ShopDoc> >();
            try
            {
                for (int i = 0; i < OutputForm.TEPanel.Rows.Count; i++)
                {
                    if (((bool)OutputForm.TEPanel.GetCell(i, 0).Value) == false || OutputForm.TEPanel.GetCell(i, 1).Value.ToString() != "ShopDoc")
                    {
                        continue;
                    }

                    Sys_TEExcel teExcelSrNo = session.QueryOver <Sys_TEExcel>()
                                              .Where(x => x.teExcelType == OutputForm.TEPanel.GetCell(i, 1).Value.ToString())
                                              .SingleOrDefault <Sys_TEExcel>();
                    if (teExcelSrNo == null)
                    {
                        continue;
                    }
                    Com_TEMain comTEMain = session.QueryOver <Com_TEMain>()
                                           .Where(x => x.comPartOperation == (Com_PartOperation)Op1Combobox.SelectedItem)
                                           .Where(x => x.sysTEExcel == teExcelSrNo)
                                           .Where(x => x.ncGroupName == OutputForm.TEPanel.GetCell(i, 2).Value.ToString())
                                           .SingleOrDefault <Com_TEMain>();

                    DB_TEMain           sDB_TEMain   = new DB_TEMain();
                    IList <Com_ShopDoc> comDimension = session.QueryOver <Com_ShopDoc>()
                                                       .Where(x => x.comTEMain == comTEMain)
                                                       .List <Com_ShopDoc>();
                    sDB_TEMain.comTEMain             = comTEMain;
                    sDB_TEMain.excelTemplateFilePath = string.Format(@"{0}\{1}\{2}\{3}\{4}.xls"
                                                                     , OutputForm.EnvVariables.env
                                                                     , "TE_Config"
                                                                     , "Config"
                                                                     , OutputForm.TEPanel.GetCell(i, 1).Value.ToString()
                                                                     , OutputForm.TEPanel.GetCell(i, 3).Value.ToString());
                    sDB_TEMain.ncGroupName = comTEMain.ncGroupName;
                    sDB_TEMain.factory     = OutputForm.TEPanel.GetCell(i, 3).Value.ToString();
                    sDB_TEMain.partDesc    = (session.QueryOver <Com_PEMain>()
                                              .Where(x => x.peSrNo == ((Com_PartOperation)Op1Combobox.SelectedItem).comPEMain.peSrNo)
                                              .SingleOrDefault <Com_PEMain>()).partDes;
                    DicShopDocData.Add(sDB_TEMain, comDimension);


                    //sDB_TEMain.comTEMain = comTEMain;
                    //sDB_TEMain.excelTemplateFilePath = string.Format(@"{0}\{1}.xls", OutputForm.serverTEConfig, OutputForm.TEPanel.GetCell(i, 3).Value.ToString());
                    //sDB_TEMain.factory = OutputForm.TEPanel.GetCell(i, 3).Value.ToString();
                    //DicShopDocData.Add(sDB_TEMain, comDimension);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
            return(true);
        }
        public static bool SetTEPanelData(Com_PartOperation comPartOperation, string cus, string partNo, string cusVer, string opVer, string op1, ref GridPanel TEPanel)
        {
            try
            {
                List <string>             ExcelData = new List <string>();
                GridComboBoxExEditControl singleCell;
                IList <Com_TEMain>        comTEMain = session.QueryOver <Com_TEMain>()
                                                      .Where(x => x.comPartOperation == comPartOperation).List <Com_TEMain>();
                int TECount = -1;
                foreach (Com_TEMain i in comTEMain)
                {
                    #region 由teExcelSrNo取得對應的ExcelType
                    Sys_TEExcel sysTEExcel = session.QueryOver <Sys_TEExcel>()
                                             .Where(x => x.teExcelSrNo == i.sysTEExcel.teExcelSrNo).SingleOrDefault <Sys_TEExcel>();
                    ExcelData = new List <string>();
                    status    = GetExcelForm.GetTEExcelForm(sysTEExcel.teExcelType, out ExcelData);
                    if (!status)
                    {
                        return(false);
                    }
                    #endregion

                    #region 插入Panel
                    TECount++;
                    object[] o = new object[] { false, sysTEExcel.teExcelType, i.ncGroupName, ""
                                                , string.Format("{0}_{1}_{2}資料夾"
                                                                , partNo
                                                                , cusVer
                                                                , opVer) };
                    TEPanel.Rows.Add(new GridRow(o));
                    TEPanel.GetCell(TECount, 0).Value      = false;
                    TEPanel.GetCell(TECount, 3).EditorType = typeof(GridComboBoxExEditControl);
                    singleCell = TEPanel.GetCell(TECount, 3).EditControl as GridComboBoxExEditControl;
                    //singleCell.Items.Add("");
                    foreach (string tempStr in ExcelData)
                    {
                        singleCell.Items.Add(tempStr);
                    }

                    if (singleCell.Items.Count == 1)
                    {
                        TEPanel.GetCell(TECount, 3).Value = singleCell.Items[0].ToString();
                    }
                    else
                    {
                        TEPanel.GetCell(TECount, 3).Value = "(雙擊)選擇表單";
                    }
                    #endregion
                }

                #region 取得ToolList的表單格式
                ExcelData = new List <string>();
                status    = GetExcelForm.GetTEExcelForm("ToolList", out ExcelData);
                if (!status)
                {
                    return(false);
                }
                #endregion

                foreach (Com_TEMain i in comTEMain)
                {
                    #region 找ToolList資料,並插入Panel
                    IList <Com_ToolList> comToolList = session.QueryOver <Com_ToolList>().Where(x => x.comTEMain == i).List();
                    if (comToolList.Count == 0)
                    {
                        continue;
                    }
                    else
                    {
                        TECount++;
                        object[] o = new object[] { false, "ToolList", i.ncGroupName, ""
                                                    , string.Format("{0}_{1}_{2}資料夾"
                                                                    , partNo
                                                                    , cusVer
                                                                    , opVer) };
                        TEPanel.Rows.Add(new GridRow(o));
                        TEPanel.GetCell(TECount, 0).Value      = false;
                        TEPanel.GetCell(TECount, 3).EditorType = typeof(GridComboBoxExEditControl);
                        singleCell = TEPanel.GetCell(TECount, 3).EditControl as GridComboBoxExEditControl;
                        //singleCell.Items.Add("");
                        foreach (string tempStr in ExcelData)
                        {
                            singleCell.Items.Add(tempStr);
                        }

                        if (singleCell.Items.Count == 1)
                        {
                            TEPanel.GetCell(TECount, 3).Value = singleCell.Items[0].ToString();
                        }
                        else
                        {
                            TEPanel.GetCell(TECount, 3).Value = "(雙擊)選擇表單";
                        }
                    }
                    #endregion
                }


                #region 找NC資料夾,並插入Panel
                string CAMFolderPath = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}\{6}", OutputForm.EnvVariables.env_Task, cus, partNo, cusVer, opVer, "OP" + op1, "CAM");
                //string CAMFolderPath = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}\{6}", CaxEnv.GetGlobaltekEnvDir() + "\\Task", cus, partNo, cusVer, opVer, "OP" + op1, "CAM");
                string[] NCFolder = Directory.GetDirectories(CAMFolderPath);
                foreach (string item in NCFolder)
                {
                    if (!item.Contains("NC"))
                    {
                        continue;
                    }
                    TECount++;
                    object[] o = new object[] { false, "NC程式", Path.GetFileNameWithoutExtension(item), ""
                                                , string.Format("{0}_{1}_{2}資料夾"
                                                                , partNo
                                                                , cusVer
                                                                , opVer) };
                    TEPanel.Rows.Add(new GridRow(o));
                }
                #endregion
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
            return(true);
        }