Ejemplo n.º 1
0
        private void OK_Click(object sender, EventArgs e)
        {
            try
            {
                Dictionary <Node, List <Node> > DicSelNodes = new Dictionary <Node, List <Node> >();
                status = Fun_Common.GetSelNodes(OISTree, out DicSelNodes);
                if (!status)
                {
                    MessageBox.Show("取得對話框資料失敗,請聯繫開發工程師");
                    this.Close();
                }

                IList <Com_PFMEA> listComPFMEA = session.QueryOver <Com_PFMEA>().List();

                status = Fun_Common.DeleteDataBase(listComPFMEA, DicSelNodes);
                if (!status)
                {
                    MessageBox.Show("刪除資料庫發生錯誤,請聯繫開發工程師");
                    this.Close();
                }

                string ExcelFolder = string.Format(@"{0}\{1}_{2}_{3}"
                                                   , Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
                                                   , PartNoCombo.Text
                                                   , CusRevCombo.Text
                                                   , OpRevCombo.Text);
                //建立桌面資料夾存放產生的Excel
                if (!Directory.Exists(ExcelFolder))
                {
                    Directory.CreateDirectory(ExcelFolder);
                }

                status = Fun_Common.CreatePFMEA(PartNoCombo.Text, CusRevCombo.Text, OpRevCombo.Text, DicSelNodes);
                if (!status)
                {
                    MessageBox.Show("輸出P-FMEA發生錯誤,請聯繫開發工程師");
                    this.Close();
                }

                MessageBox.Show("輸出成功");
                this.Close();

                /*
                 * status = GetAllNodes(out dicAllNode);
                 * if (!status)
                 * {
                 *  MessageBox.Show("取得對話框資料失敗,請聯繫開發工程師");
                 *  this.Close();
                 * }
                 *
                 * IList<Com_PFMEA> listComPFMEA = session.QueryOver<Com_PFMEA>().List();
                 *
                 * foreach (KeyValuePair<Node,List<DimenData>> kvp in dicAllNode)
                 * {
                 *  foreach (DimenData i in kvp.Value)
                 *  {
                 *      //刪除舊資料
                 *      foreach (Com_PFMEA j in listComPFMEA)
                 *      {
                 *          if (j.comDimension.dimensionSrNo == ((Com_Dimension)i.node.Tag).dimensionSrNo)
                 *              session.Delete(j);
                 *
                 *          session.BeginTransaction().Commit();
                 *      }
                 *      Com_PFMEA cCom_PFMEA = new Com_PFMEA();
                 *      cCom_PFMEA.comDimension = (Com_Dimension)i.node.Tag;
                 *      cCom_PFMEA.pFMData = i.node.Cells[2].Text;
                 *      cCom_PFMEA.pEoFData = i.node.Cells[3].Text;
                 *      cCom_PFMEA.sevData = i.node.Cells[4].Text;
                 *      cCom_PFMEA.classData = i.node.Cells[5].Text;
                 *      cCom_PFMEA.pCoFData = i.node.Cells[6].Text;
                 *      cCom_PFMEA.occurrenceData = i.node.Cells[7].Text;
                 *      cCom_PFMEA.preventionData = i.node.Cells[8].Text;
                 *      cCom_PFMEA.detectionData = i.node.Cells[9].Text;
                 *      cCom_PFMEA.detData = i.node.Cells[10].Text;
                 *      cCom_PFMEA.rpnData = i.node.Cells[11].Text;
                 *      using (ITransaction trans = session.BeginTransaction())
                 *      {
                 *          session.Save(cCom_PFMEA);
                 *          trans.Commit();
                 *      }
                 *  }
                 * }
                 * this.Close();
                 */
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
                //MessageBox.Show("取得對話框資料失敗,請聯繫開發工程師");
                this.Close();
            }
        }
Ejemplo n.º 2
0
 private void AddBtn_Click(object sender, EventArgs e)
 {
     Fun_Common.ManualAdd(panel, Manual.Text);
 }