Example #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //aici trbuie sa luati usernamul din datagridview si sa-l dati parametru la form
            Form form = new SentMessage(search);

            form.Show();
        }
Example #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string abc = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();

            Form form = new SentMessage(abc, id_cine_e_conectat, "Client-Companie");

            form.Show();
        }
Example #3
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 #4
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);
            }
        }