コード例 #1
0
        public void GetFolders()
        {
            // Taking all all records of Folders into DtFolders table

            NandanaResult objgetFolderdetails = objFolderManager.GetFolderDetails();

            if (objgetFolderdetails.resultDS != null && objgetFolderdetails.resultDS.Tables[0].Rows.Count > 0)
            {
                DtFolders = objgetFolderdetails.resultDS.Tables[0];
            }
            else
            {
                DtFolders = null;
            }

            // End
        }
コード例 #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            bool status = true;

            if (txtFolderName.Text == String.Empty)
            {
                lblErrorMsg.Visible = true;
                lblErrorMsg.Text    = "Folder Name is required";
                status = false;
                txtFolderName.Focus();
                return;
            }
            if (!status)
            {
                MessageBox.Show("Please Enter required data");
            }
            else
            {
                DashBoardHome obj = new DashBoardHome();

                if (FileCabinetID != null && FolderID != null)
                {
                    DataTable getFolderNames = new DataTable();

                    NandanaResult objgetfolderdetails = objFolderManager.GetFolderDetails();

                    if (objgetfolderdetails.resultDS != null && objgetfolderdetails.resultDS.Tables[0].Rows.Count > 0)
                    {
                        DataRow[] drResult = objgetfolderdetails.resultDS.Tables[0].Select("FileCabinet_ID = '" + FileCabinetID + "'" + "and" + " ParentFolderID = '" + FolderID + "'" + "and" + " IsDelete = '" + "True" + "'");
                        if (drResult.Count() != 0)
                        {
                            getFolderNames = drResult.CopyToDataTable();
                        }
                    }

                    //NandanaResult getFolderNames = objFolderManager.GetMainFolderNamesUsingFileCabinetID(FileCabinetID);
                    if (getFolderNames.HasErrors != null && getFolderNames.Rows.Count > 0)
                    {
                        DataTable dtAllFolders  = getFolderNames;
                        DataRow[] drMainFolders = dtAllFolders.Select("Folder_Name = '" + txtFolderName.Text + "'");
                        //DataTable dtMainFolders = drMainFolders.CopyToDataTable();
                        if (drMainFolders.Length != 0)
                        {
                            lblErrorMsg.Visible = true;
                            lblErrorMsg.Text    = "Folder already exists, type a new name";
                            txtFolderName.Focus();
                            return;
                        }
                        else if (CurrentFolderName == txtFolderName.Text)
                        {
                            lblErrorMsg.Visible = true;
                            lblErrorMsg.Text    = "Folder already exists, type a new name";
                            txtFolderName.Focus();
                            return;
                        }
                        else
                        {
                            FolderName = txtFolderName.Text;
                            this.Hide();
                        }
                    }
                    else
                    {
                        FolderName = txtFolderName.Text;
                        this.Hide();
                    }
                }
                else if (FileCabinetID != null)
                {
                    DataTable getFolderNames = new DataTable();

                    NandanaResult objgetfolderdetails = objFolderManager.GetFolderDetails();

                    if (objgetfolderdetails.resultDS != null && objgetfolderdetails.resultDS.Tables[0].Rows.Count > 0)
                    {
                        DataRow[] drResult = objgetfolderdetails.resultDS.Tables[0].Select("FileCabinet_ID = '" + FileCabinetID + "'" + "and" + " ParentFolderID = '" + 0 + "'" + "and" + " IsDelete = '" + "True" + "'");
                        if (drResult.Count() != 0)
                        {
                            getFolderNames = drResult.CopyToDataTable();
                        }
                    }


                    //NandanaResult getFolderNames = objFolderManager.GetMainFolderNamesUsingFileCabinetID(FileCabinetID);
                    if (getFolderNames.HasErrors != null && getFolderNames.Rows.Count > 0)
                    {
                        DataTable dtAllFolders  = getFolderNames;
                        DataRow[] drMainFolders = dtAllFolders.Select("Folder_Name = '" + txtFolderName.Text + "'");
                        //DataTable dtMainFolders = drMainFolders.CopyToDataTable();
                        if (drMainFolders.Length != 0)
                        {
                            lblErrorMsg.Visible = true;
                            lblErrorMsg.Text    = "Folder already exists, type a new name";
                            txtFolderName.Focus();
                            return;
                        }
                        else if (CurrentFolderName == txtFolderName.Text)
                        {
                            lblErrorMsg.Visible = true;
                            lblErrorMsg.Text    = "Folder already exists, type a new name";
                            txtFolderName.Focus();
                            return;
                        }
                        else
                        {
                            FolderName = txtFolderName.Text;
                            this.Hide();
                        }
                    }
                    else
                    {
                        FolderName = txtFolderName.Text;
                        this.Hide();
                    }
                }
                else if (FolderID != null)
                {
                    DataTable getMainFolderNames = new DataTable();

                    NandanaResult objgetfolderdetails = objFolderManager.GetFolderDetails();

                    DataTable getSubFolderNames = new DataTable();


                    if (objgetfolderdetails.resultDS != null && objgetfolderdetails.resultDS.Tables[0].Rows.Count > 0)
                    {
                        DataRow[] drResult = objgetfolderdetails.resultDS.Tables[0].Select("ParentFolderID = '" + FolderID + "'" + "and" + " ParentFolderID <> '" + 0 + "'" + "and" + " IsDelete = '" + "True" + "'");
                        if (drResult.Count() != 0)
                        {
                            getSubFolderNames = drResult.CopyToDataTable();
                        }
                    }


                    if (getSubFolderNames.HasErrors != null && getSubFolderNames.Rows.Count > 0)
                    {
                        DataTable dtAllSubFolders = getSubFolderNames;
                        DataRow[] drSubFolders    = dtAllSubFolders.Select("Folder_Name = '" + txtFolderName.Text + "'");
                        //DataTable dtMainFolders = drMainFolders.CopyToDataTable();
                        if (drSubFolders.Length != 0)
                        {
                            lblErrorMsg.Visible = true;
                            lblErrorMsg.Text    = "Folder already exists, type a new name";
                            txtFolderName.Focus();
                            return;
                        }
                        else if (CurrentFolderName == txtFolderName.Text)
                        {
                            lblErrorMsg.Visible = true;
                            lblErrorMsg.Text    = "Folder already exists, type a new name";
                            txtFolderName.Focus();
                            return;
                        }
                        else
                        {
                            FolderName = txtFolderName.Text;
                            this.Hide();
                        }
                    }
                    else
                    {
                        FolderName = txtFolderName.Text;
                        this.Hide();
                    }
                }
                else if (FileID != null)
                {
                    DataTable getfiles = new DataTable();

                    NandanaResult objgetfiledetails = objFilesManager.GetFileDetails();

                    if (objgetfiledetails.resultDS != null && objgetfiledetails.resultDS.Tables[0].Rows.Count > 0)
                    {
                        DataRow[] drResult = objgetfiledetails.resultDS.Tables[0].Select("File_ID = '" + FileID + "'" + "and" + " IsDelete = '" + "True" + "'");
                        if (drResult.Count() != 0)
                        {
                            getfiles = drResult.CopyToDataTable();
                        }
                    }


                    //NandanaResult getfiles = objFilesManager.GetFileDetailsUsingFileID(FileID);
                    if (getfiles.HasErrors != null && getfiles.Rows.Count > 0)
                    {
                        DataRow dr = getfiles.Rows[0];

                        string Folderid = dr["Folder_ID"].ToString();

                        DataTable     getfiledetailsussingfolderid = new DataTable();
                        NandanaResult objgetfolderdetails          = objFolderManager.GetFolderDetails();

                        if (objgetfolderdetails.resultDS != null && objgetfolderdetails.resultDS.Tables[0].Rows.Count > 0)
                        {
                            DataRow[] drResult = objgetfolderdetails.resultDS.Tables[0].Select("Folder_ID = '" + Folderid + "'" + "and" + " FileCabinet_ID = '" + FileCabinetID + "'" + "and" + " IsDelete = '" + "True" + "'");
                            if (drResult.Count() != 0)
                            {
                                getfiledetailsussingfolderid = drResult.CopyToDataTable();
                            }
                        }


                        //NandanaResult getfiledetailsussingfolderid = objFilesManager.GetFilesUsingFileCabinetAndFolderID(Folderid, FileCabinetID);
                        if (getfiledetailsussingfolderid.HasErrors != null && getfiledetailsussingfolderid.Rows.Count > 0)
                        {
                            foreach (DataRow drfiles in getfiledetailsussingfolderid.Rows)
                            {
                                string   FileName       = drfiles["File_Name"].ToString();
                                string[] splitfilenames = FileName.Split('.');
                                if (splitfilenames[0] == txtFolderName.Text.Trim())
                                {
                                    lblErrorMsg.Visible = true;
                                    lblErrorMsg.Text    = "File already exists, type a new name";
                                    txtFolderName.Focus();
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
    public void MatchedDocumentsInFileCabinet(string MainFolder, string SubFolder, string FileName, string FilePath)
    {
        // Checking Main Folder is present in FileCabinet, if present retrieving MainFolderID if not Inserting MainFolderName

        if (SelectedFileCabinetID == "")
        {
            SelectedFileCabinetID = "1";
        }
        int Mainfoldercount = 0;

        NandanaResult getfolderdetails = objFolderManager.GetFolderDetails();
        DataTable     getFolderNames   = new DataTable();

        if (getfolderdetails.resultDS != null && getfolderdetails.resultDS.Tables[0].Rows.Count > 0)
        {
            DataRow[] drResult = getfolderdetails.resultDS.Tables[0].Select("FileCabinet_ID = '" + SelectedFileCabinetID + "'" + "and" + " ParentFolderID = '" + "0" + "'" + "and" + " IsDelete = '" + "True" + "'");
            if (drResult.Count() != 0)
            {
                getFolderNames = drResult.CopyToDataTable();
            }


            if (getFolderNames != null && getFolderNames.Rows.Count > 0)
            {
                foreach (DataRow dr in getFolderNames.Rows)
                {
                    if (dr["Folder_Name"].ToString().ToUpper() == MainFolder.ToUpper())
                    {
                        Mainfoldercount += 1;
                        MainFolderID     = dr["Folder_ID"].ToString();
                    }
                }
            }
        }
        if (Mainfoldercount == 0)
        {
            NandanaResult objinsertintofolder = objFolderManager.InsertFolderDetails(SelectedFileCabinetID, MainFolder.ToUpper(), "0", "True");
            if (objinsertintofolder.resultDS != null && objinsertintofolder.resultDS.Tables[0].Rows.Count > 0)
            {
                DataRow dr = objinsertintofolder.resultDS.Tables[0].Rows[0];
                MainFolderID = dr["FolderId"].ToString();
            }
        }

        m_sMainFolderFile = null;
        if (m_sMainFolderFile == null)
        {
            m_sMainFolderFile = m_sRootFile + "\\" + MainFolder.ToUpper();
            if (!System.IO.Directory.Exists(m_sMainFolderFile))
            {
                System.IO.Directory.CreateDirectory(m_sMainFolderFile);
            }
        }

        //End

        if (SubFolder != "")
        {
            // Checking Sub Folder is present in Main Folder of FileCabinet, if present retrieving SubFolderID if not Inserting SubFolderName into MainFolder

            int Subfoldercount = 0;


            NandanaResult objgetfolderdetails = objFolderManager.GetFolderDetails();

            DataTable getSubFolderNames = new DataTable();
            if (objgetfolderdetails.resultDS != null && objgetfolderdetails.resultDS.Tables[0].Rows.Count > 0)
            {
                DataRow[] drResult = objgetfolderdetails.resultDS.Tables[0].Select("ParentFolderID = '" + MainFolderID + "'" + "and" + " ParentFolderID <> '" + 0 + "'" + "and" + " IsDelete = '" + "True" + "'");
                if (drResult.Count() != 0)
                {
                    getSubFolderNames = drResult.CopyToDataTable();
                }


                if (getSubFolderNames != null && getSubFolderNames.Rows.Count > 0)
                {
                    foreach (DataRow dr in getSubFolderNames.Rows)
                    {
                        if (dr["Folder_Name"].ToString().ToUpper() == SubFolder.ToUpper())
                        {
                            Subfoldercount += 1;
                            SubFolderID     = dr["Folder_ID"].ToString();
                        }
                    }
                }
            }

            if (Subfoldercount == 0)
            {
                NandanaResult objinsertintofolder = objFolderManager.InsertFolderDetails(SelectedFileCabinetID, SubFolder.ToUpper(), MainFolderID, "True");
                if (objinsertintofolder.resultDS != null && objinsertintofolder.resultDS.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = objinsertintofolder.resultDS.Tables[0].Rows[0];
                    SubFolderID = dr["FolderId"].ToString();
                }
            }

            // creating sub folders in FileCabinets path and moving that file into it
            m_sSubFolderFile = null;
            if (m_sSubFolderFile == null)
            {
                m_sSubFolderFile = m_sMainFolderFile + "\\" + SubFolder.ToUpper();
                if (!System.IO.Directory.Exists(m_sSubFolderFile))
                {
                    System.IO.Directory.CreateDirectory(m_sSubFolderFile);
                }
            }

            System.IO.File.Copy(FilePath, m_sSubFolderFile + "\\" + FileName, true);
            // End

            // Checking Files is present in Sub Folder of FileCabinet,if not Inserting Files into SubFolder

            int filecount = 0;


            NandanaResult objGetFiledetails = objFilesManager.GetFileDetails();

            DataTable objgetFiles = new DataTable();
            if (objGetFiledetails.resultDS != null && objGetFiledetails.resultDS.Tables[0].Rows.Count > 0)
            {
                DataRow[] drResult = objGetFiledetails.resultDS.Tables[0].Select("FileCabinet_ID = '" + SelectedFileCabinetID + "'" + "and" + " Folder_ID = '" + SubFolderID + "'" + "and" + " IsDelete = '" + "True" + "'");
                if (drResult.Count() != 0)
                {
                    objgetFiles = drResult.CopyToDataTable();
                }

                if (objgetFiles != null && objgetFiles.Rows.Count > 0)
                {
                    foreach (DataRow dr in objgetFiles.Rows)
                    {
                        if (dr["File_Name"].ToString() == FileName)
                        {
                            filecount += 1;
                            //MainFolderID = node["Folder_ID"].InnerText;
                        }
                    }
                }
            }

            if (filecount == 0)
            {
                NandanaResult insertintofiles = objFilesManager.InsertFileDetails(Convert.ToInt32(SubFolderID), Convert.ToInt32(SelectedFileCabinetID), FileName, m_sSubFolderFile + "\\" + FileName, "True");
                if (insertintofiles.resultDS != null && insertintofiles.resultDS.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = insertintofiles.resultDS.Tables[0].Rows[0];
                    FileID = dr["FileId"].ToString();
                }
            }
        }
        else
        {
            // Checking Files is present in Sub Folder of FileCabinet,if not Inserting Files into SubFolder

            System.IO.File.Copy(FilePath, m_sMainFolderFile + "\\" + FileName, true);

            int filecount = 0;

            NandanaResult objgetfiledetails = objFilesManager.GetFileDetails();

            DataTable objgetFiles = new DataTable();
            if (objgetfiledetails.resultDS != null && objgetfiledetails.resultDS.Tables[0].Rows.Count != 0)
            {
                DataRow[] drResult = objgetfiledetails.resultDS.Tables[0].Select("FileCabinet_ID = '" + SelectedFileCabinetID + "'" + "and" + " Folder_ID = '" + MainFolderID + "'" + "and" + " IsDelete = '" + "True" + "'");
                if (drResult.Count() != 0)
                {
                    objgetFiles = drResult.CopyToDataTable();
                }

                if (objgetFiles != null && objgetFiles.Rows.Count > 0)
                {
                    foreach (DataRow dr in objgetFiles.Rows)
                    {
                        if (dr["File_Name"].ToString() == FileName)
                        {
                            filecount += 1;
                            //MainFolderID = node["Folder_ID"].InnerText;
                        }
                    }
                }
            }


            if (filecount == 0)
            {
                // Insert into tbl_files table

                NandanaResult insertintofiles = objFilesManager.InsertFileDetails(Convert.ToInt32(MainFolderID), Convert.ToInt32(SelectedFileCabinetID), FileName, m_sMainFolderFile + "\\" + FileName, "True");
                if (insertintofiles.resultDS != null && insertintofiles.resultDS.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = insertintofiles.resultDS.Tables[0].Rows[0];
                    FileID = dr["FileId"].ToString();
                }

                // end
            }
        }
    }