Ostrzeżenie: Can't use blame annotator:
svn blame failed: ("Cannot calculate blame information for binary file 'file:///e:/subversion/BazaReklam/trunk/eCard/Expo/platnosc.aspx.cs'", 195004)

root/trunk/eCard/Expo/platnosc.aspx.cs @ 477

Wersja 477, 37.3 KB (wprowadzona przez marek, 17 years temu)

re #139

  • Właściwość svn:mime-type zmieniona na application/octet-stream
RevLine 
1using System;
2using System.Data;
3using System.Configuration;
4using System.Collections;
5using System.Web;
6using System.Web.Security;
7using System.Web.UI;
8using System.Web.UI.WebControls;
9using System.Web.UI.WebControls.WebParts;
10using System.Web.UI.HtmlControls;
11using System.Net;
12using System.IO;
13using System.Data.SqlClient;
14using System.Threading;
15using System.Globalization;
16
17public partial class _Default : System.Web.UI.Page
18{
19    protected override void InitializeCulture()
20    {
21        if (Session["culture"] != null)
22        {
23            UICulture = Session["culture"].ToString();
24            Culture = Session["culture"].ToString();
25
26            Thread.CurrentThread.CurrentCulture =
27              CultureInfo.CreateSpecificCulture(Session["culture"].ToString());
28            Thread.CurrentThread.CurrentUICulture =
29              new CultureInfo(Session["culture"].ToString());
30        }
31        base.InitializeCulture();
32    }
33
34    protected string wartoscNaString(SqlDataReader reader, int i, string rodzajZmiennej)
35    {
36        string wartosc = "";
37        if (rodzajZmiennej == "string")
38        {
39            try
40            {
41                if (!reader[i].Equals(System.DBNull.Value)) { wartosc = (string)reader[i]; };
42            }
43            catch (System.NullReferenceException err)
44            {
45                wartosc = "Error: " + err.ToString();
46            }
47            return wartosc;
48        }
49        if (rodzajZmiennej == "DateTime")
50        {
51            DateTime data;
52            try
53            {
54                if (!reader[i].Equals(System.DBNull.Value))
55                {
56                    data = (DateTime)reader[i];
57                    wartosc = data.ToShortDateString();
58                }
59
60            }
61            catch (System.NullReferenceException err)
62            {
63                wartosc = "Error: " + err.ToString();
64            }
65        }
66        if (rodzajZmiennej == "double")
67        {
68            double liczba;
69            try
70            {
71                if (!reader[i].Equals(System.DBNull.Value))
72                {
73                    liczba = (double)reader[i];
74                    wartosc = liczba.ToString();
75                }
76
77            }
78            catch (System.NullReferenceException err)
79            {
80                wartosc = "Error: " + err.ToString();
81            }
82        }
83        return wartosc;
84
85    }
86
87    protected string przeliczNaGrosze(SqlDataReader reader, int i)
88    {
89        string grosze = "";
90        double dGrosze;
91        try
92        {
93            if (!reader[i].Equals(System.DBNull.Value))
94            {
95                dGrosze = (double)reader[i];
96                dGrosze = dGrosze * 100;
97                grosze = dGrosze.ToString();
98            }
99
100        }
101        catch (System.NullReferenceException err)
102        {
103            grosze = "Error: " + err.ToString();
104        }
105        return grosze;
106    }
107
108    protected void Page_Load(object sender, EventArgs e)
109    {
110
111        if (!IsPostBack)
112        {
113            string connString = ConfigurationManager.ConnectionStrings["BazaReklamConn"].ConnectionString;
114            string cmdText = "SELECT [ID Reklamy], FirstName, LastName, Address, PostalCode, City, State, Country, [Faktura Numer], Nabywca_nip, Brutto, [Faktura Data Wystawienia], Termin_zaplaty, Sposob_zaplaty, ID_faktury, [Imię], Nazwisko, ulica, kod, miasto, telefon, fax, waluta_brutto, waluta_miano, SystemKsiegowyId FROM dbo.vDanePlatnosciEcard WHERE nip=@nip AND [Faktura Numer]=@nrFaktury";
115            string nip = (string)Session["nip"];
116            string nrZlec = (string)Session["nrFaktury"];
117            using (SqlConnection conn = new SqlConnection(connString))
118            {
119                SqlCommand cmd = new SqlCommand(cmdText, conn);
120                cmd.Parameters.Add("@nip", SqlDbType.NVarChar, 50).Value = nip;
121                cmd.Parameters.Add("@nrFaktury", SqlDbType.NVarChar, 20).Value = nrZlec;
122
123                conn.Open();
124                SqlDataReader reader = cmd.ExecuteReader();
125                reader.Read();
126
127                // formaPlatnosci i waluta               
128                string formaPlatnosci = wartoscNaString(reader, 13, "string");
129                string walBrutto = wartoscNaString(reader, 22, "double");
130                string walMiano = wartoscNaString(reader, 23, "string");
131                string systemKsiegowy = reader.GetByte(24).ToString();
132                if (walMiano != "" && walBrutto != "")
133                {
134                    WyborWaluty.Enabled = true;
135                    ArrayList values = new ArrayList();
136                    values.Add("PLN");
137                    values.Add(walMiano);
138                    WyborWaluty.DataSource = values;
139                    WyborWaluty.DataBind();                                       
140                }
141                formaPlatnosci = "karta";
142                // Czy faktura jest zapłacona?
143                /*string formaPlatnosci = "";
144                try
145                {
146                    if (!reader[13].Equals(System.DBNull.Value)) { formaPlatnosci = (string)reader[13]; };
147                }
148                catch (System.NullReferenceException err)
149                {
150                    formaPlatnosci = "Error: " + err.ToString();
151                }*/
152                if (formaPlatnosci == "karta")
153                {
154                    FormaPlatnosci = "karta";
155
156                    string firstName = wartoscNaString(reader, 1, "string");
157                    string lastName = wartoscNaString(reader, 2, "string");
158                    string adres = wartoscNaString(reader, 3, "string");
159                    string kod = wartoscNaString(reader, 4, "string");
160                    string miasto = wartoscNaString(reader, 5, "string");
161                    string tNIP = wartoscNaString(reader, 9, "string");
162                    string tNrFaktury = wartoscNaString(reader, 8, "string");
163                    Session["NrFaktury"] = tNrFaktury;
164                    string tDataWystawienia = wartoscNaString(reader, 11, "DateTime");
165                    string tTerminPlatnosci = wartoscNaString(reader, 12, "DateTime");
166                    string tBrutto = wartoscNaString(reader, 10, "double");
167                    // Amount
168                    string AmountPLN = przeliczNaGrosze(reader, 10);
169                    string AmountWaluta = przeliczNaGrosze(reader, 22);
170                    // tIDFaktury
171                    string tIDFaktury = "";
172                    int iIDFaktury;
173                    try
174                    {
175                        if (!reader[14].Equals(System.DBNull.Value))
176                        {
177                            iIDFaktury = (int)reader[14];
178                            tIDFaktury = iIDFaktury.ToString();
179                        }
180
181                    }
182                    catch (System.NullReferenceException err)
183                    {
184                        tIDFaktury = "Error: " + err.ToString();
185                    }
186
187                    string ImieHandlowca = wartoscNaString(reader, 15, "string");
188                    string NazwiskoHandlowca = wartoscNaString(reader, 16, "string");
189                    string AdresBiuraUlica = wartoscNaString(reader, 17, "string");
190                    string AdresBiuraKod = wartoscNaString(reader, 18, "string");
191                    string AdresBiuraMiasto = wartoscNaString(reader, 19, "string");
192                    string AdresBiuraTelefony = wartoscNaString(reader, 20, "string");
193                    string WalutaBrutto = wartoscNaString(reader, 22, "double");
194                    string WalutaMiano = wartoscNaString(reader, 23, "string");
195
196                    // ------------- Ustawienie zmiennych -----------------------
197                    kwotaPLN = tBrutto;
198                    kwotaWaluta = WalutaBrutto;
199                    kwotaGroszePLN = AmountPLN;
200                    kwotaGroszeWaluta = AmountWaluta;
201                    // ------------ Dane do wyświetlenia ------------------------
202
203                    // --------- Nazwa
204                    string nazwa = "";
205                    if (firstName == "")
206                    {
207                        nazwa = lastName;
208                    }
209                    else
210                    {
211                        nazwa = firstName + " " + lastName;
212                    }
213
214                    Nazwa.Text = nazwa;
215                    // --------- Adres
216                    Adres.Text = adres + ", " + kod + " " + miasto;
217                    // --------- NIP
218                    NIP.Text = tNIP;
219                    // -------- NrFaktury
220                    NrFaktury.Text = tNrFaktury;
221                    // --------- DataWystawienia
222                    DataWystawienia.Text = tDataWystawienia;
223                    // --------- TerminPlatnosci
224                    TerminPlatnosci.Text = tTerminPlatnosci;
225
226                    //------------- Informacje do kontaktu z handlowcem
227                    Handlowiec.Text = ImieHandlowca + " " + NazwiskoHandlowca;
228                    BiuroAdres.Text = AdresBiuraUlica + ", " + AdresBiuraKod + " " + AdresBiuraMiasto;
229                    BiuroTelefon.Text = AdresBiuraTelefony;
230
231                    // ---------------------- Dane przekazywane do sesji ------------
232
233                    // -------------- ORDERDESCRIPTION
234                    string ORDERDESCRIPTION = (string)Session["nrFaktury"];
235                    Session["ORDERDESCRIPTION"] = ORDERDESCRIPTION;
236                    // ---------------- ORDERNUMBER
237                    string ORDERNUMBER = "1";
238                    Session["ORDERNUMBER"] = ORDERNUMBER;
239                    // ----------------- SESSIONID
240                    string SESSIONID = Session.SessionID;
241                    Session["SESSIONID"] = SESSIONID;
242                    // ------------- LANGUAGE PL - polski, EN - angielski, DE - niemiecki, FR - francuski, RU - rosyjski
243                    string LANGUAGE = "PL";
244
245                    Session["SystemKsiegowy"] = systemKsiegowy;
246
247                    if ((string)Session["CURRENCY"] == "978")
248                    {
249                        Session["CURRENCY"] = "978";
250                        Session["AMOUNT"] = kwotaGroszeWaluta;
251                        Brutto.Text = kwotaWaluta + " €";
252                        WyborWaluty.SelectedValue = "EUR";
253                    }
254                    else if ((string)Session["CURRENCY"] == "985")
255                    {
256                        Session["CURRENCY"] = "985";
257                        Session["AMOUNT"] = kwotaGroszePLN;
258                        Brutto.Text = kwotaPLN + " zł";
259                        WyborWaluty.SelectedValue = "PLN";
260                    }
261                    //else if ((string)Session["CURRENCY"] == "826")
262                    //{
263                    //    Session["CURRENCY"] = "826";
264                    //    Session["AMOUNT"] = kwotaGroszeWaluta;
265                    //    Brutto.Text = kwotaWaluta + " £";
266                    //    WyborWaluty.SelectedValue = "GBP";
267                    //}
268                    else
269                    {
270                        Session["CURRENCY"] = "985";
271                        Session["AMOUNT"] = kwotaGroszePLN;
272                        Brutto.Text = kwotaPLN + " zł";
273                        WyborWaluty.SelectedValue = "PLN";
274                    }
275                    if (Thread.CurrentThread.CurrentCulture.Name == "pl-PL")
276                    {
277                        Session["culture"] = "pl-PL";
278                        LANGUAGE = "PL";
279                    }
280                    else if (Thread.CurrentThread.CurrentCulture.Name == "en-US")
281                    {
282                        Session["culture"] = "en-US";
283                        LANGUAGE = "EN";                       
284                    }
285                    else if (Thread.CurrentThread.CurrentCulture.Name == "fr-FR")
286                    {
287                        Session["culture"] = "fr-FR";
288                        LANGUAGE = "FR";
289                    }
290                    else if (Thread.CurrentThread.CurrentCulture.Name == "it-IT")
291                    {
292                        Session["culture"] = "it-IT";
293                        LANGUAGE = "IT";
294                    }
295                    else if (Thread.CurrentThread.CurrentCulture.Name == "de-DE")
296                    {
297                        Session["culture"] = "de-DE";
298                        LANGUAGE = "DE";
299                    }
300                    else
301                    {
302                        Session["culture"] = "en-US";
303                        LANGUAGE = "EN";
304                    }
305                    Session["LANGUAGE"] = LANGUAGE;
306                    // ----------------- CHARSET
307                    string CHARSET = "ISO-8859-2";
308                    Session["CHARSET"] = CHARSET;
309                    // ---------------- COUNTRY 616 - Polska
310                    string COUNTRY = "616";
311                    Session["COUNTRY"] = COUNTRY;
312                    // ---------------- PAYMENTTYPE
313                    string PAYMENTTYPE = "CARDS";
314                    Session["PAYMENTTYPE"] = PAYMENTTYPE;
315                    // --------------- MERCHANTID
316                    Session["MERCHANTID"] = Int32.Parse(systemKsiegowy) == 1 ? "170906000" : "171485000";
317                    // ---------------- AUTODEPOSIT
318                    Session["AUTODEPOSIT"] = "1";
319                    // ---------------- IDFAKTURY
320                    Session["IDFaktury"] = tIDFaktury;
321                }
322
323                else
324                {
325                    FormaPlatnosci = "";
326                }
327                reader.Close();
328                conn.Close();
329
330            }
331        }
332        else
333        {
334            string connString = ConfigurationManager.ConnectionStrings["BazaReklamConn"].ConnectionString;
335            string cmdText = "SELECT [ID Reklamy], FirstName, LastName, Address, PostalCode, City, State, Country, [Faktura Numer], Nabywca_nip, Brutto, [Faktura Data Wystawienia], Termin_zaplaty, Sposob_zaplaty, ID_faktury, [Imię], Nazwisko, ulica, kod, miasto, telefon, fax, waluta_brutto, waluta_miano, SystemKsiegowyId FROM dbo.vDanePlatnosciEcard WHERE nip=@nip AND [Faktura Numer]=@nrFaktury";
336            string nip = (string)Session["nip"];
337            string nrZlec = (string)Session["nrFaktury"];
338            using (SqlConnection conn = new SqlConnection(connString))
339            {
340                SqlCommand cmd = new SqlCommand(cmdText, conn);
341                cmd.Parameters.Add("@nip", SqlDbType.NVarChar, 50).Value = nip;
342                cmd.Parameters.Add("@nrFaktury", SqlDbType.NVarChar, 20).Value = nrZlec;
343
344                conn.Open();
345                SqlDataReader reader = cmd.ExecuteReader();
346                reader.Read();
347
348                // Wartości         
349                string tBrutto = wartoscNaString(reader, 10, "double");
350                string WalutaBrutto = wartoscNaString(reader, 22, "double");
351                string AmountPLN = przeliczNaGrosze(reader, 10);
352                string AmountWaluta = przeliczNaGrosze(reader, 22);
353
354                // ------------- Ustawienie zmiennych -----------------------
355                kwotaPLN = tBrutto;
356                kwotaWaluta = WalutaBrutto;
357                kwotaGroszePLN = AmountPLN;
358                kwotaGroszeWaluta = AmountWaluta;               
359
360                reader.Close();
361                conn.Close();               
362            }
363        }
364       
365    }
366
367    protected void WyborWaluty_SelectedIndexChanged(object sender, EventArgs e)
368    {
369        string waluta = WyborWaluty.SelectedItem.Value;
370        string kwota = "";       
371        if (waluta == "PLN")
372        {
373            kwota = kwotaPLN + " zł";
374            Session["CURRENCY"] = "985";
375            Session["AMOUNT"] = kwotaGroszePLN;           
376        }
377        if (waluta == "EUR")
378        {
379            kwota = kwotaWaluta + " €";
380            Session["CURRENCY"] = "978";
381            Session["AMOUNT"] = kwotaGroszeWaluta;           
382        }
383        //if (waluta == "GBP")
384        //{
385        //    kwota = kwotaWaluta + " £";
386        //    Session["CURRENCY"] = "826";
387        //    Session["AMOUNT"] = kwotaGroszeWaluta;           
388        //}
389        Session["kwotaBrutto"] = kwota;
390        Brutto.Text = kwota;         
391    }
392
393    protected void PlaceButton_Click(object sender, EventArgs e)
394    {
395        // ------------------ NAME
396        string NAME = ImieTextBox.Text;
397        Session["NAME"] = NAME;
398        // ------------------ SURNAME
399        string SURNAME = NazwiskoTextBox.Text;
400        Session["SURNAME"] = SURNAME;
401        // -------------- Przekierowanie
402        Response.Redirect("Merchant.aspx");
403    }
404
405    protected void ZamknijButton_Click(object sender, EventArgs e)
406    {
407        FormsAuthentication.SignOut();
408        Server.Transfer("login.aspx");
409    }
410
411    private string forma;
412    public string FormaPlatnosci
413    {
414        get
415        {
416            return forma;
417        }
418        set
419        {
420            forma = value;
421            if (forma == "karta")
422            {
423                forma = "karta";
424            }
425            else
426            {
427                forma = "";
428            }           
429        }
430    }
431
432    private bool czyWyswietlicWyborWaluty;
433    public bool WyswietlicWyborWaluty
434    {
435        get
436        {
437            return czyWyswietlicWyborWaluty;
438        }
439        set
440        {
441            czyWyswietlicWyborWaluty = value;           
442        }
443    }   
444   
445    private string kwotaPLN;
446    public string kwotaBruttoPLN
447    {
448        get
449        {
450            return kwotaPLN;
451        }
452        set
453        {
454            kwotaPLN = value;
455            if (kwotaPLN == "") { kwotaPLN = "0"; }
456        }
457    }
458
459    private string kwotaWaluta;
460    public string kwotaBruttoWaluta
461    {
462        get
463        {
464            return kwotaWaluta;
465        }
466        set
467        {
468            kwotaWaluta = value;
469            if (kwotaWaluta == "") { kwotaWaluta = "0"; }
470        }
471    }
472
473    private string amPLN;
474    public string kwotaGroszePLN
475    {
476        get
477        {
478            return amPLN;
479        }
480        set
481        {
482            amPLN = value;
483            if (amPLN == "") { kwotaGroszePLN = "0"; }
484        }
485    }
486
487    private string amWaluta;
488    public string kwotaGroszeWaluta
489    {
490        get
491        {
492            return amWaluta;
493        }
494        set
495        {
496            amWaluta = value;
497            if (amWaluta == "") { kwotaGroszeWaluta = "0"; }
498        }
499    }
500
501   
502}
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.