コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] != null)//Protection required ALL edits!
        {
            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))
                {
                    lblFirstName.Text = licenseeDT[0].FirstName;
                }

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

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


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

                if (!(licenseeDT.Rows[0]["cid"] is DBNull))
                {
                    dsCompanyTableAdapters.legacyusersTableAdapter legacyusersTA = new dsCompanyTableAdapters.legacyusersTableAdapter();
                    dsCompany.legacyusersDataTable legacyusersDT = new dsCompany.legacyusersDataTable();
                    legacyusersDT = legacyusersTA.GetCompanyByID(licenseeDT[0].cid);

                    if (legacyusersDT.Rows.Count > 0)
                    {
                        lblCompany.Text = legacyusersDT[0].Company;
                    }
                    else
                    {
                        lblCompany.Text = "<b><font color=\"red\">DELETED</font></b>";
                    }
                }

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

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

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

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

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

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

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

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

                if (!(licenseeDT.Rows[0]["UserLevel"] is DBNull))
                {
                    lblUserLevel.Text = licenseeDT[0].UserLevel;
                    if (licenseeDT[0].UserLevel == "D" && (!(licenseeDT.Rows[0]["FromDate"] is DBNull)) && (!(licenseeDT.Rows[0]["ToDate"] is DBNull)))//When Level D enforce the required field validator to the date range
                    {
                        lblDateRange.Text = "(" + licenseeDT[0].FromDate.ToShortDateString() + " ~ " + licenseeDT[0].ToDate.ToShortDateString() + ")";
                    }
                }

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

                if (!(licenseeDT.Rows[0]["RequestorID"] is DBNull))
                {
                    dsCompanyTableAdapters.requestorsTableAdapter requestorsTA = new dsCompanyTableAdapters.requestorsTableAdapter();
                    dsCompany.requestorsDataTable requestorsDT = new dsCompany.requestorsDataTable();
                    requestorsDT      = requestorsTA.GetRequestorByID(licenseeDT[0].RequestorID);
                    lblRequestor.Text = requestorsDT[0].name;
                }


                //dsCompanyTableAdapters.legacyusers2siteletsTableAdapter legacyusers2siteletsTA = new dsCompanyTableAdapters.legacyusers2siteletsTableAdapter();
                dsUserTableAdapters.licensee2siteletsTableAdapter licensee2siteletsTA = new dsUserTableAdapters.licensee2siteletsTableAdapter();

                //dsCompany.legacyusers2siteletsDataTable legacyusers2siteletsDT = new dsCompany.legacyusers2siteletsDataTable();
                dsUser.licensee2siteletsDataTable licensee2siteletsDT = new dsUser.licensee2siteletsDataTable();

                //legacyusers2siteletsDT = legacyusers2siteletsTA.Getc2sByCID(legacyusersDT[0].ID);
                licensee2siteletsDT = licensee2siteletsTA.Getu2sByUID(licenseeDT[0].ID);

                dsCompanyTableAdapters.siteletsTableAdapter siteletsTA = new dsCompanyTableAdapters.siteletsTableAdapter();
                dsCompany.siteletsDataTable siteletsDT = new dsCompany.siteletsDataTable();
                siteletsDT = siteletsTA.GetAllSitelets();

                string strSitelets = string.Empty;
                for (int i = 0; i < licensee2siteletsDT.Rows.Count; i++)
                {
                    for (int j = 0; j < siteletsDT.Rows.Count; j++)
                    {
                        if (siteletsDT[j].id == licensee2siteletsDT[i].sid)
                        {
                            strSitelets += siteletsDT[j].description + "<br>";
                        }
                    }
                }

                lblSitelets.Text = strSitelets;
            }
        }
        else//Take care of the deviants
        {
            Response.Redirect("./");
        }
    }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] != null)//Protection required ALL edits!
        {
            if (!Page.IsPostBack)
            {
                try{
                    legacyusersTA            = new dsCompanyTableAdapters.legacyusersTableAdapter();
                    legacyusersDT            = new dsCompany.legacyusersDataTable();
                    legacyusersDT            = legacyusersTA.GetCompanyByID(Convert.ToInt32(Request.QueryString["id"].ToString()));
                    Session["legacyusersDT"] = legacyusersDT;


                    //Populate the existing data
                    if (!(legacyusersDT.Rows[0]["Company"] is DBNull))
                    {
                        lblCompany.Text = legacyusersDT[0].Company;
                    }
                    if (!(legacyusersDT.Rows[0]["Address1"] is DBNull))
                    {
                        lblAddress1.Text = legacyusersDT[0].Address1;
                    }
                    if (!(legacyusersDT.Rows[0]["Address2"] is DBNull))
                    {
                        lblAddress2.Text = legacyusersDT[0].Address2;
                    }
                    if (!(legacyusersDT.Rows[0]["City"] is DBNull))
                    {
                        lblCity.Text = legacyusersDT[0].City;
                    }
                    if (!(legacyusersDT.Rows[0]["State"] is DBNull))
                    {
                        lblState.Text = legacyusersDT[0].State;
                    }
                    if (!(legacyusersDT.Rows[0]["Zip"] is DBNull))
                    {
                        lblZip.Text = legacyusersDT[0].Zip;
                    }
                    if (!(legacyusersDT.Rows[0]["Country"] is DBNull))
                    {
                        lblCountry.Text = legacyusersDT[0].Country;
                    }
                    if (!(legacyusersDT.Rows[0]["Phone"] is DBNull))
                    {
                        lblPhone.Text = legacyusersDT[0].Phone;
                    }
                    if (!(legacyusersDT.Rows[0]["Email"] is DBNull))
                    {
                        lblEmail.Text = legacyusersDT[0].Email;
                    }
                    if (!(legacyusersDT.Rows[0]["Contract"] is DBNull))
                    {
                        lblContract.Text = legacyusersDT[0].Contract;
                    }
                    if (!(legacyusersDT.Rows[0]["UserName"] is DBNull))
                    {
                        lblUserName.Text = legacyusersDT[0].UserName;
                    }
                    if (!(legacyusersDT.Rows[0]["Password"] is DBNull))
                    {
                        lblPassword.Text = legacyusersDT[0].Password;
                    }
                    if (!(legacyusersDT.Rows[0]["UserLevel"] is DBNull))
                    {
                        lblUserLevel.Text = legacyusersDT[0].UserLevel;
                        if (legacyusersDT[0].UserLevel == "D" && (!(legacyusersDT.Rows[0]["FromDate"] is DBNull)) && (!(legacyusersDT.Rows[0]["ToDate"] is DBNull)))//When Level D enforce the required field validator to the date range
                        {
                            lblDateRange.Text = "(" + legacyusersDT[0].FromDate.ToShortDateString() + " ~ " + legacyusersDT[0].ToDate.ToShortDateString() + ")";
                        }
                    }
                    if (!(legacyusersDT.Rows[0]["UserCategory"] is DBNull))
                    {
                        lblUserCategory.Text = legacyusersDT[0].UserCategory;
                    }
                    if (!(legacyusersDT.Rows[0]["RequestorID"] is DBNull))
                    {
                        dsCompanyTableAdapters.requestorsTableAdapter requestorsTA = new dsCompanyTableAdapters.requestorsTableAdapter();
                        dsCompany.requestorsDataTable requestorsDT = new dsCompany.requestorsDataTable();
                        requestorsDT = requestorsTA.GetRequestorByID(legacyusersDT[0].RequestorID);
                        if (requestorsDT.Rows.Count > 0)
                        {
                            lblRequestor.Text = requestorsDT[0].name;
                        }
                    }

                    dsCompanyTableAdapters.legacyusers2siteletsTableAdapter legacyusers2siteletsTA = new dsCompanyTableAdapters.legacyusers2siteletsTableAdapter();
                    dsCompany.legacyusers2siteletsDataTable legacyusers2siteletsDT = new dsCompany.legacyusers2siteletsDataTable();
                    legacyusers2siteletsDT = legacyusers2siteletsTA.Getc2sByCID(legacyusersDT[0].ID);

                    dsCompanyTableAdapters.siteletsTableAdapter siteletsTA = new dsCompanyTableAdapters.siteletsTableAdapter();
                    dsCompany.siteletsDataTable siteletsDT = new dsCompany.siteletsDataTable();
                    siteletsDT = siteletsTA.GetAllSitelets();

                    string strSitelets = string.Empty;
                    for (int i = 0; i < legacyusers2siteletsDT.Rows.Count; i++)
                    {
                        for (int j = 0; j < siteletsDT.Rows.Count; j++)
                        {
                            if (siteletsDT[j].id == legacyusers2siteletsDT[i].sid)
                            {
                                strSitelets += siteletsDT[j].description + "<br>";
                            }
                        }
                    }

                    lblSitelets.Text = strSitelets;
                }
                catch (Exception ex)
                {
                    HttpBrowserCapabilities br = Request.Browser;

                    string strHandledMessage = "ex.StackTrace: " + ex.StackTrace.ToString() +
                                               Environment.NewLine + Environment.NewLine +
                                               "The client ip: " + Request.ServerVariables["REMOTE_ADDR"] +
                                               Environment.NewLine + Environment.NewLine +
                                               "GetLastError.Message: " + ex.Message.ToString() +
                                               Environment.NewLine + Environment.NewLine +
                                               "Page: " + Request.ServerVariables["SCRIPT_NAME"] +
                                               Environment.NewLine + Environment.NewLine +
                                               "Server: " + Request.ServerVariables["SERVER_NAME"] +
                                               Environment.NewLine + Environment.NewLine +
                                               "Local Address: " + Request.ServerVariables["LOCAL_ADDR"] +
                                               Environment.NewLine + Environment.NewLine +
                                               "Browser: " + br.Browser.ToString() + " : " + br.Version.ToString();

                    if (Request.UrlReferrer != null)
                    {
                        strHandledMessage += Environment.NewLine + Environment.NewLine +
                                             "Referrer: " + Request.UrlReferrer.ToString();
                    }

                    if (Request.QueryString != null)
                    {
                        strHandledMessage += Environment.NewLine + Environment.NewLine +
                                             "Query String: " + Request.QueryString.ToString();
                    }


                    strHandledMessage += Environment.NewLine + Environment.NewLine;
                    System.Net.Mail.SmtpClient  smtpClient = new System.Net.Mail.SmtpClient();
                    System.Net.Mail.MailMessage message    = new System.Net.Mail.MailMessage();
                    try
                    {
                        System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("*****@*****.**", "Debugger");
                        smtpClient.Host = System.Configuration.ConfigurationManager.AppSettings["SMTPServer"].ToString();
                        smtpClient.Port = 25;
                        message.From    = fromAddress;
                        message.To.Add("*****@*****.**");
                        message.Subject = "MLBStyleGuide : Error on " + Request.ServerVariables["SCRIPT_NAME"] + ".. but handled";
                        //message.Body = Server.GetLastError().InnerException.Message.ToString();
                        message.Body = strHandledMessage;
                        smtpClient.Send(message);
                    }
                    catch (Exception e2)
                    {
                        //lblStatus.Text = "Send Email Failed." + ex.Message;
                    }
                }
            }
        }
        else//Take care of the deviants
        {
            Response.Redirect("./");
        }
    }
コード例 #3
0
    protected void SaveLevelA()
    {
        if ((Session["legacyusersTA"] != null) && (Session["legacyusersDT"] != null))
        {
            legacyusersTA = (dsCompanyTableAdapters.legacyusersTableAdapter)(Session["legacyusersTA"]);
            legacyusersDT = (dsCompany.legacyusersDataTable)(Session["legacyusersDT"]);
            legacyusersR  = (dsCompany.legacyusersRow)(Session["legacyusersR"]);

            //dsCompanyTableAdapters.legacyusersTableAdapter legacyusersTA = new dsCompanyTableAdapters.legacyusersTableAdapter();
            //int iPkey = Convert.ToInt32(legacyusersTA.InsertQuery(legacyusersR.UserName, legacyusersR.Password, legacyusersR.Company, true, true, true, true, true, true, legacyusersR.Email, false, legacyusersR.Contract, legacyusersR.Address1, legacyusersR.Address2, legacyusersR.City, legacyusersR.State, legacyusersR.Zip, legacyusersR.Phone, legacyusersR.Country, true, true, true, true, true, true, true, legacyusersR.UserLevel, legacyusersR.UserCategory, legacyusersR.RequestorID, legacyusersR.FromDate, legacyusersR.ToDate, legacyusersR.AllowedYear));
            //string strBefore = legacyusersDT.Rows.Count.ToString();
            legacyusersR.RegistrationDate = DateTime.Now;

            legacyusersDT.AddlegacyusersRow(legacyusersR);
            legacyusersDT.RowChanged += new DataRowChangeEventHandler(Row_Changed);

            //string strAfter = legacyusersDT.Rows.Count.ToString();
            legacyusersTA.Update(legacyusersDT);

            //Let's add sitelets
            //Get all availaible sitelets
            dsCompanyTableAdapters.siteletsTableAdapter siteletsTA = new dsCompanyTableAdapters.siteletsTableAdapter();
            dsCompany.siteletsDataTable siteletsDT = new dsCompany.siteletsDataTable();
            siteletsDT = siteletsTA.GetAllSitelets();

            dsCompanyTableAdapters.legacyusers2siteletsTableAdapter legacyusers2siteletsTA = new dsCompanyTableAdapters.legacyusers2siteletsTableAdapter();
            dsCompany.legacyusers2siteletsDataTable legacyusers2siteletsDT = new dsCompany.legacyusers2siteletsDataTable();
            legacyusers2siteletsDT = legacyusers2siteletsTA.GetAllc2s();

            for (int i = 0; i < siteletsDT.Rows.Count; i++)
            {
                dsCompany.legacyusers2siteletsRow legacyusers2siteletsR = legacyusers2siteletsDT.Newlegacyusers2siteletsRow();
                legacyusers2siteletsR.cid = iPkey;
                legacyusers2siteletsR.sid = Convert.ToInt32(siteletsDT[i].id);
                legacyusers2siteletsDT.Addlegacyusers2siteletsRow(legacyusers2siteletsR);
                legacyusers2siteletsTA.Update(legacyusers2siteletsDT);
            }


            tableRequestor.Visible = false;

            tableFinished.Visible  = true;
            lblStep.Visible        = false;
            lblDescription.Visible = false;


            //Send a confirmation email

            /*
             * Axis360Mail myMail = new Axis360Mail();
             * myMail.FromEmail = "*****@*****.**";
             * myMail.FromName = "Major League Baseball Properties";
             * myMail.IsBodyHtml = true;
             * myMail.Subject = "Welcome to the MLB Styleguide!";
             * myMail.ToEmail1 = legacyusersR.Email;
             * myMail.ToName1 = legacyusersR.Company;
             *
             * myMail.Message = "Hello " + legacyusersR.Company + " user<br><br>" +
             *               "Thank you for registering at www.mlbstyleguide.com.<br><br>" +
             *               "Your temporary login information is shown below:<br><br>" +
             *               "User name: " + legacyusersR.UserName + "<br>" +
             *               "Password: "******"<br><br>" +
             *               "You can login with this information at <a href=\"http://" + Request.ServerVariables["SERVER_NAME"].ToString() + "\">" +
             *               "http://" + Request.ServerVariables["SERVER_NAME"].ToString() + "</a>.<br>" +
             *               "Once you log in you will be asked to complete a short form and create your own unique password.<br>" +
             *               "Future access to the site will then be done by simply entering your e-mail address and desired password.<br><br>" +
             *               "If you have any questions or need any other assistance, please contact us at <a href=\"mailto:[email protected]\">[email protected]</a>.<br><br>" +
             *               "Thank you,<br><br>" +
             *               "Major League Baseball Properties";
             * myMail.Send();
             */
        }
    }