孙强的查询基类,及应用。

using System;
using System.Data.SqlClient;
using System.Data;

namespace WebShop
{
 /// <summary>
 /// Common 的摘要说明。
 /// </summary>
 public class Common:IDisposable
 {
  string sqlconn=System.Configuration.ConfigurationSettings.AppSettings["sqlconn"].ToString();
  SqlDataAdapter adapter;
  public DataSet full(string sqltext,CommandType comtype,string tablename,params SqlParameter[] para)
  {
   adapter=new SqlDataAdapter();
   adapter.SelectCommand=new SqlCommand();
   adapter.SelectCommand.Connection=new SqlConnection(sqlconn);
   adapter.SelectCommand.CommandText=sqltext;
   adapter.SelectCommand.CommandType=comtype;

   foreach(SqlParameter p in para)
   {
    adapter.SelectCommand.Parameters.Add(p);
   }

   DataSet ds=new DataSet();

   try
   {
    adapter.SelectCommand.Connection.Open();
    adapter.Fill(ds,tablename);
    return ds;
   }
   catch(System.Exception ex)
   {
    throw new Exception(ex.Message);
      
   }
   finally
   {
    adapter.SelectCommand.Connection.Close();
    
   }
   
  }

  
  public bool exec(string sqltext,CommandType comtype,params SqlParameter[] para)
  {
   adapter=new SqlDataAdapter();
   adapter.SelectCommand=new SqlCommand();
   adapter.SelectCommand.Connection=new SqlConnection(sqlconn);
   adapter.SelectCommand.CommandText=sqltext;
   adapter.SelectCommand.CommandType=comtype;

   foreach(SqlParameter p in para)
   {
    adapter.SelectCommand.Parameters.Add(p);
   }

   bool number=false;
   try
   {
    adapter.SelectCommand.Connection.Open();
    if(adapter.SelectCommand.ExecuteNonQuery()>0)
     number=true;
    return number;
    
   }
   catch(System.Exception ex)
   {
    throw new Exception(ex.Message);
    
   }
   finally
   {
    adapter.SelectCommand.Connection.Close();
    
   }
   
  }
  #region IDisposable 成员

  public void Dispose()
  {
   // TODO:  添加 Common.Dispose 实现
  }
  protected void Dispose(bool displsing)
  {
   if(displsing)
   {
    if(adapter!=null)
    {
     if(adapter.SelectCommand!=null)
     {
      if(adapter.SelectCommand.Connection!=null)
       adapter.SelectCommand.Connection.Dispose();
      adapter.SelectCommand.Dispose();
     }
     adapter.Dispose();
     adapter=null;
   
    }  
   }
  }

  #endregion
 }
}

 

 

应用

 

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;

namespace bargaining.ascx
{
 /// <summary>
 /// gerenfabu 的摘要说明。
 /// </summary>
 public class gerenfabu : System.Web.UI.Page
 {
  protected System.Web.UI.WebControls.Label Label1;
  protected System.Web.UI.WebControls.Button Button1;
  protected System.Web.UI.WebControls.DataList youxibi;
 
  private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   if(!Page.IsPostBack)
   {
    WebShop.Common common=new WebShop.Common();
    string strSql="SELECT wupinxinxi.shangpinid,wupinxinxi.serverid,dbo.game.gamename, dbo.subarea.gamesubarea,wupinxinxi.xinxibiaoti, dbo.server.gameserver,prop.propname,prop.propid, dbo.wupinxinxi.shuliang AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,wupinxinxi.xinxibiaoti,prop.propid,wupinxinxi.propid,wupinxinxi.serverid ,wupinxinxi.userid,wupinxinxi.shangpinid,dbo.wupinxinxi.shuliang,shengyushuliang HAVING (dbo.wupinxinxi.userid = '"+Session["UserId"].ToString()+"') and shengyushuliang>0";
    DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
    if(ds.Tables[0].Rows.Count>0)
    {
//     this.LabelRecord.Text=ds.Tables[0].Rows.Count.ToString();
//     int RecordCount=int.Parse(this.LabelRecord.Text);
//     int intPageNo,intPageSize,intPageCount;
//     intPageSize=5;
//     intPageCount=RecordCount%intPageSize==0?RecordCount/intPageSize:RecordCount/intPageSize+1;
//     LabelPage.Text = intPageCount.ToString();
//
//     PagedDataSource objpage=new PagedDataSource();
//     objpage.DataSource=ds.Tables[0].DefaultView;
//     objpage.AllowPaging=true;
//     objpage.PageSize=intPageSize;
//     if(this.Request["CurrentPage"]==null)
//     {
//      intPageNo=1;
//     }
//     else
//     {
//      intPageNo=int.Parse(this.Request["CurrentPage"]);
//     }
//   
//     if(!this.IsPostBack)
//     {
//      for(int i=1;i<=intPageCount;i++)
//      {
//       this.Dropdownlist2.Items.Add(i.ToString());
//      }
//      this.Dropdownlist2.SelectedValue=intPageNo.ToString();
//     }
//     intPageNo=int.Parse(this.Dropdownlist2.SelectedItem.Text);
//     this.LabelRow.Text=intPageNo.ToString();
//     objpage.CurrentPageIndex=intPageNo-1;
//     if(intPageNo>1)
//     {
//      this.HLFistPage.NavigateUrl="gerenshangdian.aspx?CurrentPage=1";
//      this.HLPrevPage.NavigateUrl=String.Concat("gerenshangdian.aspx?CurrentPage=","",intPageNo-1);
//     }
//     else
//     {
//      HLFistPage.NavigateUrl = "";
//      HLPrevPage.NavigateUrl = "";
//     }
//     if(intPageNo!=intPageCount)
//     {
//      this.HLNextPage.NavigateUrl=String.Concat("gerenshangdian.aspx?CurrentPage=","",intPageNo+1);
//      this.HLEndPage.NavigateUrl=String.Concat("gerenshangdian.aspx?CurrentPage=","",intPageCount);
//     }
//     else
//     {
//      this.HLNextPage.NavigateUrl="";
//      this.HLEndPage.NavigateUrl="";
//     }
     this.youxibi.DataSource=ds.Tables[0];
     this.youxibi.DataBind();
    }
   }
  }

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

  }
  #endregion

  public void Button1_Click(object sender, System.EventArgs e)
  {
   LinkButton d=(LinkButton)sender;
   string id=d.CommandArgument.ToString();
   WebShop.Common1 comm=new WebShop.Common1();
   string strSql="delete wupinxinxi where shangpinid='"+id+"'";
   comm.exec(strSql,CommandType.Text,"wupinxinxi");
  
  }
 }
}

 

 

 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.Web.Mail;
using System.Data.SqlClient;

namespace bargaining
{
 /// <summary>
 /// dingdan 的摘要说明。
 /// </summary>
 public class dingdan : System.Web.UI.Page
 {
  protected System.Web.UI.HtmlControls.HtmlForm Form1;
  protected System.Web.UI.HtmlControls.HtmlForm Form2;
  protected System.Web.UI.WebControls.Label Label10;
  protected System.Web.UI.WebControls.Label Label8;
  protected System.Web.UI.WebControls.Label Label9;
  protected System.Web.UI.WebControls.Label Label7;
  protected System.Web.UI.WebControls.LinkButton LinkButton1;
  protected System.Web.UI.WebControls.Label Label1;
  protected System.Web.UI.WebControls.Label Label6;
  protected System.Web.UI.WebControls.Label Label5;
  protected System.Web.UI.WebControls.Label Label3;
  protected System.Web.UI.WebControls.Label Label2;
  protected System.Web.UI.WebControls.Label Label4;
  protected System.Web.UI.WebControls.Image Image1;
  protected System.Web.UI.HtmlControls.HtmlTable Table7;
  protected System.Web.UI.WebControls.LinkButton LinkButton2;
  protected System.Web.UI.HtmlControls.HtmlForm Form3;
 
  private void Page_Load(object sender, System.EventArgs e)
  {
   string h="";
   if(!this.IsPostBack)
   {
    try
    {
     h=Session["UserId"].ToString();
    }
    catch
    {
     h="";
    }
    if(h!="")
    {
     this.Table7.Visible=false;
     string diankaname=this.Request.QueryString["dingdanname"].ToString();;
     Response.Write(diankaname);
     DataSet ds;
     string strSql="SELECT dbo.diankaxinxi.diankaid, dbo.diankaxinxi.diankaname, dbo.diankaxinxi.accountname, dbo.diankaxinxi.password, dbo.diankaxinxi.newjia, dbo.diankaxinxi.jiage, dbo.dianka.jieshengshu, dbo.dianka.dianshu, dbo.dianka.img ,dianka.beizhu,dbo.diankaxinxi.xiangxiid FROM dbo.dianka INNER JOIN dbo.diankaxinxi ON dbo.dianka.diankaid = dbo.diankaxinxi.diankaid where dianka.diankaname='"+diankaname+"'";
     using(WebShop.Common common=new WebShop.Common())
     {
      ds=common.full(strSql,CommandType.Text,"dianka");
     }
     if(ds.Tables[0].Rows.Count>0)
     {
      this.Image1.ImageUrl="dianka/"+ds.Tables[0].Rows[0][8].ToString();
      this.Label4.Text=ds.Tables[0].Rows[0][1].ToString();
      this.Label2.Text=ds.Tables[0].Rows[0][5].ToString();
      this.Label3.Text=ds.Tables[0].Rows[0][4].ToString();
      string jiesheng=ds.Tables[0].Rows[0][6].ToString();
      double jie=double.Parse(jiesheng.ToString());
      if(jie<0)
      {
       this.Label5.Text="现价高于原价";
      }
      else
      {
       this.Label5.Text=ds.Tables[0].Rows[0][6].ToString()==""?"0.00":ds.Tables[0].Rows[0][6].ToString();
      }
      this.Label6.Text=ds.Tables[0].Rows[0][7].ToString();
      this.Label1.Text=ds.Tables[0].Rows[0][9].ToString();
      this.ViewState.Add("accountname",ds.Tables[0].Rows[0][2].ToString());
      this.ViewState.Add("password",ds.Tables[0].Rows[0][3].ToString());
      this.ViewState.Add("diankaid",ds.Tables[0].Rows[0][10].ToString());
     }
     else
     {
     
      Response.Write( "<script language='javascript'>");
      Response.Write("alert('没有此点卡');");
      Response.Write( "parent.opener=null;");
      Response.Write( "window.close();");
      Response.Write( "</script>");

     }
    }
    else
    {
     Response.Write( "<script language='javascript'>");
     Response.Write("alert('请您先登陆');");
     Response.Write( "parent.opener=null;");
     Response.Write( "window.close();");
     Response.Write( "</script>");

    }

   }

   this.LinkButton1.Attributes.Add("onclick","return confirm('您确认购买吗?')");
  }
  private void sendemail(string kano,string pwd)
  {
   
   MailMessage mymail=new MailMessage();
   mymail.To=this.Session["Email"].ToString();
   mymail.From="lfjdc001@163.com";
   mymail.Subject=":您好!请查收您在天诚游戏网购买的点卡账号及密码!";
   mymail.Body="点卡账号:"+kano+"点卡密码:"+pwd;
   mymail.BodyFormat=MailFormat.Html;
   mymail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1" );
   mymail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "lfjdc001" );
   mymail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "2881056" );
   SmtpMail.SmtpServer ="smtp.163.com";
   try
   {
    SmtpMail.Send(mymail);

    this.Response.Write("<script>alert('点卡账号及密码已经发送到您的邮箱中,请注意查收!')</script>");
   }
   catch(System.Exception ex)
   {
    throw new Exception(ex.Message);
   }
  }
  #region Web 窗体设计器生成的代码
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {   
   this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
   this.LinkButton2.Click += new System.EventHandler(this.LinkButton2_Click);
   this.Load += new System.EventHandler(this.Page_Load);

  }
  #endregion

  private void LinkButton1_Click(object sender, System.EventArgs e)
  {

   DataSet account=(DataSet)this.Session["account"];
   if(account.Tables[0].Rows.Count>0)
   {
    if(double.Parse(account.Tables[0].Rows[0][2].ToString())>=double.Parse(this.Label3.Text))
    {
     int userid=int.Parse(this.Session["UserID"].ToString());
     using(WebShop.Common common=new WebShop.Common())
     {
      common.exec("pro_diankatran",CommandType.StoredProcedure,new SqlParameter("@userid",userid),new SqlParameter("@wupinname",this.Label4.Text),new SqlParameter("@jiage",decimal.Parse(this.Label3.Text)),new SqlParameter("@dingdantime",System.DateTime.Now.ToString()),new SqlParameter("@mymoney",decimal.Parse(this.Label3.Text)),new SqlParameter("@diankaid",int.Parse(this.ViewState["diankaid"].ToString())));
     }
     this.Table7.Visible=true;
     this.Label9.Visible=true;
     this.Label10.Visible=true;
     this.Label9.Text=this.ViewState["accountname"].ToString();
     this.Label10.Text=this.ViewState["password"].ToString();
     this.LinkButton1.Enabled=false;

     this.sendemail(this.ViewState["accountname"].ToString(),this.ViewState["password"].ToString());
//     this.Response.Redirect("default.aspx",false);

    }
    else
    {
     this.Response.Write("<script>alert('您的可用金额不足,请充值!')</script>");
    }
   }
   else
   {
    this.Response.Write("<script>alert('您的账户尚未充值,请先充值!')</script>");
   }
  }

  private void LinkButton2_Click(object sender, System.EventArgs e)
  {
//   this.Response.Redirect("default.aspx",true);
   DataSet account=(DataSet)this.Session["account"];
   if(account.Tables[0].Rows.Count>0)
   {
    if(double.Parse(account.Tables[0].Rows[0][2].ToString())>=double.Parse(this.Label3.Text))
    {
     int userid=int.Parse(this.Session["UserID"].ToString());
     using(WebShop.Common common=new WebShop.Common())
     {
      common.exec("pro_diankatran",CommandType.StoredProcedure,new SqlParameter("@userid",userid),new SqlParameter("@wupinname",this.Label4.Text),new SqlParameter("@jiage",decimal.Parse(this.Label3.Text)),new SqlParameter("@dingdantime",System.DateTime.Now.ToString()),new SqlParameter("@mymoney",decimal.Parse(this.Label3.Text)),new SqlParameter("@diankaid",int.Parse(this.ViewState["diankaid"].ToString())));
     }
     this.Table7.Visible=true;
     this.Label9.Visible=true;
     this.Label10.Visible=true;
     this.Label9.Text=this.ViewState["accountname"].ToString();
     this.Label10.Text=this.ViewState["password"].ToString();
     this.LinkButton1.Enabled=false;

     this.sendemail(this.ViewState["accountname"].ToString(),this.ViewState["password"].ToString());
     //     this.Response.Redirect("default.aspx",false);

    }
    else
    {
     this.Response.Write("<script>alert('您的可用金额不足,请充值!')</script>");
    }
   }
   else
   {
    this.Response.Write("<script>alert('您的账户尚未充值,请先充值!')</script>");
   }
  }

 }
}

Python网络爬虫与推荐算法新闻推荐平台:网络爬虫:通过Python实现新浪新闻的爬取,可爬取新闻页面上的标题、文本、图片、视频链接(保留排版) 推荐算法:权重衰减+标签推荐+区域推荐+热点推荐.zip项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全领域),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助。 【资源内容】:包含完整源码+工程文件+说明(如有)等。答辩评审平均分达到96分,放心下载使用!可轻松复现,设计报告也可借鉴此项目,该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的。 【提供帮助】:有任何使用问题欢迎随时与我联系,我会及时解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 下载后请首先打开README文件(如有),项目工程可直接复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值