Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        private void btLogIn_Click(object sender, EventArgs e)
        {
            try
            {
                if (password == null || username == null)
                {
                    if (password == null && username != null)
                    {
                        throw new Exception("Please write the password");
                    }
                    else if (username == null && password != null)
                    {
                        throw new Exception("Please write the username");
                    }
                    else
                    {
                        throw new Exception("Please write the username and the password");
                    }
                }
                else if (username != null && password != null)
                {
                    username = txtUsername.Text.ToString();
                    password = txtPassoword.Text.ToString();

                    if (IfCompany(username, password) == true)
                    {
                        var context = new LinkedinEntities5();
                        var results = from c in context.Companie
                                      where c.UsernameC.Equals(username)
                                      select new
                        {
                            c.ID_Companie,
                            c.Director_companie,
                            c.Adresa_companie,
                            c.Email_companie,
                            c.Telefon_companie
                        };

                        foreach (var item in results)
                        {
                            string director    = item.Director_companie;
                            string adresa      = item.Adresa_companie;
                            string email       = item.Email_companie;
                            string telefon     = item.Telefon_companie;
                            int    id_companie = item.ID_Companie;

                            Form form = new CCompanie(director, username, adresa, email, telefon, skillsC(id_companie));
                            form.Show();
                        }
                    }
                    else if (IfClient(username, password) == true)
                    {
                        var context = new LinkedinEntities5();
                        var results = from c in context.Client
                                      where c.Username.Equals(username)
                                      select new
                        {
                            c.ID_Client,
                            c.Nume,
                            c.Prenume,
                            c.Data_Nasterii,
                            c.Email,
                            c.Poza,
                            c.Facultate_absolvita,
                            c.ID_sex,
                            c.ID_statut_social,
                            c.Adresa,
                            c.Telefon,
                            c.Nationalitate,
                            c.Limbi_straine
                        };

                        foreach (var item in results)
                        {
                            string nume          = item.Nume;
                            string prenume       = item.Prenume;
                            string email         = item.Email;
                            string facultate     = item.Facultate_absolvita;
                            string adresa        = item.Adresa;
                            string telefon       = item.Telefon;
                            string nationalitate = item.Nationalitate;
                            string limbi_straine = item.Limbi_straine;
                            string data          = Convert.ToString(item.Data_Nasterii);
                            int    id_client     = item.ID_Client;
                            string sex;
                            string statut = null;
                            if (item.ID_sex.Equals(1))
                            {
                                sex = "Male";
                            }
                            else
                            {
                                sex = "Female";
                            }

                            if (item.ID_statut_social.Equals(1))
                            {
                                statut = "Single";
                            }
                            else if (item.ID_statut_social.Equals(2))
                            {
                                statut = "In a relationship";
                            }
                            else if (item.ID_statut_social.Equals(3))
                            {
                                statut = "It's complicated";
                            }
                            else if (item.ID_statut_social.Equals(4))
                            {
                                statut = "Widow";
                            }
                            else if (item.ID_statut_social.Equals(5))
                            {
                                statut = "Divorced";
                            }
                            else if (item.ID_statut_social.Equals(6))
                            {
                                statut = "Marriage";
                            }
                            Image result = ConvertByteToImage(item.Poza);

                            Form form = new CClient(nume, prenume, username, telefon, email, data, facultate, adresa, sex, statut, nationalitate, skills(id_client), result);
                            form.Show();
                        }
                    }
                    else
                    {
                        throw new Exception("Username or password invalid");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }