protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["UserName"] != null) { editor.Style["display"] = "Block"; tishi.Style["display"] = "none"; } string idStr = Page.Request.QueryString["CardID"]; SqlConnection sqlconn = sqlCon.getCon(); sqlconn.Open(); string sqlstrbind = "select * from tb_Card where CardID='" + idStr + "'"; SqlCommand sqlcom = new SqlCommand(sqlstrbind, sqlconn); SqlDataReader tmpReader = sqlcom.ExecuteReader(); if (tmpReader.Read()) { labCardTitle.Text = "问题标题:" + tmpReader["CardName"].ToString(); labCardID.Text = tmpReader["CardID"].ToString(); username.Text = "发布人:" + tmpReader["UserName"].ToString(); labCardDate.Text = "发布日期:" + tmpReader["CardDate"].ToString(); labCardContent.Text = tmpReader["CardContent"].ToString(); } tmpReader.Close(); dlBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlConnection sqlconn1 = myCon.getCon(); string strsql = "select * from tb_Module"; sqlconn1 = myCon.getCon(); sqlconn1.Open(); SqlDataAdapter myApter = new SqlDataAdapter(strsql, sqlconn1); DataSet myDS = new DataSet(); myApter.Fill(myDS, "tb_Module"); hpLinkCardMod.DataSource = myDS; hpLinkCardMod.DataTextField = "ModuleName"; hpLinkCardMod.DataValueField = "ModuleID"; hpLinkCardMod.DataBind(); string sqlstr = "select * from ModuleInfo_View where CardID='" + Request["CardID"].ToString() + "'"; SqlDataAdapter myAdapter = new SqlDataAdapter(sqlstr, sqlconn1); DataSet myDSCard = new DataSet(); myAdapter.Fill(myDSCard, "ModuleInfo_View"); DataRowView rowViewCard = myDSCard.Tables["ModuleInfo_View"].DefaultView[0]; txtCardContent.Text = Convert.ToString(rowViewCard["CardContent"]); labCardTitle.Text = Convert.ToString(rowViewCard["CardName"]); labCardDate.Text = Convert.ToDateTime(rowViewCard["CardDate"]).ToString("d"); hpLinkCardMod.SelectedValue = Convert.ToString(rowViewCard["ModuleID"]); sqlconn1.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlConnection sqlconn = myCon.getCon(); sqlconn.Open(); SqlCommand sqlcom = new SqlCommand("select UserQuePwd from tb_User where UserName='******'", sqlconn);//接受FillUserID页传值 txtQuePwd.Text = Convert.ToString(sqlcom.ExecuteScalar()); sqlconn.Close(); } }
protected void Page_Load(object sender, EventArgs e) { Response.AddHeader("P3P", "CP=CAO PSA OUR"); if (!IsPostBack) { if (Session["UserName"] == null) { Response.Redirect("/Front/Login.aspx"); } else { string strsql = "select * from tb_Module"; sqlconn = myCon.getCon(); sqlconn.Open(); SqlDataAdapter myApter = new SqlDataAdapter(strsql, sqlconn); DataSet myDS = new DataSet(); myApter.Fill(myDS, "tb_Module"); ddlModuleName.DataSource = myDS; ddlModuleName.DataTextField = "ModuleName"; ddlModuleName.DataValueField = "ModuleID"; ddlModuleName.DataBind(); sqlconn.Close(); } } }
protected void Button1_Click(object sender, EventArgs e) { string sqlstr = "select * from MEMBERS where MID=00020030"; SqlConnection sqlconn = myCon.getCon(); sqlconn.Open(); SqlCommand sqlcom = new SqlCommand(sqlstr, sqlconn); SqlDataReader read = sqlcom.ExecuteReader(); read.Read(); if (this.passwordNow.Text.ToString() != this.cpasswordNow.Text.ToString()) { Response.Write(@"<script language='javascript'>alert('Please input same password!'); location='signup1.aspx'</script>"); } else { string sqlstr_signup_baseinfo = "update MEMBERS set EDU='" + this.education.Text + "',COLLEGE='" + this.college.Text + "' where MID=00020030"; string sqlstr_signup = "update LOGINFO set PASSWORD='******' where MID=00020030"; sqlBind.DataCom(sqlstr_signup); sqlBind_info.DataCom(sqlstr_signup_baseinfo); read.Close(); sqlconn.Close(); Response.Redirect("/members/Tech-department_change.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { Response.AddHeader("P3P", "CP=CAO PSA OUR"); if (!IsPostBack) { if (Session["UserName"] == null) { Response.Redirect("/Front/Login.aspx"); } else { SqlConnection sqlconn = myCon.getCon(); sqlconn.Open(); string sqlstr = "Select * from tb_User where UserID='" + Session["UserID"].ToString() + "'"; SqlDataAdapter myApter = new SqlDataAdapter(sqlstr, sqlconn); DataSet myDS = new DataSet(); myApter.Fill(myDS, "tb_User"); DataRowView rowView = myDS.Tables["tb_User"].DefaultView[0]; txtLoginName.Text = Convert.ToString(rowView["UserName"]); txtTel.Text = Convert.ToString(rowView["UserTel"]); txtEmail.Text = Convert.ToString(rowView["UserEmail"]); txtAddress.Text = Convert.ToString(rowView["UserAddress"]); if (Convert.ToString(rowView["UserSex"]).Trim() == "男") { ddlSex.SelectedIndex = 0; } if (Convert.ToString(rowView["UserSex"]).Trim() == "女") { ddlSex.SelectedIndex = 1; } sqlconn.Close(); } } }
/// <summary> /// DataCom方法用来执行SqlCommand中的SQL语句 /// </summary> /// <param name="sqlstr">SQL字符串</param> /// <returns>操作是否成功</returns> public bool DataCom(string sqlstr) { SqlConnection sqlconn = dataCon.getCon(); sqlconn.Open(); SqlCommand sqlcomm = new SqlCommand(sqlstr, sqlconn);//SqlCommand类表示要对SQL Sever执行一个SQL语句 try { sqlcomm.ExecuteNonQuery(); return(true); } catch { return(false); } finally { sqlconn.Close(); } }
protected void gvModuleInfo_RowDeleting(object sender, GridViewDeleteEventArgs e) { DataCon dataCon = new DataCon(); SqlConnection sqlconn = dataCon.getCon(); string fileid = gvModuleInfo.DataKeys[e.RowIndex].Value.ToString(); if (fileid == "34") { Response.Write("<script language=javascript>alert('综合交流专题不能删除!');</script>"); return; } string str = "select ModuleImage from tb_Module where ModuleID=" + fileid; sqlconn.Open(); SqlCommand sqlcom = new SqlCommand(str, sqlconn); SqlDataReader sdr = sqlcom.ExecuteReader(); sdr.Read(); string filename = sdr["ModuleImage"].ToString(); string strFilePath = Server.MapPath("~/IndexImages/") + filename; if (File.Exists(strFilePath)) { File.Delete(strFilePath); } string strImageurl2 = Server.MapPath("~/NewsImages/") + filename; if (File.Exists(strImageurl2)) { File.Delete(strImageurl2); } sdr.Close(); sqlconn.Close(); string sqlstr = "delete from tb_Module where ModuleID='" + gvModuleInfo.DataKeys[e.RowIndex].Value + "'"; string sqlstrcard = "delete from tb_card where ModuleID='" + gvModuleInfo.DataKeys[e.RowIndex].Value + "'"; string sqlstrRevertCard = "delete from tb_RevertCard where CardID IN ( select CardID from tb_Card where ModuleID='" + gvModuleInfo.DataKeys[e.RowIndex].Value + "' )"; List <string> SQLStringList = new List <string>(); SQLStringList.Add(sqlstrRevertCard); //先删除所含帖子的回复贴 SQLStringList.Add(sqlstrcard); //再删除所含帖子 SQLStringList.Add(sqlstr); //最后删除专题自己 int flag = DbHelperSQL.ExecuteSqlTran(SQLStringList); if (flag > 0) { Response.Write("<script language=javascript>alert('删除成功');</script>"); Response.Redirect("ManageMudole.aspx"); } Response.Redirect("ManageMudole.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string strsql = "select * from tb_Module"; sqlconn = myCon.getCon(); sqlconn.Open(); SqlDataAdapter myApter = new SqlDataAdapter(strsql, sqlconn); DataSet myDS = new DataSet(); myApter.Fill(myDS, "tb_Module"); ddlModuleName.DataSource = myDS; ddlModuleName.DataTextField = "ModuleName"; ddlModuleName.DataValueField = "ModuleID"; ddlModuleName.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlConnection sqlconn = myCon.getCon(); sqlconn.Open(); string sqlstr = "select * from tb_Module where ModuleID = '" + Request["ModuleID"].ToString() + "'"; SqlDataAdapter myAdapter = new SqlDataAdapter(sqlstr, sqlconn); DataSet myDSModule = new DataSet(); myAdapter.Fill(myDSModule, "tb_Module"); DataRowView rowViewModule = myDSModule.Tables["tb_Module"].DefaultView[0]; txtModTitle.Text = Convert.ToString(rowViewModule["ModuleName"]); Describe.Text = Convert.ToString(rowViewModule["ModuleDescribe"]); this.Image1.ImageUrl = "~/IndexImages/" + rowViewModule["ModuleImage"]; sqlconn.Close(); } }
protected void Page_Load(object sender, EventArgs e) { string sqlstr = "select INTRO,PHOTO from MEMBERS where MID=00020030"; SqlConnection sqlconn = myCon.getCon(); sqlconn.Open(); SqlCommand sqlcom = new SqlCommand(sqlstr, sqlconn); SqlDataReader read = sqlcom.ExecuteReader(); while (read.Read()) { string intro = read["INTRO"].ToString(); this.memberIntro03.Text = intro; string photo = read["PHOTO"].ToString(); this.img03.ImageUrl = photo; } ; sqlconn.Close(); }
protected void btnSure_Click(object sender, EventArgs e) { SqlConnection sqlconn = myCon.getCon(); sqlconn.Open(); SqlCommand sqlcom = new SqlCommand("select count(*) from tb_User where UserName='******'", sqlconn); int count = Convert.ToInt32(sqlcom.ExecuteScalar()); if (count > 0) { Session["UserName"] = txtUserName.Text;//给FillQuePwd.aspx和FindPwd.aspx页传值 Response.Redirect("FillQuePwd.aspx"); } else { Response.Write("<script>alert('没有该用户ID');location='javascript:history.go(-1)'</script>"); return; } sqlconn.Close(); }
public void dlBind() { string idStr = Page.Request.QueryString["ModuleName"]; int curpage = 1; PagedDataSource ps = new PagedDataSource(); sqlconn = myCon.getCon(); sqlconn.Open(); string sqlstr = "select ModuleID, ModuleName, ModuleDate,ModuleDescribe,ModuleImage FROM tb_Module"; SqlDataAdapter MyAdapter = new SqlDataAdapter(sqlstr, sqlconn); DataSet ds = new DataSet(); MyAdapter.Fill(ds, "tb_Module"); ps.DataSource = ds.Tables["tb_Module"].DefaultView; ps.AllowPaging = false; //是否可以分页 ps.PageSize = 6; //显示的数量(当allowpaging=true时才有效) ps.CurrentPageIndex = curpage - 1; //取得当前页的页码 this.dlModuleList.DataSource = ps; this.dlModuleList.DataKeyField = "ModuleID"; this.dlModuleList.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlConnection sqlconn = myCon.getCon(); sqlconn.Open(); string sqlstr = "select a.*,b.CardName from tb_RevertCard as a join tb_Card as b on a.CardID=b.CardID where a.RevertCardID = '" + Request["RevertCardID"].ToString() + "'";//接受CardInfo.aspx页传值 SqlDataAdapter myAdapter = new SqlDataAdapter(sqlstr, sqlconn); DataSet myDSCard = new DataSet(); DataSet myDSModule = new DataSet(); myAdapter.Fill(myDSCard, "tb_RevertCard"); myAdapter.Fill(myDSModule, "tb_Card"); DataRowView rowViewCard = myDSCard.Tables["tb_RevertCard"].DefaultView[0]; DataRowView rowViewModule = myDSModule.Tables["tb_Card"].DefaultView[0]; labCardContent.Text = Convert.ToString(rowViewCard["RevertCardContent"]); labCardTitle.Text = Convert.ToString(rowViewCard["RevertCardUserName"]); labCardDate.Text = Convert.ToString(rowViewCard["RevertCardDate"]); labCardMod.Text = Convert.ToString(rowViewModule["CardName"]); sqlconn.Close(); } }
protected void testUserID(object sender, EventArgs e) { string sqlstr = "select * from MEMBERS where MID=" + this.userID.Text.ToString(); SqlConnection sqlconn = myCon.getCon(); sqlconn.Open(); SqlCommand sqlcom = new SqlCommand(sqlstr, sqlconn); SqlDataReader read = sqlcom.ExecuteReader(); read.Read(); if (read.HasRows) { if (this.userID.Text.Trim() == read["MID"].ToString().Trim()) { Response.Write(@"<script language='javascript'>alert('had registered before!'); location='signup1.aspx'</script>"); } } else if (this.password.Text.ToString() != this.cpassword.Text.ToString()) { Response.Write(@"<script language='javascript'>alert('Please input same password!'); location='signup1.aspx'</script>"); } else { string sqlstr_signup_baseinfo = "insert into MEMBERS(MID,NAME,DEPARTMENT,POS)values('" + userID.Text + "','" + Name.Text + "','技术部','部员')"; string sqlstr_signup = "insert into LOGINFO(MID,PASSWORD)values('" + userID.Text + "','" + password.Text + "')"; string sqlupdateAIA = "update AIA set MEMNUM=MEMNUM+1 where PID='0002'"; sqlBind.DataCom(sqlstr_signup); sqlBind_info.DataCom(sqlstr_signup_baseinfo); sqlBind_updateAIA.DataCom(sqlupdateAIA); read.Close(); sqlconn.Close(); Response.Redirect("/members/Tech-department_login.aspx"); } }
protected void log_btn_Click(object sender, EventArgs e) { SqlConnection sqlconn = myCon.getCon(); SqlCommand sqlcom = sqlconn.CreateCommand(); SqlCommand sqlcom_perm = sqlconn.CreateCommand(); //验证码检验 if (this.validCode.Text.Trim() != this.ValidateCode.Text.Trim()) { Response.Write("<script language=javascript>alert('验证码错误');location='javascript:history.go(-1)'</script>"); } else { sqlconn.Open(); sqlcom.CommandText = "select count(*) from LOGINFO where MID=" + this.userID.Text.ToString() + " and PASSWORD="******"select PERMISSION from MEMBERS where MID=" + this.userID.Text.ToString(); int permission = Convert.ToInt16(sqlcom_perm.ExecuteScalar()); if (permission == 3) { Page.Response.Redirect("../members.aspx"); //返回主页 } else { Page.Response.Redirect("/members/Tech-department_login.aspx"); } } else { Response.Write("<script language=javascript>alert('用户名或密码有误!');location='javascript:history.go(-1)'</script>"); return; } sqlconn.Close(); } }