<%@ WebHandler Language="C#" Class="Login" %>

using System;
using System.Web;
using HuiboBll;

public class Login : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
    private string userName=string.Empty,userPwd=string.Empty,yzCode=string.Empty,state=string.Empty;
    user IsLogin = new user();
    GetPublic Gpc = new GetPublic();
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        userName = context.Request["userName"].Trim();
        userPwd = context.Request["userPwd"].Trim();
        yzCode = context.Request["yzCode"].Trim().ToLower();
        if (!yzCode.ToLower().Equals(context.Session["S_SerialNumber"].ToString().ToLower()))
        {
            state = "yzsb";
        }
        else {
            string Pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(userPwd, "md5");
            if (IsLogin.Login(userName, Pwd))
            {
                string uName = SessionOprate.SessionOprate.Shop.username;
                string dj = Gpc.GetMember(" Grade=" + SessionOprate.SessionOprate.Shop.vip, "grpname", "grpclass");

                int DetailID = 0;
                Single CartTotalPrice = 0;
                if (SessionOprate.SessionOprate.Shop != null)
                {
                    DetailID = Gpc.GetNumber(" username='" + SessionOprate.SessionOprate.Shop.username + "' and state=8", "detailid", "orderdetail");
                    System.Data.DataSet Ds = new System.Data.DataSet();
                    Ds = Gpc.GetList("Select id,productnum from orders where detailid = " + DetailID + " order by orderid desc");
                    foreach (System.Data.DataRow Dr in Ds.Tables[0].Rows)
                    {
                        Single VipPrice = Gpc.GetVipPrice(Convert.ToInt32(Dr["id"]));
                        VipPrice = VipPrice * Convert.ToInt32(Dr["productnum"]);
                        CartTotalPrice = CartTotalPrice + VipPrice;
                    }
                }
                string gwNum = CartTotalPrice.ToString();
                int CartProNum = 0;
                if (SessionOprate.SessionOprate.Shop != null)
                {
                    CartProNum = Convert.ToInt32(Gpc.GetNumber("detailid in (Select detailid from orderdetail where username = '" + SessionOprate.SessionOprate.Shop.username + "' and state = 8)", "sum(productnum)", "orders"));
                }
                string spSum = Convert.ToString(CartProNum);
                state = uName + "@#$" + dj + "@#$" + gwNum + "@#$" + spSum;
            }
            else {
                state = "loginFailure";
            }
        }
        context.Response.Write(state);
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}