private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int ref_id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[2].Value); string command = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); if (command == "Edit") { Edit_References er = new Edit_References(ref_id); er.userID = userid; this.Close(); er.Show(); } else if (command == "Delete") { try { string qry = "delete from tbl_References where Ref_Id=" + ref_id; DatabaseCon dbcon = new DatabaseCon(); dbcon.Query = qry; dbcon.ExecuteQuery(); MessageBox.Show("Data deleted successfully"); loadReferences(); } catch (Exception ex) { throw ex; } } }
private void btn_confirm_Click(object sender, EventArgs e) { string gender = ""; if (radioMale.Checked) { gender = "Male"; } else if (radioFemale.Checked) { gender = "Female"; } else if (radioOthers.Checked) { gender = "Others"; } else { MessageBox.Show("Please choose your gender."); } UserValidation uv = new UserValidation(); if (uv.emptyValidation(txtFname.Text) == true && uv.emptyValidation(txtSurname.Text) == true) { if (!string.IsNullOrEmpty(gender)) { try { string qry = "update tbl_User set First_Name ='" + txtFname.Text + "', Surname ='" + txtSurname.Text + "', Address ='" + txtAddress.Text + "', Gender ='" + gender + "', Phone ='" + txtPhone.Text + "', Dob ='" + Datetimepicker_dob.Value.Date + "' where ID = " + userid; DatabaseCon dbcon = new DatabaseCon(); dbcon.Query = qry; dbcon.ExecuteQuery(); MessageBox.Show("Data Edited"); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Please choose your gender."); radioMale.Focus(); } } else { MessageBox.Show("Please Enter Your Full Name"); txtFname.Focus(); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { string command = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); int tag_Id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[3].Value); if (command == "Edit") { Edit_Tags et = new Edit_Tags(tag_Id); et.UserID = userId; this.Close(); et.Show(); } else if (command == "Delete") { try { string qry = "delete from [tbl_Tags] where Tag_Id =" + tag_Id; DatabaseCon dbcon = new DatabaseCon(); dbcon.Query = qry; dbcon.ExecuteQuery(); MessageBox.Show("Data deleted successfully"); loadTag(); } catch (Exception ex) { throw ex; } } else if (command == "Tagged Article") { try { string qry = "select Tag from [tbl_Tags] where Tag_Id =" + tag_Id; DatabaseCon dbcon = new DatabaseCon(); dbcon.Query = qry; DataTable dt = dbcon.GetData(); string Tag = dt.Rows[0]["Tag"].ToString(); View_myReferences vr = new View_myReferences(userId); vr.Tag = Tag; this.Close(); vr.Show(); } catch (Exception ex) { throw ex; } } }
public bool insertTag() { try { string qry = "insert into tbl_Tags values ('" + Tag + "'," + UserId + ")"; DatabaseCon dbcon = new DatabaseCon(); dbcon.Query = qry; dbcon.ExecuteQuery(); return(true); } catch (Exception ex) { throw ex; } }
private void btn_confirm_Click(object sender, EventArgs e) { loginUserdata l = new loginUserdata(); DataTable dt = l.userdata(userid); if (dt.Rows[0]["Password"].ToString() == txtCurrentpw.Text) { if (txtNewpw.Text == txtConfirmpw.Text) { DialogResult result1 = MessageBox.Show("Are you sure you want to Change password?", "The Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result1 == DialogResult.Yes) { try { string qry = "Update tbl_User set Password ='******' where ID =" + userid; DatabaseCon dbcon = new DatabaseCon(); dbcon.Query = qry; dbcon.ExecuteQuery(); MessageBox.Show("Password changed sucessfully.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); Profile p = new Profile(userid); p.Show(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } else { //nothing } } else { MessageBox.Show("Password and Confirm Password doesn't match."); } } else { MessageBox.Show("Incorrect Current Password."); } }
private void btnSave_Click(object sender, EventArgs e) { try { string qry = "update tbl_Tags set Tag='" + txtTag.Text + "' where Tag_Id= " + tagId; DatabaseCon dbcon = new DatabaseCon(); dbcon.Query = qry; dbcon.ExecuteQuery(); MessageBox.Show("Done"); this.Close(); } catch (Exception ex) { throw ex; } }
public bool insert() { try { string qry = "insert into tbl_References values ('" + Title + "','" + Authors_Fname + "','" + Authors_Lname + "','" + Document_type + "','" + Year + "','" + Publisher + "','" + City + "','" + Abstract + "','" + Name + "','" + Issue + "','" + Volume + "'," + Pageno + ",'" + Notes + "'," + Userid + ")"; DatabaseCon dbcon = new DatabaseCon(); dbcon.Query = qry; dbcon.ExecuteQuery(); return(true); } catch (Exception ex) { throw ex; } }
private void btnSave_Click(object sender, EventArgs e) { ReferencesValidation rv = new ReferencesValidation(); string[] parameters = new string[] { txtTitle.Text, txtAuthors_Fname.Text, txtAuthors_Fname.Text, txtDocumenttype.Text, txtYear.Text, txtPublisher.Text, txtAbstract.Text, txtName.Text, txtIssue.Text, txtVolume.Text, txtPageno.Text }; if (rv.checkEmpty(parameters) == true) { if (rv.numberValid(txtPageno.Text) == true) { try { string qry = "update tbl_References set Title ='" + txtTitle.Text + "', Authors_Fname ='" + txtAuthors_Fname.Text + "', Authors_Lname ='" + txtAuthors_Lname.Text + "', Document_type ='" + txtDocumenttype.Text + "', Year ='" + txtYear.Text + "', Publisher ='" + txtPublisher.Text + "', City ='" + txtCity.Text + "', Abstract ='" + txtAbstract.Text + "', Name ='" + txtName.Text + "', Issue ='" + txtIssue.Text + "', Volume ='" + txtVolume.Text + "', Page_no =" + int.Parse(txtPageno.Text) + ", Notes ='" + txtNotes.Text + "' where Ref_Id =" + referenceId; DatabaseCon dbcon = new DatabaseCon(); dbcon.Query = qry; dbcon.ExecuteQuery(); MessageBox.Show("Done."); this.Close(); } catch (Exception ex) { throw ex; } } else { MessageBox.Show("Please enter numberic value for Page number."); txtPageno.Focus(); } } else { MessageBox.Show("Don't leave any field with * empty."); } }