Zbiór zmian 486 dla trunk/eCard/Expo/login.aspx.cs
- Data:
- 2009-03-25 17:31:18 (17 years ago)
- Pliki:
-
- 1 zmodyfikowane
-
trunk/eCard/Expo/login.aspx.cs (zmodyfikowane) (3 diffs)
Legenda:
- Bez zmian
- Dodane
- Usunięte
-
trunk/eCard/Expo/login.aspx.cs
r477 r486 2 2 using System.Data; 3 3 using System.Configuration; 4 using System.Collections;5 using System.Web;6 4 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 5 using System.Data.SqlClient; 12 6 using System.Threading; 13 7 using System.Globalization; 14 using System.Resources;15 8 16 9 public partial class login : System.Web.UI.Page … … 37 30 38 31 FakturaImageButton.ImageUrl = Resources.Common.Faktura; 39 if (!IsPostBack) { SetFocus(NIPTextBox); } 32 if (!IsPostBack) { SetFocus(NIPTextBox); } 40 33 } 41 34 42 35 protected void ZalogujButton_Click(object sender, EventArgs e) 43 36 { 44 string nip = NIPTextBox.Text ;45 string nrZlec = NrZlecTextBox.Text ;37 string nip = NIPTextBox.Text.Replace(" ", string.Empty).Replace("-", string.Empty); 38 string nrZlec = NrZlecTextBox.Text.Replace(" ", string.Empty); 46 39 bool czyZalogowany = Zaloguj(nip, nrZlec); 47 40 if (czyZalogowany) 48 41 { 49 FormsAuthentication.RedirectFromLoginPage(nip, false); 42 FormsAuthentication.RedirectFromLoginPage(nip, false); 50 43 } 51 44 else … … 57 50 bool Zaloguj(string nip, string nrFaktury) 58 51 { 52 string fakturaNr = nrFaktury.Split('/')[0]; 53 string fakturaRoz = nrFaktury.Split('/')[1]; 54 string fakturaRok = nrFaktury.Split('/')[2]; 55 59 56 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)) 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)) 65 60 { 66 61 SqlCommand cmd = new SqlCommand(cmdText, conn); 67 62 cmd.Parameters.Add("@nip", SqlDbType.NVarChar, 50).Value = nip; 68 cmd.Parameters.Add("@nrFaktury", SqlDbType.NVarChar, 20).Value = nrFaktury; 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; 69 66 conn.Open(); 70 znalezione = (int)cmd.ExecuteScalar(); 71 if (znalezione > 0) 67 68 SqlDataReader reader = cmd.ExecuteReader(); 69 if (reader == null) 72 70 { 73 Session["nip"] = nip;74 Session["nrFaktury"] = nrFaktury;71 conn.Close(); 72 return false; 75 73 } 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(); 76 84 conn.Close(); 77 85 } 78 return (znalezione > 0);86 return znalezione; 79 87 } 80 81 88 }
