Esempio n. 1
0
 public frmArticles()
 {
     InitializeComponent();
     ArticleLoader();
     DGVRefList.DataSource         = TabelConnector.DataTableLoader("Select * from TblReference");
     cmbRefrenceType.SelectedIndex = 0;
 }
Esempio n. 2
0
        //Article DataGridView Cell click event.
        private void DGVArticlesList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                articleId = Convert.ToInt32(DGVArticlesList.Rows[e.RowIndex].Cells[0].Value);

                DataTable dt = TabelConnector.DataTableLoader($"Select * from tblText where id= {articleId}");//Gets a data table from the datbase and initialize data to the textbox.
                txtWordEditor.Text = dt.Rows[0][1].ToString();
                txtRefrence.Text   = dt.Rows[0][3].ToString();
            }
            catch
            {
            }
        }
        //Admin's record delete from database.
        private void DeleteData(object sender, EventArgs e)
        {
            DataTable userCheckDT = TabelConnector.DataTableLoader($"Select * from Users Where UserId ='{txtUserId.Text}' or email = '{txtEmail.Text}'");

            if (Convert.ToInt32(userCheckDT.Rows[0][0]) == UserInfo.id)//Admin cannot delete his/her own record.
            {
                MsgBox.Show($"You Cannot delete yourself", "Restriction", "OK", "Cancel");
            }
            else
            {
                DatabaseNonQuery.InsertUpdateDelete($"Delete from Users where id = '{id}'");
                ShowTableData();
                MessageBox.Show("User removed from the storage", "Update Done", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                MangingFormAndControls.PanelClear(panelUserInfo); //After operation all the text boxes are cleared.
            }
        }
 //DataGridView's cell click will load row data to the Panel's controlls.
 private void DGVCellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         id = dgvUsersData.Rows[e.RowIndex].Cells[0].Value.ToString();
         DataTable dt = TabelConnector.DataTableLoader($"Select * from Users where id = '{id}'");
         txtFirstName.Text = dt.Rows[0][1].ToString();
         txtLastName.Text  = dt.Rows[0][2].ToString();
         txtUserId.Text    = dt.Rows[0][3].ToString();
         txtContact.Text   = dt.Rows[0][4].ToString();
         txtEmail.Text     = dt.Rows[0][5].ToString();
         txtAddress.Text   = dt.Rows[0][6].ToString();
         txtPassword.Text  = dt.Rows[0][7].ToString();
         cmbUserType.Text  = dt.Rows[0][8].ToString();
     }
     catch
     {
     }
 }
Esempio n. 5
0
        /// <summary>
        /// This will initialize Database data fields to the class data fields.
        /// </summary>
        /// <param name="Command"> Database query command needs to be passed to get a datatable</param>
        void FieldInitializer(string Command)
        {
            DataTable dt = TabelConnector.DataTableLoader(Command);


            Id             = Convert.ToInt32(dt.Rows[0][0]);
            title          = dt.Rows[0][1].ToString();
            Author         = dt.Rows[0][2].ToString();
            DocumentType   = dt.Rows[0][3].ToString();
            Year           = dt.Rows[0][4].ToString();
            Publisher      = dt.Rows[0][5].ToString();
            Abstract       = dt.Rows[0][6].ToString();
            NameOfDocument = dt.Rows[0][7].ToString();
            Issue          = dt.Rows[0][8].ToString();
            Volume         = dt.Rows[0][9].ToString();
            PageNumbers    = dt.Rows[0][10].ToString();
            Notes          = dt.Rows[0][11].ToString();

            AuthorLastName();
        }
 //Update database data with additional admin feature.
 private void AdminUpdateData(object sender, EventArgs e)
 {
     if (txtFirstName.Text == "" || txtUserId.Text == "" || txtEmail.Text == "" || txtPassword.Text == "")
     {
         MessageBox.Show("User First Name, UserID, Email, Password cannot be empty", "Field Empty", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         DataTable userCheckDT = TabelConnector.DataTableLoader($"Select * from Users Where UserId ='{txtUserId.Text}'");
         if (userCheckDT.Rows.Count > 1)
         {
             MsgBox.Show($"User Already Registered", "Sign up Error", "OK", "Cancel");
         }
         else
         {
             DatabaseNonQuery.InsertUpdateDelete($"Update Users set FirstName ='{txtFirstName.Text}',LastName='{txtLastName.Text}',UserId = '{txtUserId.Text}', Contact = '{txtContact.Text}', Email = '{txtEmail.Text}', Address = '{txtAddress.Text}', Password = '******', UserType = '{cmbUserType.Text}' where id='{id}'");
             ShowTableData();
             MessageBox.Show("User Information Updated", "Update Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
             MangingFormAndControls.PanelClear(panelUserInfo); //After operation all the text boxes are cleared.
         }
     }
 }
 //Database data insert for data record.
 private void SaveData(object sender, EventArgs e)
 {
     if (txtFirstName.Text == "" || txtUserId.Text == "" || txtEmail.Text == "" || txtPassword.Text == "")
     {
         MessageBox.Show("User First Name, UserID, Email, Password cannot be empty", "Field Empty", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         DataTable userCheckDT = TabelConnector.DataTableLoader($"Select * from Users Where UserId ='{txtUserId.Text}'");
         if (userCheckDT.Rows.Count > 1)
         {
             MsgBox.Show($"User Already Registered", "Sign up Error", "OK", "Cancel");
         }
         else //If finds no previous record user's information is inserted to database.
         {
             DatabaseNonQuery.InsertUpdateDelete($"Insert into Users(FirstName, LastName, UserId, Contact, Email, Address, Password, UserType) values('{txtFirstName.Text}','{txtLastName.Text}','{txtUserId.Text}','{txtContact.Text}','{txtEmail.Text}','{txtAddress.Text}','{txtPassword.Text}','{cmbUserType.Text}')");
             ShowTableData();
             MessageBox.Show("User Registration Complete. User Can login now", "Data Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
             MangingFormAndControls.PanelClear(panelUserInfo); //After operation all the text boxes are cleared.
         }
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Stors user datafield's data to the textboxs. By getting data table from TabelConnector class.
        /// </summary>
        /// <param name="Command"> Select query for retriving data form the data field to initialze to the datafield.</param>
        void UserInformation(string Command)
        {
            DataTable dt = TabelConnector.DataTableLoader(Command);

            try
            {
                txtTitle.Text        = dt.Rows[0][1].ToString();
                txtAuthorsList.Text  = dt.Rows[0][2].ToString();
                cmbDocType.Text      = dt.Rows[0][3].ToString();
                txtYear.Text         = dt.Rows[0][4].ToString();
                txtPublisher.Text    = dt.Rows[0][5].ToString();
                txtAbstract.Text     = dt.Rows[0][6].ToString();
                txtNameOfSource.Text = dt.Rows[0][7].ToString();
                txtIssue.Text        = dt.Rows[0][8].ToString();
                txtVolume.Text       = dt.Rows[0][9].ToString();
                txtPageNumber.Text   = dt.Rows[0][10].ToString();
                txtNotes.Text        = dt.Rows[0][11].ToString();
                userId = Convert.ToInt32(dt.Rows[0][12]);
            }
            catch
            {
                MessageBox.Show("Invalid Selection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 //Loades user datatable data to the UsersDataGridView.
 void ShowTableData()
 {
     dgvUsersData.DataSource = TabelConnector.DataTableLoader("Select * from Users");
 }
 //Admin search for particular user using userid
 private void SearchData(object sender, EventArgs e)
 {
     dgvUsersData.DataSource = TabelConnector.DataTableLoader($"Select * from Users where id='{txtSearch.Text}'");
 }
Esempio n. 11
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     DGVArticlesList.DataSource = TabelConnector.DataTableLoader($"select * from tbltext where text like '%{txtSearch.Text}%' and UserId='{UserInfo.id}'");
 }
Esempio n. 12
0
 //Article DataGridView loads all the documents of the logged in user.
 void ArticleLoader()
 {
     DGVArticlesList.DataSource = TabelConnector.DataTableLoader($"Select * from TblText where userID = '{UserInfo.id}'");
 }
Esempio n. 13
0
 //Searches all the matching titles of the refrences of from the refrences.
 private void btnSearch_Click(object sender, EventArgs e)
 {
     DGVRefrenceList.DataSource = TabelConnector.DataTableLoader($"select * from TblReference where Title like '%{txtSearch.Text}%'");
 }
Esempio n. 14
0
 //Loads data table's data to the DataGridView.
 void ShowTableData()
 {
     DGVRefrenceList.DataSource = TabelConnector.DataTableLoader("Select * from TblReference");
 }