root/Baza Reklam 2 - Faktury/StartForm.cs @ 28

Wersja 2, 31.0 KB (wprowadzona przez dorota, 17 years temu)
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Data.SqlClient;
6using System.Drawing;
7using System.Text;
8using System.Windows.Forms;
9using System.Globalization;
10
11namespace Baza_Reklam
12{
13    public partial class StartForm : Form
14    {
15
16        private bool pierwszaAktywacja = false;
17
18        public static StartForm startForm;
19
20        public static StartForm getStartForm(MDIBazaReklam parent)
21        {
22            if (startForm == null) {
23                startForm = new StartForm(parent);
24            }
25            return startForm;
26        }
27
28        private StartForm(MDIBazaReklam parent)
29        {
30            InitializeComponent();
31
32            this.MdiParent = parent;
33           
34            shedulerTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
35            zastawienieKontaktowTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
36            view_Podsumowanie_Wykonania_PlanuTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
37            view_Podsumowanie_Wykonania_Planu_AgencjaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
38
39            if (User.getUser().St_kierownik) {
40                wynikAgencji();
41            }
42            else if (User.getUser().St_handlowiec | User.getUser().St_subhandlowiec) {
43                wynikAgenta();                   
44            }
45        }
46
47        private void shedulerBindingNavigatorSaveItem_Click(object sender, EventArgs e)
48        {
49            this.Validate();
50            this.shedulerBindingSource.EndEdit();
51            this.shedulerTableAdapter.Update(this.rEKLAMADataSet.sheduler);
52        }
53
54        private void zrobioneToolStripButton_Click(object sender, EventArgs e)
55        {
56            if (shedulerBindingSource.Current != null) {
57                DataRowView row = (DataRowView)shedulerBindingSource.Current;
58                row["zalatwione"] = false;
59                shedulerBindingSource.EndEdit();
60                shedulerTableAdapter.Update(rEKLAMADataSet.sheduler);
61                shedulerDataGridView.Refresh();
62            }
63        }
64
65        private void niezrobioneToolStripButton_Click(object sender, EventArgs e)
66        {
67            if (shedulerBindingSource.Current != null)
68            {
69                DataRowView row = (DataRowView)shedulerBindingSource.Current;
70                row["zalatwione"] = true;
71                shedulerBindingSource.EndEdit();
72                shedulerTableAdapter.Update(rEKLAMADataSet.sheduler);
73                shedulerDataGridView.Refresh();
74            }
75        }
76
77        private void filtrujToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e)
78        {
79            filtruj();
80        }
81
82        private void StartForm_Activated(object sender, EventArgs e)
83        {
84            if (pierwszaAktywacja)
85            {
86                wypelnijShedulerWyniki();
87            }
88        }
89
90        private void StartForm_Load(object sender, EventArgs e)
91        {
92            SqlCommand command = new SqlCommand();
93            command.Connection = new SqlConnection(ConnString.getConnString().Value);
94            SqlDataReader reader;
95
96            if (User.getUser().St_kierownik)
97            {           
98                command.CommandText = "select Symbol from dbo.AGENCI where aktywny=1 and ID_AGENCJI=@param order by Symbol";
99                command.Parameters.Clear();
100                command.Parameters.AddWithValue("@param", User.getUser().IdAgencji);
101                command.Connection.Open();
102
103                reader = command.ExecuteReader();
104
105                while (reader.Read())
106                {
107                    agenciToolStripComboBox.Items.Add(reader.GetValue(0).ToString());
108
109                }
110                agenciToolStripComboBox.Visible = true;
111            }
112
113            command.Connection.Close();
114
115            DBBindings.bindujAgencje(agencjaToolStripComboBox);
116            DBBindings.bindujAgentow(agentToolStripComboBox);
117   
118            filtrujToolStripComboBox.SelectedIndex = 0;
119            agenciToolStripComboBox.SelectedIndex = 0;         
120        }
121
122        private void agenciToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e)
123        {
124            filtruj();   
125        }
126
127        private void filtruj() {
128
129            if ((filtrujToolStripComboBox.SelectedItem != null) & (agenciToolStripComboBox.SelectedItem != null))
130            {
131                DateTime ostatniDzienMiesiaca = DateTime.Today.AddMonths(1).AddDays(-(DateTime.Today.Day));
132                DateTime ostatniDzienTygodnia = DateTime.Today.AddDays(7).AddDays(-((int)DateTime.Today.DayOfWeek));
133
134                DateTime pierwszyDzienMiesiaca = DateTime.Today.AddDays(-DateTime.DaysInMonth(DateTime.Today.Year,DateTime
135                    .Today.Month)).AddDays(DateTime.DaysInMonth(DateTime.Today.Year,DateTime.Today.Month) - DateTime.Today.Day);
136                DateTime pierwszyDzienTygodnia = DateTime.Today.AddDays(-7).AddDays(((int)DateTime.Today.DayOfWeek));
137
138                switch (filtrujToolStripComboBox.SelectedItem.ToString())
139                {
140
141                    case "NA DZISIAJ":
142                        shedulerBindingSource.Filter = "[DataPrzypomnienia] >= '" + DateTime.Today.Date.ToString() + "' AND [DataPrzypomnienia] < '" + DateTime.Today.Date.AddDays(1).ToString() + "'";
143                        break;
144                    case "NA JUTRO":
145                        shedulerBindingSource.Filter = "[DataPrzypomnienia] >= '" + DateTime.Today.Date.AddDays(1).ToString() + "' AND [DataPrzypomnienia] < '" + DateTime.Today.Date.AddDays(2).ToString() + "'";
146                        break;
147                    case "NA TYDZIEÑ":
148                        shedulerBindingSource.Filter = "[DataPrzypomnienia] >= '" +  pierwszyDzienTygodnia.ToString() + "' AND [DataPrzypomnienia] <= '" + ostatniDzienTygodnia.ToString() + "'";
149                        break;
150                    case "NA MIESI¥C":
151                        shedulerBindingSource.Filter = "[DataPrzypomnienia] >= '" + pierwszyDzienMiesiaca.ToString() + "' AND [DataPrzypomnienia] <= '" + ostatniDzienMiesiaca.ToString() + "'";
152                        break;
153                    case "WSZYSTKIE":
154                        shedulerBindingSource.Filter = " 1 = 1";
155                        break;
156                    case "NIEZA£ATWIONE ":
157                        shedulerBindingSource.Filter = "zalatwione = 1";
158                        break;
159                }
160
161                if (agenciToolStripComboBox.SelectedItem.ToString() != "WSZYSCY")
162                {
163                    shedulerBindingSource.Filter += " AND [akwizytor]='" + agenciToolStripComboBox.SelectedItem.ToString() + "'";
164                }
165            }
166        }
167
168        private void klientToolStripButton_Click(object sender, EventArgs e)
169        {
170            if (shedulerBindingSource.Current != null)
171            {
172                DataRowView row = (DataRowView)shedulerBindingSource.Current;
173
174                int custID = Convert.ToInt32(row["CustomerId"]);
175
176                ClientsForm.getClientsForm((MDIBazaReklam)this.MdiParent).pokazKlienta(custID);
177
178                this.Hide();
179
180                ClientsForm.getClientsForm((MDIBazaReklam)this.MdiParent).Show();
181            }
182        }
183
184        private void usunToolStripButton_Click(object sender, EventArgs e)
185        {
186            if (MessageBox.Show("Czy na pewno chcesz usun¹æ rekord?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
187            {
188                if (shedulerBindingSource.Current != null)
189                {
190                    shedulerBindingSource.RemoveCurrent();
191                    shedulerBindingSource.EndEdit();
192                    shedulerTableAdapter.Update(rEKLAMADataSet.sheduler);
193                }
194            }
195        }
196
197        private void shedulerDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
198        {
199            MessageBox.Show("WprowadŸ poprawnie dane");
200        }
201
202        private void zapiszToolStripButton_Click(object sender, EventArgs e)
203        {
204            shedulerDataGridView.EndEdit();
205            shedulerBindingSource.EndEdit();
206            shedulerTableAdapter.Update(rEKLAMADataSet.sheduler);           
207            MessageBox.Show("Dane zapisane"); 
208        }
209
210        private void shedulerDataGridView_CellLeave(object sender, DataGridViewCellEventArgs e)
211        {
212            shedulerDataGridView.EndEdit();
213        }
214
215
216        private void shedulerDataGridView_Leave(object sender, EventArgs e)
217        {
218            shedulerDataGridView.EndEdit();
219        }
220
221        private void sprDoZalatwieniaTabPage_Leave(object sender, EventArgs e)
222        {
223            shedulerBindingSource.EndEdit();
224
225            REKLAMADataSet.shedulerDataTable changes = rEKLAMADataSet.sheduler.GetChanges(DataRowState.Modified)
226                as REKLAMADataSet.shedulerDataTable;
227
228            if (changes != null)
229            {
230                if (MessageBox.Show("Czy zapisaæ zmiany?", "", MessageBoxButtons.YesNo,
231                    MessageBoxIcon.Question) == DialogResult.Yes)
232                {
233                    shedulerTableAdapter.Update(rEKLAMADataSet.sheduler);
234                }
235                else
236                {
237                    rEKLAMADataSet.sheduler.RejectChanges();
238                }
239            }
240        }
241
242        private void klient2ToolStripButton_Click(object sender, EventArgs e)
243        {
244            if (zastawienieKontaktowBindingSource.Current != null)
245            {
246                DataRowView row = (DataRowView)zastawienieKontaktowBindingSource.Current;
247
248                int custID = Convert.ToInt32(row["CustomerId"]);
249
250                ClientsForm.getClientsForm((MDIBazaReklam)this.MdiParent).pokazKlienta(custID);
251
252                this.Hide();
253
254                ClientsForm.getClientsForm((MDIBazaReklam)this.MdiParent).Show();
255            }
256        }
257
258        private void szukajToolStripButton_Click(object sender, EventArgs e)
259        {
260            string query = "SELECT TOP 1000 KLIENCI.FirstName, KONTAKTY.symbol_agenta, KONTAKTY.data, KONTAKTY.rodzaj,";
261            query += " KONTAKTY.opis, KLIENCI.CustomerID, KLIENCI.UserName FROM KONTAKTY LEFT OUTER JOIN KLIENCI ON KONTAKTY.customerId = KLIENCI.CustomerID ";
262            query += "left outer join AGENCI on KONTAKTY.symbol_agenta = AGENCI.Symbol left outer join ";
263            query += "AGENCJE on AGENCI.ID_AGENCJI = AGENCJE.Id_agencji where 1=1 ";
264
265            SqlConnection conn = new SqlConnection(ConnString.getConnString().Value);     
266   
267            SqlCommand command = new SqlCommand();
268            command.CommandType = CommandType.Text;
269            command.Connection = conn;       
270            command.CommandText = query;
271            command.Parameters.Clear();
272
273            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(command);
274
275
276            if (rokToolStripTextBox.Text.Trim() != "")
277            {
278                int i;
279                if (!Int32.TryParse(rokToolStripTextBox.Text.Trim(), out i))
280                {
281                    MessageBox.Show("Podaj prawid³owy rok.");
282                    return;
283                }
284                command.CommandText += " AND datepart(year,KONTAKTY.data) = @rok ";
285                command.Parameters.AddWithValue("@rok", rokToolStripTextBox.Text.Trim());
286            }
287
288            if (msToolStripTextBox.Text.Trim() != "")
289            {
290                int i;
291                if (!Int32.TryParse(msToolStripTextBox.Text.Trim(), out i))
292                {
293                    MessageBox.Show("Podaj prawid³owy miesi¹c.");
294                    return;
295                }               
296                command.CommandText += " AND datepart(month,KONTAKTY.data) = @ms ";
297                command.Parameters.AddWithValue("@ms", msToolStripTextBox.Text.Trim());
298            }
299
300            if (agencjaToolStripComboBox.Text.Trim() != "")
301            {
302                command.CommandText += " AND AGENCJE.Symbol = @agencja ";
303                command.Parameters.AddWithValue("@agencja", agencjaToolStripComboBox.Text.Trim());
304            }
305
306            if (agentToolStripComboBox.Text.Trim() != "")
307            {
308                command.CommandText += " AND AGENCI.Symbol = @agent ";
309                command.Parameters.AddWithValue("@agent", agentToolStripComboBox.Text.Trim());
310            }
311
312            if (rodzajToolStripComboBox.Text.Trim() != "")
313            {
314                command.CommandText += " AND KONTAKTY.rodzaj = @rodzaj ";
315                command.Parameters.AddWithValue("@rodzaj", rodzajToolStripComboBox.Text.Trim());
316            }
317
318            if (klientToolStripTextBox.Text.Trim() != "")
319            {
320                command.CommandText += " AND KLIENCI.FirstName like '%' + @klient + '%' ";
321                command.Parameters.AddWithValue("@klient", klientToolStripTextBox.Text.Trim());               
322            }
323                       
324            command.CommandText += " order by KONTAKTY.data";
325
326            sqlDataAdapter.SelectCommand = command;
327
328            this.Cursor = Cursors.WaitCursor;
329
330            this.rEKLAMADataSet.zastawienieKontaktow.Clear();
331
332            try
333            {
334                sqlDataAdapter.Fill(this.rEKLAMADataSet.zastawienieKontaktow);
335            }
336            catch (Exception e1)
337            {
338                MessageBox.Show(e1.Message);
339            }
340
341            this.Cursor = Cursors.Default;
342
343        }
344
345        private void wyczyscToolStripButton_Click(object sender, EventArgs e)
346        {
347            rEKLAMADataSet.KONTAKTY.Clear();
348
349            rokToolStripTextBox.Clear();
350            msToolStripTextBox.Clear();
351            klientToolStripTextBox.Clear();               
352       
353            agencjaToolStripComboBox.SelectedIndex = -1;
354            agenciToolStripComboBox.Text = "";
355
356            agentToolStripComboBox.SelectedIndex = -1;
357            agentToolStripComboBox.Text = "";
358           
359            rodzajToolStripComboBox.SelectedIndex = -1;
360            rodzajToolStripComboBox.Text = "";
361        }
362
363        private void zastawienieKontaktowDataGridView_CellLeave(object sender, DataGridViewCellEventArgs e)
364        {
365            zastawienieKontaktowBindingSource.CancelEdit();
366        }
367
368        private void wynikAgenta() {
369
370            rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu.Clear();
371            view_Podsumowanie_Wykonania_PlanuTableAdapter1.Fill(rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, User.getUser().Login, (short)DateTime.Today.Month, (short)DateTime.Today.Year);
372                     
373            //wynik miesieczny
374            Label l1 = new Label();
375            l1.Text = "BUD¯ET";
376            Label lw1 = new Label();
377            lw1.TextAlign = ContentAlignment.MiddleCenter;
378            lw1.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "W_BUDZET",true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, "0", "C2"));
379            Label lp1 = new Label();
380            lp1.TextAlign = ContentAlignment.MiddleCenter;
381            lp1.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "BUDZET", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, "0", "C2"));
382            tableLayoutPanel1.Controls.Add(l1);
383            tableLayoutPanel1.Controls.Add(lp1);
384            tableLayoutPanel1.Controls.Add(lw1);
385
386            Label l2 = new Label();
387            l2.Text = "SPOTKANIA";
388            Label lw2 = new Label();
389            lw2.TextAlign = ContentAlignment.MiddleCenter;
390            lw2.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "W_SPOTKANIA"));
391            Label lp2 = new Label();
392            lp2.TextAlign = ContentAlignment.MiddleCenter;
393            lp2.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "SPOTKANIA"));
394            tableLayoutPanel1.Controls.Add(l2);
395            tableLayoutPanel1.Controls.Add(lp2);
396            tableLayoutPanel1.Controls.Add(lw2);
397
398            Label l3 = new Label();
399            l3.Text = "KONTAKTY";
400            Label lw3 = new Label();
401            lw3.TextAlign = ContentAlignment.MiddleCenter;
402            lw3.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "W_KONTAKTY"));
403            Label lp3 = new Label();
404            lp3.TextAlign = ContentAlignment.MiddleCenter;
405            lp3.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "KONTAKTY"));
406            tableLayoutPanel1.Controls.Add(l3);
407            tableLayoutPanel1.Controls.Add(lp3);
408            tableLayoutPanel1.Controls.Add(lw3);
409
410            Label l4 = new Label();
411            l4.Text = "NOWI KLIENCI";
412            Label lw4 = new Label();
413            lw4.TextAlign = ContentAlignment.MiddleCenter;
414            lw4.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "W_N_KLIENCI"));           
415            Label lp4 = new Label();
416            lp4.TextAlign = ContentAlignment.MiddleCenter;
417            lp4.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "N_KLIENCI"));
418            tableLayoutPanel1.Controls.Add(l4);
419            tableLayoutPanel1.Controls.Add(lp4);
420            tableLayoutPanel1.Controls.Add(lw4);
421
422            Label l5 = new Label();
423            l5.Text = "ILOŒÆ REKLAM";
424            Label lw5 = new Label();
425            lw5.TextAlign = ContentAlignment.MiddleCenter;           
426            lw5.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "W_REKLAMY"));
427            Label lp5 = new Label();
428            lp5.TextAlign = ContentAlignment.MiddleCenter;           
429            lp5.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "REKLAMY"));
430            tableLayoutPanel1.Controls.Add(l5);
431            tableLayoutPanel1.Controls.Add(lp5);
432            tableLayoutPanel1.Controls.Add(lw5);
433
434            //wynik roczny
435            Label rl1 = new Label();
436            rl1.Text = "BUD¯ET";
437            Label rlw1 = new Label();
438            rlw1.TextAlign = ContentAlignment.MiddleCenter;           
439            rlw1.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "R_W_BUDZET", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, "0", "C2"));
440            Label rlp1 = new Label();
441            rlp1.TextAlign = ContentAlignment.MiddleCenter;           
442            rlp1.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "R_BUDZET", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, "0", "C2"));
443            tableLayoutPanel2.Controls.Add(rl1);
444            tableLayoutPanel2.Controls.Add(rlp1);
445            tableLayoutPanel2.Controls.Add(rlw1);
446
447            Label rl2 = new Label();
448            rl2.Text = "SPOTKANIA";
449            Label rlw2 = new Label();
450            rlw2.TextAlign = ContentAlignment.MiddleCenter;           
451            rlw2.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "R_W_SPOTKANIA"));
452            Label rlp2 = new Label();
453            rlp2.TextAlign = ContentAlignment.MiddleCenter;           
454            rlp2.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "R_SPOTKANIA"));
455            tableLayoutPanel2.Controls.Add(rl2);
456            tableLayoutPanel2.Controls.Add(rlp2);
457            tableLayoutPanel2.Controls.Add(rlw2);
458
459            Label rl3 = new Label();
460            rl3.Text = "KONTAKTY";
461            Label rlw3 = new Label();
462            rlw3.TextAlign = ContentAlignment.MiddleCenter;           
463            rlw3.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "R_W_KONTAKTY"));
464            Label rlp3 = new Label();
465            rlp3.TextAlign = ContentAlignment.MiddleCenter;           
466            rlp3.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "R_KONTAKTY"));
467            tableLayoutPanel2.Controls.Add(rl3);
468            tableLayoutPanel2.Controls.Add(rlp3);
469            tableLayoutPanel2.Controls.Add(rlw3);
470
471            Label rl4 = new Label();
472            rl4.Text = "NOWI KLIENCI";
473            Label rlw4 = new Label();
474            rlw4.TextAlign = ContentAlignment.MiddleCenter;           
475            rlw4.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "R_W_N_KLIENCI"));
476            Label rlp4 = new Label();
477            rlp4.TextAlign = ContentAlignment.MiddleCenter;           
478            rlp4.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "R_N_KLIENCI"));
479            tableLayoutPanel2.Controls.Add(rl4);
480            tableLayoutPanel2.Controls.Add(rlp4);
481            tableLayoutPanel2.Controls.Add(rlw4);
482
483            Label rl5 = new Label();
484            rl5.Text = "ILOŒÆ REKLAM";
485            Label rlw5 = new Label();
486            rlw5.TextAlign = ContentAlignment.MiddleCenter;           
487            rlw5.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "R_W_REKLAMY"));
488            Label rlp5 = new Label();
489            rlp5.TextAlign = ContentAlignment.MiddleCenter;           
490            rlp5.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu, "R_REKLAMY"));
491            tableLayoutPanel2.Controls.Add(rl5);
492            tableLayoutPanel2.Controls.Add(rlp5);
493            tableLayoutPanel2.Controls.Add(rlw5);
494        }
495
496        private void wynikAgencji()
497        {
498            rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja.Clear();
499            view_Podsumowanie_Wykonania_Planu_AgencjaTableAdapter1.Fill(
500                rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja,
501                User.getUser().SymbolAgencji, (short)DateTime.Today.Month, (short)DateTime.Today.Year);   
502
503            //wynik miesieczny
504            Label l1 = new Label();
505            l1.Text = "BUD¯ET";
506            Label lw1 = new Label();
507            lw1.TextAlign = ContentAlignment.MiddleCenter;           
508            lw1.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "W_BUDZET", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, "0", "C2"));
509            Label lp1 = new Label();
510            lp1.TextAlign = ContentAlignment.MiddleCenter;           
511            lp1.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "BUDZET", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, "0", "C2"));
512            tableLayoutPanel1.Controls.Add(l1);
513            tableLayoutPanel1.Controls.Add(lp1);
514            tableLayoutPanel1.Controls.Add(lw1);
515
516            Label l2 = new Label();
517            l2.Text = "SPOTKANIA";
518            Label lw2 = new Label();
519            lw2.TextAlign = ContentAlignment.MiddleCenter;                       
520            lw2.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "W_SPOTKANIA"));
521            Label lp2 = new Label();
522            lp2.TextAlign = ContentAlignment.MiddleCenter;                       
523            lp2.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "SPOTKANIA"));
524            tableLayoutPanel1.Controls.Add(l2);
525            tableLayoutPanel1.Controls.Add(lp2);
526            tableLayoutPanel1.Controls.Add(lw2);
527
528            Label l3 = new Label();
529            l3.Text = "KONTAKTY";
530            Label lw3 = new Label();
531            lw3.TextAlign = ContentAlignment.MiddleCenter;                       
532            lw3.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "W_KONTAKTY"));
533            Label lp3 = new Label();
534            lp3.TextAlign = ContentAlignment.MiddleCenter;                       
535            lp3.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "KONTAKTY"));
536            tableLayoutPanel1.Controls.Add(l3);
537            tableLayoutPanel1.Controls.Add(lp3);
538            tableLayoutPanel1.Controls.Add(lw3);
539
540            Label l4 = new Label();
541            l4.Text = "NOWI KLIENCI";
542            Label lw4 = new Label();
543            lw4.TextAlign = ContentAlignment.MiddleCenter;                       
544            lw4.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "W_N_KLIENCI"));
545            Label lp4 = new Label();
546            lp4.TextAlign = ContentAlignment.MiddleCenter;                       
547            lp4.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "N_KLIENCI"));
548            tableLayoutPanel1.Controls.Add(l4);
549            tableLayoutPanel1.Controls.Add(lp4);
550            tableLayoutPanel1.Controls.Add(lw4);
551
552            Label l5 = new Label();
553            l5.Text = "ILOŒÆ REKLAM";
554            Label lw5 = new Label();
555            lw5.TextAlign = ContentAlignment.MiddleCenter;                       
556            lw5.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "W_REKLAMY"));
557            Label lp5 = new Label();
558            lp5.TextAlign = ContentAlignment.MiddleCenter;                       
559            lp5.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "REKLAMY"));
560            tableLayoutPanel1.Controls.Add(l5);
561            tableLayoutPanel1.Controls.Add(lp5);
562            tableLayoutPanel1.Controls.Add(lw5);
563
564            //wynik roczny
565            Label rl1 = new Label();
566            rl1.Text = "BUD¯ET";
567            Label rlw1 = new Label();
568            rlw1.TextAlign = ContentAlignment.MiddleCenter;                     
569            rlw1.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "R_W_BUDZET", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, "0", "C2"));
570            Label rlp1 = new Label();
571            rlp1.TextAlign = ContentAlignment.MiddleCenter;                     
572            rlp1.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "R_BUDZET", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, "0", "C2"));
573            tableLayoutPanel2.Controls.Add(rl1);
574            tableLayoutPanel2.Controls.Add(rlp1);
575            tableLayoutPanel2.Controls.Add(rlw1);
576
577            Label rl2 = new Label();
578            rl2.Text = "SPOTKANIA";
579            Label rlw2 = new Label();
580            rlw2.TextAlign = ContentAlignment.MiddleCenter;                     
581            rlw2.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "R_W_SPOTKANIA"));
582            Label rlp2 = new Label();
583            rlp2.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "R_SPOTKANIA"));
584            rlp2.TextAlign = ContentAlignment.MiddleCenter;                     
585            tableLayoutPanel2.Controls.Add(rl2);
586            tableLayoutPanel2.Controls.Add(rlp2);
587            tableLayoutPanel2.Controls.Add(rlw2);
588
589            Label rl3 = new Label();
590            rl3.Text = "KONTAKTY";
591            Label rlw3 = new Label();
592            rlw3.TextAlign = ContentAlignment.MiddleCenter;       
593            rlw3.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "R_W_KONTAKTY"));
594            Label rlp3 = new Label();
595            rlp3.TextAlign = ContentAlignment.MiddleCenter;                     
596            rlp3.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "R_KONTAKTY"));
597            tableLayoutPanel2.Controls.Add(rl3);
598            tableLayoutPanel2.Controls.Add(rlp3);
599            tableLayoutPanel2.Controls.Add(rlw3);
600
601            Label rl4 = new Label();
602            rl4.Text = "NOWI KLIENCI";
603            Label rlw4 = new Label();
604            rlw4.TextAlign = ContentAlignment.MiddleCenter;                     
605            rlw4.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "R_W_N_KLIENCI"));
606            Label rlp4 = new Label();
607            rlp4.TextAlign = ContentAlignment.MiddleCenter;                     
608            rlp4.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "R_N_KLIENCI"));
609            tableLayoutPanel2.Controls.Add(rl4);
610            tableLayoutPanel2.Controls.Add(rlp4);
611            tableLayoutPanel2.Controls.Add(rlw4);
612
613            Label rl5 = new Label();
614            rl5.Text = "ILOŒÆ REKLAM";
615            Label rlw5 = new Label();
616            rlw5.TextAlign = ContentAlignment.MiddleCenter;                     
617            rlw5.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "R_W_REKLAMY"));           
618            Label rlp5 = new Label();
619            rlp5.TextAlign = ContentAlignment.MiddleCenter;                     
620            rlp5.DataBindings.Add(new Binding("Text", rEKLAMADataSet.View_Podsumowanie_Wykonania_Planu_Agencja, "R_REKLAMY"));
621            tableLayoutPanel2.Controls.Add(rl5);
622            tableLayoutPanel2.Controls.Add(rlp5);
623            tableLayoutPanel2.Controls.Add(rlw5);               
624        }
625
626        private void kryteriumWyszukiwania_KeyPress(object sender, KeyPressEventArgs e)
627        {
628            if (e.KeyChar == 13)
629            {
630                szukajToolStripButton.PerformClick();
631            }
632        }
633
634        private void StartForm_Shown(object sender, EventArgs e)
635        {
636           // MessageBox.Show("ddd");
637
638            if (User.getUser().St_kierownik)
639            {
640                agencjaToolStripComboBox.Text = User.getUser().SymbolAgencji;
641            }
642            else if (User.getUser().St_handlowiec | User.getUser().St_subhandlowiec)
643            {
644                agentToolStripComboBox.Text = User.getUser().Login;
645            }
646           
647            wypelnijShedulerWyniki();
648
649            pierwszaAktywacja = true;
650        }
651
652        private void wypelnijShedulerWyniki()
653        {         
654
655            if (User.getUser().St_kierownik)
656            {
657                shedulerTableAdapter.FillByAgencjaWgDaty(rEKLAMADataSet.sheduler, User.getUser().IdAgencji);
658            }
659            else
660            {
661                shedulerTableAdapter.FillByAgentWgDaty(rEKLAMADataSet.sheduler, User.getUser().Login);
662            }
663
664            if (User.getUser().St_kierownik)
665            {
666                wynikAgencji();
667            }
668            else if (User.getUser().St_handlowiec | User.getUser().St_subhandlowiec)
669            {
670                wynikAgenta();
671            }
672        }
673    }
674}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.