public bool CreateList() { ReadAndUpdateData r = new ReadAndUpdateData(); CurrencyList.Clear(); if (CheckForInternetConnection()) { XmlReader xmlReader = XmlReader.Create("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml"); int i = 2; bool check = false; AddToCurrencyList("EUR", "1.00", 1); //CurrencyList.Last().GetCurrencyId() + 1); while (xmlReader.Read()) { if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "Cube")) { if (xmlReader.HasAttributes) { if (check == false) { check = true; } else { Currency cur = new Currency(); // cur.SetCurrencyId(i); cur.SetCurrencyName(xmlReader.GetAttribute("currency")); cur.SetCurrencyRate(xmlReader.GetAttribute("rate")); CurrencyList.Add(cur); i++; } } } } r.UpdateCurrencyList(CurrencyList); return(true); } else { CurrencyList = r.ReadCurrencyList(); return(false); } }
/* private int GetUserId() * { * UserData user = new UserData(); * * SqlConnection con = new SqlConnection(@"Data Source = (local)\SQLEXPRESS; Initial Catalog = SysWal; Integrated Security = True"); * // string command = "select * from UserData where UserId =" + id; * string command = "SELECT @@IDENTITY"; * SqlCommand myCommand = new SqlCommand(command, con); * * con.Open(); * SqlDataReader myReader = myCommand.ExecuteReader(); * * * return id; * } */ private void AddNewUser(ref bool check) { HashPassword hsp = new HashPassword(); ReadAndUpdateData r = new ReadAndUpdateData(); UserData userData = new UserData(); string salt = hsp.CreateSalt(10); user = CreateUser(ref check, salt); if (check == true) { con = new SqlConnection(@"Data Source=(local)\SQLEXPRESS;Initial Catalog=SysWal;Integrated Security=True"); con.Open(); cmd = new SqlCommand("INSERT INTO UserData (login, password, name, surname, PESEL, accountNo, email, salt) values (@login, @password, @name, @surname, @PESEL, @accountNo, @email, @salt)", con); cmd.Parameters.AddWithValue("@login", user.GetLogin()); cmd.Parameters.AddWithValue("@password", hsp.HashUserPassword(user.GetPassword(), salt)); cmd.Parameters.AddWithValue("@name", user.GetName()); cmd.Parameters.AddWithValue("@surname", user.GetSurname()); cmd.Parameters.AddWithValue("@PESEL", user.GetPESEL()); cmd.Parameters.AddWithValue("@accountNo", user.GetAccountNo()); cmd.Parameters.AddWithValue("@email", user.GetEmail()); cmd.Parameters.AddWithValue("@salt", user.GetSalt()); cmd.ExecuteNonQuery(); string command = "SELECT MAX(UserID)FROM UserData"; SqlCommand myCommand = new SqlCommand(command, con); int id = (int)myCommand.ExecuteScalar(); SendMail sm = new SendMail(); MessageBox.Show(sm.MailSend(user.GetEmail(), user.GetName())); r.CreateWallet(id); MessageBox.Show("Rejestracja zakończona pomyslnie!"); } else { MessageBox.Show("Niepoprawne Dane!"); } }
private void SignIn_Click(object sender, EventArgs e) /* Goes to Menu2 form */ { /* HashPassword hsp = new HashPassword(); * string salt = hsp.CreateSalt(10); * loginText.Text = hsp.ComparePassword(loginText.Text, salt); * passwordText.Text = hsp.ComparePassword(loginText.Text, salt);*/ if (xml.CheckForInternetConnection()) { string login; string password; int id = 0; ReadAndUpdateData r = new ReadAndUpdateData(); login = loginText.Text; password = passwordText.Text; r.ReadLoginAndPassword(); if (r.LogInProcess(ref id, login, password)) { Hide(); Menu2 menu = new Menu2(id); menu.ShowDialog(); Close(); menu = null; } else { MessageBox.Show("Niepoprawne dane!"); } } else { MessageBox.Show("Brak połączenia Internetowego!"); } }