Пример #1
0
    public static String RegisterConsult(String data, UInt32 idAnimal, UInt32 urgencia, String morada, UInt32 idCliente, String obs = "")
    {
        db = new SQLDatabaseManager();

        String query = String.Format("SELECT * FROM dbo.MARCACAO WHERE DATA = '{0}'", data);

        DataTable temp;

        temp = db.GetDataTable(query);

        if (temp.Rows.Count > 0)
        {
            return("Já existe uma marcação nessa hora.");
        }

        Dictionary <String, String> InsertData = new Dictionary <String, String>()
        {
            { "DATA", data },
            { "LOCAL", morada },
            { "URGENCIA", Convert.ToString(urgencia) },
            { "IDCLIENTE", Convert.ToString(idCliente) },
            { "IDANIMAL", Convert.ToString(idAnimal) },
            { "ESTADO", "0" },
            { "OBSERVACOES", obs }
        };

        if (db.Insert("dbo.MARCACAO", InsertData))
        {
            return("Marcação efectuada com sucesso.");
        }
        else
        {
            return("Erro ao efectuar marcação.");
        }
    }
Пример #2
0
    public static Boolean RegisterClinicHistory(String idAnimal, String idMedicamento, String ocorrencia)
    {
        DateTime dt = DateTime.Now;

        db = new SQLDatabaseManager();

        Dictionary <String, String> InsertData = new Dictionary <String, String>()
        {
            { "IDMEDICAMENTO", idMedicamento },
            { "IDANIMAL", idAnimal },
            { "OCORRENCIA", ocorrencia },
            { "DATA", dt.ToString() }
        };

        if (!db.Insert("dbo.HISTORICOCLINICO", InsertData))
        {
            return(false);
        }

        String query = String.Format("UPDATE dbo.MARCACAO SET ESTADO='4' WHERE IDANIMAL='{0}'", idAnimal);

        if (db.ExecuteNonQuery(query) == 0)
        {
            return(false);
        }
        return(true);
    }
Пример #3
0
    protected void Confirm_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            MembershipUser     user = Membership.GetUser();
            SQLDatabaseManager db   = new SQLDatabaseManager();
            Client             c    = new Client(user.ProviderUserKey.ToString());
            int id = c.getIDCliente();


            Dictionary <String, String> InsertData = new Dictionary <String, String>()
            {
                { "IDCliente", id.ToString() },
                { "Nome", tnome.Text },
                { "Morada", tmorada.Text },
                { "DataNasc", tdata.Text },
                { "Contacto", tcontacto.Text },
                { "Condicoes", tcondicoes.Text }
            };


            db.Insert("Idoso", InsertData);
            Response.Redirect("~/Clients/MainPage.aspx");
        }
    }
Пример #4
0
    protected void accao_Click(object sender, EventArgs e)
    {
        MembershipUser     user  = Membership.GetUser();
        SQLDatabaseManager db    = new SQLDatabaseManager();
        Button             btn   = (Button)sender;
        String             texto = btn.Text;
        GridViewRow        gvr   = (GridViewRow)btn.NamingContainer;
        Client             c     = new Client(user.ProviderUserKey.ToString());
        int idv = c.getIDVolunt();


        if (texto.Equals("Aceitar"))
        {
            Label lblServ = (Label)GridView1.Rows[gvr.RowIndex].FindControl("IDS");

            String query = String.Format("UPDATE Servico SET IDVoluntario='{0}', Status='{1}' WHERE IDServico='{2}'", idv, "Aceite", lblServ.Text);

            db.ExecuteNonQuery(query);
            Response.Redirect("~/Volunts/ManageServicos.aspx");
        }
        else
        {
            Label lblServ = (Label)GridView1.Rows[gvr.RowIndex].FindControl("IDS");

            String query = String.Format("UPDATE Servico SET IDVoluntario='{0}', Status='{1}' WHERE IDServico='{2}'", "15", "Nao Aceite", lblServ.Text);

            db.ExecuteNonQuery(query);
            Response.Redirect("~/Volunts/ManageServicos.aspx");
        }
    }
Пример #5
0
    protected void Confirm_Click(object sender, EventArgs e)
    {
        MembershipUser user = Membership.GetUser();
        Client         c    = new Client(user.ProviderUserKey.ToString());
        MembershipUser newUser;

        if ((newUser = c.NovoUser(tuser.Text, tpass.Text)) == null)
        {
        }
        else
        {
            SQLDatabaseManager          db         = new SQLDatabaseManager();
            Dictionary <String, String> InsertData = new Dictionary <String, String>()
            {
                { "Nome", tnome.Text },
                { "Morada", tmorada.Text },
                { "Email", temail.Text },
                { "Contacto", tcontactos.Text },
                { "UserId", newUser.ProviderUserKey.ToString() }
            };
            db.Insert("Admin", InsertData);
            Roles.AddUserToRole(newUser.UserName, "Admin");
            Response.Redirect("~/Admin/AMain.aspx");
        }
    }
Пример #6
0
    protected void LoadAnimals(UInt32 ClientID)
    {
        SQLDatabaseManager db = new SQLDatabaseManager();

        String query = String.Format("SELECT * FROM dbo.ANIMAL WHERE IDCLIENTE='{0}'", ClientID);

        DataTable temp;
        DataTable temp2;
        String    photoPath = null;

        temp = db.GetDataTable(query);

        if (temp.Rows.Count < 1)
        {
            Response.Write("<div class='col-md-4'>");
            Response.Write("<h2>Não existem animais</h2>");
            Response.Write("<p>Pretende <a href='NewAnimal'>adicionar</a> um novo animal ?</p>");
            Response.Write("</div>");
            return;
        }

        foreach (DataRow r in temp.Rows)
        {
            query = String.Format("SELECT * FROM dbo.FOTOS WHERE IDANIMAL='{0}'", r["IDANIMAL"].ToString());
            temp2 = db.GetDataTable(query);
            foreach (DataRow x in temp2.Rows)
            {
                photoPath = x["URL"].ToString();
                break;
            }

            Animal.DrawAnimal(Response, photoPath, r["NOME"].ToString(), r["RACA"].ToString(), Convert.ToUInt32(r["IDADE"].ToString()), Convert.ToUInt32(r["IDANIMAL"].ToString()));
        }
    }
Пример #7
0
    public static void FillPaymentFields(String PaymentID, TextBox Data, TextBox Metodo, TextBox Montante, TextBox Movimentacao, TextBox Estado)
    {
        db = new SQLDatabaseManager();

        String query = String.Format("UPDATE dbo.PAGAMENTO SET ESTADO='1'WHERE IDPAGAMENTO='{0}'", PaymentID);

        db.ExecuteNonQuery(query);

        query = String.Format("UPDATE dbo.MARCACAO SET ESTADO='4' WHERE IDPAGAMENTO='{0}'", PaymentID);

        db.ExecuteNonQuery(query);

        query = String.Format("SELECT * FROM dbo.PAGAMENTO WHERE IDPAGAMENTO='{0}'", PaymentID);

        DataTable temp;

        temp = db.GetDataTable(query);

        foreach (DataRow r in temp.Rows)
        {
            Data.Text         = r["DATA_LIMITE"].ToString();
            Metodo.Text       = r["METODO"].ToString();
            Movimentacao.Text = r["NUMEROMOVIMENTACAO"].ToString();
            Montante.Text     = r["MONTANTE"].ToString();
            if (r["ESTADO"].ToString() == "0")
            {
                Estado.Text = "Falta pagar";
            }
            else
            {
                Estado.Text = "Pago";
            }
            break;
        }
    }
Пример #8
0
    protected void reject_Click(object sender, EventArgs e)
    {
        SQLDatabaseManager db    = new SQLDatabaseManager();
        String             query = String.Format("UPDATE Voluntario SET Status='Rejeitado' WHERE IDVoluntario='{0}'", DropDownList1.SelectedValue);

        db.ExecuteNonQuery(query);
        Response.Redirect("~/Admin/Accept.aspx");
    }
Пример #9
0
    protected void Confirm_Click(object sender, EventArgs e)
    {
        MembershipUser     user = Membership.GetUser();
        SQLDatabaseManager db   = new SQLDatabaseManager();

        String where = String.Format("IDServico='{0}'", DropDownList1.SelectedValue);
        db.Delete("Servico", where);

        Response.Redirect("~/Clients/VerServico.aspx");
    }
Пример #10
0
    protected void Confirm_Click(object sender, EventArgs e)
    {
        MembershipUser     user = Membership.GetUser();
        SQLDatabaseManager db   = new SQLDatabaseManager();

        String upquery = String.Format("UPDATE Cliente SET Nome='{0}', Morada='{1}', DataNasc='{2}', Email='{3}', Contactos='{4}' WHERE UserId='{5}'", tnome.Text, tmorada.Text, tdata.Text, temail.Text, tcontactos.Text, user.ProviderUserKey.ToString());

        db.ExecuteNonQuery(upquery);

        Response.Redirect("~/Clients/MainPage.aspx");
    }
Пример #11
0
    protected void Confirm_Click(object sender, EventArgs e)
    {
        MembershipUser user = Membership.GetUser();
        Client         c    = new Client(user.ProviderUserKey.ToString());

        SQLDatabaseManager db = new SQLDatabaseManager();

        String upquery = String.Format("UPDATE Idoso SET Nome='{0}', Morada='{1}', DataNasc='{2}', Contacto='{3}', Condicoes='{4}' WHERE IDIdoso='{5}'", tnome.Text, tmorada.Text, tdata.Text, tcontacto.Text, tcondicoes.Text, DropDownList1.SelectedValue);
        int    r       = db.ExecuteNonQuery(upquery);

        Response.Redirect("~/Clients/ManageIdosos.aspx");
    }
Пример #12
0
    public Boolean SaveChangesToDatabase()
    {
        db = new SQLDatabaseManager();

        String query = String.Format("UPDATE dbo.ANIMAL SET NOME='{0}', ESPECIE='{1}', RACA='{2}', IDADE='{3}', PESO='{4}', TEMPERATURA='{5}', TIPO='{6}' WHERE IDANIMAL='{7}'", _name, _species, _race, _age, _weight, _temperature, _type, animalID);

        if (db.ExecuteNonQuery(query) == 1)
        {
            return(true);
        }
        return(false);
    }
Пример #13
0
    public Boolean checkValid()
    {
        SQLDatabaseManager db    = new SQLDatabaseManager();
        String             query = String.Format("SELECT Status, IDVoluntario FROM VOluntario WHERE UserId='{0}'", userID);
        DataTable          dt;

        dt = db.GetDataTable(query);
        if (dt.Rows[0]["Status"].ToString().Equals("Aguarda") || dt.Rows[0]["Status"].ToString().Equals("Rejeitado"))
        {
            return(false);
        }
        return(true);
    }
Пример #14
0
    public static void LoadAnimals(DropDownList AnimalList, UInt32 ClientID)
    {
        db = new SQLDatabaseManager();

        DataTable temp;

        temp = db.GetDataTable("SELECT IDANIMAL, NOME FROM dbo.ANIMAL WHERE IDCLIENTE='" + ClientID + "'");

        AnimalList.DataSource     = temp;
        AnimalList.DataTextField  = temp.Columns["NOME"].ToString();
        AnimalList.DataValueField = temp.Columns["IDANIMAL"].ToString();
        AnimalList.DataBind();
    }
Пример #15
0
    public int getIDVolunt()
    {
        int id;
        SQLDatabaseManager db = new SQLDatabaseManager();

        DataTable dt;
        String    query = String.Format("SELECT IDVoluntario FROM Voluntario WHERE UserId='{0}'", userID);



        dt = db.GetDataTable(query);
        id = Convert.ToInt32(dt.Rows[0]["IDVoluntario"].ToString());
        return(id);
    }
Пример #16
0
    public int getIDIdoso(int idc, String nome)
    {
        int id;
        SQLDatabaseManager db = new SQLDatabaseManager();

        DataTable dt;
        String    query = String.Format("SELECT IDIdoso FROM Idoso WHERE (IDCliente='{0}' AND Nome='{1}')", idc, nome);



        dt = db.GetDataTable(query);
        id = Convert.ToInt32(dt.Rows[0]["IDIdoso"].ToString());
        return(id);
    }
Пример #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MembershipUser     user = Membership.GetUser();
        SQLDatabaseManager db   = new SQLDatabaseManager();

        String    query = String.Format("SELECT [Nome], [Morada], [Email], [DataNasc], [Contactos], [Disponibilidade], [Status], [Habilitacoes] FROM [Voluntario] WHERE UserId='{0}'", user.ProviderUserKey.ToString());
        DataTable temp;

        temp = db.GetDataTable(query);


        FormView1.DataSource = temp;
        FormView1.DataBind();
    }
Пример #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MembershipUser     user = Membership.GetUser();
        SQLDatabaseManager db   = new SQLDatabaseManager();
        Client             c    = new Client(user.ProviderUserKey.ToString());
        int id = c.getIDCliente();

        String    query = String.Format("SELECT Nome, Morada, Contacto, DataNasc, Condicoes FROM Idoso WHERE IDCliente='{0}'", id);
        DataTable temp;

        temp = db.GetDataTable(query);

        GridView1.DataSource = temp;
        GridView1.DataBind();
    }
Пример #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MembershipUser     user = Membership.GetUser();
        SQLDatabaseManager db   = new SQLDatabaseManager();


        String    query = String.Format("SELECT [Email], [Morada], [Nome], [Contacto], [UserId] FROM [Admin] WHERE UserId='{0}'", user.ProviderUserKey.ToString());
        DataTable temp;

        temp = db.GetDataTable(query);


        FormView1.DataSource = temp;
        FormView1.DataBind();
    }
Пример #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MembershipUser     user = Membership.GetUser();
        SQLDatabaseManager db   = new SQLDatabaseManager();
        Client             c    = new Client(user.ProviderUserKey.ToString());
        int    id    = c.getIDCliente();
        String query = String.Format("SELECT I.Nome, I.Morada, I.Contacto, S.Servico, S.Notas, S.Horario, S.Status, V.Nome AS Vnome, V.Contactos From Idoso I, Servico S, Voluntario V WHERE S.IDCliente=I.IDCliente AND V.IDVoluntario=S.IDVoluntario AND I.IDIdoso=S.IDIdoso AND S.IDCliente='{0}'", id);

        DataTable temp;

        temp = db.GetDataTable(query);

        GridView1.DataSource = temp;
        GridView1.DataBind();
    }
Пример #21
0
    public static Boolean isValidOwner(WebsiteUser obj, UInt32 AnimalID)
    {
        db = new SQLDatabaseManager();

        String query = "SELECT * FROM dbo.ANIMAL WHERE IDCLIENTE='" + obj.ClientID + "' AND IDANIMAL='" + AnimalID + "'";

        DataTable temp;

        temp = db.GetDataTable(query);

        if (temp.Rows.Count > 0)
        {
            return(true);
        }
        return(false);
    }
Пример #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            SQLDatabaseManager db = new SQLDatabaseManager();

            String    query = String.Format("SELECT IDVoluntario, Nome, Status From Voluntario WHERE IDVoluntario<>15 AND Status='Aguarda'");
            DataTable temp;
            temp = db.GetDataTable(query);
            DropDownList1.DataValueField = "IDVoluntario";
            DropDownList1.DataTextField  = "Nome";
            DropDownList1.DataSource     = temp;
            DropDownList1.DataBind();
            DropDownList1.Items.Insert(0, "Escolha um Voluntário.");
        }
    }
Пример #23
0
    public static void LoadConsultas(UInt32 IDClient, HttpResponse Response)
    {
        db = new SQLDatabaseManager();

        String query = String.Format("SELECT * FROM dbo.MARCACAO WHERE IDCLIENTE='{0}' AND ESTADO<>'2'", IDClient);

        DataTable temp;

        temp = db.GetDataTable(query);

        if (temp.Rows.Count == 0)
        {
            Response.Write("Não existem consultas agendadas.");
            return;
        }
    }
Пример #24
0
    public static Boolean PaymentExists(String PaymentID)
    {
        db = new SQLDatabaseManager();

        String query = "SELECT IDPAGAMENTO FROM dbo.PAGAMENTO WHERE IDPAGAMENTO='" + PaymentID + "'";

        DataTable temp;

        temp = db.GetDataTable(query);

        if (temp.Rows.Count > 0)
        {
            return(true);
        }
        return(false);
    }
Пример #25
0
    public static Boolean Exists(UInt32 AnimalID)
    {
        db = new SQLDatabaseManager();

        String query = "SELECT NOME FROM dbo.ANIMAL WHERE IDANIMAL='" + AnimalID + "'";

        DataTable temp;

        temp = db.GetDataTable(query);

        if (temp.Rows.Count > 0)
        {
            return(true);
        }
        return(false);
    }
Пример #26
0
    public static UInt32 Add(Animal obj)
    {
        db = new SQLDatabaseManager();

        Dictionary <String, String> Data = new Dictionary <String, String>
        {
            { "NOME", obj.Name },
            { "ESPECIE", obj.Species },
            { "RACA", obj.Race },
            { "IDADE", Convert.ToString(obj.Age) },
            { "PESO", Convert.ToString(obj.Weight) },
            { "TEMPERATURA", Convert.ToString(obj.Temperature) },
            { "IDCLIENTE", Convert.ToString(obj.OwnerID) },
            { "TIPO", Convert.ToString(obj.Type) }
        };

        if (db.Insert("dbo.ANIMAL", Data))
        {
            String query = String.Format("SELECT IDANIMAL FROM dbo.ANIMAL WHERE NOME='{0}' AND ESPECIE='{1}' AND RACA='{2}' AND IDADE='{3}' AND PESO='{4}' AND TEMPERATURA='{5}' AND IDCLIENTE='{6}'",
                                         obj.Name, obj.Species, obj.Race, obj.Age, obj.Weight, obj.Temperature, obj.OwnerID);

            DataTable temp;
            temp = db.GetDataTable(query);

            String LastInsertID = null;

            foreach (DataRow r in temp.Rows)
            {
                LastInsertID = r["IDANIMAL"].ToString();
                break;
            }

            Data = new Dictionary <String, String>
            {
                { "URL", obj._photopath },
                { "IDANIMAL", LastInsertID }
            };

            if (db.Insert("dbo.FOTOS", Data))
            {
                return(2);
            }
            return(1);
        }
        return(0);
    }
Пример #27
0
    public static String Id2Name(UInt32 AnimalID)
    {
        db = new SQLDatabaseManager();

        String query = "SELECT NOME FROM dbo.ANIMAL WHERE IDANIMAL='" + AnimalID + "'";

        DataTable temp;

        temp = db.GetDataTable(query);

        foreach (DataRow r in temp.Rows)
        {
            return(r["NOME"].ToString());
        }

        return(null);
    }
Пример #28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            MembershipUser     user = Membership.GetUser();
            SQLDatabaseManager db   = new SQLDatabaseManager();

            String    query = String.Format("SELECT Nome, Morada, DataNasc, Email, Contactos FROM Cliente WHERE UserID='{0}'", user.ProviderUserKey.ToString());
            DataTable temp;
            temp = db.GetDataTable(query);

            tnome.Text      = temp.Rows[0]["Nome"].ToString();
            tmorada.Text    = temp.Rows[0]["Morada"].ToString();
            tdata.Text      = temp.Rows[0]["DataNasc"].ToString();
            temail.Text     = temp.Rows[0]["Email"].ToString();
            tcontactos.Text = temp.Rows[0]["Contactos"].ToString();
        }
    }
Пример #29
0
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Confirm.Enabled = true;
        MembershipUser     user = Membership.GetUser();
        SQLDatabaseManager db   = new SQLDatabaseManager();
        Client             c    = new Client(user.ProviderUserKey.ToString());
        int       id            = c.getIDCliente();
        String    query         = String.Format("SELECT Nome, Morada, DataNasc, Contacto, Condicoes FROM Idoso WHERE IDIdoso='{0}'", DropDownList1.SelectedValue);
        DataTable temp;

        temp = db.GetDataTable(query);

        tnome.Text      = temp.Rows[0]["Nome"].ToString();
        tmorada.Text    = temp.Rows[0]["Morada"].ToString();
        tdata.Text      = temp.Rows[0]["DataNasc"].ToString();
        tcondicoes.Text = temp.Rows[0]["condicoes"].ToString();
        tcontacto.Text  = temp.Rows[0]["Contacto"].ToString();
    }
Пример #30
0
    public static Boolean RegisterVehicle(String marca, String modelo)
    {
        db = new SQLDatabaseManager();

        Dictionary <String, String> InsertData = new Dictionary <String, String>()
        {
            { "MARCA", marca },
            { "MODELO", modelo }
        };

        if (db.Insert("dbo.VEICULOS", InsertData))
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }