private void button7_Click(object sender, EventArgs e) { label8.Visible = false; label9.Visible = false; string fName = textBox1.Text; string lName = textBox2.Text; string pNo = textBox3.Text; string userName = comboBox1.SelectedItem.ToString(); string password = textBox5.Text; if (fName.Length < 1 || lName.Length < 1 || pNo.Length < 1 || userName.Length < 1 || password.Length < 1) { label9.Text = "Please Fill All The Fields"; label9.Visible = true; return; } if (!password.Equals(textBox6.Text)) { label8.Visible = true; return; } DataSets.Users userInfo = new DataSets.Users(); userInfo.fName = fName; userInfo.lName = lName; userInfo.pNo = pNo; userInfo.userName = userName; userInfo.password = password; DataBaseManager dbm = new DataBaseManager(); dbm.updateUser(userInfo); MessageBox.Show("The User Has Been Updated Successfully."); this.Dispose(); }
public void deleteUser(DataSets.Users userInfo) { string sql = "DELETE FROM USERS WHERE UserName='******'"; m_dbConnection.Open(); SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); m_dbConnection.Close(); }
public void updateUser(DataSets.Users userInfo) { m_dbConnection.Open(); string sql = "UPDATE USERS SET Password='******'," + "Fname='" + userInfo.fName + "',Lname='" + userInfo.lName + "', Pno='" + userInfo.pNo + "' WHERE UserName='******'"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); m_dbConnection.Close(); }
private void button1_Click(object sender, EventArgs e) { string userName = comboBox1.SelectedItem.ToString(); if (userName.Equals("admin")) { MessageBox.Show("Admin Cannot Be Deleted."); return; } DataSets.Users userInfo = new DataSets.Users(); userInfo.userName = userName; dbm.deleteUser(userInfo); MessageBox.Show("The User Has Been Deleted Successfully."); this.Dispose(); }
public List <DataSets.Users> getUsers() { List <DataSets.Users> retVal = new List <DataSets.Users>(); m_dbConnection.Open(); string sql = "SELECT * FROM USERS"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { DataSets.Users temp = new DataSets.Users(); temp.userName = reader.GetString(0); temp.password = reader.GetString(1); temp.fName = reader.GetString(2); temp.lName = reader.GetString(3); temp.pNo = reader.GetString(4); retVal.Add(temp); } reader.Close(); m_dbConnection.Close(); return(retVal); }
public bool addUser(DataSets.Users userInfo) { bool retVal = false; m_dbConnection.Open(); string sql = "SELECT * FROM USERS WHERE UserName='******'"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); SQLiteDataReader reader = command.ExecuteReader(); if (!reader.Read()) { reader.Close(); retVal = true; sql = "insert into USERS (UserName, Password,Fname,Lname,Pno,UT) values ('" + userInfo.userName + "', '" + userInfo.password + "','" + userInfo.fName + "','" + userInfo.lName + "','" + userInfo.pNo + "','C')"; command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); m_dbConnection.Close(); return(retVal); } reader.Close(); m_dbConnection.Close(); return(retVal); }