Ilova 
Login form - O`zbekiston Respublikasi Oliy va O`rta maxsus

Ilova
Login form
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;
namespace DavomatTizimi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox2.UseSystemPasswordChar = true;
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
if (textBox1.Text.Equals("admin")) {
if (textBox2.Text.Equals("admin123"))
{
f2.Show();
}
else {
MessageBox.Show("Login yoki Parol noto`g`ri","!!");
}
}
}
}
}
Asosiy form
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 System.Data.OleDb;
namespace DavomatTizimi
{
public partial class Form2 : Form
{
OleDbConnection conn;
OleDbCommand cmd;
OleDbDataAdapter adapter;
DataTable dt;
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
// TODO: данная строка кода позволяет загрузить данные в таблицу "davomatTizimiDataSet.students". При необходимости она может быть перемещена или удалена.
this.studentsTableAdapter.Fill(this.davomatTizimiDataSet.students);
// TODO: данная строка кода позволяет загрузить данные в таблицу "davomatTizimiDataSet.students". При необходимости она может быть перемещена или удалена.
}
private void button1_Click(object sender, EventArgs e)
{
conn = new OleDbConnection("Provider=Microsoft.ACE.OleDb.12.0; Data Source=davomatTizimi.mdb");
dt = new DataTable();
if (comboBox1.SelectedItem.ToString().Equals("202-KIDT"))
{
dt = new DataTable();
adapter = new OleDbDataAdapter("select * from students where guruhi='202-KIDT'", conn);
//cmd.Parameters.AddWithValue("@idk", textBox1.Text);
//cmd.Parameters.AddWithValue("@ism", textBox2.Text);
//cmd.Parameters.AddWithValue("@fam", textBox3.Text);
//cmd.Parameters.AddWithValue("@tel", textBox4.Text);
//cmd.Parameters.AddWithValue("@manzil", textBox5.Text);
//cmd.Parameters.AddWithValue("@email", textBox6.Text);
//cmd.Parameters.AddWithValue("@psp", textBox7.Text);
conn.Open();
adapter.Fill(dt);
dataGridView1.DataSource = dt;
//cmd.ExecuteNonQuery();
conn.Close();
}
else {
dt = new DataTable();
adapter = new OleDbDataAdapter("select * from students where guruhi='192-Fizika'", conn);
conn.Open();
adapter.Fill(dt);
dataGridView1.DataSource = dt;
//cmd.ExecuteNonQuery();
conn.Close();
}
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
int index = e.RowIndex;
DataGridViewRow selectedRow = dataGridView1.Rows[index];
textBox1.Text = selectedRow.Cells[1].Value.ToString();
textBox2.Text = selectedRow.Cells[2].Value.ToString();
textBox3.Text = selectedRow.Cells[3].Value.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
conn = new OleDbConnection("Provider=Microsoft.ACE.OleDb.12.0; Data Source=davomatTizimi.mdb");
dt = new DataTable();
cmd = new OleDbCommand("INSERT INTO baholar(Ismi,Familyasi,Guruhi,Fan,Baho) values" +
"(@ismi,@fam,@gur,@fan,@b)", conn);
cmd.Parameters.AddWithValue("@ism", textBox1.Text);
cmd.Parameters.AddWithValue("@fam", textBox2.Text);
cmd.Parameters.AddWithValue("@gur", textBox3.Text);
cmd.Parameters.AddWithValue("@fan", comboBox2.Text);
cmd.Parameters.AddWithValue("@b", textBox4.Text);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("Saqlandi");
}
private void button3_Click(object sender, EventArgs e)
{
Form3 f3 = new Form3();
f3.Show();
}
}
}
http://fayllar.org
|