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