Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //先判断是POST还是GET
            if (IsPostBack)
            {
                string      userName    = Request.Form["txtName"];
                string      userPwd     = Request.Form["txtPwd"];
                string      msg         = string.Empty;
                DataTable   dt          = new DataTable();
                customerBll customerBll = new customerBll();
                if (customerBll.CheckUserInfo(userName, userPwd, out msg, out dt))
                {
                    Session["userName"] = userName;
                    Response.Redirect("LoginSuccess.aspx");
                }
                else
                {
                    Msg = msg;
                }

                Response.Cookies["userName"].Value   = userName;
                Response.Cookies["userName"].Expires = DateTime.Now.AddDays(3);
            }
            else
            {
                if (Session["userName"] != null)
                {
                    Response.Redirect("LoginSuccess.aspx");
                }
            }
        }
Ejemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            int pageIndex;

            if (!int.TryParse(context.Request["pageIndex"], out pageIndex))
            {
                pageIndex = 1;
            }
            customerBll customerBll = new customerBll();

            int pageCount = customerBll.GetPageCount(10);

            pageIndex = pageIndex < 1 ? 1 : pageIndex;
            pageIndex = pageIndex > pageCount ? pageCount : pageIndex;



            DataTable dt = customerBll.GetPageList(pageIndex, 10);

            string str = JsonConvert.SerializeObject(dt);

            context.Response.Write(str);
        }
Ejemplo n.º 3
0
        protected void AddcustomerInfo()
        {
            customer customer = new customer();

            customer.Name = Context.Request.Form["Name"];
            customer.Age  = Context.Request.Form["Age"];
            customerBll customerBll = new customerBll();

            customerBll.AddCustomer(customer);
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            StringBuilder sb       = new StringBuilder();
            int           pageSize = 10;
            int           pageIndex;
            int           pageCount;
            DataTable     dt = new DataTable();

            if (!int.TryParse(Context.Request.QueryString["pageIndex"], out pageIndex))
            {
                pageIndex = 1;
            }

            customerBll customerBll = new customerBll();

            pageCount        = customerBll.GetPageCount(pageSize);
            pageIndex        = pageIndex < 1 ? 1 : pageIndex;
            pageIndex        = pageIndex > pageCount ? pageCount : pageIndex;
            CurrentPageIndex = pageIndex;
            PageCount        = pageCount;


            dt = customerBll.GetPageList(pageIndex, pageSize);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sb.AppendFormat("<li>{0}</li>", dt.Rows[i]["Name"]);
            }

            strHtml = sb.ToString();

            sb.Clear();

            int startPage = CurrentPageIndex - 5 < 1 ? 1 : CurrentPageIndex - 5;
            int endPage   = startPage + 9 > pageCount ? pageCount : startPage + 9;

            for (int i = startPage; i < endPage; i++)
            {
                if (i == CurrentPageIndex)
                {
                    sb.AppendFormat("{0}, ", i + 1);
                }
                else if (i < pageCount - 1)
                {
                    sb.AppendFormat("<a href=customerList.aspx?pageIndex={0}>{0}</a>, ", i + 1);
                }
                else
                {
                    sb.AppendFormat("<a href=customerList.aspx?pageIndex={0}>{0}</a>", i + 1);
                }
            }

            PageNum = sb.ToString();
        }
Ejemplo n.º 5
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     string userName = context.Request["name"];
     customerBll customerBll = new customerBll();
     if (customerBll.GetSingleCustomer(userName).Rows.Count == 0)
     {
         context.Response.Write("此用户名可以使用!");
     }
     else
     {
         context.Response.Write("此用户名已使用,请更换!");
     }
 }
Ejemplo n.º 6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Cache["customerInfo"] == null)
     {
         customerBll customerBll = new customerBll();
         Cache.Insert("customerInfo", customerBll.GetAllCustomerInfo(), null, DateTime.Now.AddSeconds(3), TimeSpan.Zero, CacheItemPriority.Normal, RemoveCacheItem);
         Response.Write("来自数据库的数据");
     }
     else
     {
         Response.Write("来缓存");
         //DataTable dt = (DataTable) Cache["customerInfo"];
     }
 }
Ejemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ShowEditCustomer();
     }
     else
     {
         customer    customer    = new customer();
         customerBll customerBll = new customerBll();
         customer.ID   = Convert.ToInt32(Context.Request.Form["ID"]);
         customer.Name = Context.Request.Form["Name"];
         customer.Age  = Context.Request.Form["Age"];
         customerBll.EditCustomer(customer);
         Context.Response.Redirect("customerInfo.aspx");
     }
 }
Ejemplo n.º 8
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int id;

            if (int.TryParse(context.Request.QueryString["id"], out id))
            {
                customerBll customerBll = new customerBll();
                if (customerBll.DeleteCustomer(id) > 0)
                {
                    context.Response.Redirect("customerInfo.aspx");
                }
            }
            else
            {
                context.Response.Write("参数错误~!");
            }
        }
Ejemplo n.º 9
0
        protected void ShowEditCustomer()
        {
            int id;

            if (int.TryParse(Context.Request.QueryString["id"], out id))
            {
                customerBll customerBll = new customerBll();
                dt = customerBll.GetSingleCustomer(id);
                if (dt.Rows.Count == 0)
                {
                    Context.Response.Redirect("参数错误!!");
                }
            }
            else
            {
                Context.Response.Write("参数错误!!");
            }
        }
Ejemplo n.º 10
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            customer customer = new customer();

            customer.ID   = int.Parse(context.Request["txtID"]);
            customer.Name = context.Request["txtName"];
            customer.Age  = context.Request["txtAge"];
            customerBll customerBll = new customerBll();

            if (customerBll.EditCustomer(customer) > 0)
            {
                context.Response.Write("YES");
            }
            else
            {
                context.Response.Write("NO");
            }
        }
Ejemplo n.º 11
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int id = 0;


            if (int.TryParse(context.Request["id"], out id))
            {
                customerBll customerBll = new customerBll();
                if (customerBll.DeleteCustomer(id) > 0)
                {
                    context.Response.Write("YES");
                }
                else
                {
                    context.Response.Write("NO");
                }
            }
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            customerBll customerBll = new customerBll();
            DataTable   dt          = customerBll.GetAllCustomerInfo();

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sb.AppendFormat("<tr><td>{0}</td>" +
                                "<td>{1}</td>" +
                                "<td>{2}</td>" +
                                "<td><a href = \"DeleteCustomer.ashx?id={3}\" class = \"delete\">删除</a></td>" +
                                "<td><a href = EditCustomer.aspx?id={4} class = edit>修改</a></td>" +
                                "</tr></br>",
                                dt.Rows[i]["ID"], dt.Rows[i]["Name"], dt.Rows[i]["Age"], dt.Rows[i]["ID"], dt.Rows[i]["ID"]);
            }

            strHtml = sb.ToString();
        }
Ejemplo n.º 13
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int id = 0;

            if (int.TryParse(context.Request["id"], out id))
            {
                customerBll customerBll = new customerBll();
                DataTable   dt          = customerBll.GetSingleCustomer(id);
                if (dt.Rows.Count > 0)
                {
                    string str = JsonConvert.SerializeObject(dt);
                    context.Response.Write(str);
                }
                else
                {
                    context.Response.Write("NO");
                }
            }
        }
Ejemplo n.º 14
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            customerBll customerBll = new customerBll();
            string      userName    = context.Request["name"];
            string      userPwd     = context.Request["pwd"];
            DataTable   dt          = customerBll.GetSingleCustomer(userName);

            if (dt.Rows.Count == 0)
            {
                context.Response.Write("NO:" + "登录失败");
            }
            else if (dt.Rows[0]["Age"].ToString() != userPwd)
            {
                context.Response.Write("NO:" + "用户名或密码错误");
            }
            else
            {
                context.Session["userInfo"] = userName;
                context.Response.Write("YES:" + "登录成功~~~~");
            }
        }
Ejemplo n.º 15
0
 //========================================
 // Constructor for this class
 //========================================
 public CustomerView()
 {
     dataBll = new customerBll();
 }