using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class address_book_Detail : System.Web.UI.Page
{

    static String PAGINA_AGENDA = "Default.aspx";
    static String PAGINA_EDITAR = "Update.aspx";
    static String PAGINA_APAGAR = "Delete.aspx";
    static String PAGINA_ERRO = "../Default.aspx";

    protected void Page_Load(object sender, EventArgs e)
    {

        tag_voltar.HRef = PAGINA_AGENDA;



        try
        {
           
            decimal id_contacto = Convert.ToDecimal(Request.QueryString["id"]);

            DataClassesDataContext dc = new DataClassesDataContext();
            CONTACTO contacto = dc.CONTACTOs.First(p => p.ID_CONTACTO == id_contacto);

            text_box_nome.Text = contacto.NOME;
            text_box_tipo.Text = contacto.TIPO;
            text_box_morada.Text = contacto.MORADA;
            text_box_telefone.Text = contacto.NUMERO_TELEFONE_PRI;
            text_box_fax.Text = contacto.NUMERO_FAX;
            text_box_email.Text = contacto.EMAIL;
            text_box_observacoes.Text = contacto.OBSERVACOES;
   
            tag_editar.HRef = PAGINA_EDITAR + "?id=" + id_contacto;
            tag_eliminar.CommandArgument = PAGINA_APAGAR + "?id=" + id_contacto;
          
        }
        catch (Exception ex)
        {
           
        }   

    }

    protected void Delete(object sender, EventArgs e)
    {

        LinkButton lbutton = (LinkButton)sender;

        Response.Redirect(lbutton.CommandArgument);

    }
}
