示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] != null)//Protection required ALL edits!
        {
            rblUserLevel.Attributes.Add("onclick", "CheckUserLevel()");

            if (rblUserLevel.SelectedValue == "D")//When Level D enforce the required field validator to the date range
            {
                bodyID.Attributes.Add("onload", "document.getElementById(\"dateLayer\").style.visibility=\"visible\";");
                rfvFrom.Enabled             = true;
                rfvTo.Enabled               = true;
                cvFrom.Enabled              = true;
                cvTo.Enabled                = true;
                cpvDateRange.Enabled        = true;
                Session["DateWasDisplayed"] = "yes";
            }
            else if (Session["DateWasDisplayed"] != null)//Choose "D" --> Change it to others --> w/o this code the date range fields are displayed
            {
                bodyID.Attributes.Add("onload", "document.getElementById(\"dateLayer\").style.visibility=\"hidden\";");
                rfvFrom.Enabled             = false;
                rfvTo.Enabled               = false;
                cvFrom.Enabled              = false;
                cvTo.Enabled                = false;
                cpvDateRange.Enabled        = false;
                Session["DateWasDisplayed"] = null;
            }

            if (!Page.IsPostBack)
            {
                licenseeTA            = new dsUserTableAdapters.licenseeTableAdapter();
                licenseeDT            = new dsUser.licenseeDataTable();
                licenseeDT            = licenseeTA.GetUserByID(Convert.ToInt32(Request.QueryString["id"].ToString()));
                Session["licenseeDT"] = licenseeDT;



                //Populate the existing data
                if (!(licenseeDT.Rows[0]["FirstName"] is DBNull))
                {
                    tbFirstName.Text = licenseeDT[0].FirstName;
                }

                if (!(licenseeDT.Rows[0]["MI"] is DBNull))
                {
                    tbMI.Text = licenseeDT[0].MI;
                }

                if (!(licenseeDT.Rows[0]["LastName"] is DBNull))
                {
                    tbLastName.Text = licenseeDT[0].LastName;
                }


                if (!(licenseeDT.Rows[0]["Email"] is DBNull))
                {
                    tbEmail.Text = licenseeDT[0].Email;
                }

                if (!(licenseeDT.Rows[0]["cid"] is DBNull))
                {
                    dsCompanyTableAdapters.legacyusersTableAdapter legacyusersTA = new dsCompanyTableAdapters.legacyusersTableAdapter();
                    dsCompany.legacyusersDataTable legacyusersDT = legacyusersTA.GetAllCompanies();
                    ddlCompany.DataSource     = legacyusersDT;
                    ddlCompany.DataTextField  = "Company";
                    ddlCompany.DataValueField = "ID";
                    ddlCompany.SelectedValue  = licenseeDT.Rows[0]["cid"].ToString();
                    ddlCompany.DataBind();
                }

                if (!(licenseeDT.Rows[0]["Contract"] is DBNull))
                {
                    tbContract.Text = licenseeDT[0].Contract;
                }

                if (!(licenseeDT.Rows[0]["Address1"] is DBNull))
                {
                    tbAddress1.Text = licenseeDT[0].Address1;
                }

                if (!(licenseeDT.Rows[0]["Address2"] is DBNull))
                {
                    tbAddress2.Text = licenseeDT[0].Address2;
                }

                if (!(licenseeDT.Rows[0]["City"] is DBNull))
                {
                    tbCity.Text = licenseeDT[0].City;
                }

                if (!(licenseeDT.Rows[0]["State"] is DBNull))
                {
                    bool bProvince = true;
                    foreach (ListItem l in ddlState.Items)
                    {
                        if (licenseeDT[0].State == l.Value)
                        {
                            l.Selected = true;
                            bProvince  = false;
                        }
                    }
                    if (bProvince)
                    {
                        tbProvince.Text = licenseeDT[0].State;
                    }
                }



                if (!(licenseeDT.Rows[0]["Zip"] is DBNull))
                {
                    tbZip.Text = licenseeDT[0].Zip;
                }

                if (!(licenseeDT.Rows[0]["Phone"] is DBNull))
                {
                    tbPhone.Text = licenseeDT[0].Phone;
                }

                if (!(licenseeDT.Rows[0]["Fax"] is DBNull))
                {
                    tbFax.Text = licenseeDT[0].Fax;
                }

                if (!(licenseeDT.Rows[0]["Password"] is DBNull))
                {
                    tbPassword.Text = licenseeDT[0].Password;
                }
            }
        }
        else//Take care of the deviants
        {
            Response.Redirect("./");
        }
    }
示例#2
0
    protected void btnContinue1_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            legacyusersTA = new dsCompanyTableAdapters.legacyusersTableAdapter();
            legacyusersDT = legacyusersTA.GetAllCompanies();
            legacyusersR  = legacyusersDT.NewlegacyusersRow();

            legacyusersR.Company  = tbCompany.Text;
            legacyusersR.Address1 = tbAddress1.Text;
            legacyusersR.Address2 = tbAddress2.Text;
            legacyusersR.City     = tbCity.Text;

            if (ddlState.SelectedIndex > 0)
            {
                legacyusersR.State = ddlState.SelectedValue;
            }
            else
            {
                legacyusersR.State = tbProvince.Text;
            }

            legacyusersR.Zip     = tbZip.Text;
            legacyusersR.Country = ddlCountry.SelectedValue;
            legacyusersR.Phone   = tbPhone.Text;
            //legacyusersR.Email = tbEmail.Text;
            legacyusersR.Contract = tbContract.Text;

            string companyNoSpace = tbCompany.Text.ToLower().Replace(" ", "");

            if (companyNoSpace.Length >= 5)
            {
                legacyusersR.UserName = companyNoSpace.Substring(0, 5) + "_register";
            }
            else
            {
                legacyusersR.UserName = companyNoSpace + "_register";
            }

            legacyusersR.Password = RandomPassword.Generate(7);

            //legacyusersR.UserName = tbUserName.Text;
            //legacyusersR.Password = tbPassword.Text;


            legacyusersR.Mlb    = false;
            legacyusersR.Minor  = false;
            legacyusersR.Coop   = false;
            legacyusersR.Alls   = false;
            legacyusersR.World  = false;
            legacyusersR.Mascot = false;
            legacyusersR.Spring = false;
            legacyusersR.Trend  = false;
            legacyusersR.Minorleaguestyleguide = false;
            legacyusersR.Super    = false;
            legacyusersR.Mlb2003  = false;
            legacyusersR.Creative = false;
            legacyusersR.Alls2007 = false;

            legacyusersR.BulkReg = false;

            Session["legacyusersTA"] = legacyusersTA;
            Session["legacyusersDT"] = legacyusersDT;
            Session["legacyusersR"]  = legacyusersR;

            lblStep.Text           = "Step 2 of 5:";
            lblDescription.Text    = "Choose a user level";
            tableProfile.Visible   = false;
            cvMessage.Enabled      = false;
            tableUserLevel.Visible = true;
        }
    }