Example #1
0
        public static bool IfClient(string user, string pass)
        {
            int ok      = 0;
            var context = new LinkedinEntities5();
            var results = from c in context.Client
                          select new
            {
                c.Username,
                c.Parola,
                c.Email
            };

            foreach (var item in results)
            {
                if (item.Username.Equals(user) || item.Email.Equals(user))
                {
                    if (CClient.SecurePasswordHasher.Verify(pass, item.Parola))
                    {
                        ok = 1;
                    }
                }
            }

            if (ok == 1)
            {
                return(true);
            }
            return(false);
        }
Example #2
0
        public static void inregistreaza_companie(string director, string nume, string adresa, string email, string telefon, string parola)
        {
            string hash = SecurePasswordHasher.Hash(parola);

            char[] delimiters = { ',' };
            string skills     = SignInCompany.get_skillsC();

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

            var contextC    = new LinkedinEntities5();
            var newCompanie = new Companie()
            {
                Nume_companie     = nume,
                Adresa_companie   = adresa,
                Email_companie    = email,
                Telefon_companie  = telefon,
                UsernameC         = nume,
                ParolaC           = hash,
                Director_companie = director
            };

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

            using (var context = new LinkedinEntities5())
            {
                context.Companie.Add(newCompanie);
                context.SaveChanges();
            }
        }
Example #3
0
        public CCompanie(string director, string nume, string adresa, string email, string telefon, string SkillsC)
        {
            InitializeComponent();
            picMessaging.Image = Image.FromFile("letter.png");

            panelDetails.Visible = false;

            lbCompanyName.Text = nume;
            txtCEO.Text        = director;
            txtAddress.Text    = adresa;
            txtEmail.Text      = email;
            txtPhone.Text      = telefon;


            string[] words = SkillsC.Split(',');
            foreach (string s in words)
            {
                txtSkillsRequest.Text += s + ' ';
            }
            using (var context = new LinkedinEntities5())
            {
                id_companie_logata = (from c in context.Companie
                                      where c.UsernameC.Equals(nume)
                                      select c.ID_Companie).First();
            }
        }
Example #4
0
        private void btCSV_Click(object sender, EventArgs e)
        {
            var csv = new StringBuilder();

            using (var context = new LinkedinEntities5())
            {
                var query = from c in context.Client
                            select new
                {
                    c.Username,
                    c.Nume,
                    c.Prenume,
                    c.Email,
                    c.Aptitudini
                };


                foreach (var row in query)
                {
                    var newline = string.Format("{0},{1},{2},{3},{4}", row.Username.ToString().Trim(),
                                                row.Nume.ToString().Trim(),
                                                row.Prenume.ToString().Trim(),
                                                row.Email.ToString().Trim(),
                                                row.Aptitudini.ToString().Trim());
                    csv.AppendLine(newline);
                }
                File.WriteAllText("D:\\csharp-Csv.cvs", csv.ToString());
            }
        }
Example #5
0
        public static string skillsC(int id_companie)
        {
            using (var context = new LinkedinEntities5())
            {
                var results = context.Companie.Include("Aptitudini").Where(s => s.ID_Companie == id_companie).FirstOrDefault <Companie>();

                foreach (var item in results.Aptitudini)
                {
                    skillC += item.Aptitudine;
                    skillC += ",";
                }
            }
            return(skillC);
        }
Example #6
0
        public static string skills(int id_client)
        {
            using (var context = new LinkedinEntities5())
            {
                var results = context.Client.Include("Aptitudini").Where(s => s.ID_Client == id_client).FirstOrDefault <Client>();

                foreach (var item in results.Aptitudini)
                {
                    skill += item.Aptitudine;
                    skill += ",";
                }
            }
            return(skill);
        }
Example #7
0
        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();
            }
        }
Example #8
0
        public static List <string> skillsC(int id_companie)
        {
            skillC = new List <string>();
            // skillC = null;
            using (var context = new LinkedinEntities5())
            {
                var results = context.Companie.Include("Aptitudini").Where(s => s.ID_Companie == id_companie).FirstOrDefault <Companie>();

                foreach (var item in results.Aptitudini)
                {
                    string aux = item.Aptitudine.ToString();
                    skillC.Add(aux);
                }
            }
            return(skillC);
        }
Example #9
0
        public static List <string> skills(int id_client)
        {
            skill = new List <string>();
            // skill = null;
            using (var context = new LinkedinEntities5())
            {
                var results = context.Client.Include("Aptitudini").Where(s => s.ID_Client == id_client).FirstOrDefault <Client>();

                foreach (var item in results.Aptitudini)
                {
                    string aux = item.Aptitudine.ToString();
                    skill.Add(aux);
                }
            }
            return(skill);
        }
Example #10
0
        private void btSearch_Click(object sender, EventArgs e)
        {
            try
            {
                if (search != null)
                {
                    if (search != null)
                    {
                        using (var context = new LinkedinEntities5())
                        {
                            var results = from c in context.Client
                                          where c.Nume.Contains(search) || c.Prenume.Contains(search)
                                          select c;
                            if (results.Any())
                            {
                                Form form = new Search(search, "Companie", id_companie_logata);

                                form.Show();
                            }
                            else
                            {
                                var results1 = from c in context.Companie
                                               where c.Nume_companie.Contains(search)
                                               select c;
                                if (results1.Any())
                                {
                                    Form form = new SearchC(search, "Companie", id_companie_logata);
                                    form.Show();
                                }
                                else
                                {
                                    throw new Exception("Utilizatorul nu exista!");
                                }
                            }
                        }
                    }
                }
                else
                {
                    throw new Exception("Search box is empty, can't search");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #11
0
        public Search(string search, string a, int id_conectat)
        {
            id_cel_care_e_conectat = id_conectat;
            if (a.Equals("Companie"))
            {
                InitializeComponent1();
            }
            else
            {
                InitializeComponent();
            }


            LinkedinEntities5 context = new LinkedinEntities5();

            dataGridView1.DataSource = context.Client.Where(x => x.ID_Client != id_conectat && (x.Nume.Contains(search) || x.Prenume.Contains(search))).ToList();
        }
Example #12
0
        public SearchC(string s, string a, int id_conectat)
        {
            id_cine_e_conectat = id_conectat;
            if (a.Equals("Companie"))
            {
                InitializeComponent1();
            }
            else
            {
                InitializeComponent();
            }
            search = s;

            LinkedinEntities5 context = new LinkedinEntities5();

            dataGridView1.DataSource = context.Companie.Where(x => x.ID_Companie != id_conectat && x.Nume_companie.Contains(search)).ToList();
        }
Example #13
0
        private void btOk2_Click(object sender, EventArgs e)
        {
            if (newPass.Equals(checkPass))
            {
                string hash = CClient.SecurePasswordHasher.Hash(newPass);
                if (client_companie == "client")
                {
                    var context     = new LinkedinEntities5();
                    var emailClient = (from c in context.Client
                                       where c.Email.Equals(emailForgot)
                                       select c).First();
                    emailClient.Parola = hash;
                    context.SaveChanges();
                }
                else if (client_companie == "comapanie")
                {
                    var context1      = new LinkedinEntities5();
                    var emailCompanie = (from c in context1.Companie
                                         where c.Email_companie.Equals(emailForgot)
                                         select c).First();
                    if (emailCompanie != null)
                    {
                        emailCompanie.ParolaC = hash;
                        context1.SaveChanges();
                    }
                }

                MessageBox.Show("New password was set",
                                "Information",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information
                                );

                this.Close();
            }
            else
            {
                MessageBox.Show("Password doesn't match",
                                "ERROR",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error
                                );
            }
        }
Example #14
0
        public static bool IfExists(string mail, string phone)
        {
            int ok      = 0;
            var context = new LinkedinEntities5();
            var results = from c in context.Client
                          select new
            {
                c.Telefon,
                c.Email
            };

            foreach (var item in results)
            {
                if (item.Telefon.Equals(phone) && item.Email.Equals(mail))
                {
                    ok = 1;
                    client_companie = "client";
                }
            }

            var results1 = from c in context.Companie
                           select new
            {
                c.Telefon_companie,
                c.Email_companie
            };

            foreach (var item in results1)
            {
                if (item.Telefon_companie.Equals(phone) && item.Email_companie.Equals(mail))
                {
                    ok = 1;
                    client_companie = "companie";
                }
            }

            if (ok == 1)
            {
                return(true);
            }
            return(false);
        }
Example #15
0
        public static bool IfExistsUsername(string username)
        {
            int ok      = 0;
            var context = new LinkedinEntities5();
            var results = from c in context.Client
                          select new
            {
                c.Username
            };

            foreach (var item in results)
            {
                if (item.Username.Equals(username))
                {
                    ok = 1;
                }
            }

            var results_companie = from c in context.Companie
                                   select new
            {
                c.Nume_companie
            };

            foreach (var item in results_companie)
            {
                if (item.Nume_companie.Equals(username))
                {
                    ok = 1;
                }
            }

            if (ok == 1)
            {
                return(true);
            }

            return(false);
        }
Example #16
0
        public static bool IfExistsEmail(string mail)
        {
            int ok      = 0;
            var context = new LinkedinEntities5();
            var results = from c in context.Client
                          select new
            {
                c.Email
            };

            foreach (var item in results)
            {
                if (item.Email.Equals(mail))
                {
                    ok = 1;
                }
            }

            var resultsC = from c in context.Companie
                           select new
            {
                c.Email_companie
            };

            foreach (var item in resultsC)
            {
                if (item.Email_companie.Equals(mail))
                {
                    ok = 1;
                }
            }

            if (ok == 1)
            {
                return(true);
            }

            return(false);
        }
Example #17
0
        public static bool IfClient(int id_client)
        {
            int ok      = 0;
            var context = new LinkedinEntities5();
            var results = from c in context.Client
                          select new
            {
                c.ID_Client
            };

            foreach (var item in results)
            {
                if (item.ID_Client == id_client)
                {
                    ok = 1;
                }
            }

            if (ok == 1)
            {
                return(true);
            }
            return(false);
        }
Example #18
0
        public static bool IsClient(string usrname)
        {
            int ok      = 0;
            var context = new LinkedinEntities5();
            var results = from c in context.Client
                          select new
            {
                c.Username
            };

            foreach (var item in results)
            {
                if (item.Username == usrname)
                {
                    ok = 1;
                }
            }

            if (ok == 1)
            {
                return(true);
            }
            return(false);
        }
Example #19
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                string abc = null;
                if (dataGridView1.Columns.Contains("Match") && dataGridView1.Columns["Match"].Visible)
                {
                    abc = dataGridView1.Rows[e.RowIndex].Cells[ID_Client.Index].Value.ToString();
                    int b = Int32.Parse(abc);
                    using (var context = new LinkedinEntities5())
                    {
                        List <string> apt_client   = skills(b);
                        List <string> apt_companie = skillsC(id_cel_care_e_conectat);
                        var           message      = string.Join(Environment.NewLine, apt_companie);

                        var message1 = string.Join(Environment.NewLine, apt_client);

                        var matches = apt_client.Intersect(apt_companie).Count();
                        int count   = apt_companie.Count();


                        int procent = (int)Math.Round((double)(100 * matches) / count);

                        dataGridView1.Rows[e.RowIndex].Cells["Match"].Value = procent.ToString() + '%';
                    }
                }
                if (dataGridView1.Columns.Contains("Message") && dataGridView1.Columns["Message"].Visible)
                {
                    abc = dataGridView1.Rows[e.RowIndex].Cells[ID_Client.Index].Value.ToString();

                    Form form = new SentMessage(abc, id_cel_care_e_conectat, "Companie-Client");
                    form.Show();
                }
                else if (dataGridView1.Columns.Contains("SendMessage") && dataGridView1.Columns["SendMessage"].Visible && e.ColumnIndex == dataGridView1.Columns["SendMessage"].Index)
                {
                    abc = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();

                    Form form = new SentMessage(abc, id_cel_care_e_conectat, "Client-Client");
                    form.Show();
                }
                else
                if (dataGridView1.Columns.Contains("SendRelation") && dataGridView1.Columns["SendRelation"].Visible && e.ColumnIndex == dataGridView1.Columns["SendRelation"].Index)
                {
                    abc = dataGridView1.Rows[e.RowIndex].Cells[ID_Client.Index].Value.ToString();


                    if (dataGridView1.Rows[e.RowIndex].Cells["Friendship"].FormattedValue.ToString().Equals("Add friend"))
                    {
                        var newrelatie = new Relatie()
                        {
                            ID_client_send    = id_cel_care_e_conectat,
                            ID_client_receive = Int32.Parse(abc),
                            ID_status         = 1
                        };
                        int a = Int32.Parse(abc);
                        using (var context = new LinkedinEntities5())
                        {
                            var results = (from c in context.Relatie
                                           where c.ID_client_receive == a && c.ID_client_send == id_cel_care_e_conectat && c.ID_status == 1
                                           select c).FirstOrDefault();
                            if (results == null)
                            {
                                context.Relatie.Add(newrelatie);
                                context.SaveChanges();
                                throw new Exception("Request was sent!");
                            }
                            else
                            {
                                throw new Exception("There was another request sent!");
                            }
                        }
                    }
                    else
                    if (dataGridView1.Rows[e.RowIndex].Cells["Friendship"].FormattedValue.ToString().Equals("Block"))
                    {
                        var newrelatie = new Relatie()
                        {
                            ID_client_send    = id_cel_care_e_conectat,
                            ID_client_receive = Int32.Parse(abc),
                            ID_status         = 4
                        };
                        int a = Int32.Parse(abc);
                        using (var context = new LinkedinEntities5())
                        {
                            var results = (from c in context.Relatie
                                           where c.ID_client_receive == a && c.ID_client_send == id_cel_care_e_conectat && c.ID_status == 4
                                           select c).FirstOrDefault();
                            if (results == null)
                            {
                                context.Relatie.Add(newrelatie);
                                context.SaveChanges();
                                throw new Exception("Request was sent!");
                            }
                            else
                            {
                                throw new Exception("There was another request sent!");
                            }
                        }
                    }
                }
                else
                if (dataGridView1.Columns.Contains("SendRating") && dataGridView1.Columns["SendRating"].Visible && e.ColumnIndex == dataGridView1.Columns["SendRating"].Index)
                {
                    abc = dataGridView1.Rows[e.RowIndex].Cells[ID_Client.Index].Value.ToString();
                    int a  = Int32.Parse(abc);
                    int ok = 0;
                    using (var context = new LinkedinEntities5())
                    {
                        var results = (from c in context.Rating
                                       where c.ID_client_receive == a && c.ID_client_send == id_cel_care_e_conectat
                                       select c).FirstOrDefault();
                        if (results == null)
                        {
                            ok = 1;
                        }
                    }

                    if (ok == 1)
                    {
                        if (dataGridView1.Rows[e.RowIndex].Cells["Rating"].FormattedValue.Equals("5"))
                        {
                            var newrating = new Rating()
                            {
                                ID_client_send    = id_cel_care_e_conectat,
                                ID_client_receive = Int32.Parse(abc),
                                Nota = 5
                            };

                            using (var context = new LinkedinEntities5())
                            {
                                context.Rating.Add(newrating);
                                context.SaveChanges();
                                throw new Exception("Rating was sent!");
                            }
                        }
                        else

                        if (dataGridView1.Rows[e.RowIndex].Cells["Rating"].FormattedValue.Equals("1"))
                        {
                            var newrating = new Rating()
                            {
                                ID_client_send    = id_cel_care_e_conectat,
                                ID_client_receive = Int32.Parse(abc),
                                Nota = 1
                            };

                            using (var context = new LinkedinEntities5())
                            {
                                context.Rating.Add(newrating);
                                context.SaveChanges();
                                throw new Exception("Rating was sent!");
                            }
                        }
                        else

                        if (dataGridView1.Rows[e.RowIndex].Cells["Rating"].FormattedValue.Equals("2"))
                        {
                            var newrating = new Rating()
                            {
                                ID_client_send    = id_cel_care_e_conectat,
                                ID_client_receive = Int32.Parse(abc),
                                Nota = 2
                            };

                            using (var context = new LinkedinEntities5())
                            {
                                context.Rating.Add(newrating);
                                context.SaveChanges();
                                throw new Exception("Rating was sent!");
                            }
                        }
                        else

                        if (dataGridView1.Rows[e.RowIndex].Cells["Rating"].FormattedValue.Equals("3"))
                        {
                            var newrating = new Rating()
                            {
                                ID_client_send    = id_cel_care_e_conectat,
                                ID_client_receive = Int32.Parse(abc),
                                Nota = 3
                            };

                            using (var context = new LinkedinEntities5())
                            {
                                context.Rating.Add(newrating);
                                context.SaveChanges();
                                throw new Exception("Rating was sent!");
                            }
                        }
                        else

                        if (dataGridView1.Rows[e.RowIndex].Cells["Rating"].FormattedValue.Equals("4"))
                        {
                            var newrating = new Rating()
                            {
                                ID_client_send    = id_cel_care_e_conectat,
                                ID_client_receive = Int32.Parse(abc),
                                Nota = 4
                            };

                            using (var context = new LinkedinEntities5())
                            {
                                context.Rating.Add(newrating);
                                context.SaveChanges();
                                throw new Exception("Rating was sent!");
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("You have already rated this person!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #20
0
        private void btExcel_Click(object sender, EventArgs e)
        {
            using (var context = new LinkedinEntities5())
            {
                var queryResult = (from c in context.Client
                                   select new
                {
                    Username = c.Username,
                    LastName = c.Nume,
                    FirstName = c.Prenume,
                    Email = c.Email,
                    skill = c.Aptitudini
                }).Distinct().ToList();

                Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();

                xlApp.Visible = true;

                if (xlApp == null)
                {
                    MessageBox.Show("Excel is not properly installed!!");
                    return;
                }


                Microsoft.Office.Interop.Excel.Workbook  xlWorkBook;
                Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;

                object misValue = System.Reflection.Missing.Value;

                xlWorkBook  = xlApp.Workbooks.Add(misValue);
                xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

                xlWorkSheet.Cells[1, 1] = "Friends report for user " + context.Client.ToString();
                xlWorkSheet.Cells[2, 1] = "Username";
                xlWorkSheet.Cells[2, 2] = "LastName";
                xlWorkSheet.Cells[2, 3] = "FirstName";
                xlWorkSheet.Cells[2, 4] = "E-mail";
                xlWorkSheet.Cells[2, 5] = "Skills";


                for (int i = 0; i < queryResult.Count; i++)
                {
                    xlWorkSheet.Cells[i + 3, 1] = queryResult[i].Username;
                    xlWorkSheet.Cells[i + 3, 2] = queryResult[i].LastName;
                    xlWorkSheet.Cells[i + 3, 3] = queryResult[i].FirstName;
                    xlWorkSheet.Cells[i + 3, 4] = queryResult[i].Email;
                    xlWorkSheet.Cells[i + 3, 5] = queryResult[i].skill;
                }


                xlWorkBook.SaveAs("D:\\csharp-Excel.xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                xlWorkBook.Close(true, misValue, misValue);
                xlApp.Quit();

                Marshal.ReleaseComObject(xlWorkSheet);
                Marshal.ReleaseComObject(xlWorkBook);
                Marshal.ReleaseComObject(xlApp);

                MessageBox.Show("Excel file created , you can find the file D:\\csharp-Excel.xls");
            }
        }
Example #21
0
        public Messaging(int id_logat, int client_sau_companie)
        {
            WhaAmI       = client_sau_companie;
            id_cel_logat = id_logat;
            InitializeComponent();
            if (IfClient(id_cel_logat))
            {
                using (var context = new LinkedinEntities5())
                {
                    var results = from item in context.Mesaj_Companie_Client
                                  where item.ID_client == id_cel_logat
                                  select new
                    {
                        item.Companie.Nume_companie,
                        item.Mesaj
                    };
                    DataTable  aux = new DataTable();
                    DataColumn c0  = new DataColumn("Username");
                    DataColumn c1  = new DataColumn("Content");
                    aux.Columns.Add(c0);
                    aux.Columns.Add(c1);
                    foreach (var it in results)
                    {
                        DataRow row = aux.NewRow();
                        row["Username"] = it.Nume_companie;
                        row["Content"]  = it.Mesaj;
                        aux.Rows.Add(row);
                    }

                    var result = from item in context.Mesaj_Client_Client
                                 where item.ID_Client_Receive == id_cel_logat
                                 select new
                    {
                        item.Client.Username,
                        item.Mesaj
                    };
                    foreach (var it in result)
                    {
                        DataRow row = aux.NewRow();
                        row["Username"] = it.Username;
                        row["Content"]  = it.Mesaj;
                        aux.Rows.Add(row);
                    }

                    dataGridView1.DataSource = aux;
                }
            }
            if (IfCompany(id_cel_logat))
            {
                using (var context = new LinkedinEntities5())
                {
                    var results = from item in context.Mesaj_Client_Companie
                                  where item.ID_Companie_receive == id_cel_logat
                                  select new
                    {
                        item.Client.Username,
                        item.Mesaj
                    };
                    DataTable  aux = new DataTable();
                    DataColumn c0  = new DataColumn("Username");
                    DataColumn c1  = new DataColumn("Content");
                    aux.Columns.Add(c0);
                    aux.Columns.Add(c1);
                    foreach (var it in results)
                    {
                        DataRow row = aux.NewRow();
                        row["Username"] = it.Username;
                        row["Content"]  = it.Mesaj;
                        aux.Rows.Add(row);
                    }

                    dataGridView1.DataSource = aux;
                }
            }
            DataGridViewButtonColumn Respond = new DataGridViewButtonColumn();

            Respond.Name = "Respond";
            Respond.Text = "Respond";
            dataGridView1.Columns.Insert(2, Respond);
            dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
        }
Example #22
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                string click = "";
                string ids   = null;
                int    id;
                int    ok = 0; //    =>   to a Client
                if (dataGridView1.Columns.Contains("Respond") && dataGridView1.Columns["Respond"].Visible && e.ColumnIndex == dataGridView1.Columns["Respond"].Index)
                {
                    click = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();

                    using (var context = new LinkedinEntities5())
                    {
                        var results = from item in context.Client
                                      where item.Username == click
                                      select new
                        {
                            item.ID_Client
                        };
                        foreach (var it in results)
                        {
                            ids = it.ID_Client.ToString();
                        }
                        if (ids == null)
                        {
                            ok = 1;   //    =>  to a Company
                            var rez = from itt in context.Companie
                                      where itt.UsernameC == click
                                      select new
                            {
                                itt.ID_Companie
                            };
                            foreach (var it in rez)
                            {
                                ids = it.ID_Companie.ToString();
                            }
                        }
                    }
                    id = Int32.Parse(ids);

                    if (ids != null)
                    {
                        if (WhaAmI == 1)     //from Client
                        {
                            if (ok == 0)     //  to Client
                            {
                                Form form = new SentMessage(click, id_cel_logat, "Client-Client");
                                form.Show();
                            }
                            else    //  to Company
                            {
                                Form form = new SentMessage(click, id_cel_logat, "Client-Companie");
                                form.Show();
                            }
                        }
                        else
                        if (WhaAmI == 2)         ///from Company
                        {
                            Form form = new SentMessage(click, id_cel_logat, "Companie-Client");
                            form.Show();
                        }
                    }
                    else
                    {
                        throw new Exception("NULL Destination");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #23
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);
            }
        }
Example #24
0
        public CClient(string firstname, string lastname, string username, string phone, string email, string date, string university, string address, string sex, string status, string nationality, string skills, Image ofd)
        {
            InitializeComponent();
            picMessaging.Image = Image.FromFile("message.png");
            picRequest.Image   = Image.FromFile("notification.png");
            picMe.Image        = ofd;

            panelDetails.Visible      = false;
            panelNotification.Visible = false;

            lbUsername.Text     = firstname + ' ' + lastname + ' ' + username;
            txtAddress.Text     = address;
            txtBirth.Text       = date;
            txtEmail.Text       = email;
            txtNationality.Text = nationality;
            txtPhone.Text       = phone;
            txtSex.Text         = sex;
            txtStatus.Text      = status;
            txtUniversiy.Text   = university;

            char[]   delimiters = { ',' };
            string[] words      = skills.Split(delimiters);

            foreach (string s in words)
            {
                listSkils.Items.Add(s);
            }
            using (var context = new LinkedinEntities5())
            {
                id_client_logat = (from c in context.Client
                                   where c.Username.Equals(username)
                                   select c.ID_Client).First();
            }
            using (var context = new LinkedinEntities5())
            {
                int count = (from o in context.Rating
                             where o.ID_client_receive == id_client_logat
                             select o).Count();
                var note = from o in context.Rating
                           where o.ID_client_receive == id_client_logat
                           select o.Nota;
                int suma = 0;

                foreach (int nota in note)
                {
                    suma += nota;
                }
                if (count != 0)
                {
                    float medie = suma / count;
                    listBox1.Items.Add(medie.ToString());
                }
                else
                {
                    listBox1.Items.Add(suma.ToString());
                }
            }
            using (var context = new LinkedinEntities5())
            {
                var results = context.Relatie;
                foreach (var it in results)
                {
                    if (it.ID_client_receive == id_client_logat && it.ID_status == 1)
                    {
                        dataGridView1.DataSource = context.ClientDupaID(it.ID_client_send);
                        DataGridViewComboBoxColumn choose = new DataGridViewComboBoxColumn();
                        choose.Name       = "Choose";
                        choose.HeaderText = "Choose";
                        choose.Items.Add("Accept");
                        choose.Items.Add("Decline");
                        dataGridView1.Columns.Insert(2, choose);
                        DataGridViewButtonColumn Respond = new DataGridViewButtonColumn();
                        Respond.Name = "Respond";
                        Respond.Text = "Respond";
                        dataGridView1.Columns.Insert(3, Respond);
                    }
                }
            }
        }
Example #25
0
 private void btSend_Click(object sender, EventArgs e)
 {
     try
     {
         if (message != null)
         {
             if (ok == 1)
             {
                 var newmessage = new Mesaj_Companie_Client()
                 {
                     ID_client   = receptor,
                     ID_companie = emitator,
                     Mesaj       = message
                 };
                 using (var context = new LinkedinEntities5())
                 {
                     context.Mesaj_Companie_Client.Add(newmessage);
                     context.SaveChanges();
                 }
             }
             else if (ok == 0)
             {
                 var newmessage = new Mesaj_Client_Client()
                 {
                     ID_Client_Receive = receptor,
                     ID_Client_Send    = emitator,
                     Mesaj             = message
                 };
                 using (var context = new LinkedinEntities5())
                 {
                     context.Mesaj_Client_Client.Add(newmessage);
                     context.SaveChanges();
                 }
             }
             else if (ok == 2)
             {
                 var newmessage = new Mesaj_Client_Companie()
                 {
                     ID_Client_send      = emitator,
                     ID_Companie_receive = receptor,
                     Mesaj = message
                 };
                 using (var context = new LinkedinEntities5())
                 {
                     context.Mesaj_Client_Companie.Add(newmessage);
                     context.SaveChanges();
                 }
             }
             throw new Exception("Message was sent!");
             message = null;
             this.Close();
         }
         else
         {
             throw new Exception("Can't send an emply message!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #26
0
        public SentMessage(string desti, int emi, string tip)
        {
            InitializeComponent();
            emitator = emi;


            if (tip.Equals("Client-Client"))
            {
                ok = 0;
                string aux = null;
                string a   = null;
                using (var context = new LinkedinEntities5())
                {
                    var results = from item in context.Client
                                  where item.Nume == desti || item.Username == desti
                                  select new
                    {
                        item.ID_Client
                    };
                    foreach (var it in results)
                    {
                        a = it.ID_Client.ToString();
                    }
                }
                receptor = Int32.Parse(a);
            }
            else if (tip.Equals("Companie-Client"))
            {
                ok = 1;
                string aux = null;

                using (var context = new LinkedinEntities5())
                {
                    var results = from item in context.Client
                                  where item.Username == desti || item.ID_Client.ToString() == desti
                                  select new
                    {
                        item.ID_Client
                    };
                    foreach (var it in results)
                    {
                        aux = it.ID_Client.ToString();
                    }
                }
                receptor = Int32.Parse(aux);
            }
            else if (tip.Equals("Client-Companie"))
            {
                ok = 2;
                string aux = null;
                using (var context = new LinkedinEntities5())
                {
                    var results = from item in context.Companie
                                  where item.UsernameC == desti
                                  select new
                    {
                        item.ID_Companie
                    };
                    foreach (var it in results)
                    {
                        aux = it.ID_Companie.ToString();
                    }
                }
                receptor = Int32.Parse(aux);
            }
        }