| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.Linq;
|
|---|
| 4 | using System.Web;
|
|---|
| 5 | using Platnosci.Core.Linq;
|
|---|
| 6 | using System.Threading;
|
|---|
| 7 | using System.Globalization;
|
|---|
| 8 | using System.Web.Mvc;
|
|---|
| 9 | using System.Configuration;
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | namespace Platnosci.Models
|
|---|
| 13 | {
|
|---|
| 14 | public class FunkcjePlatnosci
|
|---|
| 15 | {
|
|---|
| 16 | private const string EUR = "978";
|
|---|
| 17 | private const string GBP = "826";
|
|---|
| 18 | private const string USD = "789";
|
|---|
| 19 | private const string PLN = "985";
|
|---|
| 20 |
|
|---|
| 21 | public string BruttoToString(decimal? kwota, decimal? waluta, string miano)
|
|---|
| 22 | {
|
|---|
| 23 | string brutto = String.Format("{0:0.00}", kwota.ToString().Replace(",", ".")) + " PLN ";
|
|---|
| 24 | if (waluta > 0 && miano != "")
|
|---|
| 25 | {
|
|---|
| 26 | brutto += "(" + (waluta.ToString()).Replace(",", ".") + " " + miano + ")";
|
|---|
| 27 | }
|
|---|
| 28 | return brutto;
|
|---|
| 29 | }
|
|---|
| 30 | public bool UserIdentity(vPlatnosciEcard platnosc, string userName)
|
|---|
| 31 | {
|
|---|
| 32 | if (platnosc != null && platnosc.nip == userName)
|
|---|
| 33 | {
|
|---|
| 34 | return true;
|
|---|
| 35 | }
|
|---|
| 36 | return false;
|
|---|
| 37 | }
|
|---|
| 38 | public Waluta setAmount(vPlatnosciEcard platnosc){
|
|---|
| 39 | Waluta waluta = new Waluta();
|
|---|
| 40 | if (String.IsNullOrEmpty(platnosc.waluta_miano) || platnosc.waluta_miano == "PLN")
|
|---|
| 41 | {
|
|---|
| 42 | waluta.Amount = Convert.ToInt32(platnosc.Brutto * 100);
|
|---|
| 43 | waluta.Currency = PLN;
|
|---|
| 44 | }
|
|---|
| 45 | else
|
|---|
| 46 | {
|
|---|
| 47 | waluta.Amount = Convert.ToInt32(platnosc.waluta_brutto * 100);
|
|---|
| 48 | if (platnosc.waluta_miano == "EUR")
|
|---|
| 49 | {
|
|---|
| 50 | waluta.Currency = EUR;
|
|---|
| 51 | }
|
|---|
| 52 | else if (platnosc.waluta_miano == "GBP")
|
|---|
| 53 | {
|
|---|
| 54 | waluta.Currency = GBP;
|
|---|
| 55 | }
|
|---|
| 56 | else if (platnosc.waluta_miano == "USD")
|
|---|
| 57 | {
|
|---|
| 58 | waluta.Currency = USD;
|
|---|
| 59 | }
|
|---|
| 60 | }
|
|---|
| 61 | return waluta;
|
|---|
| 62 | }
|
|---|
| 63 | public string setLanguage(string lang){
|
|---|
| 64 |
|
|---|
| 65 | if (lang == "pl" || lang == "en" || lang == "de" || lang == "it" || lang == "fr")
|
|---|
| 66 | {
|
|---|
| 67 | if (lang != Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName.ToLower())
|
|---|
| 68 | {
|
|---|
| 69 | string culture = "pl-PL";
|
|---|
| 70 | if (lang == "pl") culture = "pl-PL";
|
|---|
| 71 | else if (lang == "en") culture = "en-US";
|
|---|
| 72 | else if (lang == "de") culture = "de-DE";
|
|---|
| 73 | else if (lang == "it") culture = "it-IT";
|
|---|
| 74 | else if (lang == "fr") culture = "fr-FR";
|
|---|
| 75 |
|
|---|
| 76 | Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture);
|
|---|
| 77 | Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
|
|---|
| 78 | }
|
|---|
| 79 | }
|
|---|
| 80 | string pom = CultureInfo.CurrentCulture.TwoLetterISOLanguageName.ToLower();
|
|---|
| 81 | return pom;
|
|---|
| 82 | }
|
|---|
| 83 | public string setTitle()
|
|---|
| 84 | {
|
|---|
| 85 | string str = "";
|
|---|
| 86 | string css = ConfigurationManager.AppSettings["Css"].ToString();
|
|---|
| 87 |
|
|---|
| 88 | if (css == "truck") str = HttpContext.GetGlobalResourceObject("tlumaczenia", "adresTruck").ToString() + " - ";
|
|---|
| 89 | else if (css == "admoto") str = HttpContext.GetGlobalResourceObject("tlumaczenia", "adresAdmoto").ToString() + " - ";
|
|---|
| 90 |
|
|---|
| 91 | return str;
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | }
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|