| 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 | using System.Security.Principal;
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | namespace Platnosci.Models
|
|---|
| 14 | {
|
|---|
| 15 | public class FunkcjePlatnosci
|
|---|
| 16 | {
|
|---|
| 17 | private const string EUR = "978";
|
|---|
| 18 | private const string GBP = "826";
|
|---|
| 19 | private const string USD = "789";
|
|---|
| 20 | private const string PLN = "985";
|
|---|
| 21 |
|
|---|
| 22 | public string BruttoToString(decimal? kwota, decimal? waluta, string miano)
|
|---|
| 23 | {
|
|---|
| 24 | string brutto = String.Format("{0:0.00}", kwota.ToString().Replace(",", ".")) + " PLN ";
|
|---|
| 25 | if (waluta > 0 && (miano != "" || miano != "PLN"))
|
|---|
| 26 | {
|
|---|
| 27 | brutto += "(" + (waluta.ToString()).Replace(",", ".") + " " + miano + ")";
|
|---|
| 28 | }
|
|---|
| 29 | return brutto;
|
|---|
| 30 | }
|
|---|
| 31 | public bool UserIdentity(vPlatnosciEcard platnosc, string userName)
|
|---|
| 32 | {
|
|---|
| 33 | if (platnosc != null && platnosc.nip == userName)
|
|---|
| 34 | {
|
|---|
| 35 | return true;
|
|---|
| 36 | }
|
|---|
| 37 | return false;
|
|---|
| 38 | }
|
|---|
| 39 | public Waluta setAmount(vPlatnosciEcard platnosc){
|
|---|
| 40 |
|
|---|
| 41 | Waluta waluta = new Waluta();
|
|---|
| 42 | waluta.Amount = Convert.ToInt32(platnosc.Brutto * 100);
|
|---|
| 43 |
|
|---|
| 44 | if (String.IsNullOrEmpty(platnosc.waluta_miano) || platnosc.waluta_miano == "PLN")
|
|---|
| 45 | {
|
|---|
| 46 | waluta.Currency = PLN;
|
|---|
| 47 | }
|
|---|
| 48 | else
|
|---|
| 49 | {
|
|---|
| 50 | if (platnosc.waluta_miano == "EUR")
|
|---|
| 51 | {
|
|---|
| 52 | waluta.Currency = EUR;
|
|---|
| 53 | }
|
|---|
| 54 | else if (platnosc.waluta_miano == "GBP")
|
|---|
| 55 | {
|
|---|
| 56 | waluta.Currency = GBP;
|
|---|
| 57 | }
|
|---|
| 58 | else if (platnosc.waluta_miano == "USD")
|
|---|
| 59 | {
|
|---|
| 60 | waluta.Currency = USD;
|
|---|
| 61 | }
|
|---|
| 62 | }
|
|---|
| 63 | return waluta;
|
|---|
| 64 | }
|
|---|
| 65 | public string setLanguage(string lang){
|
|---|
| 66 |
|
|---|
| 67 | if (lang == "pl" || lang == "en" || lang == "de" )//|| lang == "it" || lang == "fr")
|
|---|
| 68 | {
|
|---|
| 69 | if (lang != Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName.ToLower())
|
|---|
| 70 | {
|
|---|
| 71 | string culture = "pl-PL";
|
|---|
| 72 | if (lang == "pl") culture = "pl-PL";
|
|---|
| 73 | else if (lang == "en") culture = "en-US";
|
|---|
| 74 | else if (lang == "de") culture = "de-DE";
|
|---|
| 75 | // else if (lang == "it") culture = "it-IT";
|
|---|
| 76 | // else if (lang == "fr") culture = "fr-FR";
|
|---|
| 77 |
|
|---|
| 78 | Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture);
|
|---|
| 79 | Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
|
|---|
| 80 | }
|
|---|
| 81 | }
|
|---|
| 82 | string pom = CultureInfo.CurrentCulture.TwoLetterISOLanguageName.ToLower();
|
|---|
| 83 | return pom;
|
|---|
| 84 | }
|
|---|
| 85 | public string setTitle()
|
|---|
| 86 | {
|
|---|
| 87 | string str = "";
|
|---|
| 88 | string css = ConfigurationManager.AppSettings["Css"].ToString();
|
|---|
| 89 |
|
|---|
| 90 | if (css == "truck") str = HttpContext.GetGlobalResourceObject("tlumaczenia", "adresTruck").ToString() + " - ";
|
|---|
| 91 | else if (css == "admoto") str = HttpContext.GetGlobalResourceObject("tlumaczenia", "adresAdmoto").ToString() + " - ";
|
|---|
| 92 |
|
|---|
| 93 | return str;
|
|---|
| 94 | }
|
|---|
| 95 | public void SetUserLogger(string nip, string faktura){
|
|---|
| 96 |
|
|---|
| 97 | string User = nip + "-" + faktura;
|
|---|
| 98 | Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(User, ""), null);
|
|---|
| 99 | }
|
|---|
| 100 | public ErrorViewData InitErrorViewData(string errortxt, int idFaktury)
|
|---|
| 101 | {
|
|---|
| 102 | ErrorViewData er = new ErrorViewData();
|
|---|
| 103 | er.Error = errortxt;
|
|---|
| 104 | er.InvoiceId = idFaktury;
|
|---|
| 105 | return er;
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | }
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|