Beispiel #1
0
    protected void Aceitar_Click(object sender, EventArgs e)
    {
        string name = GridView4.SelectedRow.Cells[1].Text;
            MembershipUser currentLoggedInUser = Membership.GetUser();
            string id = Convert.ToString(currentLoggedInUser.ProviderUserKey);
            //perfis
            Rede.Perfil this_user = Rede.Perfil.LoadByUserId(id);
            Rede.Perfil Request_Perfil = Rede.Perfil.LoadByName(name);
            //relacoes
            Rede.Relacao request_update = Rede.Relacao.LoadByRelacao(Request_Perfil.ID, this_user.ID);

            request_update.Estado = "feito";
            request_update.Save();

            Rede.Relacao request_insert = new Rede.Relacao();
            request_insert.ProfileIDA = this_user.ID;
            request_insert.ProfileIDB = Request_Perfil.ID;
            request_insert.Forca = Convert.ToInt32(DropDownForca0.SelectedValue);
            request_insert.TagList = listtag_aceitar;
            request_insert.Estado = "feito";
            request_insert.Save();

            //SqlDataSource3.DeleteCommand = "DELETE from [TRelacao] WHERE [ProfileIDA]=" + this_user.ID + " AND [ProfileIDB]=" + ProfileIDB.ID;
            GridView3.DataBind();
            GridView4.DataBind();
    }
Beispiel #2
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        string nome = GridView1.SelectedRow.Cells[0].Text;
            Rede.Perfil ProfileIDB = Rede.Perfil.LoadByName(nome);

            MembershipUser currentLoggedInUser = Membership.GetUser();
            string id = Convert.ToString(currentLoggedInUser.ProviderUserKey);
            Rede.Perfil ProfileIDA = Rede.Perfil.LoadByUserId(id);

            if (ProfileIDA.ID != ProfileIDB.ID)
            {
                Rede.Relacao rel = new Rede.Relacao();
                rel.ProfileIDA = ProfileIDA.ID;
                rel.ProfileIDB = ProfileIDB.ID;
                rel.Forca = Convert.ToInt32(DropDownForca.SelectedValue);
                rel.TagList = this.listtag;
                rel.Estado= "pendente";
                rel.Save();
             }
            GridView2.DataBind();
    }
Beispiel #3
0
        public static IList LoadInfoForArcos()
        {
            try
            {
                DataSet ds = ExecuteQuery(GetConnection(false), "SELECT IDRelacao,ProfileIDA, ProfileIDB, Forca from TRelacao where Estado='feito'");

                IList ret = new ArrayList();

                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    int idR = (int)r["IDRelacao"];
                    int _profileIDA = (int)r["ProfileIDA"];
                    int _profileIDB = (int)r["ProfileIDB"];
                    int _forca = (int)r["Forca"];
                    IList _tag = obterTagByIDrelacao(idR);

                    Relacao re = new Relacao(_profileIDA, _profileIDB, _forca, _tag);
                    ret.Add(re);

                }

                return ret;
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erro BD", ex);
            }
        }
Beispiel #4
0
        public static Relacao LoadByRelacao(int IDA, int IDB)
        {
            DataSet ds = ExecuteQuery("SELECT * FROM TRelacao WHERE ProfileIDA=" + IDA + "AND ProfileIDB=" + IDB);
            Relacao m = new Relacao(ds.Tables[0].Rows[0]);

            return m;
        }
Beispiel #5
0
        public static Relacao LoadById(int ID)
        {
            DataSet ds = ExecuteQuery("SELECT * FROM TRelacao WHERE RelacaoID=" + ID);
            Relacao m = new Relacao(ds.Tables[0].Rows[0]);

            return m;
        }
Beispiel #6
0
        public static IList LoadAll()
        {
            try
            {
                DataSet ds = ExecuteQuery(GetConnection(false), "SELECT * from TRelacao WHERE Estado='feito'");

                IList ret = new ArrayList();

                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    Relacao re = new Relacao(r);
                    ret.Add(re);

                }

                return ret;
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Erro BD", ex);
            }
        }
Beispiel #7
0
    protected void Button4_Click1(object sender, EventArgs e)
    {
        bool flag = false;
            foreach (Control control in Table1.Controls)
            {
                if (control is TableRow)
                {
                    foreach (TableCell cell in control.Controls)
                    {
                        if (!(cell is TableHeaderCell))
                        {
                            foreach (Control c in cell.Controls)
                            {
                                if (((CheckBox)c).Checked == true)
                                {
                                    ((CheckBox)c).Checked = false;
                                    flag = true;
                                    try
                                    {
                                        /*----*/

                                        Rede.Perfil ProfileIDB = Rede.Perfil.LoadByProfileId(c.ID);

                                        MembershipUser currentLoggedInUser = Membership.GetUser();
                                        string id = Convert.ToString(currentLoggedInUser.ProviderUserKey);
                                        Rede.Perfil ProfileIDA = Rede.Perfil.LoadByUserId(id);

                                        if (ProfileIDA.ID != ProfileIDB.ID)
                                        {
                                            //se já existe relação nao faz o convite
                                            if (Rede.Relacao.VerificaSeExisteRelacao(ProfileIDA.ID, ProfileIDB.ID))
                                            {
                                                lblTags.Text = "Já efectuou estes convites antes! Tem que aguardar a respotas dos convidados.";
                                                lblTags.ForeColor = System.Drawing.Color.Red;
                                            }else{
                                                /*cria relação*/
                                                Rede.Relacao rel = new Rede.Relacao();
                                                rel.ProfileIDA = ProfileIDA.ID;
                                                rel.ProfileIDB = ProfileIDB.ID;
                                                rel.Forca = Convert.ToInt32(1);

                                                rel.TagList = null;
                                                rel.Estado = "pendente";
                                                rel.Save();

                                                lblTags.Text = "Convites enviados com sucesso! Aguarde a aceitação do pedido.";
                                                lblTags.ForeColor = System.Drawing.Color.Blue;
                                            }
                                        }

                                    }
                                    catch (Exception exc)
                                    {
                                        lblTags.Text = "Surgiu um problema no envio dos convites. Tente novamente mais tarde.";
                                        lblTags.ForeColor = System.Drawing.Color.Red;
                                    }
                                    /*----*/
                                }
                            }
                        }
                    }
                }
            }
            if (flag==false)
                lblTags.Text = "Deve primeiro seleccionar os utilizadores que pretende convidar!";
                lblTags.ForeColor = System.Drawing.Color.Red;
    }