Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox3.Text != textBox4.Text)
            {
                MessageBox.Show("Confirmare parola esuata!");
                return;
            }

            UserModel utilizatorNou = new UserModel
            {
                TipUtilizator = radioButton1.Checked == true ? 1 : 0,
                NumePenume    = textBox1.Text,
                Email         = textBox2.Text,
                Parola        = CriptareParola.Criptare(textBox3.Text)
            };

            SqlDataAcces.InregistreazaUtilizator(utilizatorNou);

            utilizatorNou.ID = SqlDataAcces.GetUserIDByEmail(utilizatorNou.Email);

            if (pictureBox2.Image != null)
            {
                string filePath = "Resurse\\Imagini\\utilizatori\\" + utilizatorNou.ID.ToString() + ".jpeg";
                Bitmap imagine  = new Bitmap(pictureBox2.Image);

                imagine.Save(filePath, ImageFormat.Jpeg);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string email  = textBox1.Text;
            string parola = CriptareParola.Criptare(textBox2.Text);

            if (String.IsNullOrWhiteSpace(email) || String.IsNullOrWhiteSpace(parola))
            {
                MessageBox.Show("Introduceti datele.");
                return;
            }

            UserModel utilizator = SqlDataAcces.Autentificare(email, parola);

            if (utilizator.Parola == parola)
            {
                var page = Singleton <BibliotecarBiblioteca> .Instance;

                page.Utilizator = utilizator;
                page.Show();

                this.Hide();
            }
            else
            {
                MessageBox.Show("Email sau parola gresita!");
            }
        }
Пример #3
0
        private static void InitiateTable(string tableName)
        {
            TruncateTable(tableName);

            string filePath = "Resurse//" + tableName + ".txt";

            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                con.Open();

                using (StreamReader reader = new StreamReader(filePath))
                {
                    while (reader.Peek() >= 0)
                    {
                        List <string> line = reader.ReadLine().Split(';').ToList();

                        string cmdText = "Insert into " + tableName + " values ( ";

                        List <string> tokens = new List <string>();
                        for (int i = 0; i < line.Count; i++)
                        {
                            string value = line[i];

                            int      x;
                            DateTime date;

                            if (Int32.TryParse(value, out x) || value.ToLower() == "null")
                            {
                                tokens.Add(value);
                            }
                            else if (DateTime.TryParseExact(value, "MM/dd/yyyy hh/mm/ss tt", CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
                            {
                                tokens.Add(String.Format("Convert( datetime, '{0}')", date));
                            }
                            else if (tableName == "utilizatori" && i == 3)
                            {
                                tokens.Add(String.Format("'{0}'", CriptareParola.Criptare(value)));
                            }
                            else
                            {
                                tokens.Add(String.Format("'{0}'", value));
                            }
                        }
                        cmdText += string.Join(" , ", tokens) + ");";

                        using (SqlCommand cmd = new SqlCommand(cmdText, con))
                        {
                            cmd.ExecuteNonQuery();
                        }
                    }
                }
            }
        }