Exemple #1
0
    /// <summary>
    /// Page_Load
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                DataTable[] tableArr = null;
                //获取域名
                string       nowurl   = HttpContext.Current.Request.Url.Host;
                User_Company uCompany = new PbProject.Logic.Login().GetByURL(nowurl);
                string       name     = (uCompany != null) ? uCompany.UninCode : "";//获取公司编号
                if (!string.IsNullOrEmpty(name))
                {
                    this.divLog.Style.Value     = "background:url('images/" + name + "/logo_top.jpg') no-repeat scroll left bottom transparent;height:70px;margin:0 auto;padding-top:12px;text-align:right;width:960px;";
                    this.divleftbox.Style.Value = "width: 330px; height: 530px;background:url(images/" + name + "/stuff.png) no-repeat";
                    divswf.InnerHtml            = "<div id='focus'>" +
                                                  "<ul>" +
                                                  "<li><a href='#' onclick='return false;'>" +
                                                  "<img src='Images/" + name + "/1.gif' style='width: 620px; height: 244px;' alt='' /></a></li>" +
                                                  "<li><a href='#' onclick='return false;'>" +
                                                  "<img src='Images/" + name + "/2.gif' style='width: 620px; height: 244px;' alt='' /></a></li>" +
                                                  "<li><a href='#' onclick='return false;'>" +
                                                  "<img src='Images/" + name + "/3.gif' style='width: 620px; height: 244px;' alt='' /></a></li>" +
                                                  "<li><a href='#' onclick='return false;'>" +
                                                  "<img src='Images/" + name + "/4.gif' style='width: 620px; height: 244px;' alt='' /></a></li>" +
                                                  "</ul>" +
                                                  "</div>";
                }
                else
                {
                    this.divLog.Style.Value     = "background:url('images/logo_top_1.jpg') no-repeat scroll left bottom transparent;height:70px;margin:0 auto;padding-top:12px;text-align:right;width:960px;";
                    this.divleftbox.Style.Value = "width: 330px; height: 530px;background:url('images/100001/stuff.png') no-repeat";

                    divswf.InnerHtml = "<div id='focus'>" +
                                       "<ul>" +
                                       "<li><a href='#' onclick='return false;'>" +
                                       "<img src='Images/1.gif' style='width: 620px; height: 244px;' alt='' /></a></li>" +
                                       "<li><a href='#' onclick='return false;'>" +
                                       "<img src='Images/2.gif' style='width: 620px; height: 244px;' alt='' /></a></li>" +
                                       "<li><a href='#' onclick='return false;'>" +
                                       "<img src='Images/3.gif' style='width: 620px; height: 244px;' alt='' /></a></li>" +
                                       "<li><a href='#' onclick='return false;'>" +
                                       "<img src='Images/4.gif' style='width: 620px; height: 244px;' alt='' /></a></li>" +
                                       "</ul>" +
                                       "</div>";
                }

                bool   IsAutoLogin    = false;
                bool   IsOrderPrompt  = false;
                string OrderPromptUrl = "";
                if (Request.QueryString["cudspeb"] != null && Request.QueryString["cpdwpdb"] != null && Request.QueryString["ctdyppbe"] != null)
                {
                    #region 自动登录

                    string loginName = Request.QueryString["cudspeb"].ToString();
                    string loginPwd  = Request.QueryString["cpdwpdb"].ToString();
                    string loginType = Request.QueryString["ctdyppbe"].ToString();

                    if (loginType == "cydepsb" && loginPwd == PbProject.WebCommon.Web.Cookie.SiteCookie.GetMD5(loginName))
                    {
                        loginPwd = "a!d@m#i$n%c^d&p*b";

                        //可以自动登录
                        PbProject.Logic.Login LoginManage = new PbProject.Logic.Login();

                        string msg = "";
                        IsAutoLogin = LoginManage.GetByName(loginName, loginPwd, true, Page.Request.UserHostAddress, out tableArr, out msg, 1, 0, 1);
                        //是否为客户端订单提醒而来
                        IsOrderPrompt = (Request["OrderPrompt"] != null && Request["OrderPrompt"].ToString() == "1") ? true : false;
                        if (IsOrderPrompt)
                        {
                            OrderPromptUrl = Request["ourl"] != null?HttpUtility.UrlEncode(Request["ourl"].ToString()) : "";
                        }
                    }

                    #endregion
                }
                else
                {
                    #region 普通登录
                    SiteCookie siteCookie  = new SiteCookie();
                    string     cookievalue = siteCookie.GetCookie("PBCookies");
                    if (!string.IsNullOrEmpty(cookievalue))
                    {
                        string[] cookies = cookievalue.Split('|');
                        txtUserName.Value          = cookies[0];
                        txtPwd.Attributes["value"] = cookies[1];
                        chkCook.Checked            = true;
                    }
                    #endregion
                }
                if (IsAutoLogin)
                {
                    string curid = tableArr[0].Rows[0]["id"].ToString();
                    string GoUrl = "Default.aspx?l=1&currentuserid=" + curid + (IsOrderPrompt ? "&ourl=" + OrderPromptUrl : "");
                    Response.Redirect(GoUrl, false);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), DateTime.Now.Ticks.ToString(), "IsOpen();", true);
                }
            }
        }
        catch (Exception ex)
        {
        }
    }