コード例 #1
0
ファイル: frmSolutionCTTM.cs プロジェクト: B06-0253/NVTHAO
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!validateForm())
                {
                    return;
                }
                string productCode = txtModel.Text.ToUpper();
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo cây thư mục..."))
                {
                    if (Directory.Exists(@"D:\"))
                    {
                        _initPath = "D:\\Thietke.Gp\\";
                        Directory.CreateDirectory(_initPath);
                    }
                    else
                    {
                        if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                        {
                            _initPath = folderBrowserDialog1.SelectedPath;
                        }
                        else
                        {
                            return;
                        }
                    }

                    ArrayList list = DesignStructureBO.Instance.FindByAttribute("Type", 3);

                    for (int i = 0; i < list.Count; i++)
                    {
                        DesignStructureModel model = (DesignStructureModel)list[i];
                        string directtion          = "";
                        if (model.Path.Contains("code"))
                        {
                            directtion = (_initPath + @"\" + model.Path).Replace("code", productCode);
                        }
                        else
                        {
                            directtion = (_initPath + @"\" + model.Path);
                        }
                        if (i == 0)
                        {
                            _duongDanChinh = directtion;
                        }
                        Directory.CreateDirectory(directtion);
                    }
                }
                MessageBox.Show("Tạo cấu trúc thiết kế thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Process.Start(_duongDanChinh);
            }
            catch (System.Exception ex)
            {
                TextUtils.ShowError(ex);
            }
        }
コード例 #2
0
 private void btnEditGroup_Click(object sender, EventArgs e)
 {
     try
     {
         int id = TextUtils.ToInt(treeData.FocusedNode.GetValue(colIDTree));
         if (id == 0)
         {
             return;
         }
         DesignStructureModel model = (DesignStructureModel)DesignStructureBO.Instance.FindByPK(id);
         frmCreate            frm   = new frmCreate();
         frm.Model    = model;
         frm.ParentID = model.ParentID;
         if (frm.ShowDialog() == DialogResult.OK)
         {
             _curentNode = frm.CurentNode;
             loadTree();
         }
     }
     catch (Exception)
     {
     }
 }
コード例 #3
0
ファイル: frmTaoCTTK.cs プロジェクト: B06-0253/NVTHAO
        private void taoDuongDan()
        {
            try
            {
                if (!validateForm())
                {
                    return;
                }
                string productCode = txtModel.Text.ToUpper();
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo cây thư mục..."))
                {
                    if (Directory.Exists(@"D:\"))
                    {
                        if (cboParent.SelectedIndex == 0)//cơ khí
                        {
                            _initPath = "D:\\Thietke.Ck\\TPAD." + productCode.ToUpper().Substring(0, 1);
                        }
                        if (cboParent.SelectedIndex == 1)//điện
                        {
                            _initPath = "D:\\Thietke.Dn\\TPAD." + productCode.ToUpper().Substring(0, 1);
                        }
                        if (cboParent.SelectedIndex == 2)//điện tử
                        {
                            _initPath = "D:\\Thietke.Dt\\PCB." + productCode.ToUpper().Substring(0, 1);
                        }
                    }
                    else
                    {
                        if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                        {
                            _initPath = folderBrowserDialog1.SelectedPath;
                        }
                        else
                        {
                            return;
                        }
                    }

                    ArrayList list = DesignStructureBO.Instance.FindByAttribute("Type", cboParent.SelectedIndex);

                    for (int i = 0; i < list.Count; i++)
                    {
                        DesignStructureModel model = (DesignStructureModel)list[i];
                        string directtion          = "";
                        if (model.Path.Contains("code"))
                        {
                            if (cboParent.SelectedIndex == 0 || cboParent.SelectedIndex == 1)//cơ khí
                            {
                                directtion = (_initPath + @"\" + model.Path).Replace("code", "TPAD." + productCode);
                            }
                            if (cboParent.SelectedIndex == 2)//điện tử
                            {
                                directtion = (_initPath + @"\" + model.Path).Replace("code", productCode);
                            }
                        }
                        else
                        {
                            directtion = (_initPath + @"\" + model.Path);
                        }
                        if (i == 0)
                        {
                            _duongDanChinh = directtion;
                        }
                        Directory.CreateDirectory(directtion);
                    }
                    if (cboParent.SelectedIndex == 0)//cơ khí
                    {
                        ModulesModel module = (ModulesModel)ModulesBO.Instance.FindByAttribute("Code", "TPAD." + productCode.ToUpper())[0];

                        #region Danh muc vat tu
                        try
                        {
                            // File.Copy(_bieuMauPath + "\\TP-TT13-BM04 - Danh muc vat tu.xlsm",
                            //_duongDanChinh + "\\VT.TPAD." + productCode + ".xlsm");

                            File.Copy(Application.StartupPath + "\\Templates\\PhongThietKe\\VT.Code.xlsm",
                                      _duongDanChinh + "\\VT.TPAD." + productCode + ".xlsm", true);

                            Excel.Application objXLApp = default(Excel.Application);
                            Excel.Workbook    objXLWb  = default(Excel.Workbook);
                            Excel.Worksheet   objXLWs  = default(Excel.Worksheet);

                            try
                            {
                                objXLApp = new Excel.Application();
                                objXLApp.Workbooks.Open(_duongDanChinh + "\\VT.TPAD." + productCode + ".xlsm");
                                objXLWb = objXLApp.Workbooks[1];
                                objXLWs = (Excel.Worksheet)objXLWb.Worksheets[1];

                                objXLWs.Cells[4, 3]   = Global.AppUserName.ToUpper();
                                objXLApp.Cells[3, 3]  = module.Name.ToUpper();
                                objXLApp.Cells[3, 10] = "Mã: TPAD." + productCode.ToUpper();
                            }
                            catch
                            {
                            }
                            finally
                            {
                                objXLApp.ActiveWorkbook.Save();
                                objXLApp.Workbooks.Close();
                                objXLApp.Quit();
                            }
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Không tạo được danh mục vật tư do module [TPAD." + productCode.ToUpper() + "] chưa có trên nguồn",
                                            TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        #endregion

                        #region Thư mục Doc
                        string   moduleCode = "TPAD." + productCode;
                        string   toFolder   = string.Format(@"D:\Thietke.Ck\{0}\{1}.Ck\DOC.{1}\", moduleCode.Substring(0, 6), moduleCode);
                        string   fromFolder = Application.StartupPath + "/Templates/PhongThietKe/DOC.TPAD.XYYYY";
                        string[] listFile   = Directory.GetFiles(fromFolder);
                        foreach (string filePath in listFile)
                        {
                            string fileName  = Path.GetFileNameWithoutExtension(filePath);
                            string extension = Path.GetExtension(filePath);
                            try
                            {
                                File.Copy(filePath, toFolder + fileName + moduleCode + extension, true);
                            }
                            catch
                            {
                            }
                        }
                        #endregion

                        #region Bảng kiểm tra phương án
                        string path           = "D:\\Thietke.Ck\\" + moduleCode.Substring(0, 6) + "\\" + moduleCode + ".Ck\\DOC." + moduleCode;
                        string filePathSource = Application.StartupPath + "\\Templates\\KTPA.docm";
                        string filePathKTPA   = path + "\\KTPA." + moduleCode + ".docm";

                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }

                        File.Copy(filePathSource, filePathKTPA, true);

                        string groupCode = moduleCode.Substring(0, 6).ToLower();
                        string groupName = ((ModuleGroupModel)ModuleGroupBO.Instance.FindByCode(groupCode)).Name.ToLower();
                        string userName  = Global.AppUserName.ToLower();

                        string parametter = TextUtils.ConvertUnicode(groupName + "$" + groupCode + "$" + module.Name.ToLower() + "$" + moduleCode.ToLower()
                                                                     + "$" + userName, 0).ToUpper();
                        TextUtils.RunMacroInWord(filePathKTPA, "Macro1", parametter);
                        #endregion
                    }
                    //if (cboParent.SelectedIndex == 1)
                    //{
                    // ModulesModel module = (ModulesModel)ModulesBO.Instance.FindByAttribute("Code", "TPAD." + productCode.ToUpper())[0];

                    #region Hang muc TK
                    //try
                    //{
                    //    File.Copy(_bieuMauPath + "\\TP-TT13-BM38 - Hang muc TK.xlsm",
                    //   _duongDanChinh + "\\DAT.TPAD." + productCode + "\\MTK.TPAD." + productCode + ".Dn.xlsm");

                    //    Excel.Application objXLApp = default(Excel.Application);
                    //    Excel.Workbook objXLWb = default(Excel.Workbook);
                    //    Excel.Worksheet objXLWs = default(Excel.Worksheet);

                    //    try
                    //    {
                    //        objXLApp = new Excel.Application();
                    //        objXLApp.Workbooks.Open(_duongDanChinh + "\\DAT.TPAD." + productCode + "\\MTK.TPAD." + productCode + ".Dn.xlsm");
                    //        objXLWb = objXLApp.Workbooks[1];
                    //        objXLWs = (Excel.Worksheet)objXLWb.Worksheets[1];

                    //        objXLWs.Cells[9, 3] = module.Name.ToUpper();
                    //        objXLWs.Cells[9, 4] = "Mã: " + module.Code.ToUpper();
                    //        objXLApp.Cells[10, 3] = Global.AppFullName;
                    //    }
                    //    catch
                    //    {
                    //    }
                    //    finally
                    //    {
                    //        objXLApp.ActiveWorkbook.Save();
                    //        objXLApp.Workbooks.Close();
                    //        objXLApp.Quit();
                    //    }
                    //}
                    //catch (Exception)
                    //{
                    //}
                    #endregion

                    #region Bang kiem tra nguyen ly
                    //try
                    //{
                    //    File.Copy(_bieuMauPath + "\\TP-TT13-BM31 - Bang kiem tra nguyen ly.xlsm",
                    //   _duongDanChinh + "\\DAT.TPAD." + productCode + "\\BKT.TPAD." + productCode + ".Dn.xlsm");

                    //    Excel.Application objXLApp = default(Excel.Application);
                    //    Excel.Workbook objXLWb = default(Excel.Workbook);
                    //    Excel.Worksheet objXLWs = default(Excel.Worksheet);

                    //    try
                    //    {
                    //        objXLApp = new Excel.Application();
                    //        objXLApp.Workbooks.Open(_duongDanChinh + "\\DAT.TPAD." + productCode + "\\BKT.TPAD." + productCode + ".Dn.xlsm");
                    //        objXLWb = objXLApp.Workbooks[1];
                    //        objXLWs = (Excel.Worksheet)objXLWb.Worksheets[1];

                    //        objXLWs.Cells[9, 4] = module.Name.ToUpper();
                    //        objXLWs.Cells[9, 9] = module.Code.ToUpper();
                    //        objXLApp.Cells[10, 4] = Global.AppFullName;
                    //    }
                    //    catch
                    //    {
                    //    }
                    //    finally
                    //    {
                    //        objXLApp.ActiveWorkbook.Save();
                    //        objXLApp.Workbooks.Close();
                    //        objXLApp.Quit();
                    //    }
                    //}
                    //catch (Exception)
                    //{
                    //}
                    #endregion

                    #region Bang du lieu lap trinh
                    //try
                    //{
                    //    File.Copy(_bieuMauPath + "\\TP-TT13-BM32 - Bang du lieu lap trinh.xlsm",
                    //   _duongDanChinh + "\\DAT.TPAD." + productCode + "\\BLT.TPAD." + productCode + ".Dn.xlsm");

                    //    Excel.Application objXLApp = default(Excel.Application);
                    //    Excel.Workbook objXLWb = default(Excel.Workbook);
                    //    Excel.Worksheet objXLWs = default(Excel.Worksheet);

                    //    try
                    //    {
                    //        objXLApp = new Excel.Application();
                    //        objXLApp.Workbooks.Open(_duongDanChinh + "\\DAT.TPAD." + productCode + "\\BLT.TPAD." + productCode + ".Dn.xlsm");
                    //        objXLWb = objXLApp.Workbooks[1];
                    //        objXLWs = (Excel.Worksheet)objXLWb.Worksheets[1];

                    //        objXLWs.Cells[8, 4] = module.Name.ToUpper();
                    //        objXLWs.Cells[8, 8] = "Mã: " + module.Code.ToUpper();
                    //        objXLApp.Cells[9, 4] = Global.AppFullName;
                    //    }
                    //    catch
                    //    {
                    //    }
                    //    finally
                    //    {
                    //        objXLApp.ActiveWorkbook.Save();
                    //        objXLApp.Workbooks.Close();
                    //        objXLApp.Quit();
                    //    }
                    //}
                    //catch (Exception)
                    //{
                    //}
                    #endregion

                    #region Du lieu cai dat
                    //try
                    //{
                    //    File.Copy(_bieuMauPath + "\\TP-TT13-BM34 - Du lieu cai dat.docm",
                    //   _duongDanChinh + "\\DAT.TPAD." + productCode + "\\BCD.TPAD." + productCode + ".Dn.docm");
                    //}
                    //catch (Exception)
                    //{
                    //}
                    #endregion
                    //}
                }
                MessageBox.Show("Tạo cấu trúc thiết kế thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                System.Diagnostics.Process.Start(_duongDanChinh);
            }
            catch (System.Exception ex)
            {
                TextUtils.ShowError(ex);
            }
        }
コード例 #4
0
ファイル: CreateFoderFacade.cs プロジェクト: mrgrey88/QLTK
 protected DesignStructureFacade(DesignStructureModel model) : base(model)
 {
 }