新闻发布网站实训报告(6)

2018-11-24 18:40

{ string Sql2 = \ + text + \; SqlCommand cmd = new SqlCommand(Sql2, conn); SqlDataAdapter myadpt = new SqlDataAdapter(Sql2, conn); DataSet ds = new DataSet(); myadpt.Fill(ds, \); DataList1.DataSource = ds.Tables[\]; DataList1.DataBind(); } catch (SqlException ee) { Response.Write(ee.ToString()); } finally { conn.Close(); } } protected void btnAdd_Click(object sender, EventArgs e) { if (Session[\] == null) { Label6.Text = \您没有登录,请登陆后评论!\; } else { string name = Session[\].ToString(); string text = Request.QueryString[\]; string connStr = ConfigurationManager.ConnectionStrings[\].ToString(); SqlConnection conn = new SqlConnection(connStr); conn.Open(); DateTime now = DateTime.Now; string Sql1 = \ + txtContent.Text + \ + text + \ + DateTime.Now + \ + Session[\] + \; try { SqlCommand cmd = new SqlCommand(Sql1, conn); cmd.ExecuteNonQuery(); } catch (SqlException ee) { Response.Write(ee.ToString()); } finally { conn.Close(); } Response.Redirect(Request.Url.ToString()); } } protected void btnClear_Click(object sender, EventArgs e) { txtContent.Text = \; } protected void Button1_Click(object sender, EventArgs e) { string connStr = ConfigurationManager.ConnectionStrings[\].ToString(); SqlConnection conn = new SqlConnection(connStr); conn.Open(); string Sql2 = \where c_content='\ + txtContent.Text + \; 第24页

SqlCommand cmd = new SqlCommand(Sql2, conn); SqlDataReader myReader = cmd.ExecuteReader(); int count = (int)myReader[\]; count++; string Sql1 = \ + count + \ + txtContent.Text + \; try { SqlCommand cmd1 = new SqlCommand(Sql1, conn); cmd1.ExecuteNonQuery(); } catch (SqlException ee) { Response.Write(ee.ToString()); } finally { conn.Close(); } } } 3. 搜索页面代码: protected void Page_Load(object sender, EventArgs e) { string text = Request.QueryString[\]; } protected void Button1_Click(object sender, EventArgs e) { DataList2.Visible = true; DataList1.Visible = false; } 4. 分类页面代码: protected void Page_Load(object sender, EventArgs e) { string ss=Request.QueryString [\]; } 5. 添加个人新闻页面: protected void Page_Load(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToString(); } protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text.Length > 30) { Response.Write(\标题过长!');\);//判断标题过长时 弹出对话框 return; } NewsModeln d = new NewsModeln(); d._n_title = TextBox1.Text; d._n_details = TextBox2.Text; d._n_data = Label1.Text; d._n_sorts = DropDownList1.Text; d._n_pictuie = FileUpload1.FileName; NewsDAL f = new NewsDAL(); if (f.newsadd(d)) { 第25页

Response.Write(\提交成功!');\); } else { Response.Write(\提交失败!');\); } } protected void Button2_Click(object sender, EventArgs e) { TextBox1.Text = \; TextBox2.Text = \; } 6. 修改个人新闻页面: protected void Page_Load(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToString(); string id=Request.QueryString[\]; string cmd=\+id+\; string str = ConfigurationManager.ConnectionStrings[\].ToString(); SqlConnection conn = new SqlConnection(str); conn.Open(); SqlCommand mycmd = new SqlCommand(cmd ,conn); SqlDataReader dr = mycmd.ExecuteReader(); while (dr.Read()) { TextBox1.Text = dr[\].ToString() + \; TextBox2.Text = dr[\].ToString(); DropDownList1.SelectedValue =dr[\].ToString (); Label1.Text = DateTime.Now.ToString(); } conn.Close(); } protected void Button1_Click(object sender, EventArgs e) { string commandString = \ + TextBox1.Text + \ + TextBox2.Text + \ + Label1.Text + \ + FileUpload1.FileName + \ + DropDownList1.SelectedValue + \; string str = ConfigurationManager.ConnectionStrings[\].ToString(); SqlConnection objconn = new SqlConnection(str); objconn.Open(); SqlCommand objcmd = new SqlCommand(commandString, objconn); objcmd.ExecuteNonQuery(); objconn.Close(); } protected void Button2_Click(object sender, EventArgs e) { TextBox1.Text =\; TextBox2.Text =\; } 7. 注册代码: protected void Page_Load(object sender, EventArgs e) { TextBoxUserName.Focus();//使文本框得到焦点,即将插入点光标移到文本框中 } protected void Button1_Click1(object sender, EventArgs e) { if (TextBoxUserName.Text == \)//如果是未登陆用户 { 第26页

Response.Write(\用户名不能为空!');\); } else { if (Page.IsValid) { string commandString = \(u_name,u_pwd,u_gender,u_birthday,u_qtn,u_answer) values('\ + TextBoxUserName.Text + \ + TextBoxPassword.Text + \ + RadioButtonListSex.SelectedValue + \ + TextBoxBirthday.Text + \+DropDownList1.SelectedValue +\ + TextBoxAnswer.Text + \; string str = ConfigurationManager.ConnectionStrings[\].ToString(); SqlConnection objconn = new SqlConnection(str); objconn.Open(); SqlCommand objcmd = new SqlCommand(commandString, objconn); objcmd.ExecuteNonQuery(); objconn.Close(); Response.Write(\注册成功');location.href='index.aspx'\); } else //注册过程出现错误 { TextBoxPassword.Text = \;//清空文本框中现有文字 TextBoxRePassword.Text = \; TextBoxUserName.Focus();//使文本框得到焦点,即将插入点光标移到文本框中 TextBoxRePassword.Text = \; TextBoxAnswer.Text = \; TextBoxBirthday.Text = \; } } } protected void Button2_Click(object sender, EventArgs e) { TextBoxUserName.Focus();//使文本框得到焦点,即将插入点光标移到文本框中 TextBoxUserName.Text = \;//清空文本框中现有文字 TextBoxPassword.Text = \; TextBoxRePassword.Text = \; TextBoxAnswer.Text = \; TextBoxBirthday.Text = \; } 8. 修改个人信息代码: protected void Page_Load(object sender, EventArgs e) { string commandString = \+Session[\]+\;//u_name 需要系统从页面自动读取(用u_id比较简单) string str = ConfigurationManager.ConnectionStrings[\].ToString(); SqlConnection objconn = new SqlConnection(str); SqlCommand objcmd = new SqlCommand(commandString, objconn); objconn.Open(); SqlDataAdapter myda = new SqlDataAdapter(commandString, objconn); DataSet myds = new DataSet(); myda.Fill(myds, \); DataRow rowview = myds.Tables[\].Rows[0]; //u_id = rowview[\ TextBoxUserName.Text = rowview[\].ToString(); TextBoxAnswer.Text = rowview[\].ToString(); // TextBoxBirthday.Text = rowview[\ RadioButtonListSex.SelectedValue = rowview[\].ToString(); objconn.Close(); } 第27页

protected void Button1_Click1(object sender, EventArgs e) { if (TextBoxUserName.Text == \)//如果是未登陆用户 { Response.Write(\用户名不能为空!');\); } else { if (Page.IsValid) { string commandString = \ + TextBoxUserName.Text + \ + TextBoxPassword.Text + \ + RadioButtonListSex.SelectedValue + \ + TextBoxBirthday.Text + \ + DropDownList1.SelectedValue + \ + TextBoxAnswer.Text + \ + Session[\] + \; string str = ConfigurationManager.ConnectionStrings[\].ToString(); SqlConnection objconn = new SqlConnection(str); objconn.Open(); SqlCommand objcmd = new SqlCommand(commandString, objconn); objcmd.ExecuteNonQuery(); objconn.Close(); Response.Write(\修改成功');location.href='index.aspx'\); } else //注册过程出现错误 { TextBoxUserName.Focus();//使文本框得到焦点,即将插入点光标移到文本框中 TextBoxPassword.Text = \;//清空文本框中现有文字 TextBoxRePassword.Text = \; TextBoxUserName.Text = \;//清空文本框中现有文字 TextBoxAnswer.Text = \; TextBoxBirthday.Text = \; } } } protected void Button2_Click(object sender, EventArgs e) { TextBoxUserName.Focus();//使文本框得到焦点,即将插入点光标移到文本框中 //清空文本框中现有文字 TextBoxPassword.Text = \; TextBoxRePassword.Text = \; TextBoxAnswer.Text = \; TextBoxBirthday.Text = \; } 9. 找回密码代码: string u_pwd; protected void Page_Load(object sender, EventArgs e) { TextBoxUserName.Focus(); //使文本框得到焦点,即将插入点光标移到文本框中 } protected void Button1_Click1(object sender, EventArgs e) { string commandString = \ + TextBoxUserName.Text + %u_answer='\ + TextBoxAnswer.Text + \; string str = ConfigurationManager.ConnectionStrings[\].ToString(); SqlConnection objconn = new SqlConnection(str); SqlCommand objcmd = new SqlCommand(commandString, objconn); objconn.Open(); SqlDataAdapter myda = new SqlDataAdapter(commandString, objconn); 第28页


新闻发布网站实训报告(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:头孢菌素类药物不良反应发生原因的临床分析

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: