using System;
using System.Collections;
using System.Configuration;
using System.Data;
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;
public partial class Adresar : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if ((!IsPostBack) && (wquObec.Active == false))
{
wquObec.ConnectString = "Database=db;Data Source=localhost;User Id=root;Password=aa21aa;";
wquObec.SQLSelect = @"SELECT COBEC.ID_OBEC AS IDOBEC, COBEC.NAZOV_OBEC AS OBEC,
COBEC.ID_OKRES AS IDOKRES, COKRES.NAZOV_OKRES AS OKRES,
COBEC.ID_KRAJ AS IDKRAJ,CKRAJ.NAZOV_KRAJ AS KRAJ
FROM
COBEC,COKRES,CKRAJ
WHERE COBEC.ID_OKRES=COKRES.ID_OKRES AND
COBEC.ID_KRAJ=CKRAJ.ID_KRAJ";
wquObec.Open();
wquObec.Columns["IDOBEC"].Caption = "Id Obec";
wquObec.Columns["OBEC"].Caption = "Obec";
wquObec.Columns["IDOKRES"].Caption = "Id Okres";
wquObec.Columns["OKRES"].Caption = "Okres";
wquObec.Columns["IDKRAJ"].Caption = "Id Kraj";
wquObec.Columns["KRAJ"].Caption = "Kraj";
}
else
{
}
if ((!IsPostBack)&&(wquAdresar.Active==false))
{
string sSQLText1 = "SELECT IDPRAVFORM AS aKEY, NAME AS aVALUE FROM PRAVFORM ORDER BY NAME";
wquAdresar.ConnectString = "Database=db;Data Source=localhost;User Id=root;Password=aa21aa;";
wquAdresar.SQLSelect = @"SELECT IDADRESAR , NAME, ADDRESS, IDPRAVNAFORMA,
CREATE_DATE, INVALID_ADRESS, IDKRAJ, IDOKRES,
IDOBEC, TEL1, TEL_POZN1, TEL2, TEL_POZN2,
TEL3, TEL_POZN3, FAX1, FAX_POZN1,
FAX2, FAX_POZN2 FROM ADRESAR04";
wquAdresar.AddParamKey("IDPRAVNAFORMA", "aKEY", "aVALUE", "aVALUE", "aKEY", sSQLText1);
wquAdresar.AddParamCheck("INVALID_ADRESS", "A", "N", false);
wquAdresar.AddParamFlyComboBox("miesto", "idkraj;idokres;idobec", "idkraj;idokres;idobec", "kraj;okres;obec",
"Obec;Okres;Kraj", "wquObec", "mvNameAndBR");
wquAdresar.AddParamGreatWebQuery("Telefon", "Tel1;Tel_Pozn1", "Tel1 - Tel_Pozn1", 3, "mvLineNumber");
wquAdresar.AddParamGreatWebQuery("Fax", "Fax1;Fax_Pozn1", "Fax1 - Fax_Pozn1", 2, "");
//wquSposOsoba.AddParamFlyComboBox("Miesto1", "IDKraj1;IDOKRES1;IDOBEC1", "IDKRAJ;IDOKRES;IDOBEC", "KRAJ;OKRES;OBEC", "OBEC;OKRES", "wquObec", "mvStandard");
wquAdresar.Open();
wquAdresar.Columns["idadresar"].Caption = "ID";
wquAdresar.Columns["name"].Caption = "Meno Osoby";
wquAdresar.Columns["idpravnaforma"].Caption = "Právna Forma";
wquAdresar.Columns["address"].Caption = "Ulica";
wquAdresar.Columns["create_date"].Caption = "Dátum založenia";
wquAdresar.Columns["invalid_adress"].Caption = "Adresa neplatná";
wquAdresar.Columns["miesto"].Caption = "Obec, Okres";
wquAdresar.Columns["tel1"].Caption = "Telefón";
wquAdresar.Columns["tel_pozn1"].Caption = "Poznámka";
wquAdresar.Columns["tel2"].Caption = "Telefón";
wquAdresar.Columns["tel_pozn2"].Caption = "Poznámka";
wquAdresar.Columns["tel3"].Caption = "Telefón";
wquAdresar.Columns["tel_pozn3"].Caption = "Poznámka";
wquAdresar.Columns["fax1"].Caption = "Fax";
wquAdresar.Columns["fax_pozn1"].Caption = "Poznámka";
wquAdresar.Columns["fax2"].Caption = "Fax";
wquAdresar.Columns["fax_pozn2"].Caption = "Poznámka";
wquAdresar.Columns["telefon"].Caption = "Spojenie";
}
else
{
}
grdAdresar.VisibleFields = "idadresar;name;idpravnaforma;address;miesto;telefon";
dbnAdresar.PxDataSource = wquAdresar;
dbnAdresar.PxVisibleButtons = "FRNL";
grdAdresar.PxVisibleButtons = "S";
grdAdresar.PxDataSource = wquAdresar;
grdAdresar.DataBind();
}
protected void btnEdit_Click(object sender, EventArgs e)
{
if (wquAdresar.Find("%a%", "name") != -1)
{
wquAdresar.Edit();
wquAdresar.Fields["name"] = "Juraj Peter Tarnoci";
wquAdresar.Fields["idpravnaforma"] = "Fyzická osoba";
wquAdresar.Fields["address"] = "Fatranska 22";
wquAdresar.Fields["create_date"] = "12.10.2010";
wquAdresar.Fields["invalid_adress"] = "N";
wquAdresar.Post();
}
}
protected void btnInsert_Click(object sender, EventArgs e)
{
wquAdresar.Insert();
wquAdresar.Fields["name"] = "Grof Monte Christo";
wquAdresar.Fields["idpravnaforma"] = "Fyzická osoba";
wquAdresar.Fields["address"] = "Karlovarska 2";
wquAdresar.Fields["create_date"] = "04.07.2010";
wquAdresar.Fields["invalid_adress"] = "N";
wquAdresar.Post();
}
protected void btnEof_Click(object sender, EventArgs e)
{
wquAdresar.First();
string s = String.Empty;
while (!wquAdresar.Eof())
{
s = s + ", " + wquAdresar.Fields["name"].ToString();
wquAdresar.Next();
}
lblAdresar.Text = s;
}
protected void btnBof_Click(object sender, EventArgs e)
{
wquAdresar.Last();
string s = String.Empty;
while (!wquAdresar.Bof())
{
s = s + ", " + wquAdresar.Fields["name"].ToString();
wquAdresar.Prior();
}
lblAdresar2.Text = s;
}
protected void btnFind_Click(object sender, EventArgs e)
{
if (wquAdresar.Find("%ško%", "name") != -1)
lblAdresar3.Text = wquAdresar.Fields["name"].ToString();
}
protected void btnFindByIdPK_Click(object sender, EventArgs e)
{
if (wquAdresar.FindByIdPK(6) != -1)
lblAdresar4.Text = wquAdresar.Fields["name"].ToString();
}
protected void btnSetPosition_Click(object sender, EventArgs e)
{
if (wquAdresar.FindByIdPK(6) != -1)
wquAdresar.ItemIndex = wquAdresar.FindByIdPK(6);
}
protected void btnDelete_Click(object sender, EventArgs e)
{
wquAdresar.Delete();
}
protected void btnLoadRows_Click(object sender, EventArgs e)
{
//Vypise cisla Id riadkov, ktore vyhovuju vvyberovemu kriteriu
DataRow[] dr = null;
dr = wquAdresar.DataSource().Select("name like '%a%'", "name");
ArrayList aList = new ArrayList();
Int32 iOrdValue = 0;
for (Int32 iCykl = 0; iCykl < dr.Length; iCykl++)
{
//Tato klauzula vykonava DISTINCT
if (!aList.Contains(dr[iCykl].ItemArray.GetValue(iOrdValue).ToString()))
{
aList.Add(dr[iCykl].ItemArray.GetValue(iOrdValue).ToString());
}
}
string s = String.Empty;
for (Int32 iCykl2 = 0; iCykl2 < aList.Count; iCykl2++)
{
s = s + ", " + aList[iCykl2].ToString();
}
lblAdresar5.Text = s;
}
protected void btnVer_Click(object sender, EventArgs e)
{
lblAdresar5.Text = wquAdresar.Version;
}
}