Exemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            String AreaCode    = txtAreaCode.Text;
            String PhoneNumber = txtPhoneNumber.Text;
            String Extension   = txtExtension.Text;
            int    PhoneTypeID = Convert.ToInt32(ddlPhoneTypeID.Text);

            // int PhoneID = Convert.ToInt32(txtPhID.Text);
            int PhoneID;

            DataManager.DataAccess da = new DataManager.DataAccess();
            switch (Request.QueryString["Mode"])
            {
            case "Edit":

                this.txtPhID.Text = Request.QueryString["PhoneID"];
                txtPhID.Enabled   = true;
                PhoneID           = Convert.ToInt32(txtPhID.Text);
                AreaCode          = txtAreaCode.Text;
                PhoneNumber       = txtPhoneNumber.Text;
                Extension         = txtExtension.Text;
                PhoneTypeID       = Convert.ToInt32(ddlPhoneTypeID.Text);
                int    PersonID    = Convert.ToInt32(txtID.Text);
                String Description = txtDescription.Text;
                String Notes       = txtNotes.Text;



                da.UpdatePhone(PhoneID, AreaCode, PhoneNumber, Extension, PhoneTypeID);     //UpdatePhone(int PhoneID, int AreaCode, int PhoneNumber, String Extension, int PhoneTypeID)
                da.UpdateCompanyPhones(PersonID, PhoneID, Description, Notes);
                Response.Redirect("EditCompany.aspx?Mode=Edit&CompanyID=" + this.txtID.Text);

                btnDone.Enabled = true;

                btnDone.Visible = false;



                // Response.Redirect("EditPerson.aspx?Mode=Edit&PersonID=" + this.txtID.Text);

                break;


            case "New":

                AreaCode    = txtAreaCode.Text;
                PhoneNumber = txtPhoneNumber.Text;
                Extension   = txtExtension.Text;
                PhoneTypeID = Convert.ToInt32(ddlPhoneTypeID.SelectedValue);

                //PersonID = Convert.ToInt32(txtID.Text);
                // PhoneID = Convert.ToInt32(txtPhID.Text);

                Description = txtDescription.Text;
                Notes       = txtNotes.Text;



                PersonID = Convert.ToInt32(txtID.Text);

                object phoneNumberID = da.InsertPhoneNumber(AreaCode, PhoneNumber, Extension, PhoneTypeID);
                txtPhID.Text = phoneNumberID.ToString();


                // da.InsertPhoneNumber(AreaCode, PhoneNumber, Extension, PhoneTypeID);
                //txtPhID.Text = phoneNumberID.ToString();
                PhoneID = Convert.ToInt32(txtPhID.Text.ToString());
                // txtNotes.Text = PhoneID.ToString();
                da.InsertCompanyPhone(PersonID, PhoneID, Description, Notes);

                // I need to send the PersonID and the PhoneID to the Edit Page

                Response.Redirect("EditCompany.aspx?Mode=Edit&CompanyID=" + this.txtID.Text);
                //           Response.Redirect("EditPersonPhoneNumber.aspx?PersonID=" +
                //this.txtID.Text + "&Mode=Edit&PhoneID=" + this.txtPhID.Text);

                break;
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            String AreaCode = txtAreaCode.Text;
            String PhoneNumber = txtPhoneNumber.Text;
            String Extension = txtExtension.Text;
            int PhoneTypeID = Convert.ToInt32(ddlPhoneTypeID.Text);

            // int PhoneID = Convert.ToInt32(txtPhID.Text);
            int PhoneID;

            DataManager.DataAccess da = new DataManager.DataAccess();
            switch (Request.QueryString["Mode"])
            {
                case "Edit":

                    this.txtPhID.Text = Request.QueryString["PhoneID"];
                    txtPhID.Enabled = true;
                    PhoneID = Convert.ToInt32(txtPhID.Text);
                    AreaCode = txtAreaCode.Text;
                    PhoneNumber = txtPhoneNumber.Text;
                    Extension = txtExtension.Text;
                    PhoneTypeID = Convert.ToInt32(ddlPhoneTypeID.Text);
                    int PersonID = Convert.ToInt32(txtID.Text);
                    String Description = txtDescription.Text;
                    String Notes = txtNotes.Text;

                    da.UpdatePhone(PhoneID, AreaCode, PhoneNumber, Extension, PhoneTypeID); //UpdatePhone(int PhoneID, int AreaCode, int PhoneNumber, String Extension, int PhoneTypeID)
                    da.UpdateCompanyPhones(PersonID, PhoneID, Description, Notes);
                    Response.Redirect("EditCompany.aspx?Mode=Edit&CompanyID=" + this.txtID.Text);

                    btnDone.Enabled = true;

                    btnDone.Visible = false;

                    // Response.Redirect("EditPerson.aspx?Mode=Edit&PersonID=" + this.txtID.Text);

                    break;

                case "New":

                    AreaCode = txtAreaCode.Text;
                    PhoneNumber = txtPhoneNumber.Text;
                    Extension = txtExtension.Text;
                    PhoneTypeID = Convert.ToInt32(ddlPhoneTypeID.SelectedValue);

                    //PersonID = Convert.ToInt32(txtID.Text);
                    // PhoneID = Convert.ToInt32(txtPhID.Text);

                    Description = txtDescription.Text;
                    Notes = txtNotes.Text;

                    PersonID = Convert.ToInt32(txtID.Text);

                    object phoneNumberID = da.InsertPhoneNumber(AreaCode, PhoneNumber, Extension, PhoneTypeID);
                    txtPhID.Text = phoneNumberID.ToString();

                    // da.InsertPhoneNumber(AreaCode, PhoneNumber, Extension, PhoneTypeID);
                    //txtPhID.Text = phoneNumberID.ToString();
                    PhoneID = Convert.ToInt32(txtPhID.Text.ToString());
                    // txtNotes.Text = PhoneID.ToString();
                    da.InsertCompanyPhone(PersonID, PhoneID, Description, Notes);

                    // I need to send the PersonID and the PhoneID to the Edit Page

                    Response.Redirect("EditCompany.aspx?Mode=Edit&CompanyID=" + this.txtID.Text);
                    //           Response.Redirect("EditPersonPhoneNumber.aspx?PersonID=" +
                    //this.txtID.Text + "&Mode=Edit&PhoneID=" + this.txtPhID.Text);

                    break;

            }
        }