using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Text; namespace BazaZamowien.Classes { class Premia { #region Fields (6)  decimal chorobowe; decimal emerytalne; decimal podatek; decimal rentowe; decimal zdrowotne1; decimal zdrowotne2; #endregion Fields  #region Constructors (2)  public Premia(decimal _emerytalne, decimal _rentowe, decimal _chorobowe, decimal _zdrowotne1, decimal _zdrowotne2, decimal _podatek) { this.emerytalne = _emerytalne; this.rentowe = _rentowe; this.chorobowe = _chorobowe; this.zdrowotne1 = _zdrowotne1; this.zdrowotne2 = _zdrowotne2; this.podatek = _podatek; } public Premia() { initWspolczynniki(); } #endregion Constructors  #region Properties (6)  public decimal Chorobowe { get { return chorobowe; } set { chorobowe = value; } } public decimal Emerytalne { get { return emerytalne; } set { emerytalne = value; } } public decimal Podatek { get { return podatek; } set { podatek = value; } } public decimal Rentowe { get { return rentowe; } set { rentowe = value; } } public decimal Zdrowotne1 { get { return zdrowotne1; } set { zdrowotne1 = value; } } public decimal Zdrowotne2 { get { return zdrowotne2; } set { zdrowotne2 = value; } } #endregion Properties  #region Methods (3)  // Public Methods (2)  public decimal BruttoToNetto(decimal kwotaBrutto) { decimal skladkiZUS = Math.Round(kwotaBrutto * emerytalne + kwotaBrutto * rentowe + kwotaBrutto * chorobowe, 2); decimal kwota1 = Math.Round(kwotaBrutto - skladkiZUS,2); decimal ubezpieczoneZdrowotne = Math.Round(kwota1 * zdrowotne1 + kwota1 * zdrowotne2,2); decimal kwotaPodatku = Math.Round(kwota1) * podatek; kwotaPodatku = Math.Round(kwotaPodatku - zdrowotne1 * kwota1); return Math.Round(kwotaBrutto - skladkiZUS - ubezpieczoneZdrowotne - kwotaPodatku,2); } public decimal NettoToBrutto(decimal kwotaNetto) { return (kwotaNetto * (decimal)1.45); } // Private Methods (1)  private void initWspolczynniki() { SqlCommand command = new SqlCommand("SELECT TOP 1 * FROM Wspolczynniki ORDER BY data DESC"); command.Connection = new SqlConnection(ConnString.getConnString().PremieConnStr); command.Connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { this.emerytalne = Convert.ToDecimal(reader.GetValue(2)); this.rentowe = Convert.ToDecimal(reader.GetValue(3)); this.chorobowe = Convert.ToDecimal(reader.GetValue(4)); this.zdrowotne1 = Convert.ToDecimal(reader.GetValue(5)); this.zdrowotne2 = Convert.ToDecimal(reader.GetValue(6)); this.podatek = Convert.ToDecimal(reader.GetValue(7)); } } command.Connection.Close(); } #endregion Methods  } }