Esempio n. 1
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            ElectronicAppDBDataContext         ElectronicAppDB         = new ElectronicAppDBDataContext();
            ElectronicAppSecurityDBDataContext ElectronicAppSecurityDB = new ElectronicAppSecurityDBDataContext();
            List <uspLoginWebuserResult>       Loginresult             = null;

            Loginresult = ElectronicAppSecurityDB.uspLoginWebuser(txtUserName.Text, txtPassword.Text).ToList <uspLoginWebuserResult>();
            if (Loginresult.Count <= 0)
            {
                List <uspLoginBrokeruserResult> brokerresult = null;
                brokerresult = ElectronicAppSecurityDB.uspLoginBrokeruser(txtUserName.Text, txtPassword.Text).ToList <uspLoginBrokeruserResult>();
                if (brokerresult.Count > 0)
                {
                    Guid brokerID = brokerresult[0].associatedWith;

                    Session.Add("BrokerID", brokerID);

                    FormsAuthentication.RedirectFromLoginPage("txtUserName.Text", false);
                }

                else
                {
                    Response.Redirect("~/Default.aspx?InvalidLogin=1", true);
                }
            }
            else
            {
                try
                {
                    Guid myClientID = Loginresult[0].AssociatedWith;
                    uspGetClientByIDResult               myClient          = ElectronicAppDB.uspGetClientByID(myClientID).Single <uspGetClientByIDResult>();
                    uspGetClientCoverageOptionsResult    myCoverageOptions = ElectronicAppDB.uspGetClientCoverageOptions(myClientID).Single <uspGetClientCoverageOptionsResult>();
                    List <uspGetClientPlanOptionsResult> myPlanOptions     = ElectronicAppDB.uspGetClientPlanOptions(myClientID).ToList <uspGetClientPlanOptionsResult>();

                    string[] myPlans = new string[myPlanOptions.Count];
                    int      i       = 0;
                    foreach (uspGetClientPlanOptionsResult po in myPlanOptions)
                    {
                        myPlans[i] = po.PlanName;
                        i          = i + 1;
                    }

                    coverageOffered myCoverageOffered = new coverageOffered(myPlans, myCoverageOptions.Medical, myCoverageOptions.Dental, myCoverageOptions.Vision, myCoverageOptions.Life, myCoverageOptions.Disability);

                    Session.Add("CoverageOffered", myCoverageOffered);
                    Session.Add("UserID", Guid.NewGuid());
                    Session.Add("ClientID", myClientID);
                    //Response.Redirect("~/Welcome.aspx", false);
                    FormsAuthentication.RedirectFromLoginPage("txtUserName.Text", false);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(ex.InnerException);
                    Response.Redirect("~/Default.aspx?Exception=1", true);
                }
            }
        }
Esempio n. 2
0
        // public string ClientName;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["ClientID"] != null)
                {
                    Guid myClientID = (Guid)Session["ClientID"];
                    try
                    {
                        ElectronicAppDBDataContext        electronicAppDB        = new ElectronicAppDBDataContext();
                        ElectronicAppStorageDBDataContext electronicAppStorageDB = new ElectronicAppStorageDBDataContext();
                        uspGetClientByIDResult            myClient        = electronicAppDB.uspGetClientByID(myClientID).Single <uspGetClientByIDResult>();
                        uspGetClientContactResult         myClientContact = electronicAppDB.uspGetClientContact(myClient.ClientID).Single <uspGetClientContactResult>();
                        uspGetBrokerByIDResult            myBroker        = electronicAppDB.uspGetBrokerByID(myClient.OwnerID).Single <uspGetBrokerByIDResult>();
                        uspGetBrokerContactResult         myBrokerInfo    = electronicAppDB.uspGetBrokerContact(myBroker.BrokerID).Single <uspGetBrokerContactResult>();
                        string ClientName = myClient.EmployerName;


                        uspGetBrokerByIDResult broker = electronicAppDB.uspGetBrokerByID(myClient.OwnerID).Single <uspGetBrokerByIDResult>();

                        System.Collections.Generic.List <uspGetBrokerImageByOwnerIDResult> searches = electronicAppStorageDB.uspGetBrokerImageByOwnerID(broker.BrokerID).ToList <uspGetBrokerImageByOwnerIDResult>();

                        bool hasImage = searches.Count > 0;

                        if (hasImage)
                        {
                            Image1.ImageUrl = "/BrokerImages/Broker.ashx?id=" + broker.BrokerID.ToString();
                        }


                        header.InnerHtml         = "<span class=\"red\">Welcome</span> " + ClientName;
                        BrokerName.InnerHtml     = myBroker.FirstName + " " + myBroker.LastName;
                        BrokerEmail.InnerHtml    = myBrokerInfo.Email;
                        BrokerPhone.InnerHtml    = myBrokerInfo.PhoneNumber;
                        BrokerFax.InnerHtml      = myBrokerInfo.Fax;
                        BrokerAddress.InnerHtml  = myBrokerInfo.Address;
                        BrokerAddress2.InnerHtml = myBrokerInfo.City + ", " + myBrokerInfo.State + " " + myBrokerInfo.Zip;

                        Session.Add("Client", myClient);
                        //ClientName = electronicAppDB.uspGetBrokerByID(myClient.OwnerID).Single<uspGetBrokerByIDResult>().
                    }
                    catch (Exception ex)
                    {
                        Session.Abandon();
                        FormsAuthentication.SignOut();
                        Response.Redirect("Default.aspx", false);
                    }
                }

                else if (Session["BrokerID"] != null)
                {
                    Response.Redirect("~/BrokerAdmin/Welcome.aspx", true);
                }

                else
                {
                    Session.Abandon();
                    FormsAuthentication.SignOut();
                    Response.Redirect("Default.aspx", false);
                }
            }
        }