Esempio n. 1
0
        //Delete button click event for Document delete.
        private void btnDeleteText_Click(object sender, EventArgs e)
        {
            DialogResult dr = MsgBox.Show("Do You want to Update the Document ?", "Confirmation", "YES", "NO");

            if (dr == DialogResult.Yes)
            {
                DatabaseNonQuery.InsertUpdateDelete($"Delete from TblText where id='{articleId}'");
                MangingFormAndControls.PanelClear(PanelText);
                ArticleLoader();
                MessageBox.Show("File Deleted From Storage", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 2
0
 //Allows user to delete their records.
 private void DeleteReference(object sender, EventArgs e)
 {
     if (UserInfo.id == userId)
     {
         DatabaseNonQuery.InsertUpdateDelete($"Delete from TblReference where id ='{id}'");
         ShowTableData();
         MangingFormAndControls.PanelClear(PanelRefrenceFields);
     }
     else
     {
         MsgBox.Show("You cannot Delete This Reference.", "Error", "OK", "Cancel");
     }
 }
        //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.
            }
        }
Esempio n. 4
0
 //Updates saved refrences if the user is trying to update own recoard.
 private void UpdateReference(object sender, EventArgs e)
 {
     if (txtTitle.Text == "" || cmbDocType.SelectedIndex == 0 || txtYear.Text == "" || txtPublisher.Text == "" || txtNameOfSource.Text == "" || txtPageNumber.Text == "")///
     {
         MessageBox.Show("Title, Document type, Year, Publisher, Name of Source, Page Number fields cannot be empty.", "Field Empty", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         if (UserInfo.id == userId)
         {
             DatabaseNonQuery.InsertUpdateDelete($"Update TblReference set Title ='{txtTitle.Text}', Author ='{txtAuthorsList.Text}' , DocumentType = '{cmbDocType.Text}', Year ='{txtYear.Text}', Publisher = '{txtPublisher.Text}' , Abstract = '{txtAbstract.Text}' , NameOfSource = '{txtNameOfSource.Text}' , Issue = '{txtIssue.Text}' , Volume = '{txtVolume.Text}' , PageNumbers = '{txtPageNumber.Text}' , Notes = '{txtNotes.Text}', UserID = '{UserInfo.id}' where id ='{id}'");
             ShowTableData();
             MangingFormAndControls.PanelClear(PanelRefrenceFields);
         }
         else
         {
             MsgBox.Show("You cannot Edit This Reference.", "Error", "OK", "Cancel");
         }
     }
 }
Esempio n. 5
0
 //Saves textbox's data to the database. if the user is not a Guest.
 private void SaveReference(object sender, EventArgs e)
 {
     if (txtTitle.Text == "" || cmbDocType.SelectedIndex == 0 || txtYear.Text == "" || txtPublisher.Text == "" || txtNameOfSource.Text == "" || txtPageNumber.Text == "")
     {
         MessageBox.Show("Title, Document type, Year, Publisher, Name of Source, Page Number fields cannot be empty.", "Field Empty", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         if (UserInfo.loggedIn == true)
         {
             DatabaseNonQuery.InsertUpdateDelete($"Insert into TblReference (Title, Author, DocumentType, Year, Publisher, Abstract, NameOfSource, Issue, Volume, PageNumbers, Notes, UserID) values('{txtTitle.Text}','{txtAuthorsList.Text}','{cmbDocType.Text}','{txtYear.Text}','{txtPublisher.Text}','{txtAbstract.Text}','{txtNameOfSource.Text}','{txtIssue.Text}','{txtVolume.Text}','{txtPageNumber.Text}','{txtNotes.Text}','{UserInfo.id}')");
             ShowTableData();
             MangingFormAndControls.PanelClear(PanelRefrenceFields);
         }
         else
         {
             //Shows error if it is Guest.
             MsgBox.Show("Please Signup / Login First", "Operation Fail", "Ok", "Cancel");
         }
     }
 }
 //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
 //Clears all textbox's of the panel.
 private void ClearTextBoxes(object sender, EventArgs e)
 {
     MangingFormAndControls.PanelClear(PanelRefrenceFields);
 }
Esempio n. 9
0
 //Formats author's names and keeps them for database entry.
 private void btnAdd_Click(object sender, EventArgs e)
 {
     txtAuthorsList.Text += $"{txtLastName.Text}, {txtFirstName.Text} {txtMiddleName.Text}; ";
     MangingFormAndControls.PanelClear(panelAuthorName);
 }