protected void Page_Load(object sender, EventArgs e)
        {
            String data;

            if (Request.QueryString["Mode"] != null)
            {
                //
            }
            else
            {
                data = Request.QueryString["Mode"].ToString();
            }

            //   ////////// Response.Redirect("EditPersonPhoneNumber.aspx?Mode=New");


            if (!IsPostBack)
            {
                string ModeStatus = Request.QueryString["Mode"];
                switch (ModeStatus)
                {
                case "New":
                    lblModeStatus.Text = "Add New Phone Number";
                    break;

                case "View":
                    lblModeStatus.Text = "View Phone Number";
                    break;

                case "Edit":
                    lblModeStatus.Text = "Edit Phone Number";
                    break;

                case "Delete":
                    lblModeStatus.Text = "Delete Phone Number";
                    break;
                }

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

                //The DataTextField is the value of what will show in the ddl
                // the DataValueField is the Value of the
                ddlPhoneTypeID.DataTextField  = "Name";
                ddlPhoneTypeID.DataValueField = "PhoneTypeID";
                ddlPhoneTypeID.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;


                        LoadPersonPhone();

                        txtPhID.Enabled        = false;
                        txtAreaCode.Enabled    = false;
                        txtPhoneNumber.Enabled = false;
                        txtExtension.Enabled   = false;
                        ddlPhoneTypeID.Enabled = false;
                        txtDescription.Enabled = false;
                        txtNotes.Enabled       = false;
                        cbDNC.Enabled          = false;
                        cbDNT.Enabled          = false;
                        txtID.Enabled          = false;
                        txtPhID.Enabled        = false;

                        break;

                    case "New":

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

                        // LoadPerson();
                        txtPhID.Enabled        = false;
                        txtAreaCode.Enabled    = true;
                        txtPhoneNumber.Enabled = true;
                        txtExtension.Enabled   = true;
                        ddlPhoneTypeID.Enabled = true;

                        break;

                    case "Edit":

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

                        txtPhID.Enabled        = false;
                        txtAreaCode.Enabled    = true;
                        txtPhoneNumber.Enabled = true;
                        txtExtension.Enabled   = true;
                        ddlPhoneTypeID.Enabled = true;
                        object PhoneID = Convert.ToInt32(Request.QueryString["PhoneID"]);

                        txtPhID.Text = PhoneID.ToString();
                        LoadPersonPhone();
                        btnDone.Visible = false;

                        break;

                    case "Delete":

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

                        LoadPersonPhone();

                        txtPhID.Enabled         = false;
                        txtAreaCode.Enabled     = false;
                        txtPhoneNumber.Enabled  = false;
                        txtExtension.Enabled    = false;
                        ddlPhoneTypeID.Enabled  = false;
                        txtNotes.ReadOnly       = true;
                        txtDescription.ReadOnly = true;
                        txtDescription.Enabled  = false;
                        txtNotes.Enabled        = false;
                        txtID.Enabled           = false;

                        break;



                        //Request.QueryString["PersonID"] = "New";
                    }
                }
                else
                {
                    Response.Redirect("FetchPerson.aspx");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            String data;
            if (Request.QueryString["Mode"] != null)
            {
                //
            }
            else
            {
                data = Request.QueryString["Mode"].ToString();
            }

            //   ////////// Response.Redirect("EditPersonPhoneNumber.aspx?Mode=New");

            if (!IsPostBack)
            {

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

                    case "View":
                        lblModeStatus.Text = "View Phone Number";
                        break;

                    case "Edit":
                        lblModeStatus.Text = "Edit Phone Number";
                        break;

                    case "Delete":
                        lblModeStatus.Text = "Delete Phone Number";
                        break;
                }

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

                //The DataTextField is the value of what will show in the ddl
                // the DataValueField is the Value of the
                ddlPhoneTypeID.DataTextField = "Name";
                ddlPhoneTypeID.DataValueField = "PhoneTypeID";
                ddlPhoneTypeID.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;

                            LoadPersonPhone();

                            txtPhID.Enabled = false;
                            txtAreaCode.Enabled = false;
                            txtPhoneNumber.Enabled = false;
                            txtExtension.Enabled = false;
                            ddlPhoneTypeID.Enabled = false;
                            txtDescription.Enabled = false;
                            txtNotes.Enabled = false;
                            cbDNC.Enabled = false;
                            cbDNT.Enabled = false;
                            txtID.Enabled = false;
                            txtPhID.Enabled = false;

                            break;

                        case "New":

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

                            // LoadPerson();
                            txtPhID.Enabled = false;
                            txtAreaCode.Enabled = true;
                            txtPhoneNumber.Enabled = true;
                            txtExtension.Enabled = true;
                            ddlPhoneTypeID.Enabled = true;

                            break;

                        case "Edit":

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

                            txtPhID.Enabled = false;
                            txtAreaCode.Enabled = true;
                            txtPhoneNumber.Enabled = true;
                            txtExtension.Enabled = true;
                            ddlPhoneTypeID.Enabled = true;
                            object PhoneID = Convert.ToInt32(Request.QueryString["PhoneID"]);

                            txtPhID.Text = PhoneID.ToString();
                            LoadPersonPhone();
                            btnDone.Visible = false;

                            break;

                        case "Delete":

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

                            LoadPersonPhone();

                            txtPhID.Enabled = false;
                            txtAreaCode.Enabled = false;
                            txtPhoneNumber.Enabled = false;
                            txtExtension.Enabled = false;
                            ddlPhoneTypeID.Enabled = false;
                            txtNotes.ReadOnly = true;
                            txtDescription.ReadOnly = true;
                            txtDescription.Enabled = false;
                            txtNotes.Enabled = false;
                            txtID.Enabled = false;

                            break;

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

                    }
                }
                else
                {
                    Response.Redirect("FetchPerson.aspx");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataManager.DataAccess da = new DataManager.DataAccess();

                DataSet dsPhoneTypes = da.FetchPhoneTypes();

                ddlPhoneTypeID.DataSource = dsPhoneTypes.Tables[0];

              // ddlPhoneTypeID.Items.Add(New ListItem("", ""));

                 ddlPhoneTypeID.DataTextField = "Name";

                ddlPhoneTypeID.DataValueField = "PhoneTypeID";

                ddlPhoneTypeID.DataBind();
             //       ddlPhoneTypeID.Items.Add(new ListItem("Please Select Phone Type", ""));

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

              //      DataPortal.PersonPhoneData ppd = new DataPortal.PersonPhoneData();

                BusinessObjects.PersonPhone pp = new BusinessObjects.PersonPhone();
                DataSet ds2 = new DataSet();

                if (Request.QueryString["Mode"] == null)
                {
                    Request.QueryString["Mode"] = "New";
                }

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

                if (Request.QueryString["phoneID"] != null)
                {

                    txtPHID.Text = Request.QueryString["phoneID"].ToString();
                }

                if (Request.QueryString != null)
                {
                    string mode = Request.QueryString["Mode"];
                    switch (mode)
                    {
                        case "View":

                            break;

                        case "New":

                            btnSave.Visible = true;
                            txtID.Enabled = false;
                            txtPHTID.Visible = false;
                            btnDelete.Visible = false;
                            break;

                        case "Edit":

                            btnSave.Visible = true;
                            txtID.Enabled = false;
                            int id = Convert.ToInt32(txtID.Text);
                            BusinessObjects.Person person = new BusinessObjects.Person(id);

                            DataSet ds = new DataSet();
                          //  id = Convert.ToInt32(txtID.ToString());
                             person.Fetch(id);
                             person.id = id;
                             object t = person.Title.ToString();
                            object fn = person.FirstName.ToString();
                            object ln = person.LastName.ToString();

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

                            int PhoneID = Convert.ToInt32(txtPHID.Text);
                            BusinessObjects.PersonPhone personPhone = new BusinessObjects.PersonPhone(id, PhoneID);
                            id = Convert.ToInt32(lblID.Text);
                            int PersonID = id;

                           ds = personPhone.Fetch(PersonID, PhoneID);
                         // object pid = personPhone.PhoneID.ToString();
               //                  object ac = personPhone.AreaCode.ToString();
                     object ac = ds.Tables[0].Rows[0]["AreaCode"].ToString();
                     object pn = ds.Tables[0].Rows[0]["PhoneNumber"].ToString();
                     object ex = ds.Tables[0].Rows[0]["Extension"].ToString();

                     object d = ds.Tables[0].Rows[0]["Description"].ToString();
                     object n = ds.Tables[0].Rows[0]["Notes"].ToString();
                     object ptid = ds.Tables[0].Rows[0]["PhoneTypeID"].ToString();
                       txtAreaCode.Text = ac.ToString();
                       txtPhoneNumber.Text = pn.ToString();
                       txtExtension.Text = ex.ToString();
                       txtDescription.Text = d.ToString();
                       txtNotes.Text = n.ToString();
                       txtPHTID.Text = ptid.ToString();
                   ddlPhoneTypeID.Text = ptid.ToString();
                object dc = ds.Tables[0].Rows[0]["DoNotCall"].ToString();
                object dt = ds.Tables[0].Rows[0]["DoNotText"].ToString();

                   cbDNT.Checked = Convert.ToBoolean(dt.ToString());
                    cbDNC.Checked = Convert.ToBoolean(dc.ToString());

                    btnDelete.Visible = false;

                            //                    txtDescription.Text = d.ToString();
                            //                    txtNotes.Text = n.ToString();

                            //                    cbDNT.Checked = Convert.ToBoolean(dt.ToString());
                            //                    cbDNC.Checked = Convert.ToBoolean(dc.ToString());
                            //                   // ddlPhoneTypeID.SelectedIndex = 0;
                            //                    btnDelete.Visible = false;

                            //First create a DataSet that returns, equals person.Fetch(PersonID) as

            /////////////////////////////////OLD CODE Start
            //                            DataPortal.PersonData pd = new DataPortal.PersonData();
            //                    DataSet pds = new DataSet();
            //        O            int PersonID = Convert.ToInt32(txtID.Text);   ///
            //        L            pds = pd.Fetch(PersonID);
            //        D            object fn = pds.Tables[0].Rows[0]["FirstName"].ToString();
            //                    object ln = pds.Tables[0].Rows[0]["LastName"].ToString();
            //        C            lblFirstName.Text = fn.ToString();  ///
            //         O           lblLastName.Text = ln.ToString();  ///
              //D
            //           E         ppd = new DataPortal.PersonPhoneData();
            //                    DataSet ds = new DataSet();
            //                    int PhoneID = Convert.ToInt32(txtPHID.Text);  ///
            //                    ds = ppd.Fetch(PersonID, PhoneID);
            //                    object pid = ds.Tables[0].Rows[0]["PhoneID"].ToString();
            //                    object ac = ds.Tables[0].Rows[0]["AreaCode"].ToString();
            //                    object pn = ds.Tables[0].Rows[0]["PhoneNumber"].ToString();
            //                    object ex = ds.Tables[0].Rows[0]["Extension"].ToString();
            //                    object ptid = ds.Tables[0].Rows[0]["PhoneTypeID"].ToString();

            //                    txtPHID.Text = pid.ToString();
            //                    txtAreaCode.Text = ac.ToString();
            //                    txtPhoneNumber.Text = pn.ToString();
            //                    txtExtension.Text = ex.ToString();
            //                    txtPHTID.Text = ptid.ToString();
            //                    txtPHTID.Visible = false;
            //                    ddlPhoneTypeID.Text = ptid.ToString();

            //                    object d = ds.Tables[0].Rows[0]["Description"].ToString();
            //                    object n = ds.Tables[0].Rows[0]["Notes"].ToString();
            //                    object dc = ds.Tables[0].Rows[0]["DoNotCall"].ToString();
            //                    object dt = ds.Tables[0].Rows[0]["DoNotText"].ToString();
            //                    txtDescription.Text = d.ToString();
            //                    txtNotes.Text = n.ToString();

            //                    cbDNT.Checked = Convert.ToBoolean(dt.ToString());
            //                    cbDNC.Checked = Convert.ToBoolean(dc.ToString());
            //                   // ddlPhoneTypeID.SelectedIndex = 0;
            //                    btnDelete.Visible = false;
            /////////////////////////////////////////OLD CODE Stop
                            break;

                        case "Delete":

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

                             btnSave.Visible = true;
                            txtID.Enabled = false;
                             id = Convert.ToInt32(txtID.Text);
                            person = new BusinessObjects.Person(id);

                           ds = new DataSet();
                          //  id = Convert.ToInt32(txtID.ToString());
                             person.Fetch(id);
                             person.id = id;
                              t = person.Title.ToString();
                           fn = person.FirstName.ToString();
                           ln = person.LastName.ToString();

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

                            PhoneID = Convert.ToInt32(txtPHID.Text);
                          personPhone = new BusinessObjects.PersonPhone(id, PhoneID);
                            id = Convert.ToInt32(lblID.Text);
                           PersonID = id;

                           ds = personPhone.Fetch(PersonID, PhoneID);
                         // object pid = personPhone.PhoneID.ToString();
               //                  object ac = personPhone.AreaCode.ToString();
                     ac = ds.Tables[0].Rows[0]["AreaCode"].ToString();
                     pn = ds.Tables[0].Rows[0]["PhoneNumber"].ToString();
                    ex = ds.Tables[0].Rows[0]["Extension"].ToString();

                      d = ds.Tables[0].Rows[0]["Description"].ToString();
                      n = ds.Tables[0].Rows[0]["Notes"].ToString();
                    ptid = ds.Tables[0].Rows[0]["PhoneTypeID"].ToString();
                       txtAreaCode.Text = ac.ToString();
                       txtPhoneNumber.Text = pn.ToString();
                       txtExtension.Text = ex.ToString();
                       txtDescription.Text = d.ToString();
                       txtNotes.Text = n.ToString();
                       txtPHTID.Text = ptid.ToString();
                   ddlPhoneTypeID.Text = ptid.ToString();
                 dc = ds.Tables[0].Rows[0]["DoNotCall"].ToString();
                dt = ds.Tables[0].Rows[0]["DoNotText"].ToString();

                   cbDNT.Checked = Convert.ToBoolean(dt.ToString());
                    cbDNC.Checked = Convert.ToBoolean(dc.ToString());

                    btnDelete.Visible = true;
                    btnSave.Visible = false;
                    disableForm();

                    //////        pd = new DataPortal.PersonData();
                    //////pds = new DataSet();
                    //////PersonID = Convert.ToInt32(txtID.Text);
              //Fix later              //////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();

                    //////ds = new DataSet();
                    ////// PhoneID = Convert.ToInt32(txtPHID.Text);
                    //////ds = ppd.Fetch(PersonID, PhoneID);
                    ////// pid = ds.Tables[0].Rows[0]["PhoneID"].ToString();
                    ////// ac = ds.Tables[0].Rows[0]["AreaCode"].ToString();
                    ////// pn = ds.Tables[0].Rows[0]["PhoneNumber"].ToString();
                    ////// ex = ds.Tables[0].Rows[0]["Extension"].ToString();
                    ////// ptid = ds.Tables[0].Rows[0]["PhoneTypeID"].ToString();

                    //txtPHID.Text = pid.ToString();
                    //txtAreaCode.Text = ac.ToString();
                    //txtPhoneNumber.Text = pn.ToString();
                    //txtExtension.Text = ex.ToString();
                    //txtPHTID.Text = ptid.ToString();
                    //txtPHTID.Visible = false;
                    //ddlPhoneTypeID.Text = ptid.ToString();

                    //txtAreaCode.Enabled = false;
                    //txtPhoneNumber.Enabled = false;
                    //txtExtension.Enabled = false;
                    //txtPHTID.Enabled = false;
                    //ddlPhoneTypeID.Enabled = false;
                    //cbDNC.Enabled = false;
                    //cbDNT.Enabled = false;
                    //txtDescription.Enabled = false;
                    //txtNotes.Enabled = false;

                    // d = ds.Tables[0].Rows[0]["Description"].ToString();
                    // n = ds.Tables[0].Rows[0]["Notes"].ToString();
                    // dc = ds.Tables[0].Rows[0]["DoNotCall"].ToString();
                    //dt = ds.Tables[0].Rows[0]["DoNotText"].ToString();
                    //txtDescription.Text = d.ToString();
                    //txtNotes.Text = n.ToString();

                    //cbDNT.Checked = Convert.ToBoolean(dt.ToString());
                    //cbDNC.Checked = Convert.ToBoolean(dc.ToString());
                            break;

                    }
                }
            }
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string ModeStatus = Request.QueryString["Mode"];
                switch (ModeStatus)
                {
                case "New":
                    lblModeStatus.Text = "Add New Phone Number";
                    break;

                case "View":
                    lblModeStatus.Text = "View Phone Number";
                    break;

                case "Edit":
                    lblModeStatus.Text = "Edit Phone Number";
                    break;

                case "Delete":
                    lblModeStatus.Text = "Delete Phone Number";
                    break;
                }

                DataManager.DataAccess da = new DataManager.DataAccess();
                DataSet ds = new DataSet();
                ds = da.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;


                        LoadEmailAddress();

                        txtID.Enabled    = false;
                        txtEID.Enabled   = false;
                        txtEmail.Enabled = false;

                        break;

                    case "New":

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

                        //  LoadEmailAddress();
                        txtEID.Enabled   = false;
                        txtID.Enabled    = false;
                        txtEmail.Enabled = true;

                        break;

                    case "Edit":

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

                        txtEID.Enabled = false;

                        LoadEmailAddress();
                        btnDone.Visible = false;

                        break;

                    case "Delete":

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


                        LoadEmailAddress();

                        txtEID.Enabled   = false;
                        txtEmail.Enabled = false;
                        txtID.Enabled    = false;

                        break;



                        //Request.QueryString["PersonID"] = "New";
                    }
                }
                else
                {
                    Response.Redirect("FetchPerson.aspx");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataManager.DataAccess da = new DataManager.DataAccess();

                DataSet dsPhoneTypes = da.FetchPhoneTypes();

                ddlPhoneTypeID.DataSource = dsPhoneTypes.Tables[0];

                // ddlPhoneTypeID.Items.Add(New ListItem("", ""));

                ddlPhoneTypeID.DataTextField = "Name";

                ddlPhoneTypeID.DataValueField = "PhoneTypeID";

                ddlPhoneTypeID.DataBind();
                //       ddlPhoneTypeID.Items.Add(new ListItem("Please Select Phone Type", ""));

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

                //      DataPortal.PersonPhoneData ppd = new DataPortal.PersonPhoneData();

                BusinessObjects.PersonPhone pp = new BusinessObjects.PersonPhone();
                DataSet ds2 = new DataSet();

                if (Request.QueryString["Mode"] == null)
                {
                    Request.QueryString["Mode"] = "New";
                }

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

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

                if (Request.QueryString != null)
                {
                    string mode = Request.QueryString["Mode"];
                    switch (mode)
                    {
                    case "View":

                        break;

                    case "New":

                        btnSave.Visible   = true;
                        txtID.Enabled     = false;
                        txtPHTID.Visible  = false;
                        btnDelete.Visible = false;
                        break;

                    case "Edit":

                        btnSave.Visible = true;
                        txtID.Enabled   = false;
                        int id = Convert.ToInt32(txtID.Text);
                        BusinessObjects.Person person = new BusinessObjects.Person(id);

                        DataSet ds = new DataSet();
                        //  id = Convert.ToInt32(txtID.ToString());
                        person.Fetch(id);
                        person.id = id;
                        object t  = person.Title.ToString();
                        object fn = person.FirstName.ToString();
                        object ln = person.LastName.ToString();

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

                        int PhoneID = Convert.ToInt32(txtPHID.Text);
                        BusinessObjects.PersonPhone personPhone = new BusinessObjects.PersonPhone(id, PhoneID);
                        id = Convert.ToInt32(lblID.Text);
                        int PersonID = id;


                        ds = personPhone.Fetch(PersonID, PhoneID);
                        // object pid = personPhone.PhoneID.ToString();
                        //                  object ac = personPhone.AreaCode.ToString();
                        object ac = ds.Tables[0].Rows[0]["AreaCode"].ToString();
                        object pn = ds.Tables[0].Rows[0]["PhoneNumber"].ToString();
                        object ex = ds.Tables[0].Rows[0]["Extension"].ToString();

                        object d    = ds.Tables[0].Rows[0]["Description"].ToString();
                        object n    = ds.Tables[0].Rows[0]["Notes"].ToString();
                        object ptid = ds.Tables[0].Rows[0]["PhoneTypeID"].ToString();
                        txtAreaCode.Text    = ac.ToString();
                        txtPhoneNumber.Text = pn.ToString();
                        txtExtension.Text   = ex.ToString();
                        txtDescription.Text = d.ToString();
                        txtNotes.Text       = n.ToString();
                        txtPHTID.Text       = ptid.ToString();
                        ddlPhoneTypeID.Text = ptid.ToString();
                        object dc = ds.Tables[0].Rows[0]["DoNotCall"].ToString();
                        object dt = ds.Tables[0].Rows[0]["DoNotText"].ToString();

                        cbDNT.Checked = Convert.ToBoolean(dt.ToString());
                        cbDNC.Checked = Convert.ToBoolean(dc.ToString());

                        btnDelete.Visible = false;


                        //                    txtDescription.Text = d.ToString();
                        //                    txtNotes.Text = n.ToString();

                        //                    cbDNT.Checked = Convert.ToBoolean(dt.ToString());
                        //                    cbDNC.Checked = Convert.ToBoolean(dc.ToString());
                        //                   // ddlPhoneTypeID.SelectedIndex = 0;
                        //                    btnDelete.Visible = false;


                        //First create a DataSet that returns, equals person.Fetch(PersonID) as


/////////////////////////////////OLD CODE Start
//                            DataPortal.PersonData pd = new DataPortal.PersonData();
//                    DataSet pds = new DataSet();
//        O            int PersonID = Convert.ToInt32(txtID.Text);   ///
//        L            pds = pd.Fetch(PersonID);
//        D            object fn = pds.Tables[0].Rows[0]["FirstName"].ToString();
//                    object ln = pds.Tables[0].Rows[0]["LastName"].ToString();
//        C            lblFirstName.Text = fn.ToString();  ///
//         O           lblLastName.Text = ln.ToString();  ///
                        //D
//           E         ppd = new DataPortal.PersonPhoneData();
//                    DataSet ds = new DataSet();
//                    int PhoneID = Convert.ToInt32(txtPHID.Text);  ///
//                    ds = ppd.Fetch(PersonID, PhoneID);
//                    object pid = ds.Tables[0].Rows[0]["PhoneID"].ToString();
//                    object ac = ds.Tables[0].Rows[0]["AreaCode"].ToString();
//                    object pn = ds.Tables[0].Rows[0]["PhoneNumber"].ToString();
//                    object ex = ds.Tables[0].Rows[0]["Extension"].ToString();
//                    object ptid = ds.Tables[0].Rows[0]["PhoneTypeID"].ToString();

//                    txtPHID.Text = pid.ToString();
//                    txtAreaCode.Text = ac.ToString();
//                    txtPhoneNumber.Text = pn.ToString();
//                    txtExtension.Text = ex.ToString();
//                    txtPHTID.Text = ptid.ToString();
//                    txtPHTID.Visible = false;
//                    ddlPhoneTypeID.Text = ptid.ToString();

//                    object d = ds.Tables[0].Rows[0]["Description"].ToString();
//                    object n = ds.Tables[0].Rows[0]["Notes"].ToString();
//                    object dc = ds.Tables[0].Rows[0]["DoNotCall"].ToString();
//                    object dt = ds.Tables[0].Rows[0]["DoNotText"].ToString();
//                    txtDescription.Text = d.ToString();
//                    txtNotes.Text = n.ToString();

//                    cbDNT.Checked = Convert.ToBoolean(dt.ToString());
//                    cbDNC.Checked = Convert.ToBoolean(dc.ToString());
//                   // ddlPhoneTypeID.SelectedIndex = 0;
//                    btnDelete.Visible = false;
/////////////////////////////////////////OLD CODE Stop
                        break;

                    case "Delete":

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


                        btnSave.Visible = true;
                        txtID.Enabled   = false;
                        id     = Convert.ToInt32(txtID.Text);
                        person = new BusinessObjects.Person(id);

                        ds = new DataSet();
                        //  id = Convert.ToInt32(txtID.ToString());
                        person.Fetch(id);
                        person.id = id;
                        t         = person.Title.ToString();
                        fn        = person.FirstName.ToString();
                        ln        = person.LastName.ToString();

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

                        PhoneID     = Convert.ToInt32(txtPHID.Text);
                        personPhone = new BusinessObjects.PersonPhone(id, PhoneID);
                        id          = Convert.ToInt32(lblID.Text);
                        PersonID    = id;


                        ds = personPhone.Fetch(PersonID, PhoneID);
                        // object pid = personPhone.PhoneID.ToString();
                        //                  object ac = personPhone.AreaCode.ToString();
                        ac = ds.Tables[0].Rows[0]["AreaCode"].ToString();
                        pn = ds.Tables[0].Rows[0]["PhoneNumber"].ToString();
                        ex = ds.Tables[0].Rows[0]["Extension"].ToString();

                        d                   = ds.Tables[0].Rows[0]["Description"].ToString();
                        n                   = ds.Tables[0].Rows[0]["Notes"].ToString();
                        ptid                = ds.Tables[0].Rows[0]["PhoneTypeID"].ToString();
                        txtAreaCode.Text    = ac.ToString();
                        txtPhoneNumber.Text = pn.ToString();
                        txtExtension.Text   = ex.ToString();
                        txtDescription.Text = d.ToString();
                        txtNotes.Text       = n.ToString();
                        txtPHTID.Text       = ptid.ToString();
                        ddlPhoneTypeID.Text = ptid.ToString();
                        dc                  = ds.Tables[0].Rows[0]["DoNotCall"].ToString();
                        dt                  = ds.Tables[0].Rows[0]["DoNotText"].ToString();

                        cbDNT.Checked = Convert.ToBoolean(dt.ToString());
                        cbDNC.Checked = Convert.ToBoolean(dc.ToString());

                        btnDelete.Visible = true;
                        btnSave.Visible   = false;
                        disableForm();

                        //////        pd = new DataPortal.PersonData();
                        //////pds = new DataSet();
                        //////PersonID = Convert.ToInt32(txtID.Text);
                        //Fix later              //////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();

                        //////ds = new DataSet();
                        ////// PhoneID = Convert.ToInt32(txtPHID.Text);
                        //////ds = ppd.Fetch(PersonID, PhoneID);
                        ////// pid = ds.Tables[0].Rows[0]["PhoneID"].ToString();
                        ////// ac = ds.Tables[0].Rows[0]["AreaCode"].ToString();
                        ////// pn = ds.Tables[0].Rows[0]["PhoneNumber"].ToString();
                        ////// ex = ds.Tables[0].Rows[0]["Extension"].ToString();
                        ////// ptid = ds.Tables[0].Rows[0]["PhoneTypeID"].ToString();

                        //txtPHID.Text = pid.ToString();
                        //txtAreaCode.Text = ac.ToString();
                        //txtPhoneNumber.Text = pn.ToString();
                        //txtExtension.Text = ex.ToString();
                        //txtPHTID.Text = ptid.ToString();
                        //txtPHTID.Visible = false;
                        //ddlPhoneTypeID.Text = ptid.ToString();

                        //txtAreaCode.Enabled = false;
                        //txtPhoneNumber.Enabled = false;
                        //txtExtension.Enabled = false;
                        //txtPHTID.Enabled = false;
                        //ddlPhoneTypeID.Enabled = false;
                        //cbDNC.Enabled = false;
                        //cbDNT.Enabled = false;
                        //txtDescription.Enabled = false;
                        //txtNotes.Enabled = false;

                        // d = ds.Tables[0].Rows[0]["Description"].ToString();
                        // n = ds.Tables[0].Rows[0]["Notes"].ToString();
                        // dc = ds.Tables[0].Rows[0]["DoNotCall"].ToString();
                        //dt = ds.Tables[0].Rows[0]["DoNotText"].ToString();
                        //txtDescription.Text = d.ToString();
                        //txtNotes.Text = n.ToString();

                        //cbDNT.Checked = Convert.ToBoolean(dt.ToString());
                        //cbDNC.Checked = Convert.ToBoolean(dc.ToString());
                        break;
                    }
                }
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

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

                    case "View":
                        lblModeStatus.Text = "View Phone Number";
                        break;

                    case "Edit":
                        lblModeStatus.Text = "Edit Phone Number";
                        break;

                    case "Delete":
                        lblModeStatus.Text = "Delete Phone Number";
                        break;
                }

                DataManager.DataAccess da = new DataManager.DataAccess();
                DataSet ds = new DataSet();
                ds = da.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;

                        LoadEmailAddress();

                            txtID.Enabled = false;
                            txtEID.Enabled = false;
                            txtEmail.Enabled = false;

                            break;

                        case "New":

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

                          //  LoadEmailAddress();
                            txtEID.Enabled = false;
                            txtID.Enabled = false;
                            txtEmail.Enabled = true;

                            break;

                        case "Edit":

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

                            txtEID.Enabled = false;

                          LoadEmailAddress();
                            btnDone.Visible = false;

                            break;

                        case "Delete":

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

                        LoadEmailAddress();

                            txtEID.Enabled = false;
                            txtEmail.Enabled = false;
                            txtID.Enabled = false;

                            break;

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

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