Web开发记事本

基于Microsoft提供的技术
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

test

Posted on 2008-09-28 12:35  郑 文  阅读(48)  评论(0)    收藏  举报

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Model;
using Components;

public partial class CardActive : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        step2.Visible = false;
        if (ConfigurationManager.AppSettings["AddScoreToCardUser"].ToString() == "1")
        { Scoretip.Visible = true;
        Label1.Text = ConfigurationManager.AppSettings["CardUserScore"].ToString(); 
        }
    }

    protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (args.Value.Length > 10 || args.Value.Length<3)

            args.IsValid = false;

        else

            args.IsValid = true;
    }
    protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (args.Value.Length > 10 || args.Value.Length < 6)

            args.IsValid = false;

        else

            args.IsValid = true;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        CardBox cb = new CardBox();
        CardInfo ci = new CardInfo();
        ci.CardNo = CardNo.Text;
        int statu;
        statu = cb.CheckStatu(ci);
        if (statu == 2) { Jscript.Alert("该卡不存在,请仔细核实卡号重新输入!"); }
        if (statu == 1) { Jscript.Alert("该卡已被其他用户使用!"); }
        if (statu == 0)
        {
            string id;

            CardUser cUser = new CardUser(UserName.Text);
            ci = cb.ReadCard(CardNo.Text);

            cUser.info.UserName = UserName.Text;
            cUser.info.Password = Password1.Text;
            cUser.info.City = "上海";
            cUser.info.ActiveTime = DateTime.Now;
            cUser.info.CardNo = CardNo.Text;
            cUser.info.Email = Email.Text;
            cUser.info.IP = Request.ServerVariables["REMOTE_ADDR"];
            cUser.info.Mobile = Mobile.Text;
            cUser.info.VipName = VipName.Text;
            if (cUser.info.Mobile.Trim() == "") { Jscript.Alert("请输入手机号码!"); }
            id = cUser.CreatId();
            cUser.info.Id = id;
            if (cUser.IsExist(cUser.info)) { Jscript.Alert("该用户名已有他人使用,请更换"); }
            else
            {
                cUser.SaveInfo();
               
                cb.BandCard(ci, cUser.info.Id);
                //cb.ac.Statu = cb.SendCoupon(cb.ac);
                cb.ac.Statu = 1;
                step1.Visible = false;
                step2.Visible = true;
                Label2.Text = ci.CardNo;
                if (cb.ac.Statu == 1)
                {
                    Message newMessage = new Message();
                    newMessage.Title = "优惠券信息";
                    newMessage.Body = "您获得了" + cb.ac.Detail + "一张,编号为:" + cb.ac.No + " 请于" + cb.ac.EndTime.ToString() + "前使用。";
                    Label3.Text = newMessage.Body;
                    Button1.Visible = true;

                    WebUser sysUser = new WebUser("酷棒网");
                    sysUser.SendMessage(cUser, newMessage);
                }


            }
        }


    }


   

    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("http://www.121-go.com/");
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Redirect("http://www.kubang.net");
    }
    protected void CustomValidator3_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (args.Value.Length !=19)

            args.IsValid = false;

        else

            args.IsValid = true;
    }


}