Sunteți pe pagina 1din 40

Ministerul Educației, Culturii și Cercetării al Republicii Moldova

IP Centrul de Excelență în Informatică și Tehnologii Informaționale

RAPORTUL
STAGIULUI DE PRACTICĂ

Elevul: Nagorneac Daria


Grupa: P -1831
Specialitatea: Programarea și analiza produselor program
Baza de practică:CEITI

Conducătorul stagiului de practică


de la Centrul de Excelență

Arcan Petru

Chişinău 2021
2

Cuprinsul

Descrierea modului de elaborare a aplicației.............................................................


Schema conceptuală a algoritmului creării aplicației......................................................................
Schema bloc detaliată a algoritmului creării aplicației............................................................................
Baza de date „Biblioteca”............................................................................................
Estimarea complexității algoritmilor aplicației...........................................................
Funcționalitatea aplicației grafice cu utilizatorul.....................................................................................
Rezultatele testării subprogramelor.............................................................................
Concluzie....................................................................................................................16
Webografie..................................................................................................................17
Anexa 1. Sarcina Variantei 23...................................................................................18
Anexa 2. Listingul programelor................................................................................19

Descrierea modului de elaborare a aplicației


3

Am optat ca interfața grafică a aplicației să arate simplu la fel cum și funcționează, dar de
asemenea să prezinte un design frumos pentru a fi plăcut ochilor. Pentru a îndeplini sarcinile
propuse, am utilizat:

 Visual Studio 2019


 Microsoft SQL Server 2019
 Figma (site pentru crearea schemelor)

Plan individual

Fig.1 Plan individual


4

Schema conceptuală a algoritmului creării aplicației

Fig.2 Shema conceptuală


5

Schema bloc detaliată a algoritmului creării aplicației

Fig.3 Schema bloc detaliată


6

Baza de date “Biblioteca”


Astfel pentru început a fost realizată baza de date cu denumirea Biblioteca în care este prezentă evidența
cărților din această bibliotecă. Care respectă anumite cerințe, pentru care sunt create tabelele prezentate în
continuare.

Fig.4 Baza de date „Biblioteca”

a) În biblioteca sunt cărţi, care aparţin mai multor domenii de interes pentru cititor. Domeniul
este identificat prin cod şi nume.

Fig.5 Tabel „Domeniu”

b) Fiecare carte este identificată prin: cod carte, titlu, autor, editură, an apariţie, preţ,cod domeniu.

Fig.6 Tabel „Carti”

c) Fiecare cititor este identifică prin: cod cititor, nume, adresă, număr de telefon.
7

Fig.7 Tabel „Cititori”

d) Cărţile pot fi închiriate de cititori. Pentru fiecare închiriere sunt ţinute următoarele evidenţe:
cartea închiriată, cititorul care a închiriat-o, data închirierii ,data la care trebuie să fie returnată,
data la care a fost returnată.

Fig.8 Tabel „Închirierea cărților”


8

Estimarea complexității algoritmilor aplicației


Funcționalitatea aplicației grafice cu utilizatorul

Fig.9 Interfața de login

Este aplicată interfața principală

Fig.10 Interfața principală

Fig.6 Tabel „Schema bloc”


9

Gestiunea bazei de date se va realiza în aplicaţia C#. În dependență de tematică se vor specifica
criteriile de integritate pentru baza de date, administra obiecte ale bazei de date, stabili planul de
întreținere a bazei de date și moduri de securizare a datelor din baza de date. Informațiile din baza
de date se v-or prelucra la solicitarea utilizatorului folosind meniuri, formulare și controlere,
ținând cont de criteriile specificate în sarcinile individuale.
Afișarea la ecran a informațiilor și printarea acestora se va realiza prin intermediul rapoartelor.

Astfel avem spre realizare 10 funcționalități, respectiv există meniu unde pentru fiecare dintre
funcționalități este butonul său. De asemenea pentru început putem vedea cele 4 tabele din baza
de date, pentru fiecare este creat buton cu denumirea tabelului.

Este aplicat tabelul Cărți

Fig.11 Vizualizarea tabelului „Carti”

Rezultatele testării subprogramelor

Sarcina 1
Înregistrează datele despre o nouă carte și autorul acestuia.

Este aplicat Sarcina 1 – Adăugarea unei cărți noi

Fig.12
10

Fig.13

Fig.14 Tabelul cărți modificat

Sarcina 2
Ce cărţi a împrumutat cititorul X în perioada D.
11

Este aplicată Sarcina 2 – Cărțile împrumutate

Fig.15

Sarcina 3
Lista cărţilor, care sunt împrumutate la data D.

Este aplicată Sarcina 3 – Cărțile împrmutate

Fig.16

Sarcina 4
Lista cărţilor, care aparţin unui autor X.
12

Este aplicată Sarcina4 – Lista cărților unui autor

Fig.17

Sarcina 5
Lista cărţilor din domeniul Y.

Este aplicată Sarcina 5 - Lista cărților din domeniu

Fig.18

Sarcina 6
Lista cărţilor din domeniul X apărute la editura Y.
13

Este aplicată Sarcina 6 - Lista cărților din domeniu la editura

Fig.19

Sarcina 7
Lista cărţilor apărute în anul X la editura Y.

Este aplicată Sarcina 7 – Lista cărților din anul la editura

Fig.20
14

Sarcina 8
Exportă într-un fișier MS Word, MS Excel lista cititorilor, care au închiriat cartea X din domeniul
Z la data D.

Este aplicată Sarcina 8 - Exportarea

Fig.21

Fig.22

Fig.23 Tabelul realizat în excel

Fig.24 Tabelul realizat în word


15

Sarcina 9
Care sunt cele mai solicitate cărţi, închiriate pe perioada anului şcolar şi cele din perioada
vacanţei?

Este aplicată Sarcina 9 – Cărțile solicitate

Fig.25

Sarcina 10
Afișează lista cărților care nu au fost încă returnate si datele personale ale cititorului dat.

Este aplicată Sarcin 10 – Lista cărților nereturnate

Fig.26
16

Concluzie
Stagiul de practică este perioada de testare a cunoștințelor obținute pe parcursul anilor de studii și
aplicarea lor la lucrul asupra sarcinilor individuale. Astfel acumulăm calități bune pentru
dezvoltarea profesională. Pe tot parcursul practicii am avut de realizat o aplicație în C# cu
interfață grafică care gestionează baza de date “Biblioteca”. În dependență de tematică am
specificat criteriile de integritate pentru baza de date “Biblioteca”, am administrat obiecte ale
bazei de date, am stabilit planul de întreținere a bazei de date și moduri de securizare a datelor din
baza de date. Informațiile din baza de date s-au prelucrat la solicitarea utilizatorului folosind
meniuri, formulare și controlere, ținând cont de criteriile specificate în sarcinile individuale.
Afișarea la ecran a informațiilor și printarea acestora realiza prin intermediul rapoartelor.
17

Webografie
https://docs.microsoft.com/ru-ru/sql/t-sql/functions/date-and-time-data-types-and-functions-
transact-sql?view=sql-server-ver15

https://docs.microsoft.com/ru-ru/dotnet/api/system.string.substring?view=net-5.0

https://docs.microsoft.com/ru-ru/dotnet/api/system.char.isdigit?view=net-5.0

https://www.mssqltips.com/sqlservertip/6055/net-exception-handling-for-database-calls-to-sql-
server-with-try-catch-and-finally/
18

Anexa 1. Sarcinile Variantei 23.


Sarcini
23. BIBLIOTECA. Informaţia despre evidenţa cărţilor dintr-o bibliotecă este înregistrată într-o
bază de date.

Evidenţa cărţilor din această bibliotecă cere respectarea următoarelor cerinţe:


a) În biblioteca sunt cărţi, care aparţin mai multor domenii de interes pentru cititor. Domeniul
este identificat prin cod şi nume.
b) Fiecare carte este identificată prin: cod carte, titlu, autor, editură, an apariţie, preţ,cod domeniu.
c) Fiecare cititor este identifică prin: cod cititor, nume, adresă, număr de telefon.
d) Cărţile pot fi închiriate de cititori. Pentru fiecare închiriere sunt ţinute următoarele evidenţe:
cartea închiriată, cititorul care a închiriat-o, data închirierii ,data la care trebuie să fie returnată,
data la care a fost returnată.

Elaboraţi o bază de date, gestiunea căreia se va realiza dintr-o aplicaţie C#. În dependență de
tematică se vor specifica criteriile de integritate pentru baza de date, administra obiecte ale bazei
de date, stabili planul de întreținere a bazei de date și moduri de securizare a datelor din baza de
date. Informațiile din baza de date se v-or prelucra la solicitarea utilizatorului folosind meniuri,
formulare și controlere, ținând cont de următoarele funcţionalităţi:

1) Înregistrează datele despre o nouă carte și autorul acestuia.


2) Ce cărţi a împrumutat cititorul X în perioada D.
3) Lista cărţilor, care sunt împrumutate la data D.
4) Lista cărţilor, care aparţin unui autor X.
5) Lista cărţilor din domeniul Y.
6) Lista cărţilor din domeniul X apărute la editura Y.
7) Lista cărţilor apărute în anul X la editura Y.
8) Exportă într-un fișier MS Word, MS Excel lista cititorilor, care au închiriat cartea X din
domeniul Z la data D.
9) Care sunt cele mai solicitate cărţi, închiriate pe perioada anului şcolar şi cele din perioada
vacanţei?
10) Afișează lista cărților care nu au fost încă returnate si datele personale ale cititorului dat.

Afișarea la ecran a informațiilor și printarea acestora se va realiza prin intermediul rapoartelor.


19

Anexa 2. Listingul programelor


Listingul programului
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 Biblioteca
{
public partial class Form1 : Form
{
private Form activeForm = null;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
// TODO: This line of code loads data into the 'bibliotecaDataSet11.Cititori' table. You can move, or
remove it, as needed.
this.cititoriTableAdapter1.Fill(this.bibliotecaDataSet11.Cititori);
// TODO: This line of code loads data into the 'bibliotecaDataSet10.Domeniu' table. You can move,
or remove it, as needed.
this.domeniuTableAdapter1.Fill(this.bibliotecaDataSet10.Domeniu);
// TODO: This line of code loads data into the 'bibliotecaDataSet9.Inchirierea_cartilor' table. You
can move, or remove it, as needed.
this.inchirierea_cartilorTableAdapter4.Fill(this.bibliotecaDataSet9.Inchirierea_cartilor);
// TODO: This line of code loads data into the 'bibliotecaDataSet8.Carti' table. You can move, or
remove it, as needed.
this.cartiTableAdapter2.Fill(this.bibliotecaDataSet8.Carti);
// TODO: данная строка кода позволяет загрузить данные в таблицу "bibliotecaDataSet6.Carti".
При необходимости она может быть перемещена или удалена.

private void button13_Click(object sender, EventArgs e)

{
label6.Text = "Este aplicat tabelul Cărți";

/* dataGridView1.Refresh();
label5.Visible = false;
label3.Visible = false;
label4.Visible = false;
dataGridView2.Visible = false;
dataGridView3.Visible = false;
dataGridView4.Visible = false;
if (dataGridView1.Visible == true) dataGridView1.Visible = false;
else if (dataGridView1.Visible == false) dataGridView1.Visible = true;
if (label2.Visible == true) label2.Visible = false;
else if (label2.Visible == false) label2.Visible = true;*/
openChildFormInPanel(new Form12());
}

private void button14_Click(object sender, EventArgs e)


{
20
label6.Text = "Este aplicat tabelul Cititori";
/* dataGridView2.Refresh();
label2.Visible = false;
label5.Visible = false;
label4.Visible = false;
dataGridView1.Visible = false;
dataGridView3.Visible = false;
dataGridView4.Visible = false;
if (dataGridView2.Visible == true) dataGridView2.Visible = false;
else if (dataGridView2.Visible == false) dataGridView2.Visible = true;
if (label3.Visible == true) label3.Visible = false;
else if (label3.Visible == false) label3.Visible = true;*/
openChildFormInPanel(new Form14());
}

private void button15_Click(object sender, EventArgs e)


{
label6.Text = "Este aplicat tabelul Domeniu";
/* dataGridView3.Refresh();
label2.Visible = false;
label5.Visible = false;
label3.Visible = false;

dataGridView2.Visible = false;
dataGridView1.Visible = false;
dataGridView4.Visible = false;
if (dataGridView3.Visible == true) dataGridView3.Visible = false;
else if (dataGridView3.Visible == false) dataGridView3.Visible = true;
if (label4.Visible == true) label4.Visible = false;
else if (label4.Visible == false) label4.Visible = true;*/
openChildFormInPanel(new Form15());
}

private void button16_Click(object sender, EventArgs e)


{
label6.Text = "Este aplicat tabelul Închirierea Cărților";
/* dataGridView4.Refresh();
label2.Visible = false;
label3.Visible = false;
label4.Visible = false;
dataGridView2.Visible = false;
dataGridView3.Visible = false;
dataGridView1.Visible = false;
if (dataGridView4.Visible == true) dataGridView4.Visible = false;
else if (dataGridView4.Visible == false) dataGridView4.Visible = true;
if (label5.Visible == true) label5.Visible = false;
else if (label5.Visible == false) label5.Visible = true;*/
openChildFormInPanel(new Form16());
}

private void openChildFormInPanel(Form childForm)


{
if (activeForm != null)
activeForm.Close();
activeForm = childForm;
childForm.TopLevel = false;
childForm.FormBorderStyle = FormBorderStyle.None;
childForm.Dock = DockStyle.Fill;
panel5.Controls.Add(childForm);
panel5.Tag = childForm;
childForm.BringToFront();
childForm.Show();

}
private void button4_Click(object sender, EventArgs e)
21
{
label6.Text = "Este aplicat Sarcina 1 - Adăugarea unei cărți noi";
openChildFormInPanel(new Form2());

private void button3_Click(object sender, EventArgs e)


{
label6.Text = "Este aplicat Sarcina 2 - Cărțile împrumutate";
openChildFormInPanel(new Form3());
}

private void dataGridView4_CellContentClick(object sender, DataGridViewCellEventArgs e)


{
label6.Text = "Este aplicat Sarcina 3 - Cărțile împrumutate";
}

private void button5_Click(object sender, EventArgs e)


{
label6.Text = "Este aplicat Sarcina 3 - Cărțile împrumutate";

openChildFormInPanel(new Form5());
}

private void button6_Click(object sender, EventArgs e)


{
label6.Text = "Este aplicat Sarcina 4 - Cărțile care aparțin unui autor";

openChildFormInPanel(new Form6());
}

private void button7_Click(object sender, EventArgs e)


{
label6.Text = "Este aplicat Sarcina 5 - Lista cărților din domeniu";

openChildFormInPanel(new Form7());
}

private void button8_Click(object sender, EventArgs e)


{
label6.Text = "Este aplicat Sarcina 6 - Lista cărților din domeniul și editura ";

openChildFormInPanel(new Form8());
}

private void button9_Click(object sender, EventArgs e)


{
label6.Text = "Este aplicat Sarcina 7 - Lista cărților din anul și editura";

openChildFormInPanel(new Form9());
}

private void button10_Click(object sender, EventArgs e)


{
label6.Text = "Este aplicat Sarcina 8 - Exportarea în MsWord/MsExcel";

openChildFormInPanel(new Form10());
}

private void button11_Click(object sender, EventArgs e)


{
label6.Text = "Este aplicat Sarcina 9 - Cărțile solicitate";
openChildFormInPanel(new Form13());
22
}

private void button12_Click(object sender, EventArgs e)


{
label6.Text = "Este aplicat Sarcina 10 - Cărțile nereturnate";
openChildFormInPanel(new Form11());
}
}
}

Listingul Form2

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

namespace Biblioteca
{
public partial class Form2 : Form
{
private string codc;
private string titl;
private string autor;
private string editurac;

private string anulc;


private string pretc;
private string coddd;
public Form2()
{
InitializeComponent();
}

private void Form2_Load(object sender, EventArgs e)


{

private void cod_TextChanged(object sender, EventArgs e)


{
codc = cod.Text;
}

private void titlul_TextChanged(object sender, EventArgs e)


{
titl = titlul.Text;
}

private void autorl_TextChanged(object sender, EventArgs e)


{
autor = autorl.Text;
}

private void editur_TextChanged(object sender, EventArgs e)


{
editurac = editur.Text;
}
23
private void anu_TextChanged(object sender, EventArgs e)
{
anulc = anu.Text;
}

private void pre_TextChanged(object sender, EventArgs e)


{
pretc = pre.Text;
}

private void co_TextChanged(object sender, EventArgs e)


{
coddd = co.Text;
}
private void button1_Click(object sender, EventArgs e)
{

private void button2_Click(object sender, EventArgs e)


{

this.Hide();

private void button1_Click_1(object sender, EventArgs e)


{
SqlConnection con = new SqlConnection(@"Data Source = .;Initial Catalog = Biblioteca; Integrated
Security = True");
String sql = "INSERT INTO Carti(Cod_carte,Titlu,Autor,Editura,Anul,Pret,Cod_dom) VALUES('"
+ codc + "','" + titl + "', '" + autor + "','" + editurac + "' , '" + anulc + "','" + pretc + "','" + coddd + "');";

con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
cmd.ExecuteNonQuery();
con.Close();

MessageBox.Show("Cartea este adăugată cu succes");


}

}
}

Listingul Form3

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

namespace Biblioteca
{
public partial class Form3 : Form
{
private string cititori;
private string period;
24
public Form3()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{

}
private void Form3_Load(object sender, EventArgs e)
{

private void button2_Click(object sender, EventArgs e)


{
this.Hide();
}

private void button1_Click_1(object sender, EventArgs e)


{
SqlConnection con = new SqlConnection(@"Data Source = .;Initial Catalog = Biblioteca; Integrated
Security = True");

String sql = "Select cod_carte from inchirierea_cartilor where data_impr=" + period + " and
cod_cititor = (select cod_cititor from cititori where nume =" + cititori+");";

con.Open();
SqlCommand cmd1 = new SqlCommand(sql, con);
string txt = cmd1.ExecuteScalar().ToString();

using (SqlCommand cmd = new SqlCommand("Sarcina4", con))


{

cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@autor", txt);

cmd.ExecuteNonQuery();

SqlDataAdapter da = new SqlDataAdapter(cmd);


DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;

con.Close();
}

private void label9_Click(object sender, EventArgs e)


{

private void label2_Click(object sender, EventArgs e)


{

private void label1_Click(object sender, EventArgs e)


{
25

private void citotor_TextChanged(object sender, EventArgs e)


{
cititori = "'" + citotor.Text + "'";
}

private void textBox1_TextChanged(object sender, EventArgs e)


{
period = "'"+textBox1.Text+"'";
}
}

Listingul Form5

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

namespace Biblioteca
{
public partial class Form5 : Form
{
private string datad;
public Form5()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
try
{
SqlConnection con = new SqlConnection(@"Data Source = .;Initial Catalog = Biblioteca;
Integrated Security = True");

String sql = "select cod_carte from Inchirierea_cartilor where Data_impr = " + datad + ";";

con.Open();
SqlCommand cmd1 = new SqlCommand(sql, con);
string txt = cmd1.ExecuteScalar().ToString();

using (SqlCommand cmd = new SqlCommand("Sarcina3", con))


{

cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@data", txt);

cmd.ExecuteNonQuery();

SqlDataAdapter da = new SqlDataAdapter(cmd);


DataTable dt = new DataTable();
26
da.Fill(dt);
dataGridView1.DataSource = dt;

con.Close();
}
}
catch(Exception)
{

MessageBox.Show("Introduceti datele corect");


}
}

private void data_TextChanged(object sender, EventArgs e)


{
datad = "'"+data.Text+"'";
}

private void button2_Click(object sender, EventArgs e)


{
this.Hide();
}
}
}

Listingul Form6

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

namespace Biblioteca
{
public partial class Form6 : Form
{
private string autor;
public Form6()
{
InitializeComponent();
}

private void autorx_TextChanged(object sender, EventArgs e)


{
autor = autorx.Text;
}

private void button1_Click(object sender, EventArgs e)


{
try
{
SqlConnection con = new SqlConnection(@"Data Source = .;Initial Catalog = Biblioteca;
Integrated Security = True");

String sql = "select cod_carte from carti where autor = '" + autor + "';";

con.Open();
SqlCommand cmd1 = new SqlCommand(sql, con);
string txt = cmd1.ExecuteScalar().ToString();
27

using (SqlCommand cmd = new SqlCommand("Sarcina4", con))


{

cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@autor", txt);

cmd.ExecuteNonQuery();

SqlDataAdapter da = new SqlDataAdapter(cmd);


DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;

con.Close();
}
}
catch (Exception)
{

MessageBox.Show("Introduceti datele corect");


}
}

private void button2_Click(object sender, EventArgs e)


{
this.Hide();
}
}
}

Listingul Form 7

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

namespace Biblioteca
{
public partial class Form7 : Form
{
private string domeniu;
public Form7()
{
InitializeComponent();
}

private void autorx_TextChanged(object sender, EventArgs e)


{
domeniu ="'" +autorx.Text+"'";
}

private void button1_Click(object sender, EventArgs e)


{

try
28
{
SqlConnection con = new SqlConnection(@"Data Source = .;Initial Catalog = Biblioteca;
Integrated Security = True");

String sql = "select cod_carte from carti where cod_dom = (select cod_dom from domeniu where
den_dom = "+domeniu+");";

con.Open();
SqlCommand cmd1 = new SqlCommand(sql, con);
string txt = cmd1.ExecuteScalar().ToString();

using (SqlCommand cmd = new SqlCommand("Sarcina4", con))


{

cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@autor", txt);

cmd.ExecuteNonQuery();

SqlDataAdapter da = new SqlDataAdapter(cmd);


DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;

con.Close();
}
}
catch (Exception)
{

MessageBox.Show("Introduceti datele corect");


}
}

private void button2_Click(object sender, EventArgs e)


{
this.Hide();
}
}
}

Listingul Form 8

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

namespace Biblioteca
{
public partial class Form8 : Form
{
private string domeniul;
private string editura;
public Form8()
{
InitializeComponent();
29
}

private void button2_Click(object sender, EventArgs e)


{
this.Hide();
}

private void domeniulx_TextChanged(object sender, EventArgs e)


{
domeniul= "'" + domeniulx.Text + "'";
}

private void edituray_TextChanged(object sender, EventArgs e)


{
editura = "'" + edituray.Text + "'";
}

private void button1_Click(object sender, EventArgs e)


{
try
{
SqlConnection con = new SqlConnection(@"Data Source = .;Initial Catalog = Biblioteca;
Integrated Security = True");

String sql = "select cod_carte from carti where editura = "+editura+" and cod_dom = (select
cod_dom from domeniu where den_dom = "+domeniul+");";

con.Open();
SqlCommand cmd1 = new SqlCommand(sql, con);
string txt = cmd1.ExecuteScalar().ToString();

using (SqlCommand cmd = new SqlCommand("Sarcina4", con))


{

cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@autor", txt);

cmd.ExecuteNonQuery();

SqlDataAdapter da = new SqlDataAdapter(cmd);


DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;

con.Close();
}
}
catch (Exception)
{

MessageBox.Show("Introduceti datele corect");


}
}

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)


{

private void label9_Click(object sender, EventArgs e)


{

}
30

private void label2_Click(object sender, EventArgs e)


{

private void label1_Click(object sender, EventArgs e)


{

}
}
}

Listingul Form 9

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

namespace Biblioteca
{
public partial class Form9 : Form
{
private string anul;
private string editura;
public Form9()
{
InitializeComponent();
}

private void domeniulx_TextChanged(object sender, EventArgs e)


{
anul = "'"+domeniulx.Text+"'";
}

private void edituray_TextChanged(object sender, EventArgs e)


{
editura = "'"+edituray.Text+"'";
}

private void button1_Click(object sender, EventArgs e)


{
try
{
SqlConnection con = new SqlConnection(@"Data Source = .;Initial Catalog = Biblioteca;
Integrated Security = True");

String sql = "select cod_carte from carti where editura = " + editura + " and anul ="+anul+";";

con.Open();
SqlCommand cmd1 = new SqlCommand(sql, con);
string txt = cmd1.ExecuteScalar().ToString();

using (SqlCommand cmd = new SqlCommand("Sarcina4", con))


{
31
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@autor", txt);

cmd.ExecuteNonQuery();

SqlDataAdapter da = new SqlDataAdapter(cmd);


DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;

con.Close();
}
}
catch (Exception)
{

MessageBox.Show("Introduceti datele corect");


}
}

private void button2_Click(object sender, EventArgs e)


{
this.Hide();
}
}
}

Listingul Form10

using ClosedXML.Excel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;
namespace Biblioteca
{
public partial class Form10 : Form
{
private string cartea;
private string dom;
private string data;
public Form10()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
cartea = "'" + textBox1.Text + "'";
}

private void textBox2_TextChanged(object sender, EventArgs e)


{
dom = "'" + textBox2.Text + "'";
}

private void textBox3_TextChanged(object sender, EventArgs e)


{
data = "'" + textBox3.Text + "'";
32
}

private void button4_Click(object sender, EventArgs e)


{

try
{
SqlConnection con = new SqlConnection(@"Data Source = .;Initial Catalog = Biblioteca;
Integrated Security = True");

String sql = "select cod_cititor from Inchirierea_cartilor where Data_impr ="+data+" and
Cod_carte=(select cod_carte from carti where titlu = "+cartea+" and cod_dom = (select cod_dom from domeniu
where den_dom = "+dom+")); ";

con.Open();
SqlCommand cmd1 = new SqlCommand(sql, con);
string txt = cmd1.ExecuteScalar().ToString();

using (SqlCommand cmd = new SqlCommand("Sarcina8", con))


{

cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@autor", txt);

cmd.ExecuteNonQuery();

/* SqlDataAdapter da = new SqlDataAdapter(cmd);


DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;*/

con.Close();
}
}
catch (Exception ex)
{

MessageBox.Show("Introduceti datele corect"+ex);


}
Form10 frm10 = new Form10();
this.Hide();
frm10.Show();

private void label2_Click(object sender, EventArgs e)


{

private void button2_Click(object sender, EventArgs e)


{

this.Hide();

SqlConnection con = new SqlConnection(@"Data Source = DESKTOP-K91A4HJ\


SQLEXPRESS;Initial Catalog = Biblioteca; Integrated Security = True");

String sql = "delete from export; ";


33
con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
cmd.ExecuteNonQuery();

private void button1_Click(object sender, EventArgs e)


{
using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "Excel Workbook|*.xlsx" })
{
if (sfd.ShowDialog() == DialogResult.OK)
{
try
{
using (XLWorkbook workbook = new XLWorkbook())
{
workbook.Worksheets.Add(this.bibliotecaDataSet13.Export.CopyToDataTable(), "Lista
cititorilor");
workbook.SaveAs(sfd.FileName);
}
MessageBox.Show("Datele sunt exportate. Controlați fișierul Excel");

}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}
public void Export_Data_To_Word(DataGridView DGV, string filename)
{
if (DGV.Rows.Count != 0)
{
int RowCount = DGV.Rows.Count;
int ColumnCount = DGV.Columns.Count;
Object[,] DataArray = new object[RowCount + 1, ColumnCount + 1];

//add rows
int r = 0;
for (int c = 0; c <= ColumnCount - 1; c++)
{
for (r = 0; r <= RowCount - 1; r++)
{
DataArray[r, c] = DGV.Rows[r].Cells[c].Value;
} //end row loop
} //end column loop

Word.Document oDoc = new Word.Document();


oDoc.Application.Visible = true;

//page orintation
oDoc.PageSetup.Orientation = Word.WdOrientation.wdOrientLandscape;

dynamic oRange = oDoc.Content.Application.Selection.Range;


string oTemp = "";
for (r = 0; r <= RowCount - 1; r++)
{
for (int c = 0; c <= ColumnCount - 1; c++)
{
oTemp = oTemp + DataArray[r, c] + "\t";

}
34
}

//table format
oRange.Text = oTemp;

object Separator = Word.WdTableFieldSeparator.wdSeparateByTabs;


object ApplyBorders = true;
object AutoFit = true;
object AutoFitBehavior = Word.WdAutoFitBehavior.wdAutoFitContent;

oRange.ConvertToTable(ref Separator, ref RowCount, ref ColumnCount,


Type.Missing, Type.Missing, ref ApplyBorders,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing, ref AutoFit, ref AutoFitBehavior, Type.Missing);

oRange.Select();

oDoc.Application.Selection.Tables[1].Select();
oDoc.Application.Selection.Tables[1].Rows.AllowBreakAcrossPages = 0;
oDoc.Application.Selection.Tables[1].Rows.Alignment = 0;
oDoc.Application.Selection.Tables[1].Rows[1].Select();
oDoc.Application.Selection.InsertRowsAbove(1);
oDoc.Application.Selection.Tables[1].Rows[1].Select();

//header row style


oDoc.Application.Selection.Tables[1].Rows[1].Range.Bold = 1;
oDoc.Application.Selection.Tables[1].Rows[1].Range.Font.Name = "Tahoma";
oDoc.Application.Selection.Tables[1].Rows[1].Range.Font.Size = 14;

//add header row manually


for (int c = 0; c <= ColumnCount - 1; c++)
{
oDoc.Application.Selection.Tables[1].Cell(1, c + 1).Range.Text =
DGV.Columns[c].HeaderText;
}

//table style
//oDoc.Application.Selection.Tables[1].set_Style("Grid Table 4 - Accent 5");
oDoc.Application.Selection.Tables[1].Rows[1].Select();
oDoc.Application.Selection.Cells.VerticalAlignment =
Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;

//header text
foreach (Word.Section section in oDoc.Application.ActiveDocument.Sections)
{
Word.Range headerRange =
section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
headerRange.Fields.Add(headerRange, Word.WdFieldType.wdFieldPage);
headerRange.Text = "Lista cititorilor";
headerRange.Font.Size = 16;
headerRange.ParagraphFormat.Alignment =
Word.WdParagraphAlignment.wdAlignParagraphCenter;
}

//save the file


oDoc.SaveAs2(filename);

//NASSIM LOUCHANI
}
}
private void button3_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
35
sfd.Filter = "Word Documents (*.docx)|*.docx";

sfd.FileName = "export.docx";

if (sfd.ShowDialog() == DialogResult.OK)
{

Export_Data_To_Word(dataGridView1, sfd.FileName);
}
}

private void Form10_Load(object sender, EventArgs e)


{
// TODO: This line of code loads data into the 'bibliotecaDataSet13.Export' table. You can move, or
remove it, as needed.
this.exportTableAdapter.Fill(this.bibliotecaDataSet13.Export);

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)


{

private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)


{

}
}
}

Listingul Form11

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

namespace Biblioteca
{
public partial class Form11 : Form
{
public Form11()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
try
{
SqlConnection con = new SqlConnection(@"Data Source = .;Initial Catalog = Biblioteca;
Integrated Security = True");

con.Open();
36

using (SqlCommand cmd = new SqlCommand("Sarcina10", con))


{

cmd.CommandType = CommandType.StoredProcedure;

cmd.ExecuteNonQuery();

SqlDataAdapter da = new SqlDataAdapter(cmd);


DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;

con.Close();
}
}
catch (Exception ex)
{

MessageBox.Show("Introduceti datele corect" + ex);


}
}

private void button2_Click(object sender, EventArgs e)


{
this.Hide();
}
}
}

Listingul Form12

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 Biblioteca
{
public partial class Form12 : Form
{
public Form12()
{
InitializeComponent();
}

private void Form12_Load(object sender, EventArgs e)


{
// TODO: This line of code loads data into the 'bibliotecaDataSet14.Carti' table. You can move, or
remove it, as needed.
this.cartiTableAdapter.Fill(this.bibliotecaDataSet14.Carti);

private void button2_Click(object sender, EventArgs e)


{
this.Hide();
37
}
}
}

Listingul Form13

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

namespace Biblioteca
{
public partial class Form13 : Form
{
public Form13()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
try
{
SqlConnection con = new SqlConnection(@"Data Source = .;Initial Catalog = Biblioteca;
Integrated Security = True");

using (SqlCommand cmd = new SqlCommand("Sarcina9", con))


{
con.Open();
cmd.CommandType = CommandType.StoredProcedure;

cmd.ExecuteNonQuery();

SqlDataAdapter da = new SqlDataAdapter(cmd);


DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;

con.Close();
}
using (SqlCommand cmd = new SqlCommand("Sarcina99", con))
{
con.Open();
cmd.CommandType = CommandType.StoredProcedure;

cmd.ExecuteNonQuery();

SqlDataAdapter da = new SqlDataAdapter(cmd);


DataTable dt = new DataTable();
da.Fill(dt);
38
dataGridView2.DataSource = dt;

con.Close();
}
}
catch (Exception)
{

MessageBox.Show("Introduceti datele corect");


}
}

private void button2_Click(object sender, EventArgs e)


{
this.Hide();
}
}
}

Litingul Form14

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 Biblioteca
{
public partial class Form14 : Form
{
public Form14()
{
InitializeComponent();
}

private void Form14_Load(object sender, EventArgs e)


{
// TODO: This line of code loads data into the 'bibliotecaDataSet15.Cititori' table. You can move, or
remove it, as needed.
this.cititoriTableAdapter.Fill(this.bibliotecaDataSet15.Cititori);

private void button2_Click(object sender, EventArgs e)


{
this.Hide();
}

private void label1_Click(object sender, EventArgs e)


{

}
}
}

Listingul Form15

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

namespace Biblioteca
{
public partial class Form15 : Form
{
public Form15()
{
InitializeComponent();
}

private void Form15_Load(object sender, EventArgs e)


{
// TODO: This line of code loads data into the 'bibliotecaDataSet16.Domeniu' table. You can move,
or remove it, as needed.
this.domeniuTableAdapter.Fill(this.bibliotecaDataSet16.Domeniu);

private void button2_Click(object sender, EventArgs e)


{
this.Hide();
}

private void label1_Click(object sender, EventArgs e)


{

}
}
}

Listingul Form16

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 Biblioteca
{
public partial class Form16 : Form
{
public Form16()
{
InitializeComponent();
}

private void Form16_Load(object sender, EventArgs e)


{
// TODO: This line of code loads data into the 'bibliotecaDataSet17.Inchirierea_cartilor' table. You
can move, or remove it, as needed.
this.inchirierea_cartilorTableAdapter.Fill(this.bibliotecaDataSet17.Inchirierea_cartilor);

}
40
private void button2_Click(object sender, EventArgs e)
{
this.Hide();
}
}
}

S-ar putea să vă placă și