private void btnOK_Click(object sender, EventArgs e)
        {
            bool status = true;

            if (cmbFileCabinet.Text == "Choose a Cabinet" || cmbFileCabinet.Text.Length == 0)
            {
                pnlError.Visible     = true;
                pnlError.Location    = new Point((this.Width - pnlError.ClientSize.Width) / 2, 64);
                pnlError.BackColor   = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                lblErrorMsg.Text     = "Select a Cabinet";
                lblErrorMsg.Location = new Point((pnlError.Width - lblErrorMsg.ClientSize.Width) / 2, (pnlError.Height - lblErrorMsg.ClientSize.Height) / 2);
                status = false;
                cmbFileCabinet.Focus();
                return;
            }
            if (!status)
            {
                MessageBox.Show("Please Enter required data");
            }
            else
            {
                FileCabinetID   = cmbFileCabinet.SelectedValue.ToString();
                FileCabinetName = cmbFileCabinet.Text.ToUpper();

                NewMenu objNewMenu = new NewMenu();

                //DashBoardHome obj = new DashBoardHome();
                //obj.strRootNodeID = FileCabinetID;
                //obj.strRootNode = FileCabinetName;

                //this.Hide();
                ////obj.MdiParent = this;
                //obj.Show();

                DashBoardHome obj = new DashBoardHome();
                obj.strRootNodeID = FileCabinetID;
                obj.strRootNode   = FileCabinetName;
                obj.MdiParent     = (NewMenu)this.MdiParent;
                obj.Show();
                //AdminHomePage obj1 = new AdminHomePage();
                //DashBoardHome obj = new DashBoardHome();
                //obj.strRootNode = Cabinet;
                ////this.Hide();
                //obj.MdiParent = obj1;
                //obj.Show();
            }
        }
        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
        private void btnOK_Click(object sender, EventArgs e)
        {
            bool status = true;

            if (txtFileCabinet.Text == String.Empty)
            {
                pnlError.Visible     = true;
                pnlError.Location    = new Point((this.Width - pnlError.ClientSize.Width) / 2, 64);
                pnlError.BackColor   = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                lblErrorMsg.Text     = "Cabinet name is required";
                lblErrorMsg.Location = new Point((pnlError.Width - lblErrorMsg.ClientSize.Width) / 2, (pnlError.Height - lblErrorMsg.ClientSize.Height) / 2);
                status = false;
                txtFileCabinet.Focus();
                return;
            }
            if (!status)
            {
                MessageBox.Show("Please Enter required data");
            }
            else
            {
                try
                {
                    // Checking duplicate cabinet names

                    FileCabinetManager objFileCabinetManager = new FileCabinetManager();
                    NandanaResult      result = new NandanaResult();
                    result = objFileCabinetManager.GetFileCabinets();

                    if (!result.HasError && result.resultDS.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in result.resultDS.Tables[0].Rows)
                        {
                            string CabinetName = dr["FileCabinet_Name"].ToString();

                            if (CabinetName.ToUpper() == txtFileCabinet.Text.ToUpper())
                            {
                                pnlError.Visible     = true;
                                pnlError.Location    = new Point((this.Width - pnlError.ClientSize.Width) / 2, 64);
                                pnlError.BackColor   = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                                lblErrorMsg.Text     = "Cabinet already exists, type a new name";
                                lblErrorMsg.Location = new Point((pnlError.Width - lblErrorMsg.ClientSize.Width) / 2, (pnlError.Height - lblErrorMsg.ClientSize.Height) / 2);
                                status = false;
                                txtFileCabinet.Focus();
                                return;
                            }
                        }
                    }

                    //end

                    //* inserting File Cabinet details in FileCabinet table *//

                    NandanaResult insertFileCabinet = objFileCabinetManager.InsertFileCabinetDetails(txtFileCabinet.Text.Trim(), "True");
                    if (insertFileCabinet.resultDS != null && insertFileCabinet.resultDS.Tables[0].Rows.Count > 0)
                    {
                        DataRow dr = insertFileCabinet.resultDS.Tables[0].Rows[0];
                        FileCabinetID   = dr["CabinetID"].ToString();
                        FileCabinetName = txtFileCabinet.Text;
                    }

                    //* End  *//

                    DashBoardHome obj = new DashBoardHome();
                    obj.strRootNodeID = FileCabinetID;
                    obj.strRootNode   = FileCabinetName;
                    obj.MdiParent     = (NewMenu)this.MdiParent;
                    obj.Show();

                    this.Hide();
                }
                catch (Exception x)
                {
                    MessageBox.Show(x.Message, "Error while Inserting Data from InsertFileCabinet SP");
                }
            }
        }