⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ranpic.aspx.cs

📁 这是个短信群发的程序
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.IO;

namespace WebSiteSoft
{
	/// <summary>
	/// WebForm1 的摘要说明。
	/// </summary>
	public partial class WebForm1 : System.Web.UI.Page
	{
		public string v_banktype="";
	    public string g_payerid="";
		protected void Page_Load(object sender, System.EventArgs e)
		{
			string tmp = RndNum(4);
            string Id = Request["id"] == null ? "0" : Request["id"].ToString().Trim();
            if (Id == "1")
            {
                Session["RandCode1"] = tmp;
                CreateCheckCodeImage(tmp);
            }
            else if (Id == "2")
            {
                Session["RandCode2"] = tmp;
                CreateCheckCodeImage(tmp);
            }
            else
            {
                Session["RandCode"] = tmp;
                CreateCheckCodeImage(tmp);
            }
			//HttpCookie a = new HttpCookie("ImageV",tmp);
            
			//this.ValidateCode(tmp);

            
		}
		private void ValidateCode(string VNum) 
		{
			Bitmap Img=null;
			Graphics g=null;
			MemoryStream ms=null;

			int gheight=VNum.Length*13;
			Img=new Bitmap(gheight,25);
			g=Graphics.FromImage(Img);
			//背景颜色
			g.Clear(Color.Blue);
			//文字字体
			Font f=new Font("黑体",15);
		
			//文字颜色
			SolidBrush s=new SolidBrush(Color.White);
			g.DrawString(VNum,f,s,3,3);
			ms=new MemoryStream();
			Img.Save(ms,ImageFormat.Jpeg);
			Response.ClearContent(); 
			Response.ContentType="image/Jpeg";
			Response.BinaryWrite(ms.ToArray());

			g.Dispose();
			Img.Dispose();
			Response.End();
		}

        private void CreateCheckCodeImage(string checkCode)
        { //将验证码生成图片显示
            if (checkCode == null || checkCode.Trim() == String.Empty)
                return;

            System.Drawing.Bitmap image = new System.Drawing.Bitmap((int)Math.Ceiling((checkCode.Length * 12.5+5)), 22);
            Graphics g = Graphics.FromImage(image);

            try
            {
                //生成随机生成器 
                Random random = new Random();

                //清空图片背景色 
                g.Clear(Color.White);

                //画图片的背景噪音线 
                for (int i = 0; i < 25; i++)
                {
                    int x1 = random.Next(image.Width);
                    int x2 = random.Next(image.Width);
                    int y1 = random.Next(image.Height);
                    int y2 = random.Next(image.Height);

                    g.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2);
                }

                Font font = new System.Drawing.Font("Arial", 12, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic));
                System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.DarkRed, 1.2f, true);
                g.DrawString(checkCode, font, brush, 2, 2);

                //画图片的前景噪音点 
                for (int i = 0; i < 100; i++)
                {
                    int x = random.Next(image.Width);
                    int y = random.Next(image.Height);

                    image.SetPixel(x, y, Color.FromArgb(random.Next()));
                }

                //画图片的边框线 
                g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);

                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
                Response.ClearContent();
                Response.ContentType = "image/Gif";
                Response.BinaryWrite(ms.ToArray());
            }
            finally
            {
                g.Dispose();
                image.Dispose();
            }
        }

		private void WriteCount()
		{
			string temp="server=127.0.0.1;database=WebSite;uid=sa;pwd=please";
			SqlConnection conn = new SqlConnection(temp);
		    temp="select NetDNS from down_count";
			SqlCommand cmd= new SqlCommand(temp,conn);
			conn.Open();
			string ip;
			ip=Request.UserHostAddress.ToString();
			string ce=cmd.ExecuteScalar().ToString();
			int lc=Int32.Parse(ce)+1;
			temp="Update down_count Set NetDNS="+lc+",lasttime='"+DateTime.Now.ToString()+"',userip='"+ip+"'";
			//Response.Write(temp);
			cmd.CommandText=temp;
			cmd.ExecuteNonQuery();
	        conn.Close();


		}

		private void Write_BankLog()
		{
		
			string temp="";
			//if (Int32.Parse(g_payerid.ToString()))
		    string connstr="server=127.0.0.1;database=WebSite;uid=sa;pwd=please";
		    SqlConnection conn = new SqlConnection(connstr);
			if(g_payerid.ToString() !="" || g_payerid !=null)
			{
				try
				{
					int payid=Int32.Parse(g_payerid.ToString());
				    temp="select s_id from web_payer where s_id="+payid;
				    SqlCommand scmd =new SqlCommand(temp,conn);
					conn.Open();
					if(Int32.Parse(scmd.ExecuteScalar().ToString()) != payid)
					{
						conn.Close();
						Response.Write("支付者ID非法,请返回重新操作!");
						return;
					}
					conn.Close();
				}
				catch
				{
					Response.Write("支付者ID非法,请返回重新操作!");
					return;
				}

			}
	        string v_order_id,v_bank_type,v_deal_money,v_begin_time,v_product_name,v_client_ip,v_moneytype;
			if(Request["v_banktype"].ToString().Trim() == "云网在线")
			{
				v_order_id=Request.Form["v_dingdan2"].ToString();
				v_bank_type=Request.Form["v_banktype"].ToString();
				v_deal_money=Request.Form["v_amount2"].ToString();;
				v_begin_time=DateTime.Now.ToString();
				v_product_name=Request.Form["productname"].ToString();
				v_client_ip=Request.UserHostAddress.ToString();
				v_moneytype=Request.Form["c_moneytype"].ToString();
			
			}
			else
			{
	         v_order_id=Request.Form["v_dingdan"].ToString();
		     v_bank_type=Request.Form["v_banktype"].ToString();
			 v_deal_money=Request.Form["v_amount"].ToString();;
			 v_begin_time=DateTime.Now.ToString();
			 v_product_name=Request.Form["productname"].ToString();
			 v_client_ip=Request.UserHostAddress.ToString();
			 v_moneytype=Request.Form["v_moneytype"].ToString();
			}
			try
			{
			 float.Parse(v_deal_money);
			}
			catch
			{
				v_deal_money="0";
			}
			/*string v_payment_code="";
			string v_deal_number="";
			string v_status_code="";
			string v_end_time="";
			string v_real_money="";
			string v_str_result="";
			string v_card_mode="";
			string v_md5str="";*/
            string sql="insert into website_payment(order_id,bank_type,deal_money,begin_time,product_name,client_ip,moneytype,payer) values "+
                                                  "('"+v_order_id+"','"+v_bank_type+"',"+v_deal_money+",'"+v_begin_time+"','"+v_product_name+"','"+v_client_ip+"','"+v_moneytype+"',"+Int32.Parse(g_payerid.ToString())+")";	
		    SqlCommand cmd = new SqlCommand(sql,conn);
			conn.Open();
			cmd.ExecuteNonQuery();
			conn.Close();
		}

		private string RndNum(int VcodeNum)
		{
			string Vchar="0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P"+
				",Q,R,S,T,U,V,W,X,Y,Z";
			string[] VcArray=Vchar.Split(new Char [] {','});
			string VNum="";
			int temp=-1;

			Random rand=new Random();

			for(int i=1;i<VcodeNum+1;i++)
			{
				if(temp!=-1)
				{
					rand=new Random(i*temp*unchecked((int)DateTime.Now.Ticks));
				}

				int t=rand.Next(35);
				if(temp!=-1&&temp==t)
				{
					return RndNum(VcodeNum);
				}
				temp=t;
				VNum+=VcArray[t];
			}
			return VNum;
		}


		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    

		}
		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -