Beispiel #1
0
        private void Button_AddOk_Click(object sender, EventArgs e)
        {
            try
            {
                var context = new Asociatie_ProprietariEntities();

                var newCategory = new Membri_Asociatie()
                {
                    //Nume = _nume,
                    Prenume        = _prenume,
                    Numar_telefon  = _numar_telefon,
                    Emai           = _email,
                    Functie        = _functie,
                    Data_Inscriere = DateTime.Parse(_data_inscriere)
                };

                context.Membri_Asociatie.Add(newCategory);

                context.SaveChanges();
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Eroare de contectare la server");
            }
        }
Beispiel #2
0
        private void informatii_personale_next_Click(object sender, EventArgs e)
        {
            int canProcessNextStep = 1;

            warning_label.Text = "";

            //verific daca exista text in casete
            if (Nume_textBox.Text.Length == 0)
            {
                nume_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                if (char.IsUpper(Nume_textBox.Text.ToString().First()) != true)
                {
                    canProcessNextStep = 0;
                    warning_label.Text = "Numele pot incepe doar cu litera mare!";
                }
                if (Nume_textBox.Text.All(Char.IsLetter) != true)
                {
                    canProcessNextStep = 0;
                    warning_label.Text = "Numele pot contine doar litere!";
                }
                nume_error_label.Hide();
            }

            if (prenume_textBox.Text.Length == 0)
            {
                prenume_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                if (char.IsUpper(prenume_textBox.Text.ToString().First()) != true)
                {
                    canProcessNextStep = 0;
                    warning_label.Text = "Prenumele pot incepe doar cu litera mare!";
                }
                if (prenume_textBox.Text.All(Char.IsLetter) != true)
                {
                    canProcessNextStep = 0;
                    warning_label.Text = "Prenumele pot contine doar litere!";
                }
                prenume_error_label.Hide();
            }

            if (numar_telefon_textBox.Text.Length == 0)
            {
                numar_telefon_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                if (Regex.Match(numar_telefon_textBox.Text, @"^0[1-9][0-9]{8}$").Success != true)
                {
                    warning_label.Text = "Format numar telefon invalid!";
                    canProcessNextStep = 0;
                }
                numar_telefon_error_label.Hide();
            }

            if (email_text_box.Text.Length == 0)
            {
                email_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                if (Regex.Match(email_text_box.Text, @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|" +
                                @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)" +
                                @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$").Success != true)
                {
                    warning_label.Text = "Format e-mail invalid!";
                    canProcessNextStep = 0;
                }
                email_error_label.Hide();
            }

            if (canProcessNextStep == 1)
            {
                var context = new Asociatie_ProprietariEntities();

                var membruAsociatieNou = new Membri_Asociatie()                  //salvam datele personale ale utilizatorului
                {
                    Nume           = Nume_textBox.Text,
                    Prenume        = prenume_textBox.Text,
                    Numar_telefon  = numar_telefon_textBox.Text,
                    Emai           = email_text_box.Text,
                    Functie        = "Membru",
                    Data_Inscriere = DateTime.Today
                };

                datePersonale = membruAsociatieNou;
                personalDataPanel.Hide();
                panel_inregistrare_apartamente.Show();
                panel_date_apartament.Hide();
            }
        }