https://www.coursehero.com
https://it-black.ru/rabota-s-bazoj-dannyh-v-ci_sharp
https://metanit.com
Ilovalar Umumiy qism LoginForm:
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 DocumentKafedra
{
publicpartialclassForm1 : Form
{
public Form1()
{
InitializeComponent();
}
privatevoid Form1_Load(object sender, EventArgs e)
{
textBox2.UseSystemPasswordChar = true;
}
privatevoid button1_Click(object sender, EventArgs e)
{
Form2 f2 = newForm2();
if (textBox1.Text == "kafedra"&& textBox2.Text == "kafedra22")
{
this.Hide();
f2.Show();
}
else
{
MessageBox.Show("Login yoki parol noto'g'ri");
}
}
privatevoid checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
textBox2.UseSystemPasswordChar = false;
}
else
{
textBox2.UseSystemPasswordChar = true;
}
}
privatevoid button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Ikkichi 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 DocumentKafedra
{
publicpartialclassForm2 : Form
{
OleDbConnection conn;
OleDbCommand cmd;
OleDbDataAdapter adapter;
DataTabledt;
public Form2()
{
InitializeComponent();
}
privatevoid button1_Click(object sender, EventArgs e)
{
if (comboBox1.SelectedItem.ToString() == "Bakalavr"&& comboBox2.SelectedItem.ToString() == "2"&&comboBox3.SelectedItem.ToString() == "Kompyuter ilmlari va dasturlash texnologiyalari"&& comboBox4.SelectedItem.ToString() == "O'quv rejalari")
{
conn = newOleDbConnection("Provider=Microsoft.ACE.OleDb.12.0; Data Source=Kafedra.accdb");
dt = newDataTable();
adapter = newOleDbDataAdapter("select * from reja", conn);
conn.Open();
adapter.Fill(dt);
dataGridView1.DataSource = dt;
conn.Close();
textBox9.Visible = false;
label14.Visible = false;
label6.Visible = true;
label7.Visible = true;
label8.Visible = true;
label9.Visible = true;
label10.Visible = true;
label11.Visible = true;
label12.Visible = true;
label13.Visible = true;
textBox1.Visible = true;
textBox2.Visible = true;
textBox3.Visible = true;
textBox4.Visible = true;
textBox5.Visible = true;
textBox6.Visible = true;
textBox7.Visible = true;
textBox8.Visible = true;
button3.Visible = true;
button4.Visible = true;
button5.Visible = true;
}
if (comboBox1.SelectedItem.ToString() == "Bakalavr"&& comboBox2.SelectedItem.ToString() == "2"&& comboBox3.SelectedItem.ToString() == "Kompyuter ilmlari va dasturlash texnologiyalari"&& comboBox4.SelectedItem.ToString() == "Studentlar va magistrlar haqida ma'lumot")
{
conn = newOleDbConnection("Provider=Microsoft.ACE.OleDb.12.0; Data Source=Kafedra.accdb");
dt = newDataTable();
adapter = newOleDbDataAdapter("select * from bakalavr2kurs", conn);
conn.Open();
adapter.Fill(dt);
dataGridView1.DataSource = dt;
conn.Close();
conn.Close();
label6.Visible = false;
label7.Visible = false;
label8.Visible = false;
label9.Visible = false;
label10.Visible = false;
label11.Visible = false;
label12.Visible = false;
label13.Visible = false;
textBox1.Visible = false;
textBox2.Visible = false;
textBox3.Visible = false;
textBox4.Visible = false;
textBox5.Visible = false;
textBox6.Visible = false;
textBox7.Visible = false;
textBox8.Visible = false;
button3.Visible = false;
button4.Visible = false;
button5.Visible = false;
label14.Visible = true;
textBox9.Visible = true;
dataGridView1.Width = 527;
dataGridView1.Height = 258;
}
if (comboBox1.SelectedItem.ToString() == "Magistr"&& comboBox2.SelectedItem.ToString() == "1"&& comboBox3.SelectedItem.ToString() == "Kompyuter ilmlari va dasturlash texnologiyalari"&& comboBox4.SelectedItem.ToString() == "Studentlar va magistrlar haqida ma'lumot")
{
conn = newOleDbConnection("Provider=Microsoft.ACE.OleDb.12.0; Data Source=Kafedra.accdb");
dt = newDataTable();
adapter = newOleDbDataAdapter("select * from magistr1", conn);
conn.Open();
adapter.Fill(dt);
dataGridView1.DataSource = dt;
conn.Close();
label6.Visible = false;
label7.Visible = false;
label8.Visible = false;
label9.Visible = false;
label10.Visible = false;
label11.Visible = false;
label12.Visible = false;
label13.Visible = false;
textBox1.Visible = false;
textBox2.Visible = false;
textBox3.Visible = false;
textBox4.Visible = false;
textBox5.Visible = false;
textBox6.Visible = false;
textBox7.Visible = false;
textBox8.Visible = false;
button3.Visible = false;
button4.Visible = false;
button5.Visible = false;
dataGridView1.Width = 527;
dataGridView1.Height = 265;
label14.Visible = true;
textBox9.Visible = true;
}
}
privatevoid button2_Click(object sender, EventArgs e)
{
this.Hide();
}
privatevoid dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
DataGridViewRow row=dataGridView1.Rows[e.RowIndex];
textBox8.Text =row.Cells[0].Value.ToString();
textBox1.Text=row.Cells[1].Value.ToString();
textBox2.Text = row.Cells[2].Value.ToString();
textBox3.Text = row.Cells[3].Value.ToString();
textBox4.Text = row.Cells[4].Value.ToString();
textBox5.Text = row.Cells[5].Value.ToString();
textBox6.Text = row.Cells[6].Value.ToString();
textBox7.Text = row.Cells[7].Value.ToString();
}
}
privatevoid button3_Click(object sender, EventArgs e)
{
string query = "INSERT INTO reja (Fan_nomi,Fan_turi,Maruza_mashguloti,Seminar,Mustaqil_talim,Jami_yuklama,Kredit) values" + "(@fan_nomi,@fan_turi,@maruza_mashguloti,@seminar,@mustaqil_talim,@jami_yuklama,@kredit)";
cmd = newOleDbCommand(query, conn);
cmd.Parameters.AddWithValue("@fan_nomi", textBox1.Text);
cmd.Parameters.AddWithValue("@fan_turi", textBox2.Text);
cmd.Parameters.AddWithValue("@maruza_mashguloti", textBox3.Text);
cmd.Parameters.AddWithValue("@seminar", textBox4.Text);
cmd.Parameters.AddWithValue("@mustaqil-talim", textBox5.Text);
cmd.Parameters.AddWithValue("@jami_yuklama", textBox6.Text);
cmd.Parameters.AddWithValue("@kredit", textBox7.Text);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("Saqlandi");
reja();
}
privatevoid reja()
{
conn = newOleDbConnection("Provider=Microsoft.ACE.OleDb.12.0; Data Source=Kafedra.accdb");
dt = newDataTable();
adapter = newOleDbDataAdapter("select * from reja", conn);
conn.Open();
adapter.Fill(dt);
dataGridView1.DataSource = dt;
conn.Close();
}
privatevoid button5_Click(object sender, EventArgs e)
{
DataGridViewRow row = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex];
string query = "DELETE FROM reja WHERE №=@№";
cmd = newOleDbCommand(query, conn);
cmd.Parameters.AddWithValue("@№", int.Parse(row.Cells[0].Value.ToString()));
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("O`chirildi");
reja();
}
privatevoid button4_Click(object sender, EventArgs e)
{
DataGridViewRow row = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex];
string query = "UPDATE reja SET Fan_nomi=@fan_nomi, Fan_turi=@fan_turi,Maruza_mashguloti=@maruza_mashguloti,Seminar=@seminar,Mustaqil_talim=@mustaqil_talim,Jami_yuklama=@jami_yuklama,Kredit=@kredit WHERE №=@№ ";
cmd = newOleDbCommand(query, conn);
cmd.Parameters.AddWithValue("@fan_nomi", textBox1.Text);
cmd.Parameters.AddWithValue("@fan_turi", textBox2.Text);
cmd.Parameters.AddWithValue("@maruza_mashguloti", textBox3.Text);
cmd.Parameters.AddWithValue("@seminar", textBox4.Text);
cmd.Parameters.AddWithValue("@mustaqil-talim", textBox5.Text);
cmd.Parameters.AddWithValue("@jami_yuklama", textBox6.Text);
cmd.Parameters.AddWithValue("@kredit", textBox7.Text);
cmd.Parameters.AddWithValue("@№", int.Parse(textBox8.Text));
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("Yangilandi");
reja();
}
privatevoid textBox9_TextChanged(object sender, EventArgs e)
{
DataView dv = dt.DefaultView;
dv.RowFilter = "Ism LIKE '%" + textBox9.Text + "%'";
}
privatevoid Form2_Load(object sender, EventArgs e)
{
label6.Visible = false;
label7.Visible = false;
label8.Visible = false;
label9.Visible = false;
label10.Visible = false;
label11.Visible = false;
label12.Visible = false;
label13.Visible = false;
textBox1.Visible = false;
textBox2.Visible = false;
textBox3.Visible = false;
textBox4.Visible = false;
textBox5.Visible = false;
textBox6.Visible = false;
textBox7.Visible = false;
textBox8.Visible = false;
button3.Visible = false;
button4.Visible = false;
button5.Visible = false;
textBox9.Visible = false;
label14.Visible = false;
}
}
}
|