Файл: Содержание информационнологическое (Инфологическое) проектирование бд. 6 Определение требований к операционной обстановке 8 Заключение 40 Список литературы 41 Введение.docx
Добавлен: 19.03.2024
Просмотров: 69
Скачиваний: 0
ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.
textBox16.Text = Convert.ToString(fill.Cells[1].Value);
}
private void button5_Click(object sender, EventArgs e)
{
bd.Showмарки(dataGridView1);
}
private void button6_Click(object sender, EventArgs e)
{
bd.Showсерия(dataGridView2);
}
private void button11_Click(object sender, EventArgs e)
{
bd.Showтом(dataGridView3);
}
private void button30_Click(object sender, EventArgs e)
{
bd.Showмарки_том(dataGridView4);
}
private void button20_Click(object sender, EventArgs e)
{
bd.Showмарки_серия(dataGridView5);
}
private void dataGridView5_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
{
DataGridViewRow fill = dataGridView5.CurrentRow;
textBox19.Text = Convert.ToString(fill.Cells[0].Value);
textBox20.Text = Convert.ToString(fill.Cells[1].Value);
}
private void button1_Click(object sender, EventArgs e)
{
string n1 = textBox1.Text;
int n2 = Convert.ToInt32(textBox2.Text);
int n3 = Convert.ToInt32(textBox3.Text);
string n4 = textBox23.Text;
string n5 = textBox22.Text;
string n6 = textBox21.Text;
bd.Addмарка(n1, n2, n3, n4, n5, n6);
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox23.Text = "";
textBox22.Text = "";
textBox21.Text = "";
bd.Showмарки(dataGridView1);
}
private void button2_Click(object sender, EventArgs e)
{
string n1 = textBox1.Text;
int n2 = Convert.ToInt32(textBox2.Text);
int n3 = Convert.ToInt32(textBox3.Text);
string n4 = textBox23.Text;
string n5 = textBox22.Text;
string n6 = textBox21.Text;
string n7 = textBox25.Text;
bd.Updмарка(n1, n2, n3, n4, n5, n6, n7);
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox23.Text = "";
textBox22.Text = "";
textBox21.Text = "";
textBox25.Text = "";
bd.Showмарки(dataGridView1);
}
private void button3_Click(object sender, EventArgs e)
{
string n7 = textBox25.Text;
bd.Delмарка(n7);
textBox25.Text = "";
bd.Showмарки(dataGridView1);
}
private void button10_Click(object sender, EventArgs e)
{
string n1 = textBox4.Text;
string n2 = textBox5.Text;
bd.Addсерия(n1, n2);
textBox4.Text = "";
textBox5.Text = "";
bd.Showсерия(dataGridView2);
}
private void button9_Click(object sender, EventArgs e)
{
string n1 = textBox4.Text;
string n2 = textBox5.Text;
string n7 = textBox26.Text;
bd.Updсерия(n1, n2, n7);
textBox4.Text = "";
textBox5.Text = "";
textBox26.Text = "";
bd.Showсерия(dataGridView2);
}
private void button8_Click(object sender, EventArgs e)
{
string n7 = textBox26.Text;
bd.Delсерия(n7);
textBox26.Text = "";
bd.Showсерия(dataGridView2);
}
private void button15_Click(object sender, EventArgs e)
{
string n1 = textBox8.Text;
string n2 = textBox9.Text;
string n3 = textBox10.Text;
bd.Addтом(n1,n2,n3);
textBox8.Text = "";
textBox9.Text = "";
textBox10.Text = "";
bd.Showтом(dataGridView3);
}
private void button14_Click(object sender, EventArgs e)
{
string n1 = textBox8.Text;
string n2 = textBox9.Text;
string n3 = textBox10.Text;
string n4 = textBox27.Text;
bd.Updтом(n1, n2, n3, n4);
textBox8.Text = "";
textBox9.Text = "";
textBox10.Text = "";
textBox27.Text = "";
bd.Showтом(dataGridView3);
}
private void button13_Click(object sender, EventArgs e)
{
string n4 = textBox27.Text;
bd.Delтом(n4);
textBox27.Text = "";
bd.Showтом(dataGridView3);
}
private void button19_Click(object sender, EventArgs e)
{
string n3 = textBox15.Text;
string n4 = textBox16.Text;
bd.Addмарки_серия(n3, n4);
textBox15.Text = "";
textBox16.Text = "";
bd.Showмарки_серия(dataGridView4);
}
private void button18_Click(object sender, EventArgs e)
{
string n3 = textBox15.Text;
string n4 = textBox16.Text;
string n5 = textBox28.Text;
bd.Updмарки_серия(n3, n4, n5);
textBox15.Text = "";
textBox16.Text = "";
textBox28.Text = "";
bd.Showмарки_серия(dataGridView4);
}
private void button17_Click(object sender, EventArgs e)
{
string n5 = textBox28.Text;
bd.Delмарки_серия(n5);
textBox28.Text = "";
bd.Showмарки_серия(dataGridView4);
}
private void button24_Click(object sender, EventArgs e)
{
string n3 = textBox19.Text;
string n4 = textBox20.Text;
bd.Addмарки_том(n3, n4);
textBox15.Text = "";
textBox16.Text = "";
textBox28.Text = "";
bd.Showмарки_том(dataGridView5);
}
private void button23_Click(object sender, EventArgs e)
{
string n3 = textBox19.Text;
string n4 = textBox20.Text;
string n5 = textBox29.Text;
bd.Updмарки_том(n3, n4, n5);
textBox15.Text = "";
textBox16.Text = "";
textBox28.Text = "";
bd.Showмарки_том(dataGridView5);
}
private void button22_Click(object sender, EventArgs e)
{
string n5 = textBox29.Text;
bd.Delмарки_том(n5);
textBox28.Text = "";
bd.Showмарки_том(dataGridView5);
}
private void button32_Click(object sender, EventArgs e)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string countcmd = "SELECT Номер_тома FROM марки_том WHERE Номер_марки = '" + textBox24.Text + "';";
OleDbDataAdapter checks = new OleDbDataAdapter (countcmd, Conn);
var exec_check = checks.ExecuteScalar();
string countr = "SELECT Страна FROM том WHERE Номер_тома = '" + exec_check.ToString() + "';";
OleDbDataAdapter checkr = new OleDbDataAdapter (countr, Conn);
var exec_checkr = checkr.ExecuteScalar();
textBox31.Text = " Справка о стране марки №" + textBox24.Text + "\n\n" + " Страна марки : " + exec_checkr.ToString() + "\n\n" + " Дата: "
+ DateTime.Now.Date.ToString() +
" \n\n " + "Подпись администратора___________" + " \n\n " + " Администратор___________";
}
private void button31_Click(object sender, EventArgs e)
{
if (printPreviewDialog1.ShowDialog() == DialogResult.OK)
{
printDocument1.Print();
}
}
private void printPreviewDialog1_Load(object sender, EventArgs e)
{
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString(textBox31.Text, new Font("Times New Roman", 20, FontStyle.Bold), Brushes.Black, new PointF(100, 100));
}
private void button34_Click(object sender, EventArgs e)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string countcmd = "select Номер_тома from Том where Страна = '" + textBox33.Text + "';";
OleDbDataAdapter checks = new OleDbDataAdapter(countcmd, Conn);
var exec_check = checks.ExecuteScalar();
string countr = "select count(Номер_марки) from марки_том where Номер_тома = '" + exec_check.ToString() + "';";
OleDbDataAdapter checkr = new OleDbDataAdapter(countr, Conn);
var exec_checkr = checkr.ExecuteScalar();
textBox6.Text = " Число марок по стране "+ textBox33.Text +" = " + exec_checkr.ToString();
}
private void button33_Click(object sender, EventArgs e)
{
}
}
}
Листинг 3 – Form3.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 БД_марки
{
public partial class Form3 : Form
{
Dtdb bd = new Dtdb();
public Form3()
{
InitializeComponent();
bd.Showмарки(dataGridView1);
bd.Showтом(dataGridView3);
bd.Showсерия(dataGridView2);
bd.Showмарки_том(dataGridView5);
bd.Showмарки_серия(dataGridView4);
}
private void button4_Click(object sender, EventArgs e)
{
bd.Showпоиск_марки(dataGridView1, textBox25.Text);
}
private void button7_Click(object sender, EventArgs e)
{
bd.Showпоиск_серия(dataGridView2, textBox26.Text);
}
private void button12_Click(object sender, EventArgs e)
{
bd.Showпоиск_том(dataGridView3, textBox27.Text);
}
private void button16_Click(object sender, EventArgs e)
{
bd.Showпоиск_марки_серия(dataGridView4, textBox28.Text);
}
private void button21_Click(object sender, EventArgs e)
{
bd.Showпоиск_марки_том(dataGridView5, textBox29.Text);
}
private void button5_Click(object sender, EventArgs e)
{
bd.Showмарки(dataGridView1);
}
private void button6_Click(object sender, EventArgs e)
{
bd.Showсерия(dataGridView2);
}
private void button11_Click(object sender, EventArgs e)
{
bd.Showтом(dataGridView3);
}
private void button30_Click(object sender, EventArgs e)
{
bd.Showмарки_серия(dataGridView4);
}
private void button20_Click(object sender, EventArgs e)
{
bd.Showмарки_том(dataGridView5);
}
}
}
Листинг 4 – Dtdb.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
namespace БД_марки
{
class Dtdb
{
public void Showмарки(DataGridView data)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "select * from Марка;";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
data.DataSource = ds.Tables[0];
Conn.Close();
}
public void Showсерия(DataGridView data)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "select * from Серия;";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
data.DataSource = ds.Tables[0];
Conn.Close();
}
public void Showтом(DataGridView data)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "select * from Том;";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
data.DataSource = ds.Tables[0];
Conn.Close();
}
public void Showмарки_том(DataGridView data)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "select * from Марки_том;";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
data.DataSource = ds.Tables[0];
Conn.Close();
}
public void Showмарки_серия(DataGridView data)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "select * from Марки_серия;";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
data.DataSource = ds.Tables[0];
Conn.Close();
}
public void Showпоиск_марки(DataGridView data, string number1)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "select * from Марка where Номер_марки = '" + number1 + "';";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
data.DataSource = ds.Tables[0];
Conn.Close();
}
public void Showпоиск_серия(DataGridView data, string number1)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "select * from Серия where Номер_серии = '" + number1 + "';";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
data.DataSource = ds.Tables[0];
Conn.Close();
}
public void Showпоиск_том(DataGridView data, string number1)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "select * from Том where Номер_тома = '" + number1 + "';";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
data.DataSource = ds.Tables[0];
Conn.Close();
}
public void Showпоиск_марки_том(DataGridView data, string number1)
{
NpgsqlConnection Conn = new NpgsqlConnection("Host=localhost; Port=5432; User Id=postgres; Password=qazwsx2000; Database=marki");
Conn.Open();
string insertcmd = "select * from Марки_том where Номер_марки = '" + number1 + "';";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
data.DataSource = ds.Tables[0];
Conn.Close();
}
public void Showпоиск_марки_серия(DataGridView data, string number1)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "select * from Марки_серия where Номер_марки = '" + number1 + "';";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
data.DataSource = ds.Tables[0];
Conn.Close();
}
public void Addмарка(string number, int n1, int n2, string n3, string n4, string n5)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "INSERT INTO Марка VALUES(" + Convert.ToString(number) + "," + n1 + "," + n2 + ",'" + Convert.ToString(n3) + "','" + Convert.ToString(n4) + "','"+Convert.ToString(n5) + "')";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
Conn.Close();
}
public void Delмарка(string number1)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "DELETE FROM Марка WHERE Номер_марки = '" + Convert.ToString(number1) + "';";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
Conn.Close();
}
public void Updмарка(string number, int n1, int n2, string n3, string n4, string n5, string number1)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "UPDATE Марка SET Номер_марки = '" + Convert.ToString(number) + "', Цена = " + n1 + " , Год_выпуска = " + n2 + ", Цвет= '" + Convert.ToString(n3) + "', Размер = '" + Convert.ToString(n4) + "', Номер_страницы = '" + Convert.ToString(n5) + "' WHERE Номер_марки = '" + Convert.ToString(number1) + "';";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
Conn.Close();
}
public void Addсерия(string number, string name)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "INSERT INTO Серия VALUES('" + Convert.ToString(number) + "','" + Convert.ToString(name) + "')";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
Conn.Close();
}
public void Delсерия(string number1)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "DELETE FROM Серия WHERE Номер_серии = '" + Convert.ToString(number1) + "';";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
Conn.Close();
}
public void Updсерия(string number, string name, string number1)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "UPDATE Серия SET Номер_серии = '" + Convert.ToString(number) + "', Тема_серии = '" + Convert.ToString(name) + "' WHERE Номер_серии = '" + Convert.ToString(number1) + "';";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
Conn.Close();
}
public void Addтом(string number, string number1, string number2)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "INSERT INTO Том VALUES('" + Convert.ToString(number) + "','" + Convert.ToString(number1) + "','" + Convert.ToString(number2) + "')";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
Conn.Close();
}
public void Delтом(string number1)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "DELETE FROM Том WHERE Номер_тома = '" + Convert.ToString(number1) + "';";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
Conn.Close();
}
public void Updтом(string number, string sim1, string sim2, string number1)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));
Conn.Open();
string insertcmd = "UPDATE Том SET Номер_тома = '" + Convert.ToString(number) + "', Страна ='" + Convert.ToString(sim1) + "', Тема_марки ='" + Convert.ToString(sim2) + "' WHERE Номер_тома = '" + Convert.ToString(number1) + "';";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(insertcmd, Conn);
ds.Reset();
da.Fill(ds);
Conn.Close();
}
public void Addмарки_серия(string number, string number1)
{
OleDbConnection Conn = new OleDbConnection(cd.Provider="LCPI.IBProvider", cd.Add("Host=localhost; Port=3050; User Id=sysdba; Password=0000; Database=marki; Ctype=win1251"));