protected void btnOK_Click(object sender, EventArgs e) { if (this.txtVali.Text != this.labVali.Text) { Response.Write("<script lanuage=javascript>alert('验证码错误');location='javascript:history.go(-1)'</script>"); } else { SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]); con.Open(); SqlCommand com = new SqlCommand("select count(*) from tb_Admin where UserName='******' and PassWord='******'", con); SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from tb_Admin where UserName='******'"); read.Read(); if (read.HasRows) { Session["SuperAdmin"] = read["SuperAdmin"].ToString(); } read.Close(); int count = Convert.ToInt32(com.ExecuteScalar()); if (count > 0) { Session["UserName"] = this.txtUid.Text; Session["PassWord"] = this.txtPwd.Text; Page.Response.Redirect("ST_BlogIndex.aspx"); } else { Response.Write("<script lanuage=javascript>alert('用户名或密码有误!');location='javascript:history.go(-1)'</script>"); return; } } }
//登录事件 protected void ImageButton2_Click(object sender, ImageClickEventArgs e) { string userName = username.Text.Trim(); string passWord = password.Text.Trim(); if (string.IsNullOrEmpty(userName)) { Response.Write("<script lanuage=javascript>alert('请输入用户名!');location='javascript:history.go(-1)'</script>"); return; } if (string.IsNullOrEmpty(passWord)) { Response.Write("<script lanuage=javascript>alert('请输入密码!');location='javascript:history.go(-1)'</script>"); return; } string sql = string.Format("SELECT *,userlevelname FROM [userinfo]A,[gy_Userlevel]B where A.userlevelID=B.userlevelID AND username='******' and userpwd='{1}'", userName, Md5.Encrypt(passWord)); SqlData da = new SqlData(); SqlDataReader read = da.ExceRead(sql); read.Read(); if (read.HasRows) { string userlevelname = Convert.ToString(read["userlevelname"]); Session["username"] = this.username.Text; Session["password"] = this.password.Text; Session["userlevel"] = userlevelname; Session["userinfoID"] = read["userinfoID"]; Page.Response.Redirect("chaxun.aspx"); } else { Response.Write("<script lanuage=javascript>alert('用户名或密码有误!');location='javascript:history.go(-1)'</script>"); return; } }
protected void btnOK_Click(object sender, EventArgs e) { SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from tb_Admin where UserName='******'"); read.Read(); if (read.HasRows) { if (this.txtName.Text == read["UserName"].ToString()) { Response.Write("<script language=javascript>alert('对不起,该用户已经注册!');location='Register.aspx'</script>"); return; } } read.Close(); string P_str_Com = "insert into tb_Admin(UserName,PassWord,Question,Answer,ReallyName,Birthday,Address" + ",PostCode,Email,HomePhone,MobilePhone,QQ,ICQ,RegTime,Sex,SuperAdmin,IP) values('" + this.txtName.Text + "'" + ",'" + this.txtPwd.Text + "','" + this.txtQues.Text + "','" + this.txtAns.Text + "','" + this.txtRealName.Text + "'" + ",'" + this.txtBirthday.Text + "','" + this.txtAddress.Text + "','" + this.txtPostCode.Text + "','" + this.txtEmail.Text + "'" + ",'" + this.txtHphone.Text + "','" + this.txtMphone.Text + "','" + this.txtQQ.Text + "','" + this.txtICQ.Text + "','" + DateTime.Now.ToString() + "','" + this.DropDownList1.SelectedValue + "','"+this.DropDownList2.SelectedValue+"','"+Request.UserHostAddress+"')"; bool add = da.ExceSQL(P_str_Com); if (add == true) { Response.Write("<script language=javascript>alert('注册成功!');location='AdminManage.aspx'</script>"); } else { Response.Write("<script language=javascript>alert('注册失败!');location='javascript:history.go(-1)'</script>"); } }
protected void btnOK_Click(object sender, EventArgs e) { SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from tb_Visitor where VisitorName='" + this.txtName.Text + "'"); read.Read(); if (read.HasRows) { if (this.txtName.Text == read["VisitorName"].ToString()) { Response.Write("<script language=javascript>alert('对不起,该用户已经注册!');location='Register.aspx'</script>"); return; } } read.Close(); //若用户名不存在,则执行下面的SQL语句 string Com = "insert into tb_Visitor(VisitorName,PassWord,ReallyName,Birthday,Address,PostCode,Email,HomePhone,MobilePhone,QQ,ICQ,Sex,RegTime,IP,BlogID)" + " values('" + this.txtName.Text + "','" + this.txtPwd.Text + "','" + this.txtRealName.Text + "','" + this.txtBirthday.Text + "'" + ",'" + this.txtAddress.Text + "','" + this.txtPostCode.Text + "','" + this.txtEmail.Text + "','" + this.txtHphone.Text + "'" + ",'" + this.txtMphone.Text + "','" + this.txtQQ.Text + "','" + this.txtICQ.Text + "'" + ",'" + this.DropDownList1.SelectedValue + "','" + DateTime.Now.ToString() + "','" + Page.Request.UserHostAddress + "','" + ID + "')"; da.ExceSQL(Com); string StrName = this.txtName.Text; Response.Redirect("RegSuccess.aspx?VisitorName=" + StrName); }
protected void btnOK_Click(object sender, EventArgs e) { SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from tb_Admin where UserName='******'"); read.Read(); if (read.HasRows) { if (this.txtName.Text == read["UserName"].ToString()) { Response.Write("<script language=javascript>alert('对不起,该用户已经注册!');location='Register.aspx'</script>"); return; } } read.Close(); string P_str_Com = "insert into tb_Admin(UserName,PassWord,Question,Answer,ReallyName,Birthday,Address" + ",PostCode,Email,HomePhone,MobilePhone,QQ,ICQ,RegTime,Sex,SuperAdmin,IP) values('" + this.txtName.Text + "'" + ",'" + this.txtPwd.Text + "','" + this.txtQues.Text + "','" + this.txtAns.Text + "','" + this.txtRealName.Text + "'" + ",'" + this.txtBirthday.Text + "','" + this.txtAddress.Text + "','" + this.txtPostCode.Text + "','" + this.txtEmail.Text + "'" + ",'" + this.txtHphone.Text + "','" + this.txtMphone.Text + "','" + this.txtQQ.Text + "','" + this.txtICQ.Text + "','" + DateTime.Now.ToString() + "','" + this.DropDownList1.SelectedValue + "','" + this.DropDownList2.SelectedValue + "','" + Request.UserHostAddress + "')"; bool add = da.ExceSQL(P_str_Com); if (add == true) { Response.Write("<script language=javascript>alert('注册成功!');location='AdminManage.aspx'</script>"); } else { Response.Write("<script language=javascript>alert('注册失败!');location='javascript:history.go(-1)'</script>"); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["userName"] == null) { Response.Write("<script language=javascript>alert('尚未登陆,请登陆后学习');location='Login.aspx'</script>"); } else { SqlData da = new SqlData(); String sqlNextWord = "select * from words where wordId=(select nextWordId from people where userName='******')"; SqlDataReader sqlDataReader = da.ExceRead(sqlNextWord); //Response.Write("1<br>"); if (sqlDataReader.HasRows) { //Response.Write("2<br>"); // Response.Write(sqlDataReader.ToString()); sqlDataReader.Read(); word = sqlDataReader.GetValue(0).ToString().Trim(); explanation = sqlDataReader.GetValue(1).ToString().Trim(); } else { //Response.Write("5<br>"); Response.Write( "<script language=javascript>alert('请联系管理员,您的单词库出现错误!');/*location='Register.aspx'*/;</script>"); } } }
/// <summary> /// 获得评论。 /// </summary> public void ST_get_Replay() { Response.Write("<table width=100% border=0 cellspacing=0 cellpadding=0>"); string sqlstr = "select * from ST_replay where ST_n_id=" + Request.QueryString["id"] + ""; SqlDataReader ST_read = myobj.ExceRead(sqlstr); while (ST_read.Read()) { Response.Write("<tr height=25><td bgcolor=eeeeee><div align=center><font style='FONT-SIZE: 12px' color=red>" + ST_read[2].ToString() + "</font></div></td></tr><tr height=30><td><font style='FONT-SIZE: 12px'>" + ST_read[3].ToString() + "</font></td></tr><tr><td bgcolor=f8f8f8><div align=right><font style='FONT-SIZE: 12px'>" + ST_read[1].ToString() + "评论于" + ST_read[4].ToString() + "</font></div></td></tr>"); } Response.Write("</table>"); }
public void SqlDR() { string mydr = "select top 4 * from ST_news order by ST_n_date desc"; SqlData sqldata = new SqlData(); SqlDataReader dr = sqldata.ExceRead(mydr); while (dr.Read()) { Response.Write("<a href='article.aspx?id=" + dr["ST_n_id"].ToString() + "'>" + dr["ST_n_title"].ToString() + "  摘要:" + dr["ST_n_key"].ToString() + "  时间:" + dr["ST_n_date"].ToString() + "</a><br/>"); } dr.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from tb_Blog where BlogID='" + Session["pwd1"].ToString() + "'"); while (read.Read()) { this.txtPwd.Text = read["PassWord"].ToString(); } read.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from tb_Blog where BlogID='" + Session["pwd1"] + "'"); while (read.Read()) { txtPwd.Text = read["PassWord"].ToString(); } read.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { if (Session["username"] != null && Session["username"].ToString() != string.Empty) { this.user.Text = Session["username"].ToString(); SqlData da = new SqlData(); string id = Request.QueryString["id"]; if (id != null && id.ToString() != string.Empty) { Button1.Visible = false; string sqlstr = "select * from gy_train where gy_trainID=" + id + " "; SqlDataReader read = da.ExceRead(sqlstr); read.Read(); if (read.HasRows) { this.datetime.Text = read["gy_t_time"].ToString(); this.carNO.Text = read["gy_t_carno"].ToString(); this.shipper.Text = read["gy_t_shipper"].ToString(); this.beginarea.Text = read["gy_t_bgarea"].ToString(); this.consignee.Text = read["gy_t_consignee"].ToString(); this.totalamount.Text = read["gy_t_totalamount"].ToString(); this.factamount.Text = read["gy_t_realamount"].ToString(); this.carriage.Text = read["gy_t_carriage"].ToString(); this.djf.Text = read["gy_t_djf"].ToString(); this.yfk.Text = read["gy_t_yff"].ToString(); this.remark.Text = read["gy_t_remark"].ToString(); this.DropDownList1.SelectedValue = read["jsID"].ToString(); read.Close(); } } else { this.Button2.Visible = false; } } else { ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "click", "alert('您还未登录系统,不能访问此页!请先登录系统。');location='default.aspx'", true); return; } } }
protected void btnOK_Click(object sender, EventArgs e) { //定义一个SqlData的新实例对象 SqlData da = new SqlData(); //调用公共类的ExceRead方法,返回SqlDataReader类型的数据 SqlDataReader read = da.ExceRead("select * from tb_Blog where UserName='******'"); //读取数据库中的数据 read.Read(); //判断用户是否已经注册 if (read.HasRows) { if (txtName.Text == read["UserName"].ToString()) { Response.Write("<script language=javascript>alert('对不起,该用户已经注册!');location='Register.aspx'</script>"); return; } } read.Close(); //定义一个字符串,插入相关的用户注册信息 string P_str_Com = "insert into tb_Blog(UserName,PassWord,ReallyName,Birthday,Address,PostCode,Subject,Email,HomePhone,MobilePhone,QQ,ICQ, Question,Answer,Sex,RegTime,IP)" + " values('" + txtName.Text + "','" + txtPwd.Text + "','" + txtRealName.Text + "','" + txtBirthday.Text + "'" + ",'" + txtAddress.Text + "','" + txtPostCode.Text + "','" + txtSubject.Text + "','" + txtEmail.Text + "'" + ",'" + txtHphone.Text + "','" + txtMphone.Text + "','" + txtQQ.Text + "','" + txtICQ.Text + "','" + txtQues.Text + "'" + ",'" + txtAns.Text + "','" + ddlSex.SelectedValue + "','" + DateTime.Now.ToString() + "','" + Page.Request.UserHostAddress + "')"; if (!ValidateDate1(txtBirthday.Text) && !ValidateDate2(txtBirthday.Text) && !ValidateDate3(txtBirthday.Text)) { Response.Write("<script language=javascript>alert('输入的生日日期格式有误!');location='Register.aspx'</script>"); } else { //调用公共类中的ExceSQL方法,执行insert语句 bool add = da.ExceSQL(P_str_Com); if (add) { Response.Write("<script language=javascript>alert('恭喜您!注册成功!');location='../../BlogIndex.aspx'</script>"); } else { Response.Write( "<script language=javascript>alert('对不起!您注册失败!');location='javascript:history.go(-1)'</script>"); } } }
protected void txtOK_Click(object sender, EventArgs e) { if (Session["VisitorName"] == null) { int id; string str2; string str = Request["ArticleID"].ToString(); string com = "select * from tb_Article where ArticleID='" + str + "'"; SqlData da = new SqlData(); SqlDataReader read = da.ExceRead(com); read.Read(); id = Convert.ToInt32(read["BlogID"]); str2 = Convert.ToString(read["Subject"]); read.Close(); string Com = "insert into tb_Revert(VisitorName,Subject,Content,IP,Time,ArticleID,BlogID) values('匿名','" + str2 + "','" + this.txtContent.Text + "','" + Request.UserHostAddress.ToString() + "','" + DateTime.Now.ToString() + "','" + str + "','" + id + "')"; bool add = da.ExceSQL(Com); if (add) { Response.Write("<script language=javascript>alert('提交成功!');location='../../Module/Visitor/Index.aspx'</script>"); } else { Response.Write("<script language=javascript>alert('提交失败!');location='javascript:history.go(-1)'</script>"); } } else { int id; string str2; string str = Request["ArticleID"].ToString(); string com = "select * from tb_Article where ArticleID='" + str + "'"; SqlData da = new SqlData(); SqlDataReader read = da.ExceRead(com); read.Read(); id = Convert.ToInt32(read["BlogID"]); str2 = Convert.ToString(read["Subject"]); read.Close(); string Com = "insert into tb_Revert(VisitorID,VisitorName,Subject,Content,IP,Time,ArticleID,BlogID) values('" + this.txtID.Text + "','" + Session["VisitorName"].ToString() + "','" + str2 + "','" + this.txtContent.Text + "','" + Request.UserHostAddress.ToString() + "','" + DateTime.Now.ToString() + "','" + str + "','" + id + "')"; bool add = da.ExceSQL(Com); if (add == true) { Response.Write("<script language=javascript>alert('提交成功!');location='../../Module/Visitor/Index.aspx'</script>"); } else { Response.Write("<script language=javascript>alert('提交失败!');location='javascript:history.go(-1)'</script>"); } } }
protected void btnOK_Click(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["CheckCode"]; //判断验证码是否有误 if (cookie.Value != txtVali.Text.Trim()) { Response.Write("<script lanuage=javascript>alert('验证码错误');location='javascript:history.go(-1)'</script>"); } else { SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]); con.Open(); string strsql = "select count(*) from tb_Admin where UserName='******'and PassWord='******' and SuperAdmin='True'"; SqlCommand com = new SqlCommand(strsql, con); SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from tb_Admin where UserName='******' and PassWord='******'"); read.Read(); if (read.HasRows) { Session["SuperAdmin"] = read["SuperAdmin"].ToString(); } read.Close(); int count = Convert.ToInt32(com.ExecuteScalar()); if (count > 0) { if (Equals(Request.Cookies["UserName"], null)) { CreateCookie(); } else { CreateCookie(); } Session["UserName"] = txtUid.Text; Session["PassWord"] = txtPwd.Text; Page.Response.Redirect("ST_BlogIndex.aspx"); } else { Response.Write( "<script lanuage=javascript>alert('用户名或密码有误!');location='javascript:history.go(-1)'</script>"); return; } } }
protected void Page_Load(object sender, EventArgs e) { string str = Page.Request["id"].ToString(); SqlData myData = new SqlData(); string mysql = "select * from ST_news where ST_n_id='" + str + "'"; SqlDataReader dr = myData.ExceRead(mysql); while (dr.Read()) { str_title = dr["ST_n_title"].ToString(); str_key = dr["ST_n_key"].ToString(); str_content = dr["ST_n_content"].ToString(); str_date = dr["ST_n_date"].ToString(); } }
protected void Page_Load(object sender, EventArgs e) { SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from tb_Admin where UserName='******'"); read.Read(); if (read.HasRows) { this.txtQues.Text = read["Question"].ToString(); } else { Response.Write("<script language=javascript>alert('此用户不存在!');location='Findpwd1.aspx'</script>"); } read.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { if (Session["username"] != null && Session["username"].ToString() != string.Empty) { this.user.Text = Session["username"].ToString(); SqlData da = new SqlData(); string id = Request.QueryString["id"]; if (id != null && id.ToString() != string.Empty) { this.Button2.Visible = false; string sqlstr = "select * from gy_xiao_billno where gy_xiao_billnoID=" + id + " "; SqlDataReader read = da.ExceRead(sqlstr); read.Read(); if (read.HasRows) { this.client.SelectedValue = read["gy_clientID"].ToString(); this.begintime.Text = read["gy_x_b_bgtime"].ToString(); this.endtime.Text = read["gy_x_b_endtime"].ToString(); this.totalcar.Text = read["gy_x_b_totalcar"].ToString(); this.totalamount.Text = read["gy_x_b_totalamount"].ToString(); this.bill.Text = read["gy_x_b_billno"].ToString(); this.gathering.Text = read["gy_x_b_gathering"].ToString(); this.remark.Text = read["gy_x_b_remark"].ToString(); read.Close(); } } else { this.updata.Visible = false; } } else { ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "click", "alert('您还未登录系统,不能访问此页!请先登录系统。');location='default.aspx'", true); return; } } }
protected void btnOK_Click(object sender, EventArgs e) { SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from tb_Admin where UserName='******'"); read.Read(); if (this.txtQues.Text == read["Question"].ToString() && this.txtAns.Text == read["Answer"].ToString()) { Session["pwd"] = read["ID"].ToString(); Page.Response.Redirect("ShowPwd.aspx"); } else { Response.Write("<script language=javascript>alert('您输入的信息不正确,请重新输入!');</script>"); } read.Close(); }
public static bool Exist(string name) { bool exist = false; SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from gy_KName where K_name='" + name + "'"); read.Read(); if (read.HasRows) { if (name == read["K_name"].ToString()) { exist = true; } } read.Close(); return exist; }
protected void jcname_Click(object sender, EventArgs e) { SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from userinfo where username='******'"); read.Read(); if (read.HasRows) { if (this.username.Text == read["username"].ToString()) { Response.Write("<script lanuage=javascript>alert('对不起,该用户名已经注册!');location='adduser.aspx'</script>"); } } else { Response.Write("<script lanuage=javascript>alert('此用户名可以注册!');</script>"); } read.Close(); }
protected void Button3_Click(object sender, EventArgs e) { SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from gy_client where gy_c_name='" + this.username.Text + "'"); read.Read(); if (read.HasRows) { if (this.username.Text == read["username"].ToString()) { ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "click", "alert('对不起,该用户名已经注册!')", true); } } else { ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "click", "alert('此用户名可以注册!')", true); } read.Close(); }
protected void Button1_Click(object sender, EventArgs e) { SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from tb_Admin where UserName='******'"); read.Read(); if (read.HasRows) { if (this.txtName.Text == read["UserName"].ToString()) { Response.Write("<script language=javascript>alert('对不起,该用户已经注册!');location='Register.aspx'</script>"); } } else { Response.Write("<script language=javascript>alert('恭喜您,该用户可以注册!');</script>"); } read.Close(); }
protected void btnOK_Click(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["CheckCode"]; //判断验证码是否有误 if (cookie.Value != this.txtVali.Text.Trim()) { Response.Write("<script lanuage=javascript>alert('验证码错误');location='javascript:history.go(-1)'</script>"); } else { SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]); con.Open(); string strsql = "select count(*) from tb_Admin where UserName='******'and PassWord='******' and SuperAdmin='True'"; SqlCommand com = new SqlCommand(strsql,con); SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select * from tb_Admin where UserName='******' and PassWord='******'"); read.Read(); if (read.HasRows) { Session["SuperAdmin"] = read["SuperAdmin"].ToString(); } read.Close(); int count = Convert.ToInt32(com.ExecuteScalar()); if (count > 0) { if(object.Equals(Request.Cookies["UserName"],null)) { CreateCookie(); } else { CreateCookie(); } Session["UserName"] = this.txtUid.Text; Session["PassWord"] = this.txtPwd.Text; Page.Response.Redirect("ST_BlogIndex.aspx"); } else { Response.Write("<script lanuage=javascript>alert('用户名或密码有误!');location='javascript:history.go(-1)'</script>"); return; } } }
public static ProductArea Get(int id) { ProductArea area = new ProductArea(); string sqlstr = "select * from gy_KName where k_ID =" + id + " "; SqlData da = new SqlData(); SqlDataReader read = da.ExceRead(sqlstr); read.Read(); if (read.HasRows) { area.Id = id; area.Name = read["k_name"].ToString(); area.Phone = read["k_phone"].ToString(); area.Remark = read["k_remark"].ToString(); } read.Close(); return area; }
protected void btnOK_Click(object sender, EventArgs e) { //定义一个SqlData的新实例对象 SqlData da = new SqlData(); //调用公共类的ExceRead方法,返回SqlDataReader类型的数据 SqlDataReader read = da.ExceRead("select * from tb_Blog where UserName='******'"); //读取数据库中的数据 read.Read(); //判断用户是否已经注册 if (read.HasRows) { if (this.txtName.Text == read["UserName"].ToString()) { Response.Write("<script language=javascript>alert('对不起,该用户已经注册!');location='Register.aspx'</script>"); return; } } read.Close(); //定义一个字符串,插入相关的用户注册信息 string P_str_Com = "insert into tb_Blog(UserName,PassWord,ReallyName,Birthday,Address,PostCode,Subject,Email,HomePhone,MobilePhone,QQ,ICQ, Question,Answer,Sex,RegTime,IP)" + " values('" + this.txtName.Text + "','" + this.txtPwd.Text + "','" + this.txtRealName.Text + "','" + this.txtBirthday.Text + "'" + ",'" + this.txtAddress.Text + "','" +this.txtPostCode.Text+ "','" + this.txtSubject.Text + "','" + this.txtEmail.Text + "'" + ",'" +this.txtHphone.Text + "','" + this.txtMphone.Text + "','" +this.txtQQ.Text+ "','" +this.txtICQ.Text + "','" + this.txtQues.Text + "'" + ",'" + this.txtAns.Text + "','" + this.ddlSex.SelectedValue + "','" + DateTime.Now.ToString() + "','" + Page.Request.UserHostAddress + "')"; if (!ValidateDate1(txtBirthday.Text) && !ValidateDate2(txtBirthday.Text) && !ValidateDate3(txtBirthday.Text)) { Response.Write("<script language=javascript>alert('输入的生日日期格式有误!');location='Register.aspx'</script>"); } else { //调用公共类中的ExceSQL方法,执行insert语句 bool add = da.ExceSQL(P_str_Com); if (add) { Response.Write("<script language=javascript>alert('恭喜您!注册成功!');location='../../BlogIndex.aspx'</script>"); } else { Response.Write("<script language=javascript>alert('对不起!您注册失败!');location='javascript:history.go(-1)'</script>"); } } }
protected void LogIn(object sender, EventArgs e) { SqlData da = new SqlData(); string sqlString = "select userName,userPwd,userEmail from people where userName='******' or userEmail='" + UserNameUserEmail.Text.Trim() + "'"; SqlDataReader sqlDataReader = da.ExceRead(sqlString); // Response.Write("1<br>"); try { if (sqlDataReader.HasRows) { // Response.Write("2<br>"); sqlDataReader.Read(); Boolean isPasswordRight = (sqlDataReader.GetValue(1).ToString().Equals(Password.Text.Trim().GetHashCode().ToString())); //Response.Write("Password.Text.Trim().GetHashCode()"+ Password.Text.Trim().GetHashCode()); //Response.Write("<br>sqlDataReader.GetValue(1).ToString().Trim()" + sqlDataReader.GetValue(1).ToString().Trim() + "<br>"); if (isPasswordRight) { // Response.Write("3<br>"); Session["userName"] = sqlDataReader.GetValue(0); Session["userId"] = sqlDataReader.GetValue(2); Response.Write("<script language=javascript>alert('登陆成功!');location='Default.aspx';</script>"); } else { // Response.Write("4<br>"); Response.Write("<script language=javascript>alert('用户名或密码错误!');"); } // Response.Write(Request.Form["xingbie"].ToString()); } else { // Response.Write("5<br>"); Response.Write("<script language=javascript>alert('您还未注册,请进行注册!');location='Register.aspx';</script>"); } }finally { sqlDataReader.Close(); } }
protected void Button1_Click(object sender, EventArgs e) { if (Page.IsValid) { SqlData da = new SqlData(); SqlDataReader read = da.ExceRead("select sum(gy_x_amount) AS totalamount,count(gy_x_amount) as totalcar from gy_xiao where gy_x_time between '" + this.begintime.Text + "' and '" + this.endtime.Text + "' and gy_clientID='" + this.client.Text + "'"); read.Read(); if (read.HasRows) { this.totalcar.Text = Convert.ToString(read["totalcar"]); this.totalamount.Text = Convert.ToString(read["totalamount"]); } else { ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "click", "alert('未能查到相关记录!请确认输入是否有误!')", true); return; } } }
/// <summary> /// 获取用户信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public static UserInfo Get(int id) { string sqlstr = "select * from userinfo where userinfoID=" + id + " "; SqlData da = new SqlData(); SqlDataReader read = da.ExceRead(sqlstr); read.Read(); UserInfo userinfo = new UserInfo(); if (read.HasRows) { userinfo.userinfoID = id; userinfo.UserPwd = read["UserPwd"].ToString(); userinfo.UserName = read["username"].ToString(); userinfo.usersexID =Convert.ToInt16(read["usersexID"].ToString()); userinfo.userlevelID =Convert.ToInt16(read["userlevelID"].ToString()); } read.Close(); return userinfo; }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { if (Session["username"] != null && Session["username"].ToString() != string.Empty) { SqlData da = new SqlData(); string id = Request.QueryString["id"]; if (!string.IsNullOrEmpty(id)) { Button1.Visible = false; string sqlstr = "select * from gy_client where gy_clientID=" + id + " "; SqlDataReader read = da.ExceRead(sqlstr); read.Read(); if (read.HasRows) { this.username.Text = read["gy_c_name"].ToString(); this.phone.Text = read["gy_c_phone"].ToString(); this.addres.Text = read["gy_c_address"].ToString(); this.E_mail.Text = read["gy_c_Email"].ToString(); this.remark.Text = read["gy_c_remark"].ToString(); read.Close(); } } else { this.Button2.Visible = false; } } else { ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "click", "alert('您还未登录系统,不能访问此页!请先登录系统。');location='default.aspx'", true); return; } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["userName"] == null) { Response.Write("<script language=javascript>alert('登陆失效,请登陆');location='Login.aspx';</script>"); } else { SqlData da = new SqlData(); //这是返回30天的数据的SQL语句 string sqlString = "select * from learningRecord where DATEDIFF(day,GETDATE(),learnTime) < 30 and userName='******' ORDER BY learnTime aSC"; string sqlString = "select COUNT(*) as 次数,day(learnTime) as 日 from learningRecord where DATEDIFF(day, GETDATE(), learnTime) < 7 and userName = '******'group by day(learnTime)"; SqlDataReader sqlDataReader = da.ExceRead(sqlString); if (sqlDataReader.HasRows) { int i = Convert.ToInt32((DateTime.Now.Day.ToString())) - 7; // Response.Write("第 前7天的号:"); // Response.Write(Convert.ToInt32((DateTime.Now.Day.ToString())) - 7); // Response.Write("<br>"); while (sqlDataReader.Read()) { //Response.Write("<font >"+sqlDataReader.GetValue(0).ToString()+"</>"); if (i == Convert.ToInt16(sqlDataReader.GetValue(1).ToString())) { strWordsNum = strWordsNum + sqlDataReader.GetValue(0) + ","; i++; } //wordNum[i] = Convert.ToInt16(sqlDataReader.GetValue(0).ToString()); } strWordsNum = strWordsNum.TrimEnd(',') + "]"; } else { Response.Write("暂无学习记录<br>"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { if (Session["username"] != null && Session["username"].ToString() != string.Empty) { SqlData da = new SqlData(); this.user.Text = Session["username"].ToString(); string id = Request.QueryString["id"]; SqlDataReader km = da.ExceRead("select * from gy_KName"); this.K_name.DataSource = km; this.K_name.DataTextField = "k_name"; this.K_name.DataValueField = "k_ID"; this.K_name.DataBind(); km.Close(); /* SqlDataReader updata_js = da.ExceRead("select * from gy_js"); this.K_name.DataSource = updata_js; this.K_name.DataTextField = "jsname"; this.K_name.DataValueField = "jsID"; this.K_name.DataBind(); updata_js.Close(); */ if (id != null && id.ToString() != string.Empty) { Button1.Visible = false; string sqlstr = "select * from gy_gou where gou_id=" + id + " "; SqlDataReader read = da.ExceRead(sqlstr); read.Read(); if (read.HasRows) { this.time.Text = read["gou_time"].ToString(); this.amount.Text = read["gou_amount"].ToString(); this.price.Text = read["gou_price"].ToString(); this.total.Text = read["gou_total"].ToString(); this.remark.Text = read["gou_remark"].ToString(); this.billno.Text = read["gou_billno"].ToString(); this.yfk.Text = read["gou_pqyment"].ToString(); string jsID = read["jsID"].ToString(); string kmID = read["k_ID"].ToString(); read.Close(); SqlDataReader sdr = da.ExceRead("select * from gy_KName"); this.K_name.DataSource = sdr; this.K_name.DataTextField = "k_name"; this.K_name.DataValueField = "k_ID"; this.K_name.SelectedValue = kmID; this.K_name.DataBind(); sdr.Close(); SqlDataReader xg_js = da.ExceRead("select * from gy_js "); this.djs.DataSource = xg_js; this.djs.DataTextField = "jsname"; this.djs.DataValueField = "jsID"; this.djs.SelectedValue = jsID; this.djs.DataBind(); xg_js.Close(); } } else { this.Button4.Visible = false; } } else { ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "click", "alert('您还未登录系统,不能访问此页!请先登录系统。');location='default.aspx'", true); return; } } }
protected void DropDownList2_SelectedIndexChanged1(object sender, EventArgs e) { this.Label1.Text =""; this.Label2.Text = ""; this.Label3.Text =""; SqlData sd = new SqlData(); if (DropDownList2.SelectedValue.ToString() == "all") { this.Label3.Visible = false; this.DropDownList3.Visible = false; this.TextBox1.Visible = false; this.TextBox2.Visible = false; this.TextBox3.Visible = false; this.Label1.Visible = false; this.Label2.Visible = false; } else if (DropDownList2.SelectedValue.ToString() == "xl" || DropDownList2.SelectedValue.ToString() == "xl1") { if (DropDownList2.SelectedItem.ToString() == "按产地查询") { this.Label3.Text = "产地"; SqlDataReader sdr = sd.ExceRead("select k_name from gy_KName"); this.DropDownList3.DataSource = sdr; this.DropDownList3.DataTextField = "k_name"; this.DropDownList3.DataValueField = "k_name"; this.DropDownList3.DataBind(); } else if (DropDownList2.SelectedItem.ToString() == "操作员") { this.Label3.Text = "操作员"; SqlDataReader sdr = sd.ExceRead("select username from userinfo"); this.DropDownList3.DataSource = sdr; this.DropDownList3.DataTextField = "username"; this.DropDownList3.DataValueField = "username"; this.DropDownList3.DataBind(); } else if (DropDownList2.SelectedItem.ToString() == "按销售单位查询") { this.Label3.Text = "销售单位"; SqlDataReader sdr = sd.ExceRead("select gy_c_name from gy_client"); this.DropDownList3.DataSource = sdr; this.DropDownList3.DataTextField = "gy_c_name"; this.DropDownList3.DataValueField = "gy_c_name"; this.DropDownList3.DataBind(); } else if (DropDownList2.SelectedItem.ToString() == "按顾客单位名称查询") { this.Label3.Text = "单位名称"; SqlDataReader sdr = sd.ExceRead("select gy_c_name from gy_client"); this.DropDownList3.DataSource = sdr; this.DropDownList3.DataTextField = "gy_c_name"; this.DropDownList3.DataValueField = "gy_c_name"; this.DropDownList3.DataBind(); } else if (DropDownList2.SelectedItem.ToString() == "按产地单位名称查询") { this.Label3.Text = "单位名称"; SqlDataReader sdr = sd.ExceRead("select k_name from gy_KName"); this.DropDownList3.DataSource = sdr; this.DropDownList3.DataTextField = "K_name"; this.DropDownList3.DataValueField = "K_name"; this.DropDownList3.DataBind(); } this.Label3.Visible = true; this.DropDownList3.Visible = true; this.TextBox1.Visible = false; this.TextBox2.Visible = false; this.TextBox3.Visible = false; this.Label1.Visible = false; this.Label2.Visible = false; } else if (DropDownList2.SelectedValue.ToString() == "1TextBox" || DropDownList2.SelectedValue.ToString() == "1TextBox1" || DropDownList2.SelectedValue.ToString() == "1TextBox2") { if (DropDownList2.SelectedItem.ToString() == "按时间查询") { this.Label1.Text = "时间"; } else if (DropDownList2.SelectedItem.ToString() == "按凭证号查询") { this.Label1.Text = "凭证号"; } else if (DropDownList2.SelectedItem.ToString() == "按车号查询") { this.Label1.Text = "车号"; } else if (DropDownList2.SelectedItem.ToString() == "按托运人查询") { this.Label1.Text = "托运人"; } this.Label1.Visible = true; this.TextBox1.Visible = true; this.Label3.Visible = false; this.DropDownList3.Visible = false; this.TextBox2.Visible = false; this.TextBox3.Visible = false; this.Label2.Visible = false; this.Label3.Visible = false; } else if (DropDownList2.SelectedValue.ToString() == "2TextBox") { if (DropDownList2.SelectedItem.ToString() == "按时间段查询") { this.Label2.Text = "时间段"; } this.Label2.Visible = true; this.TextBox2.Visible = true; this.TextBox3.Visible = true; this.Label3.Visible = false; this.DropDownList3.Visible = false; this.TextBox1.Visible = false; this.Label1.Visible = false; this.Label3.Visible = false; } else if (DropDownList2.SelectedValue.ToString() == "3TextBox") { if (DropDownList2.SelectedItem.ToString() == "按车号,时间段查询") { this.Label1.Text = "车号"; this.Label2.Text = "时间段"; } this.Label1.Visible = true; this.TextBox1.Visible = true; this.Label2.Visible = true; this.TextBox2.Visible = true; this.TextBox3.Visible = true; this.Label3.Visible = false; this.DropDownList3.Visible = false; } else if (DropDownList2.SelectedValue.ToString() == "xl2TextBox") { if (DropDownList2.SelectedItem.ToString() == "按产地,时间段查询") { this.Label2.Text = "时间段"; this.Label3.Text = "产地"; SqlDataReader sdr= sd.ExceRead("select k_name from gy_KName"); this.DropDownList3.DataSource = sdr; this.DropDownList3.DataTextField = "k_name"; this.DropDownList3.DataValueField = "k_name"; this.DropDownList3.DataBind(); } else if (DropDownList2.SelectedItem.ToString() == "按销售单位,时间段查询") { this.Label2.Text = "时间段"; this.Label3.Text = "销售单位"; SqlDataReader sdr = sd.ExceRead("select gy_c_name from gy_client"); this.DropDownList3.DataSource = sdr; this.DropDownList3.DataTextField = "gy_c_name"; this.DropDownList3.DataValueField = "gy_c_name"; this.DropDownList3.DataBind(); } else if (DropDownList2.SelectedItem.ToString() == "按销售单位,起始时间段查询") { this.Label2.Text = "起始时间段"; this.Label3.Text = "销售单位"; SqlDataReader sdr = sd.ExceRead("select gy_c_name from gy_client"); this.DropDownList3.DataSource = sdr; this.DropDownList3.DataTextField = "gy_c_name"; this.DropDownList3.DataValueField = "gy_c_name"; this.DropDownList3.DataBind(); } this.DropDownList3.Visible = true; this.Label3.Visible = true; this.Label2.Visible = true; this.TextBox2.Visible = true; this.TextBox3.Visible = true; this.TextBox1.Visible = false; this.Label1.Visible = false; } else if (DropDownList2.SelectedValue.ToString() == "all" ) { this.Label3.Visible = false; this.DropDownList3.Visible = false; this.TextBox1.Visible = false; this.TextBox2.Visible = false; this.TextBox3.Visible = false; this.Label1.Visible = false; this.Label2.Visible = false; this.Label3.Visible = false; } }
/// <summary> /// 选择二级查询条件 /// </summary> protected void ddl2_SelectedIndexChanged1(object sender, EventArgs e) { Label1.Text = ""; Label2.Text = ""; Label3.Text = ""; Label1.Visible = false; Label2.Visible = false; Label3.Visible = false; TextBox1.Visible = false; TextBox2.Visible = false; TextBox3.Visible = false; ddl3.Visible = false; string ddlValue2 = ddl2.SelectedValue; string ddlText2 = ddl2.SelectedItem.ToString(); SqlData sd = new SqlData(); SqlDataReader dr= sd.ExceRead("select k_name from gy_KName"); switch (ddlValue2) { case "all": break; case "xl": case "xl1": switch (ddlText2) { case "按产地查询": { Label3.Text = "产地"; ddl3BindChandi(); } break; case "操作员": { Label3.Text = "操作员"; ddl3BindOperator(); } break; case "按销售单位查询": case "按顾客单位名称查询": { Label3.Text = "单位名称"; ddl3BindClient(); } break; case "按产地单位名称查询": { Label3.Text = "单位名称"; ddl3BindChandi(); } break; } Label3.Visible = true; ddl3.Visible = true; break; case "1TextBox": case "1TextBox1": case "1TextBox2": switch (ddlText2) { case "按时间查询": Label1.Text = "时间"; break; case "按凭证号查询": Label1.Text = "凭证号"; break; case "按车号查询": Label1.Text = "车号"; break; case "按托运人查询": Label1.Text = "托运人"; break; } Label1.Visible = true; TextBox1.Visible = true; break; case "2TextBox": if (ddlText2 == "按时间段查询") { Label2.Text = "时间段"; } Label2.Visible = true; TextBox2.Visible = true; TextBox3.Visible = true; break; case "3TextBox": if (ddlText2 == "按车号,时间段查询") { Label1.Text = "车号"; Label2.Text = "时间段"; } Label1.Visible = true; TextBox1.Visible = true; Label2.Visible = true; TextBox2.Visible = true; TextBox3.Visible = true; break; case "xl2TextBox": switch (ddlText2) { case "按产地,时间段查询": Label2.Text = "时间段"; Label3.Text = "产地"; ddl3BindChandi(); break; case "按销售单位,时间段查询": Label2.Text = "时间段"; Label3.Text = "销售单位"; ddl3BindClient(); break; case "按销售单位,起始时间段查询": Label2.Text = "起始时间段"; Label3.Text = "销售单位"; ddl3BindClient(); break; } ddl3.Visible = true; Label3.Visible = true; Label2.Visible = true; TextBox2.Visible = true; TextBox3.Visible = true; break; } }
/// <summary> /// 绑定产地信息 /// </summary> private void ddl3BindChandi() { SqlData sd = new SqlData(); SqlDataReader dr = sd.ExceRead("select k_name from gy_KName"); ddl3.DataSource = dr; ddl3.DataTextField = "k_name"; ddl3.DataValueField = "k_name"; ddl3.DataBind(); }
/// <summary> /// 绑定操作员信息 /// </summary> private void ddl3BindOperator() { SqlData sd = new SqlData(); SqlDataReader dr = sd.ExceRead("select username from userinfo"); ddl3.DataSource = dr; ddl3.DataTextField = "username"; ddl3.DataValueField = "username"; ddl3.DataBind(); }
/// <summary> /// 绑定单位信息 /// </summary> private void ddl3BindClient() { SqlData sd = new SqlData(); SqlDataReader dr = sd.ExceRead("select gy_c_name from gy_client"); ddl3.DataSource = dr; ddl3.DataTextField = "gy_c_name"; ddl3.DataValueField = "gy_c_name"; ddl3.DataBind(); }