root/branches/Abonament/BazaZamowien/Classes/Premie/Premia.cs @ 876

Wersja 710, 3.6 KB (wprowadzona przez dorota, 18 years temu)

baza zamowien i premii 1.0.0.1

Line 
1using System;
2using System.Collections.Generic;
3using System.Data.SqlClient;
4using System.Text;
5
6namespace BazaZamowien.Classes
7{
8    class Premia
9    {
10
11                #region Fields (6) 
12
13        decimal chorobowe;
14        decimal emerytalne;
15        decimal podatek;
16        decimal rentowe;
17        decimal zdrowotne1;
18        decimal zdrowotne2;
19
20                #endregion Fields 
21
22                #region Constructors (2) 
23
24        public Premia(decimal _emerytalne, decimal _rentowe, decimal _chorobowe, decimal _zdrowotne1, decimal _zdrowotne2, decimal _podatek)
25        {
26            this.emerytalne = _emerytalne;
27            this.rentowe = _rentowe;
28            this.chorobowe = _chorobowe;
29            this.zdrowotne1 = _zdrowotne1;
30            this.zdrowotne2 = _zdrowotne2;
31            this.podatek = _podatek;
32        }
33
34        public Premia()
35        {
36            initWspolczynniki();
37        }
38
39                #endregion Constructors 
40
41                #region Properties (6) 
42
43        public decimal Chorobowe
44        {
45            get { return chorobowe; }
46            set { chorobowe = value; }
47        }
48
49        public decimal Emerytalne
50        {
51            get { return emerytalne; }
52            set { emerytalne = value; }
53        }
54
55        public decimal Podatek
56        {
57            get { return podatek; }
58            set { podatek = value; }
59        }
60
61        public decimal Rentowe
62        {
63            get { return rentowe; }
64            set { rentowe = value; }
65        }
66
67        public decimal Zdrowotne1
68        {
69            get { return zdrowotne1; }
70            set { zdrowotne1 = value; }
71        }
72
73        public decimal Zdrowotne2
74        {
75            get { return zdrowotne2; }
76            set { zdrowotne2 = value; }
77        }
78
79                #endregion Properties 
80
81                #region Methods (3) 
82
83
84                // Public Methods (2) 
85
86        public decimal BruttoToNetto(decimal kwotaBrutto)
87        {
88            decimal skladkiZUS = Math.Round(kwotaBrutto * emerytalne + kwotaBrutto * rentowe + kwotaBrutto * chorobowe, 2);
89
90            decimal kwota1 = Math.Round(kwotaBrutto - skladkiZUS,2);
91
92            decimal ubezpieczoneZdrowotne = Math.Round(kwota1 * zdrowotne1 + kwota1 * zdrowotne2,2);
93
94            decimal kwotaPodatku = Math.Round(kwota1) * podatek;
95
96            kwotaPodatku = Math.Round(kwotaPodatku - zdrowotne1 * kwota1);
97
98            return Math.Round(kwotaBrutto - skladkiZUS - ubezpieczoneZdrowotne - kwotaPodatku,2);
99
100        }
101
102        public decimal NettoToBrutto(decimal kwotaNetto)
103        {
104            return (kwotaNetto * (decimal)1.45);
105        }
106
107
108
109                // Private Methods (1) 
110
111        private void initWspolczynniki()
112        {
113            SqlCommand command = new SqlCommand("SELECT TOP 1 * FROM Wspolczynniki ORDER BY data DESC");
114            command.Connection = new SqlConnection(ConnString.getConnString().PremieConnStr);
115
116            command.Connection.Open();
117
118            SqlDataReader reader = command.ExecuteReader();
119
120            if (reader.HasRows)
121            {
122                while (reader.Read())
123                {
124                    this.emerytalne = Convert.ToDecimal(reader.GetValue(2));
125                    this.rentowe = Convert.ToDecimal(reader.GetValue(3));
126                    this.chorobowe = Convert.ToDecimal(reader.GetValue(4));
127                    this.zdrowotne1 = Convert.ToDecimal(reader.GetValue(5));
128                    this.zdrowotne2 = Convert.ToDecimal(reader.GetValue(6));
129                    this.podatek = Convert.ToDecimal(reader.GetValue(7));
130                }
131            }
132
133            command.Connection.Close();
134
135        }
136
137
138                #endregion Methods 
139
140    }
141}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.