-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSellerForm.cs
179 lines (141 loc) · 5.33 KB
/
SellerForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
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 System.Data.SqlClient;
using System.Drawing.Printing;
namespace ProiectPAWGestiune
{
public partial class SellerForm : Form
{
public SellerForm()
{
InitializeComponent();
}
private void btExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void panel9_Paint(object sender, PaintEventArgs e)
{
}
SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\proiectBaza.mdf;Integrated Security=True;Connect Timeout=30");
private void populareTabel()
{
conn.Open();
string query = "SELECT nume_prod,cant_prod FROM ProdTbl";
SqlDataAdapter sda = new SqlDataAdapter(query, conn);
SqlCommandBuilder scb = new SqlCommandBuilder(sda);
var ds = new DataSet();
sda.Fill(ds);
dataGridViewSeller1.DataSource = ds.Tables[0];
conn.Close();
}
private void SellerForm_Load(object sender, EventArgs e)
{
populareTabel();
populareTabel3();
}
private void dataGridViewSeller1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
Datalbl.Text = DateTime.Today.Day.ToString()+"/"+DateTime.Today.Month.ToString()+"/"+DateTime.Today.Year;
//Oralbl.Text = Datalbl.Text = DateTime.Now.ToString();
}
private void Oralbl_Click(object sender, EventArgs e)
{
}
private void Datalbl_Click(object sender, EventArgs e)
{
}
// initializat global pentru a realiza suma totala
int GrdT = 0;
int n = 0;
private void label13_Click(object sender, EventArgs e)
{
int total = Convert.ToInt32(tb_Pretp.Text) * Convert.ToInt32(tb_Cantitateap.Text);
DataGridViewRow newRow = new DataGridViewRow();
newRow.CreateCells(dataGridView2);
newRow.Cells[0].Value = n + 1;
newRow.Cells[1].Value = tb_Numep.Text;
newRow.Cells[2].Value = tb_Pretp.Text;
newRow.Cells[3].Value = tb_Cantitateap.Text;
newRow.Cells[4].Value = Convert.ToInt32(tb_Pretp.Text)*Convert.ToInt32(tb_Cantitateap.Text);
dataGridView2.Rows.Add(newRow);
GrdT += total;
lbl_Suma.Text = "" + GrdT;
}
private void label25_Click(object sender, EventArgs e)
{
Form1 log = new Form1();
this.Hide();
log.Show();
}
private void populareTabel3()
{
conn.Open();
string query = "SELECT * FROM FormularPrintat";
SqlDataAdapter sda = new SqlDataAdapter(query, conn);
SqlCommandBuilder scb = new SqlCommandBuilder(sda);
var ds = new DataSet();
sda.Fill(ds);
dataGridView3.DataSource = ds.Tables[0];
conn.Close();
}
private void label21_Click(object sender, EventArgs e)
{
// add - pentru formularul printat
try
{
conn.Open();
// introducere in baza de date
string query = "INSERT INTO FormularPrintat VALUES(" + tbID_p.Text + ",'" + Datalbl.Text + "'," + lbl_Suma.Text + ",'" + tb_Numep.Text + "')";
SqlCommand cmd = new SqlCommand(query, conn);
cmd.ExecuteNonQuery();
MessageBox.Show("Tranzactia a fost introdusa cu succes!");
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Nu a reusit introducerea in tabel!");
}
finally
{
conn.Close();
populareTabel3();
}
}
private void lbl_Suma_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label22_Click(object sender, EventArgs e)
{
// PRINT
if(printPreviewDialog1.ShowDialog() == DialogResult.OK)
{
printDocument1.Print();
}
}
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawString("Alexandru Robert-Mihai", new Font("Berlin Sans FB", 15, FontStyle.Italic),Brushes.DarkOrange, new Point(230));
e.Graphics.DrawString("GESTIUNEA TRANZACTIILOR", new Font("Berlin Sans FB", 25, FontStyle.Italic), Brushes.OrangeRed, new Point(230,50));
e.Graphics.DrawString("ID-ul Tranzactiei: " + dataGridView3.Rows[0].Cells[0].Value.ToString(),
new Font("Berlin Sans FB", 15, FontStyle.Regular), Brushes.OrangeRed, new Point(70, 70));
}
}
}