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 attekintes : System.Web.UI.Page
{
    protected int cegID;

    protected void Page_Load(object sender, EventArgs e)
    {
        string UserName = Page.User.Identity.Name;
        db.adatbazisMuveletek.UserNameToCegID(UserName, out cegID);
        tablaFeltolt();
        szCimFeltolt();
    }

    protected void tablaFeltolt()
    {
        db.cegLista cegLista = new db.cegLista();
        db.adatbazisMuveletek.cegAdatokLekerdezes(cegID, out cegLista);
        lblFejlec.Text = cegLista.cegNev;
        lblIrSzam0.Text = cegLista.irszam;
        lblHazszam0.Text = cegLista.hazszam;
        lblVaros0.Text = cegLista.varos;
        lblAdoszam0.Text = cegLista.adoszam.ToString();
        lblBanszamlaszam0.Text = cegLista.bankszamlaszam.ToString();
        lblEuadoszam0.Text = cegLista.euadoszam.ToString();
        lblHazszam0.Text = cegLista.hazszam.ToString();
        lblHitelkeret0.Text = cegLista.hitelkeret.ToString();
        lblUtca0.Text = cegLista.utca.ToString();
        
    }

    protected void szCimFeltolt()
    {
        div1.Controls.Clear();
        System.Collections.Generic.List<db.szallitasicim> szCimLista = new System.Collections.Generic.List<db.szallitasicim>();
        db.adatbazisMuveletek.szCimLekerdezCegIDalapjan(cegID, out szCimLista);


        Table table = new Table();
        table.Width = System.Web.UI.WebControls.Unit.Pixel(820);
        table.BorderStyle = BorderStyle.None;
        for (int i = 0; i < szCimLista.Count; i++)
        {
            db.kontakt kontakt = new db.kontakt();
            db.adatbazisMuveletek.szCimIdToKontakt(szCimLista[i].szCimID, out kontakt);

            Label varos = new Label();
            varos.Font.Bold = true;
            varos.Text = szCimLista[i].varos;
            varos.ID = "lblVaros" + i.ToString();

            Label utca = new Label();
            utca.Text = szCimLista[i].utcaHazszam;
            utca.ID = "lblUtcaHazszam" + i.ToString();

            Label irszam = new Label();
            irszam.Text = szCimLista[i].irszam;
            irszam.ID = "lblIrszam" + i.ToString();

            Label kontaktNev = new Label();
            kontaktNev.Text = kontakt.nev;
            kontaktNev.ID = "lblKontakt" + i.ToString();

            Label kontaktTel = new Label();
            kontaktTel.Text = kontakt.mobil;
            kontaktTel.ID = "lblKontaktTel" + i.ToString();

            Label kontaktMail = new Label();
            kontaktMail.Text = kontakt.email;
            kontaktMail.ID = "lblKontaktTel" + i.ToString();

            //_______________________________________________

            Label sorszam = new Label();
            sorszam.Font.Bold = true;
            sorszam.Text = i.ToString();
            sorszam.ID = "lblSorszam" + i.ToString();

            Label varos0 = new Label();
            varos0.Font.Bold = true;
            varos0.Text = "Város";
            varos0.ID = "lblVaros0" + i.ToString();

            Label utca0 = new Label();
            utca0.Font.Bold = true;
            utca0.Text = "Utca";
            utca0.ID = "lblUtcaHazszam0" + i.ToString();

            Label irszam0 = new Label();
            irszam0.Font.Bold = true;
            irszam0.Text = "Irányítószám";
            irszam0.ID = "lblIrszam0" + i.ToString();

            Label kontaktNev0 = new Label();
            kontaktNev0.Font.Bold = true;
            kontaktNev0.Text = "Kontakt";
            kontaktNev0.ID = "lblKontakt0" + i.ToString();

            Label kontaktTel0 = new Label();
            kontaktTel0.Font.Bold = true;
            kontaktTel0.Text = "Mobil";
            kontaktTel0.ID = "lblKontaktTel0" + i.ToString();

            Label kontaktMail0 = new Label();
            kontaktMail0.Font.Bold = true;
            kontaktMail0.Text = "e-mail";
            kontaktMail0.ID = "lblKontaktTel0" + i.ToString();

            TableCell tCell1 = new TableCell();
            TableCell tCell2 = new TableCell();
            TableCell tCell3 = new TableCell();
            TableCell tCell4 = new TableCell();
            TableCell tCell5 = new TableCell();
            TableCell tCell6 = new TableCell();
            TableCell tCell7 = new TableCell();
            TableCell tCell8 = new TableCell();
            TableCell tCell9 = new TableCell();
            TableCell tCell10 = new TableCell();
            TableCell tCell11 = new TableCell();
            TableCell tCell12 = new TableCell();
            TableCell tCell13 = new TableCell();

            tCell1.Controls.Add(sorszam);
            tCell1.Width = System.Web.UI.WebControls.Unit.Pixel(100);

            tCell2.Controls.Add(varos0);
            tCell2.Width = System.Web.UI.WebControls.Unit.Pixel(100);
            tCell3.Controls.Add(utca0);
            tCell3.Width = System.Web.UI.WebControls.Unit.Pixel(100);
            tCell4.Controls.Add(irszam0);
            tCell4.Width = System.Web.UI.WebControls.Unit.Pixel(100);
            tCell5.Controls.Add(kontaktNev0);
            tCell5.Width = System.Web.UI.WebControls.Unit.Pixel(100);
            tCell6.Controls.Add(kontaktTel0);
            tCell6.Width = System.Web.UI.WebControls.Unit.Pixel(100);
            tCell7.Controls.Add(kontaktMail0);
            tCell7.Width = System.Web.UI.WebControls.Unit.Pixel(100);

            tCell8.Controls.Add(varos);
            tCell8.Width = System.Web.UI.WebControls.Unit.Pixel(100);
            tCell9.Controls.Add(utca);
            tCell9.Width = System.Web.UI.WebControls.Unit.Pixel(100);
            tCell10.Controls.Add(irszam);
            tCell10.Width = System.Web.UI.WebControls.Unit.Pixel(100);
            tCell11.Controls.Add(kontaktNev);
            tCell11.Width = System.Web.UI.WebControls.Unit.Pixel(100);
            tCell12.Controls.Add(kontaktTel);
            tCell12.Width = System.Web.UI.WebControls.Unit.Pixel(100);
            tCell13.Controls.Add(kontaktMail);
            tCell13.Width = System.Web.UI.WebControls.Unit.Pixel(100);

            TableRow tRow1 = new TableRow();
            TableRow tRow2 = new TableRow();
            TableRow tRow3 = new TableRow();
            TableRow tRow4 = new TableRow();
            TableRow tRow5 = new TableRow();
            TableRow tRow6 = new TableRow();
            TableRow tRow7 = new TableRow();

            

                tRow1.Controls.Add(tCell1);
                tRow2.Controls.Add(tCell2);
                tRow2.Controls.Add(tCell8);
                tRow3.Controls.Add(tCell3);
                tRow3.Controls.Add(tCell9);
                tRow4.Controls.Add(tCell4);
                tRow4.Controls.Add(tCell10);
                tRow5.Controls.Add(tCell5);
                tRow5.Controls.Add(tCell11);
                tRow6.Controls.Add(tCell6);
                tRow6.Controls.Add(tCell12);
                tRow7.Controls.Add(tCell7);
                tRow7.Controls.Add(tCell13);
                            

                table.Controls.Add(tRow1);
                table.Controls.Add(tRow2);
                table.Controls.Add(tRow3);
                table.Controls.Add(tRow4);
                table.Controls.Add(tRow5);
                table.Controls.Add(tRow6);
                table.Controls.Add(tRow7);
               
        }
       
        div1.Controls.Add(table);
    }

}
