«Axborot tizimlari» kafedrasi Axborot tizimlari va texnologiyalari yo’nalishi 20 21 guruh talabasi Normamatova Sevinchning


Download 59.9 Kb.
Sana15.06.2023
Hajmi59.9 Kb.
#1485697
Bog'liq
algaretim 7


OʻZBEKISTON RESPUBLIKASI OLIY VA O‘RTA MAXSUS TA’LIM VAZIRLIGI
MIRZO ULUG‘BEK NOMIDAGI MILLIY UNIVERSITETININIG JIZZAX FILIALI



AMALIY MATEMATIKA FAKULTETI
«Axborot tizimlari» kafedrasi
Axborot tizimlari va texnologiyalari yo’nalishi
20 21 guruh talabasi
Normamatova Sevinchning
ALGORITMIK TILLAR VA DASTURLASH” FANIDAN

7-amaliy topshiriq


Jizzax – 2023


Berilgan Topshiriq: VAR17


Quyidagi rasmda ko’rsatilgan tasvirni hosil qiluvchi dastur tuzing:
Berilgan Topshiriqning chiqarilgan javobi:




Berilgan Topshiriqni Codi:
SQLCODE:
CREATE TABLE Xodimlar ( FIO VARCHAR(50) NOT NULL, lavozimi VARCHAR(50) NOT NULL, bo_lim_raqami INT NOT NULL, jinsi VARCHAR(10) NOT NULL, manzili VARCHAR(100) NOT NULL, tug_ilgan_sanasi DATE NOT NULL,
PRIMARY KEY (FIO)
);
CREATE TABLE Tashkilot (
tashkilot_nomi VARCHAR(100) NOT NULL, faoliyat_turi VARCHAR(100) NOT NULL, davlat VARCHAR(50) NOT NULL, shahar VARCHAR(50) NOT NULL, manzili VARCHAR(100) NOT NULL, direktor_FIO VARCHAR(50) NOT NULL,
PRIMARY KEY (tashkilot_nomi)
);
CREATE TABLE Shartnomalar ( shartnoma_raqami INT NOT NULL, shartnoma_tuzilgan_sana DATE NOT NULL, tashkilot_nomi VARCHAR(100) NOT NULL, shartnoma_qiymati INT NOT NULL, PRIMARY KEY (shartnoma_raqami),
FOREIGN KEY (tashkilot_nomi) REFERENCES Tashkilot (tashkilot_nomi)
);
CREATE TABLE Loyiha_ishlari ( boshlanish_sanasi DATE NOT NULL, tugallanish_sanasi DATE NOT NULL, shartnoma_raqami INT NOT NULL, rivojlantirish_bo_lim INT NOT NULL,
PRIMARY KEY (boshlanish_sanasi),
FOREIGN KEY (shartnoma_raqami) REFERENCES Shartnomalar (shartnoma_raqami)
);
FORM1.cs
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 tashkilot_13var
{
public partial class Form1 : Form
{
DataBase dataBase = new DataBase();
public Form1()
{
InitializeComponent();
}
private void Xodimlarlink_LinkClicked(object sender,
LinkLabelLinkClickedEventArgs e)
{
Form2 form2 = new Form2(); form2.Show();
}
} }
DATAGRIDVIEW.cs
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 tashkilot_13var
{ public partial class DataGridViewForm : Form
{
private DataGridView dataGridView; public DataGridViewForm(DataTable table)
{
dataGridView = new DataGridView(); dataGridView.DataSource = table; Controls.Add(dataGridView); dataGridView.Dock = DockStyle.Fill;
}
public DataGridViewForm()
{
InitializeComponent();
}
} } Form2.cs
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.SqlClient;
namespace tashkilot_13var
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
StartPosition = FormStartPosition.CenterScreen;
}
private void Form2_Load(object sender, EventArgs e)
{
fishtxt.MaxLength = 50; lavozimtxt.MaxLength = 50; manziltxt.MaxLength = 70;
}
private void button1_Click(object sender, EventArgs e)
{
string connectionString = con.Text; string jinsi = "belgilanmagan"; if (erkakradiobutton.Checked == true)
{
jinsi = "erkak";
}
else if (ayolradiobutton.Checked == true)
{
jinsi = "ayol";
}
string tableName = "Xodimlar";
List fieldNames = new List { "FIO", "lavozimi",
"bo_lim_raqami", "jinsi", "manzili", "tug_ilgan_sanasi" };
List fieldValues = new List { fishtxt.Text, lavozimtxt.Text,
(int)raqamiupdown.Value, jinsi, manziltxt.Text, tugilganDate.Value };
string queryParameters = string.Join(",", fieldNames.Select((name, i) =>
$"@p{i}"));
string queryString = $"INSERT INTO {tableName} ({string.Join(",",
fieldNames)}) VALUES ({queryParameters})";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand(queryString, connection))
{
for (int i = 0; i < fieldValues.Count; i++)
{
command.Parameters.AddWithValue($"@p{i}", fieldValues[i]);
}
command.ExecuteNonQuery();
}
}
MessageBox.Show("Muvoffaqiyatli qo'shildi!!");
}
private void button3_Click(object sender, EventArgs e)
{
string idToDelete = fishtxt.Text; string tableName = "Xodimlar"; string connectionString = con.Text;
string queryString = $"DELETE FROM {tableName} WHERE FIO = '{idToDelete}'";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand(queryString, connection))
{
command.ExecuteNonQuery();
}
}
MessageBox.Show("Muvoffaqiyatli o'chirildi!!");
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
{
lavozimtxt.Enabled = false; raqamiupdown.Enabled = false; erkakradiobutton.Enabled = false; ayolradiobutton.Enabled = false; manziltxt.Enabled = false; tugilganDate.Enabled = false;
} else {
lavozimtxt.Enabled = true; raqamiupdown.Enabled = true; erkakradiobutton.Enabled = true; ayolradiobutton.Enabled = true; manziltxt.Enabled = true; tugilganDate.Enabled = true;
}
}
private void button2_Click(object sender, EventArgs e)
{
DataTable table = new DataTable(); string connectionString = con.Text;
string queryString = "SELECT * FROM Xodimlar";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter(queryString, connection)) {
adapter.Fill(table);
}
}
DataGridViewForm form = new DataGridViewForm(table);
form.Show();
}
} }

Download 59.9 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling