0% found this document useful (0 votes)
10 views

Using System

Uploaded by

Naidine Villeroz
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Using System

Uploaded by

Naidine Villeroz
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ADODB;

namespace C_CRUDApp_Villeroz2022_C_153_
{
public partial class Form1 : Form
{
ADODB.Connection con = new ADODB.Connection();
ADODB.Command cmd = new ADODB.Command();
ADODB.Recordset rs = new ADODB.Recordset();

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
con.Open($"Provider=Microsoft.ACE.OLEDB.12.0;Data
Source={Application.StartupPath}\\C#Database(Crud).accdb");
cmd.ActiveConnection = con;

private void button1_Click(object sender, EventArgs e)


{
try
{
cmd.CommandText = $"Select * from Usertable where User =
'{UserTxt.Text}' and Pass = '{PassTxt.Text}'";
rs = cmd.Execute(out object recordsAffected, Type.Missing, -1);
if (rs.EOF == false)
{
var crud1 = new CRUD_C__();
UserTxt.Clear();
PassTxt.Clear();
crud1.Show();
con.Close();
this.Hide();
}
else if (UserTxt.Text == "" || PassTxt.Text == "")
{
MessageBox.Show("Type your username or password");

}
else
{
cmd.CommandText = $"Select * from Usertable where User =
'{UserTxt.Text}'";
rs = cmd.Execute(out object recordsAffected1, Type.Missing, -
1);
if (rs.EOF == false)
{
MessageBox.Show("Wrong password", "Error");
}
else
{
MessageBox.Show("This account does not exist", "Error");
}

}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void panel1_Paint(object sender, PaintEventArgs e)

private void ClearBT_Click(object sender, EventArgs e)


{
UserTxt.Text = string.Empty;
PassTxt.Text = string.Empty;
}

private void checkBox1_CheckedChanged(object sender, EventArgs e)


{
PassTxt.PasswordChar = checkBox1.Checked ? '\0' : '*';
}

private void label4_Click(object sender, EventArgs e)


{
Close();
}
}
}

You might also like