root/Baza Reklam 2 - Faktury/ProvisionForm.cs @ 2

Wersja 2, 26.3 KB (wprowadzona przez dorota, 17 years temu)
RevLine 
[2]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;
9
10namespace Baza_Reklam
11{
12    public partial class ProvisionForm : Form
13    {
14
15        private short rok=0;       
16        private short miesiac=0;
17        private int agencja=0;
18
19
20
21        /// <summary>
22        /// Klasa pomocnicza do wyœwietlania w 0 - 2 w gridzie
23        /// </summary>
24        class Ocena {
25            private int label;
26
27            public int Label
28            {
29                get { return label; }
30                set { label = value; }
31            }
32            private Single value;
33
34            public Single Value
35            {
36                get { return this.value; }
37                set { this.value = value; }
38            }
39
40            public Ocena(int l, Single v) {
41                label = l;
42                value = v;
43            }
44        }
45
46        /// <summary>
47        /// List do databindings
48        /// </summary>
49        List<Ocena> oceny = new List<Ocena>();
50 
51
52        private static ProvisionForm provisionForm;
53
54        public static ProvisionForm getProvisionForm(MDIBazaReklam parent)
55        {
56            if (provisionForm == null)
57            {
58                provisionForm = new ProvisionForm(parent);
59            }
60            return provisionForm;
61        }
62
63        public ProvisionForm(MDIBazaReklam parent)
64        {
65            InitializeComponent();
66
67            this.MdiParent = parent;
68
69            pLANTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
70            aGENCITableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
71            agencjeTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
72
73            //bindowanie ocen z comboBoxColumn
74            oceny.Add(new Ocena(0,0));
75            oceny.Add(new Ocena(1,50));
76            oceny.Add(new Ocena(2,100));         
77
78            OCENAComboCoxColumn.DataSource = oceny;
79            OCENAComboCoxColumn.DisplayMember = "label";
80            OCENAComboCoxColumn.ValueMember = "value";
81
82            dodajPlanToolStripButton.Enabled = User.getUser().St_kierownik;
83            usunToolStripButton.Enabled = User.getUser().St_kierownik;
84        }
85
86        private void ProvisionForm_Load(object sender, EventArgs e)
87        {
88            rokToolStripTextBox.Text = DateTime.Today.Year.ToString();
89            msToolStripTextBox.Text = DateTime.Today.Month.ToString();
90
91            ((ComboBox)agencjaToolStripComboBox.Control).DataSource = agencjeTableAdapter1.GetData();
92            ((ComboBox)agencjaToolStripComboBox.Control).DisplayMember = "Symbol";
93            ((ComboBox)agencjaToolStripComboBox.Control).ValueMember = "ID_Agencji";
94
95            ((ComboBox)agencjaToolStripComboBox.Control).SelectedValue = User.getUser().IdAgencji;
96
97            if (!User.getUser().St_kierownik)
98            {
99                agencjaToolStripComboBox.Enabled = false;
100            }
101
102        }
103     
104        private void treeView1_AfterExpand(object sender, TreeViewEventArgs e)
105        {
106            SqlCommand command = new SqlCommand();
107            command.Connection = new SqlConnection(ConnString.getConnString().Value);
108
109            if (e.Node != null)
110            {
111                switch (e.Node.Level) {
112                    case 0:
113                        e.Node.Nodes.Clear();
114
115                        TreeNode node;
116                       
117                        command.CommandText = "select distinct datepart(year,DATA_W) as rok from dbo.NR where datepart(year,DATA_W) is not null and datepart(year,DATA_W)>= 2003 order by rok desc";
118                        command.Connection.Open();
119                        SqlDataReader reader = command.ExecuteReader();
120
121                        while (reader.Read())
122                        {
123                            node = new TreeNode(reader.GetValue(0).ToString());
124                            node.Name = reader.GetValue(0).ToString();
125
126                            for (int i = 12; i >= 1; i--)
127                            {
128                                TreeNode node2 = new TreeNode(i.ToString());
129                                node2.Name = i.ToString();
130                              //  node2.Nodes.Add(new TreeNode());
131                                node.Nodes.Add(node2);
132                            }
133                            e.Node.Nodes.Add(node);
134                        }
135                        command.Connection.Close();                         
136       
137                        break;
138                    case 1:
139                        break;
140                    case 2:
141                        break;
142                }
143            }
144        }
145               
146        /// <summary>
147        ///  Pobiera dane o kontaktach i bud¿ecie.
148        /// </summary>
149        private void pobierzDaneToolStripButton_Click(object sender, EventArgs e)
150        {
151            this.Cursor = Cursors.WaitCursor;
152
153            SqlCommand command = new SqlCommand();
154
155            command.Connection = new SqlConnection(ConnString.getConnString().Value);
156
157            command.CommandType = CommandType.StoredProcedure;
158
159            command.CommandText = "PROC_WYLICZ_I_ZAPISZ_DANE_O_KONTAKTACH_I_BUDZECIE";
160            command.Parameters.AddWithValue("@rok", rok);
161            command.Parameters.AddWithValue("@ms", miesiac);
162
163            command.Connection.Open();
164
165            SqlTransaction transaction = command.Connection.BeginTransaction();
166
167            command.Transaction = transaction;
168
169            try
170            {
171                command.ExecuteNonQuery();
172                transaction.Commit();
173                MessageBox.Show("Dane pobrano!");
174            }
175            catch (Exception ex)
176            {
177                MessageBox.Show(ex.GetType() + ex.Message);
178
179                try
180                {
181                    transaction.Rollback();
182                }
183                catch (Exception ex2)
184                {
185                    MessageBox.Show("ROLLBACK:" + ex2.GetType() + ex2.Message);
186                }
187            }
188
189            command.Connection.Close();               
190
191            this.rEKLAMADataSet.PLAN.Clear();
192            this.pLANTableAdapter.FillByAgencja(this.rEKLAMADataSet.PLAN, rok, miesiac,agencja);
193            this.Cursor = Cursors.Default;
194        }
195
196        /// <summary>
197        /// Wylicza i zapisuje prowizjê agenta do planu
198        /// </summary>
199        private void zapiszToolStripButton_Click(object sender, EventArgs e)
200        {
201            this.Cursor = Cursors.WaitCursor;
202
203            SqlCommand command = new SqlCommand();
204
205            command.Connection = new SqlConnection(ConnString.getConnString().Value);
206
207            command.CommandType = CommandType.StoredProcedure;
208
209            command.CommandText = "PROC_WYLICZ_I_ZAPISZ_PROWIZJE_AGENTA_DO_PLANU";
210            command.Parameters.AddWithValue("@rok", rok);
211            command.Parameters.AddWithValue("@ms", miesiac);
212            command.Parameters.AddWithValue("@id_Agencji", agencja);
213            command.Connection.Open();
214
215            SqlTransaction transaction = command.Connection.BeginTransaction();
216
217            command.Transaction = transaction;
218
219            try
220            {
221                command.ExecuteNonQuery();
222                transaction.Commit();             
223                MessageBox.Show("Prowizja zosta³a zapisana!");
224            }
225            catch (Exception ex)
226            {
227                MessageBox.Show(ex.GetType() + ex.Message);
228
229                try
230                {
231                    transaction.Rollback();
232                }
233                catch (Exception ex2)
234                {
235                    MessageBox.Show("ROLLBACK:" + ex2.GetType() + ex2.Message);
236                }
237            }
238
239            command.Connection.Close();
240
241            this.rEKLAMADataSet.PLAN.Clear();
242
243            this.pLANTableAdapter.FillByAgencja(this.rEKLAMADataSet.PLAN, rok, miesiac, agencja);
244
245            this.Cursor = Cursors.Default;
246        }
247
248        private void naniesNaReklamyToolStripButton_Click(object sender, EventArgs e)
249        {
250            this.Cursor = Cursors.WaitCursor;
251
252            SqlCommand command = new SqlCommand();
253
254            command.Connection = new SqlConnection(ConnString.getConnString().Value);
255
256            command.CommandType = CommandType.StoredProcedure;
257
258            command.CommandText = "PROC_WYLICZ_I_ZAPISZ_PROWIZJE_DO_REKLAM";
259            command.Parameters.AddWithValue("@rok", this.rok);
260            command.Parameters.AddWithValue("@ms", this.miesiac);
261
262            command.Connection.Open();
263
264            SqlTransaction transaction = command.Connection.BeginTransaction();
265
266            command.Transaction = transaction;
267
268            try
269            {
270                command.ExecuteNonQuery();
271                transaction.Commit();
272                MessageBox.Show("Prowizja zosta³a naniesiona na zlecenia");
273            }
274            catch (Exception ex)
275            {
276                MessageBox.Show(ex.GetType() + ex.Message);
277
278                try
279                {
280                    transaction.Rollback();
281                }
282                catch (Exception ex2)
283                {
284                    MessageBox.Show("ROLLBACK:" + ex2.GetType() + ex.Message);
285                }
286            }
287
288            command.Connection.Close();
289
290            this.Cursor = Cursors.Default;
291
292            MessageBox.Show("Prowizja naniesiona na zlecenia");
293        }
294
295        /*
296        private void przeliczStripButton_Click(object sender, EventArgs e)
297        {
298            if (pLANBindingSource.List.Count != 0)
299            {
300                foreach (DataRowView r in pLANBindingSource.List)
301                {
302                    REKLAMADataSet.PLANRow row = (REKLAMADataSet.PLANRow)r.Row;
303                    przelicz(row);
304                    pLANBindingSource.EndEdit();
305                }
306            }
307
308        }*/
309
310        /*
311        private void przelicz(REKLAMADataSet.PLANRow row)
312        {
313
314            row.ECP = 0;
315            row.ESP = 0;
316            row.ELK = 0;
317            row.EP = 0;
318            row.EPK = 0;
319            row.EPR = 0;
320            row.WH = 0;
321            row.QO = 0;
322            row.OCENA = 0;
323
324            if (row.IsNull("BUDZET")) { row.BUDZET = 0; }
325            if (row.IsNull("REKLAMY")) { row.REKLAMY = 0; }
326            if (row.IsNull("W_REKLAMY")) { row.W_REKLAMY = 0; }
327            if (row.IsNull("W_BUDZET")) { row.W_BUDZET = 0; }
328            if (row.IsNull("N_KLIENCI")) { row.N_KLIENCI = 0; }
329            if (row.IsNull("W_N_KLIENCI")) { row.W_N_KLIENCI = 0; }
330            if (row.IsNull("W_SPOTKANIA")) { row.W_SPOTKANIA = 0; }
331            if (row.IsNull("W_TEL")) { row.W_TEL = 0; }
332            if (row.IsNull("W_EMAIL")) { row.W_EMAIL = 0; }
333            if (row.IsNull("W_FAX")) { row.W_FAX = 0; }
334            if (row.IsNull("W_LIST")) { row.W_LIST = 0; }
335            if (row.IsNull("KONTAKTY")) { row.KONTAKTY = 0; }
336
337
338            float W_BUDZET = Convert.ToSingle(row.W_BUDZET);
339            float BUDZET = Convert.ToSingle(row.BUDZET);
340            float W_REKLAMY = Convert.ToSingle(row.W_REKLAMY);
341            float REKLAMY = Convert.ToSingle(row.REKLAMY);
342            float W_N_KLIENCI = Convert.ToSingle(row.W_N_KLIENCI);
343            float N_KLIENCI = Convert.ToSingle(row.N_KLIENCI);
344            float W_SPOTKANIA = Convert.ToSingle(row.W_SPOTKANIA);
345            float W_TEL = Convert.ToSingle(row.W_TEL);
346            float W_EMAIL = Convert.ToSingle(row.W_EMAIL);
347            float W_FAX = Convert.ToSingle(row.W_FAX);
348            float W_LIST = Convert.ToSingle(row.W_LIST);
349            float KONTAKTY = Convert.ToSingle(row.KONTAKTY);
350            float JAKOSC_KORESPONDENCJI = Convert.ToSingle(row.JAKOSC_KORESPONDENCJI);
351            float JAKOSC_OFERT = Convert.ToSingle(row.JAKOSC_OFERT);
352            float JAKOSC_ROZMOWY_TEL = Convert.ToSingle(row.JAKOSC_ROZMOWY_TEL);
353            float JAKOSC_SPOTKAN = Convert.ToSingle(row.JAKOSC_SPOTKAN);
354            float WIEDZA_O_FIRMIE = Convert.ToSingle(row.WIEDZA_O_FIRMIE);
355            float WIEDZA_O_PRODUKCIE = Convert.ToSingle(row.WIEDZA_O_PRODUKCIE);
356            float WIEDZA_O_RYNKU = Convert.ToSingle(row.WIEDZA_O_RYNKU);
357            float WIEDZA_OGOLNO_HANDLOWA = Convert.ToSingle(row.WIEDZA_OGOLNO_HANDLOWA);
358
359            if (BUDZET != 0)
360            {
361                row.EP = 100 * W_BUDZET / BUDZET;
362            }
363
364            if (REKLAMY != 0)
365            {
366                row.ESP = 100 * W_REKLAMY / REKLAMY;
367            }
368
369            if ((REKLAMY != 0) && (W_REKLAMY != 0))
370            {
371                row.EPR = 100 * (W_BUDZET/W_REKLAMY)/(BUDZET/REKLAMY);
372            }
373
374            if (N_KLIENCI != 0)
375            {
376                row.EPK = 100 * (W_N_KLIENCI/N_KLIENCI);
377            }
378
379            row.ECP = 100 * ((120 * W_SPOTKANIA + 5 * W_TEL + 30 * W_EMAIL + 30 * W_FAX + 30 * W_LIST) / (20 * 7 * 60));
380
381            if (KONTAKTY != 0)
382            {
383                row.ELK = 100 * ((W_SPOTKANIA + W_TEL + W_EMAIL + W_FAX + W_LIST) / KONTAKTY);
384            }
385
386            row.QO = 100 * (JAKOSC_KORESPONDENCJI / 10 + JAKOSC_OFERT / 10 + JAKOSC_ROZMOWY_TEL / 10 + JAKOSC_SPOTKAN / 10) / 4;
387            row.WH = 100 * (WIEDZA_O_FIRMIE / 10 + WIEDZA_O_PRODUKCIE / 10 + WIEDZA_O_RYNKU / 10 + WIEDZA_OGOLNO_HANDLOWA / 10) / 4;
388            row.OCENA = (float)Math.Round(((row.WH + row.QO + row.ELK + row.ECP + row.EPK + 1 * row.EPR + 1 * row.ESP + 1 * row.EP) / 8), 2);
389        }
390        */
391
392        private void dodajPlanToolStripButton_Click(object sender, EventArgs e)
393        {
394            OcenaAddForm oaf = new OcenaAddForm();
395            oaf.Show();           
396        }
397
398        private void usunToolStripButton_Click(object sender, EventArgs e)
399        {
400            if (pLANBindingSource.Current != null)
401            {
402                if (MessageBox.Show("Czy na pewno usun¹æ rekord?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
403                {
404                    pLANBindingSource.RemoveCurrent();
405                    pLANBindingSource.EndEdit();
406                    pLANTableAdapter.Update(this.rEKLAMADataSet.PLAN);
407                }
408            }
409        }
410
411        private void zapiszDaneToolStripButton_Click(object sender, EventArgs e)
412        {
413            this.Cursor = Cursors.WaitCursor;
414
415            if (Validate())
416            {
417                pLANBindingSource.EndEdit();
418                pLANTableAdapter.Update(this.rEKLAMADataSet.PLAN);
419            }
420            this.Cursor = Cursors.Default;
421
422            MessageBox.Show("Zmiany zapisane");
423        }
424
425        private void ukryjKolumnyToolStripButton_Click(object sender, EventArgs e)
426        {
427            rOKDataGridViewTextBoxColumn.Visible = rOKDataGridViewTextBoxColumn.Visible ? false : true;
428
429            mSDataGridViewTextBoxColumn.Visible = mSDataGridViewTextBoxColumn.Visible ? false : true;             
430        }
431
432        private void prowizjeDataGridView_Leave(object sender, EventArgs e)
433        {
434            //ukrytyLabel.Select();
435            prowizjeDataGridView.EndEdit();
436            //pLANBindingSource.EndEdit();
437
438            REKLAMADataSet.PLANDataTable changes = rEKLAMADataSet.PLAN.GetChanges(DataRowState.Modified) as
439                REKLAMADataSet.PLANDataTable;
440
441            if (changes != null)
442            {
443                if (Validate())
444                {
445                    pLANBindingSource.EndEdit();
446                    pLANTableAdapter.Update(this.rEKLAMADataSet.PLAN);
447                }
448            }
449        }
450
451        /// <summary>
452        /// Podsumowuje bud¿et do wykonania
453        /// </summary>
454        private void uzupelnijBDsuma(){
455            int kasa=0;
456            foreach (DataRowView r in pLANBindingSource.List) {
457                kasa += Convert.ToInt32(r["BUDZET"]);
458            }
459            BDsumaTextBox.Text = String.Format("{0:C}", kasa);
460        }
461
462        /// <summary>
463        /// Podsumowuje bud¿et wykonany
464        /// </summary>
465        private void uzupelnijBDWykonanySuma()
466        {
467            int kasa = 0;
468            foreach (DataRowView r in pLANBindingSource.List)
469            {
470                kasa += Convert.ToInt32(r["W_BUDZET"]);
471            }
472            BDWykonanySumaTextBox.Text = String.Format("{0:C}", kasa);
473        }
474
475        /// <summary>
476        /// Zamienia wpisan¹ liczbê do decimal
477        /// </summary>
478        private void prowizjeDataGridView_CellLeave(object sender, DataGridViewCellEventArgs e)
479        {
480            ukrytyLabel.Select();
481            prowizjeDataGridView.EndEdit();   
482            pLANBindingSource.EndEdit();
483
484            if (prowizjeDataGridView.Columns[e.ColumnIndex].Name == "PR_PROWIZJI")
485            {
486                 
487                if (Convert.ToDecimal(prowizjeDataGridView[e.ColumnIndex,e.RowIndex].Value) >= 1)
488                {                   
489                    prowizjeDataGridView[e.ColumnIndex, e.RowIndex].Value = Convert.ToDecimal(prowizjeDataGridView[e.ColumnIndex, e.RowIndex].Value) / 100;                   
490                }
491            }
492
493           REKLAMADataSet.PLANDataTable changes = rEKLAMADataSet.PLAN.GetChanges( DataRowState.Modified) as
494                REKLAMADataSet.PLANDataTable;
495
496            if (changes != null)
497            {               
498                pLANBindingSource.EndEdit();
499                pLANTableAdapter.Update(this.rEKLAMADataSet.PLAN);
500            }
501        }
502
503        private void pLANBindingSource_ListChanged(object sender, ListChangedEventArgs e)
504        {
505            uzupelnijBDsuma();
506            uzupelnijBDWykonanySuma();
507        }
508       
509       
510        private void szukajToolStripButton_Click(object sender, EventArgs e)
511        {
512            if (rokToolStripTextBox.Text != "")
513            {
514                short i;
515                if (!Int16.TryParse(rokToolStripTextBox.Text, out i))
516                {
517                    MessageBox.Show("Podaj prawid³owy rok.");
518                    this.Cursor = Cursors.Default;
519                    return;
520                }
521            }
522            else {
523                MessageBox.Show("Podaj prawid³owy rok.");
524                this.Cursor = Cursors.Default;
525                return;
526            }
527
528            if (msToolStripTextBox.Text != "")
529            {
530                short i;
531                if (!Int16.TryParse(msToolStripTextBox.Text, out i))
532                {
533                    MessageBox.Show("Podaj prawid³owy miesi¹c.");
534                    this.Cursor = Cursors.Default;
535                    return;
536                }
537            }
538            else
539            {
540                MessageBox.Show("Podaj prawid³owy miesi¹c.");
541                this.Cursor = Cursors.Default;
542                return;
543            }
544
545            if (((ComboBox)agencjaToolStripComboBox.Control).SelectedValue == null)
546            {
547                MessageBox.Show("Wybierz agencjê");
548                return;
549            }
550
551            this.rok = Convert.ToInt16(rokToolStripTextBox.Text);
552            this.miesiac = Convert.ToInt16(msToolStripTextBox.Text);
553            this.agencja = Convert.ToInt32(((ComboBox)agencjaToolStripComboBox.Control).SelectedValue);
554
555            uprawnienia();       
556
557            this.sLOWNIKDataSet.AGENCI.Clear();
558            this.rEKLAMADataSet.PLAN.Clear();
559
560            this.aGENCITableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.AGENCI, this.agencja);
561            this.pLANTableAdapter.FillByAgencja(this.rEKLAMADataSet.PLAN, this.rok, this.miesiac, this.agencja);
562        }
563       
564        /*
565        private void szukajToolStripButton_Click(object sender, EventArgs e)
566        {           
567            this.Cursor = Cursors.WaitCursor;
568
569            string query = "SELECT   top 1000 [PLAN].* FROM AGENCJE INNER JOIN AGENCI ON AGENCJE.Id_agencji = AGENCI.ID_AGENCJI " +
570                " INNER JOIN [PLAN] ON AGENCI.Symbol = [PLAN].SYMBOL WHERE  1 = 1 ";
571
572            SqlCommand command = new SqlCommand();
573            command.CommandText = query;
574
575            if (rokToolStripTextBox.Text != "")
576            {
577                short i;
578                if (!Int16.TryParse(rokToolStripTextBox.Text, out i))
579                {
580                    MessageBox.Show("Podaj prawid³owy rok.");
581                    this.Cursor = Cursors.Default;
582                    return;
583                }
584                command.CommandText += " AND [PLAN].rok = @rok ";
585                command.Parameters.AddWithValue("@rok", rokToolStripTextBox.Text);
586                this.rok = Convert.ToInt16(rokToolStripTextBox.Text);
587            }           
588
589            if (msToolStripTextBox.Text != "")
590            {
591                short i;
592                if (!Int16.TryParse(msToolStripTextBox.Text, out i))
593                {
594                    MessageBox.Show("Podaj prawid³owy miesi¹c.");
595                    this.Cursor = Cursors.Default;
596                    return;
597                }
598                command.CommandText += " AND [PLAN].ms = @ms ";
599                command.Parameters.AddWithValue("ms", msToolStripTextBox.Text);
600                this.miesiac = Convert.ToInt16(msToolStripTextBox.Text);
601            }
602
603            if (((ComboBox)agencjaToolStripComboBox.Control).SelectedValue == null)
604            {
605                MessageBox.Show("Wybierz agencjê");
606                return;
607            }
608            else
609            {
610                command.CommandText += " AND AGENCJE.Id_Agencji=@agencja";
611                command.Parameters.AddWithValue("@agencja", ((ComboBox)agencjaToolStripComboBox.Control).SelectedValue);
612                this.agencja = Convert.ToInt32(((ComboBox)agencjaToolStripComboBox.Control).SelectedValue);
613            }
614
615          //  uprawnienia();   
616            poblokujWiersze();
617                     
618           
619            this.sLOWNIKDataSet.AGENCI.Clear();
620            this.aGENCITableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.AGENCI, this.agencja);
621
622            this.rEKLAMADataSet.PLAN.Clear();
623           // this.pLANTableAdapter.FillByAgencja(this.rEKLAMADataSet.PLAN, this.rok, this.miesiac, this.agencja);
624
625            command.Connection = new SqlConnection(ConnString.getConnString().Value);
626            SqlDataAdapter adapter = new SqlDataAdapter();
627            adapter.SelectCommand = command;
628
629            adapter.Fill(rEKLAMADataSet.PLAN);
630
631            this.Cursor = Cursors.Default;   
632        }
633
634        private void poblokujWiersze()
635        {
636            if (User.getUser().St_kierownik)
637            {
638                prowizjeDataGridView.ReadOnly = false;
639                foreach (DataGridViewRow r in prowizjeDataGridView.Rows)
640                {
641                    if (!((Convert.ToInt32(r.Cells["rOKDataGridViewTextBoxColumn"].Value) > DateTime.Today.Year) |
642                        ((Convert.ToInt32(r.Cells["rOKDataGridViewTextBoxColumn"].Value) == DateTime.Today.Year) & (Convert.ToInt32(r.Cells["mSDataGridViewTextBoxColumn"].Value) >= DateTime.Today.Month - 1)) |
643                        ((Convert.ToInt32(r.Cells["rOKDataGridViewTextBoxColumn"].Value) == DateTime.Today.Year - 1) & (Convert.ToInt32(r.Cells["mSDataGridViewTextBoxColumn"].Value) == 12) & (DateTime.Today.Month == 1))))
644                    {
645                        r.ReadOnly = true;
646                    }
647                }
648            }
649        }
650        */
651
652        private void uprawnienia()
653        {
654            if (User.getUser().St_kierownik)
655            {
656
657                if (!((this.rok > DateTime.Today.Year) |
658                    ((this.rok == DateTime.Today.Year) & (this.miesiac >= DateTime.Today.Month -1)) |
659                    ((this.rok == DateTime.Today.Year - 1) & (this.miesiac == 12) & (DateTime.Today.Month == 1))))
660                {
661                    OCENAComboCoxColumn.Visible = false;
662                    oCENADataGridViewTextBoxColumn.Visible = true;
663                   
664                    prowizjeDataGridView.ReadOnly = true;
665                    usunToolStripButton.Enabled = false;
666                    pobierzDaneToolStripButton.Enabled = false;
667                    naniesNaReklamyToolStripButton.Enabled = false;
668                    zapiszDaneToolStripButton.Enabled = false;
669                    zapiszToolStripButton.Enabled = false;
670                   
671                }
672                else
673                {
674                    OCENAComboCoxColumn.Visible = true;
675                    oCENADataGridViewTextBoxColumn.Visible = false;
676                    prowizjeDataGridView.ReadOnly = false;
677                 
678                    usunToolStripButton.Enabled = true;
679                    pobierzDaneToolStripButton.Enabled = true;
680                    naniesNaReklamyToolStripButton.Enabled = true;
681                    zapiszDaneToolStripButton.Enabled = true;
682                    zapiszToolStripButton.Enabled = true;
683                }
684            }
685        }
686
687        private void prowizjeDataGridView_DataError_1(object sender, DataGridViewDataErrorEventArgs e)
688        {           
689            MessageBox.Show("WprowadŸ poprawne dane");
690        }
691
692        private void ProvisionForm_Leave(object sender, EventArgs e)
693        {
694            prowizjeDataGridView.EndEdit();
695            //pLANBindingSource.EndEdit();
696
697            REKLAMADataSet.PLANDataTable changes = rEKLAMADataSet.PLAN.GetChanges(DataRowState.Modified) as
698                REKLAMADataSet.PLANDataTable;
699
700            if (changes != null)
701            {
702                if (Validate())
703                {
704                    pLANBindingSource.EndEdit();
705                    pLANTableAdapter.Update(this.rEKLAMADataSet.PLAN);
706                }
707            }
708        }
709
710        private void printToolStripButton_Click(object sender, EventArgs e)
711        {
712            PrintDGV.Print_DataGridView(prowizjeDataGridView,50);
713        }
714
715        private void wyczyscToolStripButton_Click(object sender, EventArgs e)
716        {
717
718        }
719
720        private void przeliczStripButton_Click(object sender, EventArgs e)
721        {
722
723        }
724
725   }
726}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.