コード例 #1
0
ファイル: SignIn.cs プロジェクト: craducanu96/Baze
        private void btNext_Click(object sender, EventArgs e)
        {
            try
            {
                if (username != null && IfExistsUsername(username) == true)
                {
                    throw new Exception("Username already exist!");
                }

                else if (pass != null && Conditions(pass) == false)
                {
                    throw new Exception("Parola nu coresounde conditiilor!");
                }

                else if (pass != null && checkpass != null && pass.Equals(checkpass) == false)
                {
                    throw new Exception("Password dosen't match!");
                }

                else if (email != null && ValidEmailAddress(email) == false)
                {
                    throw new Exception("E-mail address must be valid e-mail address format!");
                }

                else if (IfExistsEmail(email) == true)
                {
                    throw new Exception("Email already exist!");
                }

                else if (IsPhoneNumber(phone) == false)

                {
                    throw new Exception("Number incorect!");
                }

                else if (firstname != null && lastname != null &&
                         username != null && phone != null &&
                         email != null && status != null &&
                         pass != null && checkpass != null &&
                         date != null && universiy != null &&
                         adress != null && sex != null &&
                         nationality != null && Skills.get_skill() != null)
                {
                    throw new Exception("Register successfully!");
                    this.Close();
                    CClient.inregistreaza_client(firstname, lastname, username, pass, phone, email, date, universiy, adress, sex_id, status_id, nationality, result);
                    Form form = new CClient(firstname, lastname, username, phone, email, date, universiy, adress, sex, status, nationality, Skills.get_skill(), pbProfile.Image);
                    form.Show();
                }
                else
                {
                    throw new Exception("Some empty filled!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
ファイル: CClient.cs プロジェクト: craducanu96/Baze
        public static void inregistreaza_client(string firstname, string lastname, string username, string pass, string phone, string email, string date, string university, string address, int sex_id, int status_id, string nationality, Byte[] result)
        {
            string      format   = "dd/MM/yyyy";
            CultureInfo provider = CultureInfo.InvariantCulture;

            DateTime myDate = DateTime.ParseExact(date, format, provider);

            string hash     = SecurePasswordHasher.Hash(pass);
            var    verifica = SecurePasswordHasher.Verify(pass, hash);

            char[] delimiters = { ',' };
            string skills     = Skills.get_skill();

            string[] words = skills.Split(delimiters);


            var newClient = new Client()
            {
                Nume                = firstname,
                Prenume             = lastname,
                Data_Nasterii       = myDate,
                Email               = email,
                Poza                = result,
                Facultate_absolvita = university,
                ID_sex              = sex_id,
                ID_statut_social    = status_id,
                Adresa              = address,
                Telefon             = phone,
                Nationalitate       = nationality,
                Limbi_straine       = "engleza",
                Username            = username,
                Parola              = hash
            };

            foreach (string s in words)
            {
                Aptitudini apt = new Aptitudini {
                    Aptitudine = s
                };
                newClient.Aptitudini.Add(apt);
            }

            using (var context = new LinkedinEntities5())
            {
                context.Client.Add(newClient);
                context.SaveChanges();
            }
        }