Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool status = true;

            if (cmbRoles.Text == "Choose Role" || cmbRoles.Text.Length == 0)
            {
                pnlError.Visible   = true;
                pnlError.Location  = new Point((this.Width - pnlError.ClientSize.Width) / 2, 26);
                pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                lblError.Text      = "Select a Role";
                lblError.Location  = new Point((pnlError.Width - lblError.ClientSize.Width) / 2, (pnlError.Height - lblError.ClientSize.Height) / 2);
                status             = false;
                cmbRoles.Focus();
                return;
            }
            if (!status)
            {
                MessageBox.Show("Please Enter required data");
            }
            else
            {
                if (dgvUserAccessPermissions.Rows.Count > 0)
                {
                    foreach (DataGridViewRow gvrow in dgvUserAccessPermissions.Rows)
                    {
                        bool View = Convert.ToBoolean(gvrow.Cells[2].Value);

                        NandanaResult dsResult = new NandanaResult();
                        try
                        {
                            UserManager objUserManager = new UserManager();
                            dsResult = objUserManager.InsertUpdateUserAccessPermissions(cmbRoles.SelectedValue.ToString(), Convert.ToString(gvrow.Cells[0].Value), Convert.ToBoolean(gvrow.Cells[2].Value));
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Error while Inserting Data from UserAccessPermissions table");
                        }
                    }

                    SaveSuccess objSaveSuccess = new SaveSuccess();
                    objSaveSuccess.ShowDialog();
                }
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            bool status = true;

            if (txtFirstName.Text == string.Empty)
            {
                pnlError.Visible   = true;
                pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                pnlError.Location  = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12);
                lblError.Text      = "First Name is required";
                lblError.Location  = new Point((pnlError.Width - lblError.ClientSize.Width) / 2, (pnlError.Height - lblError.ClientSize.Height) / 2);
                status             = false;
                txtFirstName.Focus();
                return;
            }
            if (txtLastName.Text == string.Empty)
            {
                pnlError.Visible   = true;
                pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                pnlError.Location  = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12);
                lblError.Text      = "Last Name is required";
                lblError.Location  = new Point((pnlError.Width - lblError.ClientSize.Width) / 2, (pnlError.Height - lblError.ClientSize.Height) / 2);
                status             = false;
                txtLastName.Focus();
                return;
            }
            if (txtUserName.Text == string.Empty)
            {
                pnlError.Visible   = true;
                pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                pnlError.Location  = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12);
                lblError.Text      = "User Name is required";
                lblError.Location  = new Point((pnlError.Width - lblError.ClientSize.Width) / 2, (pnlError.Height - lblError.ClientSize.Height) / 2);
                status             = false;
                txtUserName.Focus();
                return;
            }
            if (txtPassword.Text == string.Empty)
            {
                pnlError.Visible   = true;
                pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                pnlError.Location  = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12);
                lblError.Text      = "Password is required";
                lblError.Location  = new Point((pnlError.Width - lblError.ClientSize.Width) / 2, (pnlError.Height - lblError.ClientSize.Height) / 2);
                status             = false;
                txtPassword.Focus();
                return;
            }
            if (txtConfirmPassword.Text == string.Empty)
            {
                pnlError.Visible   = true;
                pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                pnlError.Location  = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12);
                lblError.Text      = "Please confirm Password";
                lblError.Location  = new Point((pnlError.Width - lblError.ClientSize.Width) / 2, (pnlError.Height - lblError.ClientSize.Height) / 2);
                status             = false;
                txtConfirmPassword.Focus();
                return;
            }
            if (cmbRoles.Text == "Choose Role" || cmbRoles.Text.Length == 0)
            {
                pnlError.Visible   = true;
                pnlError.Location  = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12);
                pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                lblError.Text      = "Select a Role";
                lblError.Location  = new Point((pnlError.Width - lblError.ClientSize.Width) / 2, (pnlError.Height - lblError.ClientSize.Height) / 2);
                status             = false;
                cmbRoles.Focus();
                return;
            }
            if (cmbStatus.Text == "-Choose a Status-")
            {
                pnlError.Visible   = true;
                pnlError.Location  = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12);
                pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                lblError.Text      = "Select a Status";
                lblError.Location  = new Point((pnlError.Width - lblError.ClientSize.Width) / 2, (pnlError.Height - lblError.ClientSize.Height) / 2);
                status             = false;
                cmbStatus.Focus();
                return;
            }
            if (txtPassword.Text != txtConfirmPassword.Text)
            {
                pnlError.Visible   = true;
                pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                pnlError.Location  = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12);
                lblError.Text      = "Password and Confirm Password does not match, try again";
                lblError.Location  = new Point((pnlError.Width - lblError.ClientSize.Width) / 2, (pnlError.Height - lblError.ClientSize.Height) / 2);
                status             = false;
                return;
            }
            if (!status)
            {
                MessageBox.Show("Please Enter Required Data");
            }
            else
            {
                try
                {
                    //* Updating User details in Users table *//

                    Boolean Status = Convert.ToBoolean(0);
                    if (cmbStatus.Text == "Active")
                    {
                        Status = Convert.ToBoolean(1);
                    }
                    else if (cmbStatus.Text == "InActive")
                    {
                        Status = Convert.ToBoolean(0);
                    }
                    NewUserManager objNewUserManager = new NewUserManager();
                    NandanaResult  insertUserValues  = objNewUserManager.UpdateUserDetails(UserID, txtFirstName.Text.Trim(), txtLastName.Text.Trim(), txtMiddleName.Text.Trim(), txtAddress.Text.Trim(), txtCity.Text.Trim(), txtState.Text.Trim(), txtCountry.Text.Trim(), txtZip.Text.Trim(), txtMobile.Text.Trim(), txtHomePhone.Text.Trim(), txtUserName.Text.Trim(), this.Encrypt(txtPassword.Text.Trim()), cmbRoles.SelectedValue.ToString(), Status);

                    //* End  *//

                    SaveSuccess objSaveSuccess = new SaveSuccess();
                    objSaveSuccess.FormName = "NewUser";
                    objSaveSuccess.ShowDialog();

                    EmptyControls();

                    GetUsersDetails();

                    txtUserName.ReadOnly = false;

                    btnUpdate.Visible = false;
                    btnSave.Visible   = true;
                }
                catch (Exception x)
                {
                    MessageBox.Show(x.Message, "Error while Inserting Data from InsertUserValues SP");
                }
            }
        }
        private void btnSave_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, 54);
                pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                lblError.Text      = "Select a Cabinet";
                lblError.Location  = new Point((pnlError.Width - lblError.ClientSize.Width) / 2, (pnlError.Height - lblError.ClientSize.Height) / 2);
                status             = false;
                cmbFileCabinet.Focus();
                return;
            }
            if (FileArray.Length == 0)
            {
                pnlError.Visible   = true;
                pnlError.Location  = new Point((this.Width - pnlError.ClientSize.Width) / 2, 54);
                pnlError.BackColor = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                lblError.Text      = "Select one or more Documents to Import";
                lblError.Location  = new Point((pnlError.Width - lblError.ClientSize.Width) / 2, (pnlError.Height - lblError.ClientSize.Height) / 2);
                status             = false;
                btnBrowse.Focus();
                return;
            }
            if (!status)
            {
                MessageBox.Show("Please Enter required data");
            }
            else
            {
                FilesManager objFilesManager = new FilesManager();

                string[] splitFileName     = FileArray.Split('|');
                string[] splitFilePathName = FilePathArray.Split('|');

                m_sConfigFile         = null;
                m_sFileCabinetDocFile = null;
                m_sMainFolderDocFile  = null;
                m_sSubFolderDocFile   = null;

                for (int i = 0; i < splitFileName.Length; i++)
                {
                    if (m_sConfigFile == null)
                    {
                        m_sConfigFile = ConfigurationManager.AppSettings["TreeviewFilepath"].ToString();
                        if (!System.IO.Directory.Exists(m_sConfigFile))
                        {
                            System.IO.Directory.CreateDirectory(m_sConfigFile);
                        }
                    }

                    if (m_sFileCabinetDocFile == null)
                    {
                        m_sFileCabinetDocFile = m_sConfigFile + "\\" + cmbFileCabinet.Text;
                        if (!System.IO.Directory.Exists(m_sFileCabinetDocFile))
                        {
                            System.IO.Directory.CreateDirectory(m_sFileCabinetDocFile);
                        }
                    }

                    if (cmbFileCabinet.Text != "Choose a Cabinet" && (cmbParentFolder.Text == "Choose a Parent Folder" || cmbParentFolder.Text.Length == 0 || cmbParentFolder.Text == null))
                    {
                        System.IO.File.Copy(splitFilePathName[i], m_sFileCabinetDocFile + "\\" + splitFileName[i], true);

                        // inserting files into documentslist table //

                        MoveMyFilesManager objMoveMyFilesManager = new MoveMyFilesManager();
                        NandanaResult      insertdocumentdetails = objMoveMyFilesManager.InsertDocumentlistDetails(DateTime.Now.ToString("yyyy-MM-dd h:mm:ss tt"), splitFileName[i], "Manual");
                        if (insertdocumentdetails.resultDS != null && insertdocumentdetails.resultDS.Tables[0].Rows.Count > 0)
                        {
                            DataRow dr = insertdocumentdetails.resultDS.Tables[0].Rows[0];
                            DocumentID = dr["DocumentId"].ToString();
                        }

                        // End

                        NandanaResult insertfiledetails = objFilesManager.InsertFileDetails(0, Convert.ToInt32(cmbFileCabinet.SelectedValue.ToString()), splitFileName[i], m_sFileCabinetDocFile + "\\" + splitFileName[i], "True");
                    }
                    else if (cmbFileCabinet.Text != "Choose a Cabinet" && cmbParentFolder.Text != "Choose a Parent Folder" && (cmbSubFolder.Text == "Choose a Sub-Folder" || cmbSubFolder.Text.Length == 0 || cmbSubFolder.Text == null))
                    {
                        if (m_sMainFolderDocFile == null)
                        {
                            m_sMainFolderDocFile = m_sFileCabinetDocFile + "\\" + cmbParentFolder.Text;
                            if (!System.IO.Directory.Exists(m_sMainFolderDocFile))
                            {
                                System.IO.Directory.CreateDirectory(m_sMainFolderDocFile);
                            }
                        }

                        System.IO.File.Copy(splitFilePathName[i], m_sMainFolderDocFile + "\\" + splitFileName[i], true);

                        // inserting files into documentslist table //

                        MoveMyFilesManager objMoveMyFilesManager = new MoveMyFilesManager();
                        NandanaResult      insertdocumentdetails = objMoveMyFilesManager.InsertDocumentlistDetails(DateTime.Now.ToString("yyyy-MM-dd h:mm:ss tt"), splitFileName[i], "Manual");
                        if (insertdocumentdetails.resultDS != null && insertdocumentdetails.resultDS.Tables[0].Rows.Count > 0)
                        {
                            DataRow dr = insertdocumentdetails.resultDS.Tables[0].Rows[0];
                            DocumentID = dr["DocumentId"].ToString();
                        }

                        // End

                        NandanaResult insertfiledetails = objFilesManager.InsertFileDetails(Convert.ToInt32(cmbParentFolder.SelectedValue.ToString()), Convert.ToInt32(cmbFileCabinet.SelectedValue.ToString()), splitFileName[i], m_sMainFolderDocFile + "\\" + splitFileName[i], "True");
                    }
                    else if (cmbFileCabinet.Text != "Choose a Cabinet" && cmbParentFolder.Text != "Choose a Parent Folder" && cmbSubFolder.Text != "Choose a Sub-Folder")
                    {
                        if (m_sMainFolderDocFile == null)
                        {
                            m_sMainFolderDocFile = m_sFileCabinetDocFile + "\\" + cmbParentFolder.Text;
                            if (!System.IO.Directory.Exists(m_sMainFolderDocFile))
                            {
                                System.IO.Directory.CreateDirectory(m_sMainFolderDocFile);
                            }
                        }
                        if (m_sSubFolderDocFile == null)
                        {
                            m_sSubFolderDocFile = m_sMainFolderDocFile + "\\" + cmbSubFolder.Text;
                            if (!System.IO.Directory.Exists(m_sSubFolderDocFile))
                            {
                                System.IO.Directory.CreateDirectory(m_sSubFolderDocFile);
                            }
                        }

                        System.IO.File.Copy(splitFilePathName[i], m_sSubFolderDocFile + "\\" + splitFileName[i], true);

                        // inserting files into documentslist table //

                        MoveMyFilesManager objMoveMyFilesManager = new MoveMyFilesManager();
                        NandanaResult      insertdocumentdetails = objMoveMyFilesManager.InsertDocumentlistDetails(DateTime.Now.ToString("yyyy-MM-dd h:mm:ss tt"), splitFileName[i], "Manual");
                        if (insertdocumentdetails.resultDS != null && insertdocumentdetails.resultDS.Tables[0].Rows.Count > 0)
                        {
                            DataRow dr = insertdocumentdetails.resultDS.Tables[0].Rows[0];
                            DocumentID = dr["DocumentId"].ToString();
                        }

                        // End

                        NandanaResult insertfiledetails = objFilesManager.InsertFileDetails(Convert.ToInt32(cmbSubFolder.SelectedValue.ToString()), Convert.ToInt32(cmbFileCabinet.SelectedValue.ToString()), splitFileName[i], m_sSubFolderDocFile + "\\" + splitFileName[i], "True");
                    }
                }
                //MessageBox.Show("Files are Imported into Selected Filecabinet Successfully");

                SaveSuccess objsavesuccess = new SaveSuccess();
                objsavesuccess.ShowDialog();

                FileArray     = string.Empty;
                FilePathArray = string.Empty;

                cmbFileCabinet.SelectedValue = 0;
                cmbParentFolder.DataSource   = null;
                cmbSubFolder.DataSource      = null;
            }
        }