protected void btnYes_Click_Click(object sender, EventArgs e)
        {
            //CREATE SOME INSTANCE OF TH ADDRESS BOOK
            ClsAddressCollection AddressBook = new ClsAddressCollection();

            //Find the record to delete
            AddressBook.ThisAddress.Find(AddressNo);
            //delete the record
            AddressBook.Delete();
            //redirect back to the main page
            Response.Redirect("AddressList.aspx");
        }
Example #2
0
        protected void btnApply_Click(object sender, EventArgs e)
        {
            //create an instance of the address collection
            ClsAddressCollection Addresses = new ClsAddressCollection();

            Addresses.ReportByPostCode(txtFilter.Text);
            lstAddressList.DataSource = Addresses.AddressList;
            //set the name of the primary key
            lstAddressList.DataValueField = "AddressNo";
            //set the name of the field to display
            lstAddressList.DataTextField = "PostCode";
            //bind the data to the list
            lstAddressList.DataBind();
        }
Example #3
0
        protected void btnClear_Click(object sender, EventArgs e)
        {
            //create an instance of the address collection
            ClsAddressCollection Addresses = new ClsAddressCollection();

            Addresses.ReportByPostCode("");
            //clear any existing filter to tidy up the interface
            txtFilter.Text            = "";
            lstAddressList.DataSource = Addresses.AddressList;
            //set the name of the primary key
            lstAddressList.DataValueField = "AddressNo";
            //set the name of the field to display
            lstAddressList.DataTextField = "PostCode";
            //bind the data to the list
            lstAddressList.DataBind();
        }
Example #4
0
        void DisplayAddresses()
        {
            ClsAddressCollection AddressesBook = new ClsAddressCollection();

            //find the record to update
            AddressesBook.ThisAddress.Find(AddressNo);
            //display the data for this record
            txtAddressNo.Text = AddressesBook.ThisAddress.AddressNo.ToString();
            txtHouseNo.Text   = AddressesBook.ThisAddress.HouseNo;
            txtStreet.Text    = AddressesBook.ThisAddress.Street;
            txtTown.Text      = AddressesBook.ThisAddress.Town;
            txtPostCode.Text  = AddressesBook.ThisAddress.PostCode;
            txtDateAdded.Text = AddressesBook.ThisAddress.DateAdded.ToString();
            chkActive.Checked = AddressesBook.ThisAddress.Active;
            txtCounty.Text    = AddressesBook.ThisAddress.CountyNo.ToString();
        }
Example #5
0
        public void btnOK_Clicked(object sender, EventArgs args)
        {
            ClsAddress AnAddress = new ClsAddress();
            //capture the house no
            string HouseNo = txtHouseNo.Text;
            //capture the street
            string Street = txtStreet.Text;
            //capture the town
            string Town = txtTown.Text;
            //capture the post code
            string PostCode = txtPostalCode.Text;
            //capture the county
            string CountyNo = txtCounty.Text;
            //capture date added
            string DateAdded = Convert.ToDateTime(txtDateAdded.Text);
            //Store the address in th session object
            //variable to store any error message
            string Error = "";

            Error = AnAddress.Valid(HouseNo, Street, Town, PostCode, DateAdded);
            if (Error == "")
            {
                //capture the address no
                AnAddress.AddressNo = AddressNo;
                //capture the house no
                AnAddress.HouseNo = HouseNo;
                //capture the street
                AnAddress.Street = Street;
                //capture the town
                AnAddress.Town = Town;
                //capture the post code
                AnAddress.PostCode = PostCode;
                //capture the county
                AnAddress.CountyNo = Convert.ToInt32(CountyNo);
                //capture date added
                AnAddress.DateAdded = Convert.ToDateTime(DateAdded);
                //capture active
                AnAddress.Active = chkActive.Checked;
                //Store the address in th session object
                //create new instance of the address collection
                ClsAddressCollection AddressList = new ClsAddressCollection();

                if (AddressNo == -1)
                {
                    //set the ThisAddress property
                    AddressList.ThisAddress = AnAddress;
                    //add the new record
                    AddressList.Add();
                }
                //otherwise
                else
                {
                    //find the record to update
                    AddressList.ThisAddress.Find(AddressNo);
                    //set the ThisAddress property
                    AddressList.ThisAddress = AnAddress;
                    //update the record
                    AddressList.Update();
                }
                //redirect back to the listpage
                Response.Redirect("AnAddressList.aspx");
            }
            else
            {
                //display the error message
                lblError.Text = Error;
            }
        }