Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                txtATID.Visible = false;
                ddlAddressTypeID.Enabled = true;
                DataManager.DataAccess da2 = new DataManager.DataAccess();
                DataSet ds3 = new DataSet();
                ds3 = da2.FetchAddressTypes();
                ddlAddressTypeID.DataSource = ds3.Tables[0];

                //The DataTextField is the value of what will show in the ddl
                // the DataValueField is the Value of the
                ddlAddressTypeID.DataTextField = "Name";
                ddlAddressTypeID.DataValueField = "AddressTypeID";
                ddlAddressTypeID.DataBind();

                ddlAddressTypeID.Items.Insert(0, new ListItem("PLEASE SELECT ADDRESS TYPE", string.Empty));

                if (Request.QueryString["Mode"] == null)
                {
                    Request.QueryString["Mode"] = "New";
                    //Response.Redirect("AddressForm.aspx?Mode=Edit");
                }
                if (Request.QueryString["PersonID"] != null)
                {
                    txtID.Text = Request.QueryString["PersonID"].ToString();
                    //

                }

                if (Request.QueryString["addressID"] != null)
                {
                    txtAID.Text = Request.QueryString["addressID"].ToString();
                }

                if (Request.QueryString != null)
                {

                    string mode = Request.QueryString["Mode"];
                    // if mode = null then mode = new
                    //one other way would be to get rid of the test and in the switch statement  view edit delete and instead of case new
                    // change that so that you are doing it to false      whenmode is new, view,   a default case   would be new
                    switch (mode)
                    {

                        case "View":
                            //btnDone.Visible = true;
                            //btnSave.Visible = false;
                            btnDelete.Visible = false;

                            //LoadPerson();

                            //txtID.Enabled = false;
                            //txtFirstName.Enabled = false;
                            //txtLastName.Enabled = false;
                            //btnCancel.Visible = false;
                            //fillPhoneGrid();
                            //fillAddressGrid();
                            //fillEmail();

                            break;

                        case "New":

                            //btnDone.Visible = false;
                            btnSave.Visible = true;
                            //btnDelete.Visible = false;

                            // LoadPerson();

                            txtID.Enabled = false;
                            ddlAddressTypeID.Visible = true;
                            btnDelete.Visible = false;
                            //txtFirstName.Enabled = true;
                            //txtLastName.Enabled = true;
                            //btnAddPhoneNum.Visible = false;
                            ddlAddressTypeID.SelectedIndex = 0;

                            break;

                        case "Edit":

                            //btnDone.Visible = true;
                            btnSave.Visible = true;
                            //btnDelete.Visible = false;
                            btnDelete.Visible = false;
                            //LoadPerson();

                            txtID.Enabled = false;
                            ddlAddressTypeID.Visible = true;
                            ddlAddressTypeID.Enabled = true;

                            int id = Convert.ToInt32(txtID.Text);

                            loadPerson(id);

                    //                 DataPortal.PersonData pd = new DataPortal.PersonData();
                    //        DataSet pds = new DataSet();
                    //        int PersonID = Convert.ToInt32(txtID.Text);
                    //        pds = pd.Fetch(PersonID);
                    //        object fn = pds.Tables[0].Rows[0]["FirstName"].ToString();
                    //        object ln = pds.Tables[0].Rows[0]["LastName"].ToString();
                    //        ////////txtFirstName.Text = fn.ToString();
                    //        ////////txtLastName.Text = ln.ToString();
                    //        lblFirstName.Text = fn.ToString();
                    //        lblLastName.Text = ln.ToString();

                    //DataPortal.PersonAddressData pad = new DataPortal.PersonAddressData();
                    //DataSet ds = new DataSet();

                            int AddressID = Convert.ToInt32(txtAID.Text);
                            BusinessObjects.PersonAddress personAddress = new BusinessObjects.PersonAddress();

                            DataSet ds = new DataSet();

                            ds = personAddress.LoadAddress(id, AddressID);

                            txtStreet1.Text = ds.Tables[0].Rows[0]["Street1"].ToString();
                            txtStreet2.Text = ds.Tables[0].Rows[0]["Street2"].ToString();

                            txtCity.Text = ds.Tables[0].Rows[0]["City"].ToString();
                            txtState.Text = ds.Tables[0].Rows[0]["State"].ToString();
                            txtZip.Text = ds.Tables[0].Rows[0]["Zip"].ToString();
                            txtNotes.Text = ds.Tables[0].Rows[0]["Notes"].ToString();
                            txtDescription.Text = ds.Tables[0].Rows[0]["Description"].ToString();

                    //int AddressID = Convert.ToInt32(txtAID.Text);
                    //ds = pad.Fetch(PersonID, AddressID);
                    //object s1 = ds.Tables[0].Rows[0]["Street1"].ToString();
                    //object s2 = ds.Tables[0].Rows[0]["Street2"].ToString();
                    //object ci = ds.Tables[0].Rows[0]["City"].ToString();
                    //object st = ds.Tables[0].Rows[0]["State"].ToString();
                    //object zi = ds.Tables[0].Rows[0]["Zip"].ToString();
                    //object atid = ds.Tables[0].Rows[0]["AddressTypeID"].ToString();
                    //object d = ds.Tables[0].Rows[0]["Description"].ToString();
                    //object n = ds.Tables[0].Rows[0]["Notes"].ToString();
                    //txtStreet1.Text = s1.ToString();
                    //txtStreet2.Text = s2.ToString();
                    //txtCity.Text = ci.ToString();
                    //txtState.Text = st.ToString();
                    //txtZip.Text = zi.ToString();
                    //ddlAddressTypeID.Text = atid.ToString();
                    //txtATID.Text = atid.ToString();
                    //txtDescription.Text = d.ToString();
                    //txtNotes.Text = n.ToString();

                            break;

                        case "Delete":

                             btnSave.Visible = false;
                            //btnDelete.Visible = false;
                            btnDelete.Visible = true;
                            //LoadPerson();

                            txtID.Enabled = false;
                            ddlAddressTypeID.Visible = true;
                            ddlAddressTypeID.Enabled = true;
                   //         pd = new DataPortal.PersonData();
                   //  pds = new DataSet();
                   //   PersonID = Convert.ToInt32(txtID.Text);

                   // pds = pd.Fetch(PersonID);
                   //fn = pds.Tables[0].Rows[0]["FirstName"].ToString();
                   //ln = pds.Tables[0].Rows[0]["LastName"].ToString();

                   // lblFirstName.Text = fn.ToString();
                   // lblLastName.Text = ln.ToString();

                   // pad = new DataPortal.PersonAddressData();
                   // ds = new DataSet();
                   // AddressID = Convert.ToInt32(txtAID.Text);
                   // ds = pad.Fetch(PersonID, AddressID);
                   // s1 = ds.Tables[0].Rows[0]["Street1"].ToString();
                   // s2 = ds.Tables[0].Rows[0]["Street2"].ToString();
                   //  ci = ds.Tables[0].Rows[0]["City"].ToString();
                   //  st = ds.Tables[0].Rows[0]["State"].ToString();
                   //  zi = ds.Tables[0].Rows[0]["Zip"].ToString();
                   //  atid = ds.Tables[0].Rows[0]["AddressTypeID"].ToString();
                   //  d = ds.Tables[0].Rows[0]["Description"].ToString();
                   //  n = ds.Tables[0].Rows[0]["Notes"].ToString();
                   // txtStreet1.Text = s1.ToString();
                   // txtStreet2.Text = s2.ToString();
                   // txtCity.Text = ci.ToString();
                   // txtState.Text = st.ToString();
                   // txtZip.Text = zi.ToString();
                   // ddlAddressTypeID.Text = atid.ToString();
                   // txtATID.Text = atid.ToString();
                   // txtDescription.Text = d.ToString();
                   // txtNotes.Text = n.ToString();

                   // txtStreet1.Enabled = false;
                   //         //city state zip notes description
                   // txtStreet2.Enabled = false;
                   // txtCity.Enabled = false;
                   // txtState.Enabled = false;
                   // txtZip.Enabled = false;
                   // txtNotes.Enabled = false;
                   // txtDescription.Enabled = false;
                   // ddlAddressTypeID.Enabled = false;

                            break;
                    }

                }

                if (txtID.Text != "")
                {
                    if (txtAID.Text == null)
                    {
                        //DataPortal.PersonData pd = new DataPortal.PersonData();
                        //DataSet pds = new DataSet();
                        //int PersonID = Convert.ToInt32(txtID.Text);
                        //pds = pd.Fetch(PersonID);
                        //object fn = pds.Tables[0].Rows[0]["FirstName"].ToString();
                        //object ln = pds.Tables[0].Rows[0]["LastName"].ToString();

                        int id = Convert.ToInt32(txtID.Text);
                        loadPerson(id);

                      //  DataPortal.PersonAddressData pad = new DataPortal.PersonAddressData();
                      //  DataSet ds = new DataSet();

                      //  int AddressID = Convert.ToInt32(txtAID.Text);

                      //  ds = pad.Fetch(PersonID, AddressID);
                      //  object s1 = ds.Tables[0].Rows[0]["Street1"].ToString();
                      //  object s2 = ds.Tables[0].Rows[0]["Street2"].ToString();
                      //  object ci = ds.Tables[0].Rows[0]["City"].ToString();
                      //  object st = ds.Tables[0].Rows[0]["State"].ToString();
                      //  object zi = ds.Tables[0].Rows[0]["Zip"].ToString();
                      //  object atid = ds.Tables[0].Rows[0]["AddressTypeID"].ToString();

                      //  object d = ds.Tables[0].Rows[0]["Description"].ToString();
                      //  object n = ds.Tables[0].Rows[0]["Notes"].ToString();

                      //  txtStreet1.Text = s1.ToString();
                      //  txtStreet2.Text = s2.ToString();
                      //  txtCity.Text = ci.ToString();
                      //  txtState.Text = st.ToString();
                      //  txtZip.Text = zi.ToString();
                      //txtATID.Text = atid.ToString();
                      //  txtDescription.Text = d.ToString();
                      //  txtNotes.Text = n.ToString();

                         int AddressID = Convert.ToInt32(txtAID.Text);
                            BusinessObjects.PersonAddress personAddress = new BusinessObjects.PersonAddress();

                            DataSet ds = new DataSet();

                            ds = personAddress.LoadAddress(id, AddressID);

                            txtStreet1.Text = ds.Tables[0].Rows[0]["Street1"].ToString();
                            txtStreet2.Text = ds.Tables[0].Rows[0]["Street2"].ToString();

                            txtCity.Text = ds.Tables[0].Rows[0]["City"].ToString();
                            txtState.Text = ds.Tables[0].Rows[0]["State"].ToString();
                            txtZip.Text = ds.Tables[0].Rows[0]["Zip"].ToString();
                            txtNotes.Text = ds.Tables[0].Rows[0]["Notes"].ToString();
                            txtDescription.Text = ds.Tables[0].Rows[0]["Description"].ToString();

                        //DataManager.DataAccess da = new DataManager.DataAccess();
                        DataSet ds2 = new DataSet();
                        //ds2 = pad.FetchAddressTypes();
                        //ddlAddressTypeID.DataSource = ds2.Tables[0];

                        BusinessObjects.PersonAddress pa = new BusinessObjects.PersonAddress();
                      ds2 = pa.FetchDataTypes();
                      ddlAddressTypeID.DataSource = ds2.Tables[0];

                        //The DataTextField is the value of what will show in the ddl
                        // the DataValueField is the Value of the
                        ddlAddressTypeID.DataTextField = "Name";
                        ddlAddressTypeID.DataValueField = "AddressTypeID";
                        ddlAddressTypeID.DataBind();

                        //  DataPortal.PersonAddressData pad = new DataPortal.PersonAddressData();
                        //  //DataManager.DataAccess da = new DataManager.DataAccess();
                        //  DataSet ds = new DataSet();
                        //  //DataSet dsPersons = new DataSet();
                        ///////  int PersonID = Convert.ToInt32(txtID.Text);
                        //  int AddressID = Convert.ToInt32(txtAID.Text);

                        //  ds = pad.Fetch(PersonID, AddressID);
                        //  //  txtFirstName.Text =
                        //  object s1 = ds.Tables[0].Rows[0]["Street1"];
                        //  object s2 = ds.Tables[0].Rows[0]["Street2"];

                        //  txtStreet1.Text = s1.ToString();
                        //  txtStreet2.Text = s2.ToString();

                        //gvPersonName.DataSource = dsPersons;
                        //gvPersonName.DataBind();

                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtATID.Visible          = false;
                ddlAddressTypeID.Enabled = true;
                DataManager.DataAccess da2 = new DataManager.DataAccess();
                DataSet ds3 = new DataSet();
                ds3 = da2.FetchAddressTypes();
                ddlAddressTypeID.DataSource = ds3.Tables[0];

                //The DataTextField is the value of what will show in the ddl
                // the DataValueField is the Value of the
                ddlAddressTypeID.DataTextField  = "Name";
                ddlAddressTypeID.DataValueField = "AddressTypeID";
                ddlAddressTypeID.DataBind();

                ddlAddressTypeID.Items.Insert(0, new ListItem("PLEASE SELECT ADDRESS TYPE", string.Empty));


                if (Request.QueryString["Mode"] == null)
                {
                    Request.QueryString["Mode"] = "New";
                    //Response.Redirect("AddressForm.aspx?Mode=Edit");
                }
                if (Request.QueryString["PersonID"] != null)
                {
                    txtID.Text = Request.QueryString["PersonID"].ToString();
                    //
                }

                if (Request.QueryString["addressID"] != null)
                {
                    txtAID.Text = Request.QueryString["addressID"].ToString();
                }

                if (Request.QueryString != null)
                {
                    string mode = Request.QueryString["Mode"];
                    // if mode = null then mode = new
                    //one other way would be to get rid of the test and in the switch statement  view edit delete and instead of case new
                    // change that so that you are doing it to false      whenmode is new, view,   a default case   would be new
                    switch (mode)
                    {
                    case "View":
                        //btnDone.Visible = true;
                        //btnSave.Visible = false;
                        btnDelete.Visible = false;

                        //LoadPerson();

                        //txtID.Enabled = false;
                        //txtFirstName.Enabled = false;
                        //txtLastName.Enabled = false;
                        //btnCancel.Visible = false;
                        //fillPhoneGrid();
                        //fillAddressGrid();
                        //fillEmail();

                        break;

                    case "New":

                        //btnDone.Visible = false;
                        btnSave.Visible = true;
                        //btnDelete.Visible = false;

                        // LoadPerson();

                        txtID.Enabled            = false;
                        ddlAddressTypeID.Visible = true;
                        btnDelete.Visible        = false;
                        //txtFirstName.Enabled = true;
                        //txtLastName.Enabled = true;
                        //btnAddPhoneNum.Visible = false;
                        ddlAddressTypeID.SelectedIndex = 0;

                        break;

                    case "Edit":

                        //btnDone.Visible = true;
                        btnSave.Visible = true;
                        //btnDelete.Visible = false;
                        btnDelete.Visible = false;
                        //LoadPerson();

                        txtID.Enabled            = false;
                        ddlAddressTypeID.Visible = true;
                        ddlAddressTypeID.Enabled = true;

                        int id = Convert.ToInt32(txtID.Text);

                        loadPerson(id);


                        //                 DataPortal.PersonData pd = new DataPortal.PersonData();
                        //        DataSet pds = new DataSet();
                        //        int PersonID = Convert.ToInt32(txtID.Text);
                        //        pds = pd.Fetch(PersonID);
                        //        object fn = pds.Tables[0].Rows[0]["FirstName"].ToString();
                        //        object ln = pds.Tables[0].Rows[0]["LastName"].ToString();
                        //        ////////txtFirstName.Text = fn.ToString();
                        //        ////////txtLastName.Text = ln.ToString();
                        //        lblFirstName.Text = fn.ToString();
                        //        lblLastName.Text = ln.ToString();

                        //DataPortal.PersonAddressData pad = new DataPortal.PersonAddressData();
                        //DataSet ds = new DataSet();

                        int AddressID = Convert.ToInt32(txtAID.Text);
                        BusinessObjects.PersonAddress personAddress = new BusinessObjects.PersonAddress();

                        DataSet ds = new DataSet();

                        ds = personAddress.LoadAddress(id, AddressID);

                        txtStreet1.Text = ds.Tables[0].Rows[0]["Street1"].ToString();
                        txtStreet2.Text = ds.Tables[0].Rows[0]["Street2"].ToString();

                        txtCity.Text        = ds.Tables[0].Rows[0]["City"].ToString();
                        txtState.Text       = ds.Tables[0].Rows[0]["State"].ToString();
                        txtZip.Text         = ds.Tables[0].Rows[0]["Zip"].ToString();
                        txtNotes.Text       = ds.Tables[0].Rows[0]["Notes"].ToString();
                        txtDescription.Text = ds.Tables[0].Rows[0]["Description"].ToString();


                        //int AddressID = Convert.ToInt32(txtAID.Text);
                        //ds = pad.Fetch(PersonID, AddressID);
                        //object s1 = ds.Tables[0].Rows[0]["Street1"].ToString();
                        //object s2 = ds.Tables[0].Rows[0]["Street2"].ToString();
                        //object ci = ds.Tables[0].Rows[0]["City"].ToString();
                        //object st = ds.Tables[0].Rows[0]["State"].ToString();
                        //object zi = ds.Tables[0].Rows[0]["Zip"].ToString();
                        //object atid = ds.Tables[0].Rows[0]["AddressTypeID"].ToString();
                        //object d = ds.Tables[0].Rows[0]["Description"].ToString();
                        //object n = ds.Tables[0].Rows[0]["Notes"].ToString();
                        //txtStreet1.Text = s1.ToString();
                        //txtStreet2.Text = s2.ToString();
                        //txtCity.Text = ci.ToString();
                        //txtState.Text = st.ToString();
                        //txtZip.Text = zi.ToString();
                        //ddlAddressTypeID.Text = atid.ToString();
                        //txtATID.Text = atid.ToString();
                        //txtDescription.Text = d.ToString();
                        //txtNotes.Text = n.ToString();



                        break;

                    case "Delete":


                        btnSave.Visible = false;
                        //btnDelete.Visible = false;
                        btnDelete.Visible = true;
                        //LoadPerson();

                        txtID.Enabled            = false;
                        ddlAddressTypeID.Visible = true;
                        ddlAddressTypeID.Enabled = true;
                        //         pd = new DataPortal.PersonData();
                        //  pds = new DataSet();
                        //   PersonID = Convert.ToInt32(txtID.Text);

                        // pds = pd.Fetch(PersonID);
                        //fn = pds.Tables[0].Rows[0]["FirstName"].ToString();
                        //ln = pds.Tables[0].Rows[0]["LastName"].ToString();

                        // lblFirstName.Text = fn.ToString();
                        // lblLastName.Text = ln.ToString();

                        // pad = new DataPortal.PersonAddressData();
                        // ds = new DataSet();
                        // AddressID = Convert.ToInt32(txtAID.Text);
                        // ds = pad.Fetch(PersonID, AddressID);
                        // s1 = ds.Tables[0].Rows[0]["Street1"].ToString();
                        // s2 = ds.Tables[0].Rows[0]["Street2"].ToString();
                        //  ci = ds.Tables[0].Rows[0]["City"].ToString();
                        //  st = ds.Tables[0].Rows[0]["State"].ToString();
                        //  zi = ds.Tables[0].Rows[0]["Zip"].ToString();
                        //  atid = ds.Tables[0].Rows[0]["AddressTypeID"].ToString();
                        //  d = ds.Tables[0].Rows[0]["Description"].ToString();
                        //  n = ds.Tables[0].Rows[0]["Notes"].ToString();
                        // txtStreet1.Text = s1.ToString();
                        // txtStreet2.Text = s2.ToString();
                        // txtCity.Text = ci.ToString();
                        // txtState.Text = st.ToString();
                        // txtZip.Text = zi.ToString();
                        // ddlAddressTypeID.Text = atid.ToString();
                        // txtATID.Text = atid.ToString();
                        // txtDescription.Text = d.ToString();
                        // txtNotes.Text = n.ToString();

                        // txtStreet1.Enabled = false;
                        //         //city state zip notes description
                        // txtStreet2.Enabled = false;
                        // txtCity.Enabled = false;
                        // txtState.Enabled = false;
                        // txtZip.Enabled = false;
                        // txtNotes.Enabled = false;
                        // txtDescription.Enabled = false;
                        // ddlAddressTypeID.Enabled = false;

                        break;
                    }
                }

                if (txtID.Text != "")
                {
                    if (txtAID.Text == null)
                    {
                        //DataPortal.PersonData pd = new DataPortal.PersonData();
                        //DataSet pds = new DataSet();
                        //int PersonID = Convert.ToInt32(txtID.Text);
                        //pds = pd.Fetch(PersonID);
                        //object fn = pds.Tables[0].Rows[0]["FirstName"].ToString();
                        //object ln = pds.Tables[0].Rows[0]["LastName"].ToString();

                        int id = Convert.ToInt32(txtID.Text);
                        loadPerson(id);

                        //  DataPortal.PersonAddressData pad = new DataPortal.PersonAddressData();
                        //  DataSet ds = new DataSet();

                        //  int AddressID = Convert.ToInt32(txtAID.Text);

                        //  ds = pad.Fetch(PersonID, AddressID);
                        //  object s1 = ds.Tables[0].Rows[0]["Street1"].ToString();
                        //  object s2 = ds.Tables[0].Rows[0]["Street2"].ToString();
                        //  object ci = ds.Tables[0].Rows[0]["City"].ToString();
                        //  object st = ds.Tables[0].Rows[0]["State"].ToString();
                        //  object zi = ds.Tables[0].Rows[0]["Zip"].ToString();
                        //  object atid = ds.Tables[0].Rows[0]["AddressTypeID"].ToString();

                        //  object d = ds.Tables[0].Rows[0]["Description"].ToString();
                        //  object n = ds.Tables[0].Rows[0]["Notes"].ToString();

                        //  txtStreet1.Text = s1.ToString();
                        //  txtStreet2.Text = s2.ToString();
                        //  txtCity.Text = ci.ToString();
                        //  txtState.Text = st.ToString();
                        //  txtZip.Text = zi.ToString();
                        //txtATID.Text = atid.ToString();
                        //  txtDescription.Text = d.ToString();
                        //  txtNotes.Text = n.ToString();

                        int AddressID = Convert.ToInt32(txtAID.Text);
                        BusinessObjects.PersonAddress personAddress = new BusinessObjects.PersonAddress();

                        DataSet ds = new DataSet();

                        ds = personAddress.LoadAddress(id, AddressID);

                        txtStreet1.Text = ds.Tables[0].Rows[0]["Street1"].ToString();
                        txtStreet2.Text = ds.Tables[0].Rows[0]["Street2"].ToString();

                        txtCity.Text        = ds.Tables[0].Rows[0]["City"].ToString();
                        txtState.Text       = ds.Tables[0].Rows[0]["State"].ToString();
                        txtZip.Text         = ds.Tables[0].Rows[0]["Zip"].ToString();
                        txtNotes.Text       = ds.Tables[0].Rows[0]["Notes"].ToString();
                        txtDescription.Text = ds.Tables[0].Rows[0]["Description"].ToString();

                        //DataManager.DataAccess da = new DataManager.DataAccess();
                        DataSet ds2 = new DataSet();
                        //ds2 = pad.FetchAddressTypes();
                        //ddlAddressTypeID.DataSource = ds2.Tables[0];

                        BusinessObjects.PersonAddress pa = new BusinessObjects.PersonAddress();
                        ds2 = pa.FetchDataTypes();
                        ddlAddressTypeID.DataSource = ds2.Tables[0];


                        //The DataTextField is the value of what will show in the ddl
                        // the DataValueField is the Value of the
                        ddlAddressTypeID.DataTextField  = "Name";
                        ddlAddressTypeID.DataValueField = "AddressTypeID";
                        ddlAddressTypeID.DataBind();


                        //  DataPortal.PersonAddressData pad = new DataPortal.PersonAddressData();
                        //  //DataManager.DataAccess da = new DataManager.DataAccess();
                        //  DataSet ds = new DataSet();
                        //  //DataSet dsPersons = new DataSet();
                        ///////  int PersonID = Convert.ToInt32(txtID.Text);
                        //  int AddressID = Convert.ToInt32(txtAID.Text);

                        //  ds = pad.Fetch(PersonID, AddressID);
                        //  //  txtFirstName.Text =
                        //  object s1 = ds.Tables[0].Rows[0]["Street1"];
                        //  object s2 = ds.Tables[0].Rows[0]["Street2"];

                        //  txtStreet1.Text = s1.ToString();
                        //  txtStreet2.Text = s2.ToString();


                        //gvPersonName.DataSource = dsPersons;
                        //gvPersonName.DataBind();
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["Mode"] == null)
                {
                    // Request.QueryString["Mode"] = "New"; Try to adjust this right
                    Response.Redirect("EditPersonAddress.aspx?Mode=New");
                }

                string ModeStatus = Request.QueryString["Mode"];
                switch (ModeStatus)
                {
                case "New":
                    lblModeStatus.Text = "Add New Address";
                    break;

                case "View":
                    lblModeStatus.Text = "View Address";
                    break;

                case "Edit":
                    lblModeStatus.Text = "Edit Address";
                    break;

                case "Delete":
                    lblModeStatus.Text = "Delete Address";
                    break;
                }

                DataManager.DataAccess da = new DataManager.DataAccess();
                DataSet ds = new DataSet();
                ds = da.FetchAddressTypes();
                ddlAddressTypeID.DataSource = ds.Tables[0];

                //The DataTextField is the value of what will show in the ddl
                // the DataValueField is the Value of the
                ddlAddressTypeID.DataTextField  = "Name";
                ddlAddressTypeID.DataValueField = "AddressTypeID";
                ddlAddressTypeID.DataBind();
                //object phoneTypeID = da5.FetchPhoneTypes();

                if (Request.QueryString != null)
                {
                    if (Request.QueryString["PersonID"] != null)
                    {
                        this.txtID.Text = Request.QueryString["PersonID"].ToString();
                    }
                    string Mode = Request.QueryString["Mode"];

                    switch (Mode)
                    {
                    case "View":
                        btnDone.Visible   = true;
                        btnSave.Visible   = false;
                        btnDelete.Visible = false;
                        btnCancel.Visible = false;


                        LoadPersonAddress();

                        txtID.Enabled            = false;
                        txtAID.Enabled           = false;
                        ddlAddressTypeID.Enabled = false;
                        txtFullName.Enabled      = false;
                        txtStreet1.Enabled       = false;
                        txtStreet2.Enabled       = false;
                        txtCity.Enabled          = false;
                        txtState.Enabled         = false;
                        txtZip.Enabled           = false;
                        txtDescription.Enabled   = false;
                        txtNotes.Enabled         = false;


                        break;

                    case "New":

                        btnDone.Visible   = false;
                        btnSave.Visible   = true;
                        btnDelete.Visible = false;

                        // LoadPerson();
                        txtID.Enabled            = false;
                        txtAID.Enabled           = false;
                        ddlAddressTypeID.Enabled = true;
                        txtFullName.Enabled      = true;
                        txtStreet1.Enabled       = true;
                        txtStreet2.Enabled       = true;
                        txtCity.Enabled          = true;
                        txtState.Enabled         = true;
                        txtZip.Enabled           = true;
                        txtDescription.Enabled   = true;
                        txtNotes.Enabled         = true;
                        break;

                    case "Edit":

                        txtID.Enabled     = false;
                        btnDone.Visible   = true;
                        btnSave.Visible   = true;
                        btnDelete.Visible = false;
                        btnCancel.Visible = true;

                        txtID.Enabled            = false;
                        txtAID.Enabled           = false;
                        ddlAddressTypeID.Enabled = true;
                        txtFullName.Enabled      = false;
                        txtStreet1.Enabled       = true;
                        txtStreet2.Enabled       = true;
                        txtCity.Enabled          = true;
                        txtState.Enabled         = true;
                        txtZip.Enabled           = true;
                        txtDescription.Enabled   = true;
                        txtNotes.Enabled         = true;
                        object AddressID = Convert.ToInt32(Request.QueryString["AddressID"]);

                        txtAID.Text = AddressID.ToString();
                        LoadPersonAddress();
                        btnDone.Visible = false;

                        break;

                    case "Delete":

                        btnDone.Visible   = false;
                        btnSave.Visible   = false;
                        btnDelete.Visible = true;
                        //NameDisplayLabel.Visible = false;

                        LoadPersonAddress();

                        txtID.Enabled            = false;
                        txtAID.Enabled           = false;
                        ddlAddressTypeID.Enabled = false;
                        txtFullName.Enabled      = false;
                        txtStreet1.Enabled       = false;
                        txtStreet2.Enabled       = false;
                        txtCity.Enabled          = false;
                        txtState.Enabled         = false;
                        txtZip.Enabled           = false;
                        txtDescription.Enabled   = false;
                        txtNotes.Enabled         = false;
                        txtNotes.ReadOnly        = true;
                        txtDescription.ReadOnly  = true;
                        txtDescription.Enabled   = false;
                        txtNotes.Enabled         = false;
                        txtID.Enabled            = false;

                        break;

                    //Request.QueryString["PersonID"] = "New";
                    default:

                        break;
                    }
                }
                else
                {
                    Response.Redirect("FetchPerson.aspx");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

            if (Request.QueryString["Mode"] == null)
            {
                // Request.QueryString["Mode"] = "New"; Try to adjust this right
                Response.Redirect("EditPersonAddress.aspx?Mode=New");

            }

             string ModeStatus = Request.QueryString["Mode"];
                switch (ModeStatus)
                {
                    case "New":
                        lblModeStatus.Text = "Add New Address";
                        break;

                    case "View":
                        lblModeStatus.Text = "View Address";
                        break;

                    case "Edit":
                        lblModeStatus.Text = "Edit Address";
                        break;

                    case "Delete":
                        lblModeStatus.Text = "Delete Address";
                        break;
                }

                DataManager.DataAccess da = new DataManager.DataAccess();
                DataSet ds = new DataSet();
                ds = da.FetchAddressTypes();
                ddlAddressTypeID.DataSource = ds.Tables[0];

                //The DataTextField is the value of what will show in the ddl
                // the DataValueField is the Value of the
                ddlAddressTypeID.DataTextField = "Name";
                ddlAddressTypeID.DataValueField = "AddressTypeID";
                 ddlAddressTypeID.DataBind();
                //object phoneTypeID = da5.FetchPhoneTypes();

                if (Request.QueryString != null)
                {

                    if (Request.QueryString["PersonID"] != null)
                    {
                        this.txtID.Text = Request.QueryString["PersonID"].ToString();
                    }
                    string Mode = Request.QueryString["Mode"];

                    switch (Mode)
                    {

                        case "View":
                            btnDone.Visible = true;
                            btnSave.Visible = false;
                            btnDelete.Visible = false;
                            btnCancel.Visible = false;

                            LoadPersonAddress();

                            txtID.Enabled = false;
                            txtAID.Enabled = false;
                            ddlAddressTypeID.Enabled = false;
                            txtFullName.Enabled = false;
                            txtStreet1.Enabled = false;
                            txtStreet2.Enabled = false;
                            txtCity.Enabled = false;
                            txtState.Enabled = false;
                            txtZip.Enabled = false;
                            txtDescription.Enabled = false;
                            txtNotes.Enabled = false;

                            break;

                        case "New":

                            btnDone.Visible = false;
                            btnSave.Visible = true;
                            btnDelete.Visible = false;

                            // LoadPerson();
                           txtID.Enabled = false;
                            txtAID.Enabled = false;
                            ddlAddressTypeID.Enabled = true;
                            txtFullName.Enabled = true;
                            txtStreet1.Enabled = true;
                            txtStreet2.Enabled = true;
                            txtCity.Enabled = true;
                            txtState.Enabled = true;
                            txtZip.Enabled = true;
                            txtDescription.Enabled = true;
                            txtNotes.Enabled = true;
                            break;

                        case "Edit":

                            txtID.Enabled = false;
                            btnDone.Visible = true;
                            btnSave.Visible = true;
                            btnDelete.Visible = false;
                            btnCancel.Visible = true;

                           txtID.Enabled = false;
                            txtAID.Enabled = false;
                            ddlAddressTypeID.Enabled = true;
                            txtFullName.Enabled = false;
                            txtStreet1.Enabled = true;
                            txtStreet2.Enabled = true;
                            txtCity.Enabled = true;
                            txtState.Enabled = true;
                            txtZip.Enabled = true;
                            txtDescription.Enabled = true;
                            txtNotes.Enabled = true;
                           object AddressID = Convert.ToInt32(Request.QueryString["AddressID"]);

                           txtAID.Text = AddressID.ToString();
                           LoadPersonAddress();
                           btnDone.Visible = false;

                            break;

                        case "Delete":

                            btnDone.Visible = false;
                            btnSave.Visible = false;
                            btnDelete.Visible = true;
                            //NameDisplayLabel.Visible = false;

                            LoadPersonAddress();

                            txtID.Enabled = false;
                            txtAID.Enabled = false;
                            ddlAddressTypeID.Enabled = false;
                            txtFullName.Enabled = false;
                            txtStreet1.Enabled = false;
                            txtStreet2.Enabled = false;
                            txtCity.Enabled = false;
                            txtState.Enabled = false;
                            txtZip.Enabled = false;
                            txtDescription.Enabled = false;
                            txtNotes.Enabled = false;
                            txtNotes.ReadOnly = true;
                            txtDescription.ReadOnly = true;
                            txtDescription.Enabled = false;
                            txtNotes.Enabled = false;
                            txtID.Enabled = false;

                            break;

                        //Request.QueryString["PersonID"] = "New";
                        default:

                         break;
                    }
                }
                else
                {
                    Response.Redirect("FetchPerson.aspx");
                }
            }
        }