| 1 | using System;
|
|---|
| 2 | using System.Data;
|
|---|
| 3 | using System.Configuration;
|
|---|
| 4 | using System.Collections;
|
|---|
| 5 | using System.Web;
|
|---|
| 6 | using System.Web.Security;
|
|---|
| 7 | using System.Web.UI;
|
|---|
| 8 | using System.Web.UI.WebControls;
|
|---|
| 9 | using System.Web.UI.WebControls.WebParts;
|
|---|
| 10 | using System.Web.UI.HtmlControls;
|
|---|
| 11 | using System.Data.SqlClient;
|
|---|
| 12 | using System.Threading;
|
|---|
| 13 | using System.Globalization;
|
|---|
| 14 | using System.Resources;
|
|---|
| 15 |
|
|---|
| 16 | public partial class login : System.Web.UI.Page
|
|---|
| 17 | {
|
|---|
| 18 | protected override void InitializeCulture()
|
|---|
| 19 | {
|
|---|
| 20 | if (Session["culture"] != null)
|
|---|
| 21 | {
|
|---|
| 22 | UICulture = Session["culture"].ToString();
|
|---|
| 23 | Culture = Session["culture"].ToString();
|
|---|
| 24 |
|
|---|
| 25 | Thread.CurrentThread.CurrentCulture =
|
|---|
| 26 | CultureInfo.CreateSpecificCulture(Session["culture"].ToString());
|
|---|
| 27 | Thread.CurrentThread.CurrentUICulture =
|
|---|
| 28 | new CultureInfo(Session["culture"].ToString());
|
|---|
| 29 | }
|
|---|
| 30 | base.InitializeCulture();
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | protected void Page_Load(object sender, EventArgs e)
|
|---|
| 34 | {
|
|---|
| 35 | //throw new ApplicationException("TEST");
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | FakturaImageButton.ImageUrl = Resources.Common.Faktura;
|
|---|
| 39 | if (!IsPostBack) { SetFocus(NIPTextBox); }
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | protected void ZalogujButton_Click(object sender, EventArgs e)
|
|---|
| 43 | {
|
|---|
| 44 | string nip = NIPTextBox.Text;
|
|---|
| 45 | string nrZlec = NrZlecTextBox.Text;
|
|---|
| 46 | bool czyZalogowany = Zaloguj(nip, nrZlec);
|
|---|
| 47 | if (czyZalogowany)
|
|---|
| 48 | {
|
|---|
| 49 | FormsAuthentication.RedirectFromLoginPage(nip, false);
|
|---|
| 50 | }
|
|---|
| 51 | else
|
|---|
| 52 | {
|
|---|
| 53 | errorMsg.Text = GetLocalResourceObject("errorMsg").ToString();
|
|---|
| 54 | }
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | bool Zaloguj(string nip, string nrFaktury)
|
|---|
| 58 | {
|
|---|
| 59 | string connString = ConfigurationManager.ConnectionStrings["BazaReklamConn"].ConnectionString;
|
|---|
| 60 | string cmdText = "SELECT COUNT(*) FROM dbo.vDanePlatnosciEcard WHERE nip=@nip AND [Faktura Numer]=@nrFaktury";
|
|---|
| 61 | nip = nip.Replace(" ", "");
|
|---|
| 62 | nip = nip.Replace("-", "");
|
|---|
| 63 | int znalezione = 0;
|
|---|
| 64 | using(SqlConnection conn = new SqlConnection(connString))
|
|---|
| 65 | {
|
|---|
| 66 | SqlCommand cmd = new SqlCommand(cmdText, conn);
|
|---|
| 67 | cmd.Parameters.Add("@nip", SqlDbType.NVarChar, 50).Value = nip;
|
|---|
| 68 | cmd.Parameters.Add("@nrFaktury", SqlDbType.NVarChar, 20).Value = nrFaktury;
|
|---|
| 69 | conn.Open();
|
|---|
| 70 | znalezione = (int)cmd.ExecuteScalar();
|
|---|
| 71 | if (znalezione > 0)
|
|---|
| 72 | {
|
|---|
| 73 | Session["nip"] = nip;
|
|---|
| 74 | Session["nrFaktury"] = nrFaktury;
|
|---|
| 75 | }
|
|---|
| 76 | conn.Close();
|
|---|
| 77 | }
|
|---|
| 78 | return (znalezione > 0);
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | }
|
|---|