using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Drawing.Printing;
using System.Drawing.Imaging;
using System.IO;
//**************************************************************************************
//    姓名：姜士振
//    时间：2011-07-17
//    备注：产生验证码
//    更改人：姜士振
//**************************************************************************************


namespace HteamFeedback.Web.Web
{
    public partial class ValidateNum : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string NumStr = null;
            System.Random Rad = new System.Random();
            int RadNum = Rad.Next(9999);
            if (RadNum.ToString().Length != 4)
            {

                for (int i = 1; i <= 4 - RadNum.ToString().Length; i++)
                {
                    NumStr += "0";
                }
                NumStr += RadNum.ToString();
            }
            else
            {
                NumStr = RadNum.ToString();
            }
            string str = NumStr;
            Session["verifycode"] = NumStr;
            Bitmap image = new Bitmap(58, 20);
            Graphics g = Graphics.FromImage(image);
            g.Clear(Color.Chocolate);
            g.DrawString(str, new Font("宋体", 16, System.Drawing.FontStyle.Bold), new SolidBrush(Color.AliceBlue), 0, 0);
            image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
            Response.Cache.SetNoStore(); 

            string validateNum = str;
            Session["validateNum"] = validateNum;                    
        }  
    }
}