Example #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            int id = TextUtils.ToInt(grvListFile.SelectedRows[0].Cells[colIDListFile.Index].Value);

            if (id == 0)
            {
                return;
            }
            PBDLFileModel model = (PBDLFileModel)PBDLFileBO.Instance.FindByPK(id);
            frmPBDLFile   frm   = new frmPBDLFile();

            frm.FModel = model;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                loadListFileGrid();
            }
        }
Example #2
0
 protected PBDLFileFacade(PBDLFileModel model) : base(model)
 {
 }
Example #3
0
        /// <summary>
        /// Phân bổ dữ liệu cho phòng kế toán
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button10_Click(object sender, EventArgs e)
        {
            DocUtils.InitFTPQLSX();
            string    _productCode  = "TPAD.A2106";
            string    _projectCode  = "DA1";
            string    _serverPathCK = "Thietke.Ck/" + _productCode.Substring(0, 6) + "/" + _productCode + ".Ck/";
            DataTable dt            = TextUtils.Select("vPBDL_Structure_File", new Expression("DepartmentID", 8));
            ArrayList listStruc     = PBDLStructureBO.Instance.FindByAttribute("DepartmentID", 8);

            if (listStruc.Count > 0)
            {
                FolderBrowserDialog fbd = new FolderBrowserDialog();
                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    string initPath = fbd.SelectedPath;

                    #region Lấy dữ liệu trong file danh mục vật tư cơ khí
                    try
                    {
                        if (DocUtils.CheckExits(_serverPathCK + "/VT." + _productCode + ".xlsm"))
                        {
                            //Download file danh mục vật tư
                            DocUtils.DownloadFile(initPath, "VT." + _productCode + ".xlsm", _serverPathCK + "/VT." + _productCode + ".xlsm");
                        }
                    }
                    catch
                    {
                    }

                    string    pathDMVT = initPath + "/VT." + _productCode + ".xlsm";
                    DataTable dtDMVT   = TextUtils.ExcelToDatatable(pathDMVT, "DMVT");

                    for (int i = 0; i <= 4; i++)
                    {
                        dtDMVT.Rows.RemoveAt(0);
                    }
                    File.Delete(pathDMVT);

                    #endregion

                    foreach (var item in listStruc)
                    {
                        PBDLStructureModel strucModel = (PBDLStructureModel)item;
                        string             pathStruc  = strucModel.Path.Replace("project", _projectCode).Replace("code", _productCode);
                        string             pathLocal  = initPath + "/" + pathStruc;
                        Directory.CreateDirectory(pathLocal);
                        DataTable dtFile = TextUtils.Select("vPBDL_Structure_File", new Expression("PBDLStructureID", strucModel.ID));
                        foreach (DataRow row in dtFile.Rows)
                        {
                            int           pBDLFileID = TextUtils.ToInt(row["PBDLFileID"]);
                            PBDLFileModel fileModel  = (PBDLFileModel)PBDLFileBO.Instance.FindByPK(pBDLFileID);

                            if (fileModel.GetType == 0)//nhieu file
                            {
                                string pathServer = fileModel.FolderContain.Replace("group", _productCode.Substring(0, 6)).Replace("code", _productCode);

                                #region Mã vật liệu
                                if (fileModel.FilterMaVatLieu)//nếu có mã vật liệu
                                {
                                    DataRow[] listMaVatLieu = dtDMVT.Select("F5 <> '' and F4 like '%TPAD%' ");
                                    foreach (DataRow rowMVL in listMaVatLieu)
                                    {
                                        string fileName = rowMVL["F4"].ToString();
                                        try
                                        {
                                            if (DocUtils.CheckExits(pathServer + "/" + fileName + ".dwg"))
                                            {
                                                DocUtils.DownloadFile(pathLocal, fileName + fileModel.Extension, pathServer + "/" + fileName + fileModel.Extension);
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                                #endregion

                                #region Đơn vị
                                if (fileModel.FilterDonVi != "")
                                {
                                    DataRow[] listDonVi = dtDMVT.Select("F6 like '%" + fileModel.FilterDonVi.ToUpper() + "%' and F4 like '%TPAD%' ");
                                    foreach (DataRow rowMVL in listDonVi)
                                    {
                                        string fileName = rowMVL["F4"].ToString();
                                        try
                                        {
                                            if (DocUtils.CheckExits(pathServer + "/" + fileName + ".dwg"))
                                            {
                                                DocUtils.DownloadFile(pathLocal, fileName + fileModel.Extension, pathServer + "/" + fileName + fileModel.Extension);
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                                #endregion Đơn vị

                                #region Thông Số
                                if (fileModel.FilterThongSo != "")
                                {
                                    DataRow[] listThongSo = dtDMVT.Select("F3 like '%" + fileModel.FilterThongSo.ToUpper() + "%' and F4 like '%TPAD%' ");
                                    foreach (DataRow rowThongSo in listThongSo)
                                    {
                                        string fileName = rowThongSo["F4"].ToString();
                                        try
                                        {
                                            if (DocUtils.CheckExits(pathServer + "/" + fileName + ".dwg"))
                                            {
                                                DocUtils.DownloadFile(pathLocal, fileName + fileModel.Extension, pathServer + "/" + fileName + fileModel.Extension);
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                                #endregion Thông Số

                                #region MẶT
                                if (fileModel.MAT)
                                {
                                    try
                                    {
                                        string[] listFileMat = DocUtils.GetFilesList(pathServer);
                                        if (listFileMat != null)
                                        {
                                            foreach (string fileName in listFileMat)
                                            {
                                                try
                                                {
                                                    if (DocUtils.CheckExits(pathServer + "/" + fileName))
                                                    {
                                                        DocUtils.DownloadFile(pathLocal, fileName, pathServer + "/" + fileName);
                                                    }
                                                }
                                                catch
                                                {
                                                }
                                            }
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                                #endregion Mặt

                                #region TEM
                                if (fileModel.TEM)
                                {
                                    try
                                    {
                                        string[] listFileTEM = DocUtils.GetFilesList(pathServer);
                                        if (listFileTEM != null)
                                        {
                                            foreach (string fileName in listFileTEM)
                                            {
                                                try
                                                {
                                                    if (DocUtils.CheckExits(pathServer + "/" + fileName))
                                                    {
                                                        DocUtils.DownloadFile(pathLocal, fileName, pathServer + "/" + fileName);
                                                    }
                                                }
                                                catch
                                                {
                                                }
                                            }
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                                #endregion TEM
                            }
                            else//1 file
                            {
                                if (strucModel.FolderType != 2)//nếu không phải là thư mục điện tử
                                {
                                    string filePathServer = fileModel.FolderContain.Replace("group", _productCode.Substring(0, 6)).Replace("code", _productCode);
                                    try
                                    {
                                        if (DocUtils.CheckExits(filePathServer))
                                        {
                                            DocUtils.DownloadFile(pathLocal, Path.GetFileName(filePathServer), filePathServer);
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                                else
                                {
                                    DataRow[] listPCB = dtDMVT.Select("F4 like '%PCB%'");
                                    foreach (DataRow rowDT in listPCB)
                                    {
                                        string pcbCode = rowDT["F4"].ToString();
                                        string pathPCB = pathLocal + "/" + pcbCode;
                                        if (pathPCB == "")
                                        {
                                            continue;
                                        }
                                        Directory.CreateDirectory(pathPCB);

                                        string filePathServer = fileModel.FolderContain.Replace("tpat", "TPAT." + pcbCode.Substring(4, 7)).Replace("code", pcbCode);
                                        try
                                        {
                                            if (DocUtils.CheckExits(filePathServer))
                                            {
                                                DocUtils.DownloadFile(pathPCB, Path.GetFileName(filePathServer), filePathServer);
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }