using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class Default4 : System.Web.UI.Page
{
string strcon = "server=.;database=pubs;uid=sa;pwd=sa";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
fatie();
}
}
public DataSet returnds()
{
SqlConnection cn = new SqlConnection(strcon);
SqlDataAdapter da = new SqlDataAdapter("select * from tiezi where waiid=1",cn);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
public void add(int vg, int g, int b, int vb, string biaoti, string neirong, DateTime dt)
{
using (SqlConnection cn = new SqlConnection(strcon))
{
cn.Open();
SqlCommand cmd = new SqlCommand("insert into tiezi(vgood,good,bad,vbad,biaoti,neirong,times,waiid) values('" + vg + "','" + g + "','" + b + "','" + vb + "','" + biaoti + "','" + neirong + "','" + dt + "',1)", cn);
cmd.ExecuteNonQuery();
}
}
public static int count1, count2, count3, count4;
protected void Button1_Click(object sender, EventArgs e)
{
if (RadioButton1.Checked == true)
{
add(10, 0, 0, 0, TextBox2.Text, TextBox3.Text, DateTime.Now);
fatie();
}
if (RadioButton2.Checked == true)
{
add(0, 10, 0, 0, TextBox2.Text, TextBox3.Text, DateTime.Now);
fatie();
}
if (RadioButton3.Checked == true)
{
add(0, 0, 10, 0, TextBox2.Text, TextBox3.Text, DateTime.Now);
fatie();
}
if (RadioButton4.Checked == true)
{
add(0, 0, 0, 10, TextBox2.Text, TextBox3.Text, DateTime.Now);
fatie();
}
}
public void fatie()
{
DataSet ds = new DataSet();
ds = returnds();
DataTable dt = ds.Tables[0];
string juti = null;
foreach (DataRow dr in dt.Rows)
{
string Titles = dr[5].ToString();
string Neitong = dr[6].ToString();
DateTime dt1 = Convert.ToDateTime(dr[7].ToString());
juti += "标题为:" + Titles + "/t" + "发表时间" + dt1 + "/n" + "内容为:" +"/n"+ Neitong+"/n";
}
if (juti == null)
{
this.TextBox1.Text = null;
}
else
{
this.TextBox1.Text = juti.ToString();
}
double v1 = 0;
double v2 = 0;
double v3 = 0;
double v4 = 0;
DataSet ds1 = new DataSet();
ds1 = returnds();
DataTable dt2 = ds1.Tables[0];
foreach (DataRow dr in dt2.Rows)
{
int d1 = int.Parse(dr[1].ToString());
int d2 = int.Parse(dr[2].ToString());
int d3 = int.Parse(dr[3].ToString());
int d4 = int.Parse(dr[4].ToString());
v1 += d1;
v2 += d2;
v3 += d3;
v4 += d4;
}
if (v1 != 0 || v2 != 0 || v3 != 0 || v4 != 0)
{
count1 = Convert.ToInt32(v1 / (v1 + v2 + v3 + v4) * 100);
count2 = Convert.ToInt32(v2 / (v1 + v2 + v3 + v4) * 100);
count3 = Convert.ToInt32(v3 / (v1 + v2 + v3 + v4) * 100);
count4 = Convert.ToInt32(v4 / (v1 + v2 + v3 + v4) * 100);
}
}
public void toupiao()
{
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 46%;
height: 225px;
}
.style8
{
width: 67px;
}
.style9
{
width: 67px;
text-align: center;
}
.style10
{
width: 67px;
text-align: center;
height: 4px;
}
.style12
{
width: 66px;
text-align: center;
height: 4px;
z-index: -1;
}
.style15
{
width: 59px;
text-align: center;
}
.style16
{
width: 59px;
text-align: center;
height: 4px;
}
.style17
{
width: 66px;
text-align: center;
}
.style18
{
width: 66px;
text-align: center;
height: 4px;
}
#Image1
{
height: 30px;
width: 20px;
}
.style19
{
width: 59px;
text-align: center;
height: 30px;
}
.style20
{
width: 67px;
text-align: center;
height: 30px;
}
.style22
{
width: 66px;
text-align: center;
height: 30px;
}
#form1
{
height: 381px;
width: 942px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table align="center" class="style1">
<tr>
<td class="style19">
<%=count1%> %</td>
<td class="style20">
<%=count2%> %</td>
<td class="style22">
<%=count3%> %</td>
<td class="style22">
<%=count4%> %</td>
<td class="style22">
<asp:TextBox ID="TextBox1" runat="server" Height="109px" TextMode="MultiLine"
Width="193px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style16" valign="bottom">
<img src="红色1.jpg" alt="" id="Img4" height="<%=1.5*count1 %>"
width="20" /></td>
<td class="style10" valign="bottom">
<img src="黄色.jpg" alt="" id="Img1" height="<%=1.5*count2 %>"
width="20" /></td>
<td class="style12" valign="bottom" >
<img src="蓝色.jpg" alt="" id="Img2" height="<%=1.5*count3 %>"
width="20" /></td>
<td class="style18" valign="bottom">
<img src="绿色.jpg" alt="" id="Img3" height="<%=1.5*count4 %>"
width="20" /></td>
<td class="style18">
</td>
</tr>
<tr>
<td class="style15">
<asp:RadioButton ID="RadioButton1" runat="server" Text="很好" GroupName="1" />
</td>
<td class="style8" style="text-align: center">
<asp:RadioButton ID="RadioButton2" runat="server" Text="一般" GroupName="1" />
</td>
<td class="style17">
<asp:RadioButton ID="RadioButton3" runat="server" Text="差" GroupName="1" />
</td>
<td class="style17">
<asp:RadioButton ID="RadioButton4" runat="server" Text="很差" GroupName="1" />
</td>
<td class="style17">
标题:<asp:TextBox ID="TextBox2" runat="server" Width="177px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style15">
</td>
<td class="style9">
<asp:Button ID="Button1" runat="server" Text="提交" οnclick="Button1_Click" />
</td>
<td class="style17">
</td>
<td class="style17">
</td>
<td class="style17">
内容<asp:TextBox ID="TextBox3" runat="server" Height="46px"
TextMode="MultiLine" Width="191px"></asp:TextBox>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class Default4 : System.Web.UI.Page
{
string strcon = "server=.;database=pubs;uid=sa;pwd=sa";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
fatie();
}
}
public DataSet returnds()
{
SqlConnection cn = new SqlConnection(strcon);
SqlDataAdapter da = new SqlDataAdapter("select * from tiezi where waiid=1",cn);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
public void add(int vg, int g, int b, int vb, string biaoti, string neirong, DateTime dt)
{
using (SqlConnection cn = new SqlConnection(strcon))
{
cn.Open();
SqlCommand cmd = new SqlCommand("insert into tiezi(vgood,good,bad,vbad,biaoti,neirong,times,waiid) values('" + vg + "','" + g + "','" + b + "','" + vb + "','" + biaoti + "','" + neirong + "','" + dt + "',1)", cn);
cmd.ExecuteNonQuery();
}
}
public static int count1, count2, count3, count4;
protected void Button1_Click(object sender, EventArgs e)
{
if (RadioButton1.Checked == true)
{
add(10, 0, 0, 0, TextBox2.Text, TextBox3.Text, DateTime.Now);
fatie();
}
if (RadioButton2.Checked == true)
{
add(0, 10, 0, 0, TextBox2.Text, TextBox3.Text, DateTime.Now);
fatie();
}
if (RadioButton3.Checked == true)
{
add(0, 0, 10, 0, TextBox2.Text, TextBox3.Text, DateTime.Now);
fatie();
}
if (RadioButton4.Checked == true)
{
add(0, 0, 0, 10, TextBox2.Text, TextBox3.Text, DateTime.Now);
fatie();
}
}
public void fatie()
{
DataSet ds = new DataSet();
ds = returnds();
DataTable dt = ds.Tables[0];
string juti = null;
foreach (DataRow dr in dt.Rows)
{
string Titles = dr[5].ToString();
string Neitong = dr[6].ToString();
DateTime dt1 = Convert.ToDateTime(dr[7].ToString());
juti += "标题为:" + Titles + "/t" + "发表时间" + dt1 + "/n" + "内容为:" +"/n"+ Neitong+"/n";
}
if (juti == null)
{
this.TextBox1.Text = null;
}
else
{
this.TextBox1.Text = juti.ToString();
}
double v1 = 0;
double v2 = 0;
double v3 = 0;
double v4 = 0;
DataSet ds1 = new DataSet();
ds1 = returnds();
DataTable dt2 = ds1.Tables[0];
foreach (DataRow dr in dt2.Rows)
{
int d1 = int.Parse(dr[1].ToString());
int d2 = int.Parse(dr[2].ToString());
int d3 = int.Parse(dr[3].ToString());
int d4 = int.Parse(dr[4].ToString());
v1 += d1;
v2 += d2;
v3 += d3;
v4 += d4;
}
if (v1 != 0 || v2 != 0 || v3 != 0 || v4 != 0)
{
count1 = Convert.ToInt32(v1 / (v1 + v2 + v3 + v4) * 100);
count2 = Convert.ToInt32(v2 / (v1 + v2 + v3 + v4) * 100);
count3 = Convert.ToInt32(v3 / (v1 + v2 + v3 + v4) * 100);
count4 = Convert.ToInt32(v4 / (v1 + v2 + v3 + v4) * 100);
}
}
public void toupiao()
{
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 46%;
height: 225px;
}
.style8
{
width: 67px;
}
.style9
{
width: 67px;
text-align: center;
}
.style10
{
width: 67px;
text-align: center;
height: 4px;
}
.style12
{
width: 66px;
text-align: center;
height: 4px;
z-index: -1;
}
.style15
{
width: 59px;
text-align: center;
}
.style16
{
width: 59px;
text-align: center;
height: 4px;
}
.style17
{
width: 66px;
text-align: center;
}
.style18
{
width: 66px;
text-align: center;
height: 4px;
}
#Image1
{
height: 30px;
width: 20px;
}
.style19
{
width: 59px;
text-align: center;
height: 30px;
}
.style20
{
width: 67px;
text-align: center;
height: 30px;
}
.style22
{
width: 66px;
text-align: center;
height: 30px;
}
#form1
{
height: 381px;
width: 942px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table align="center" class="style1">
<tr>
<td class="style19">
<%=count1%> %</td>
<td class="style20">
<%=count2%> %</td>
<td class="style22">
<%=count3%> %</td>
<td class="style22">
<%=count4%> %</td>
<td class="style22">
<asp:TextBox ID="TextBox1" runat="server" Height="109px" TextMode="MultiLine"
Width="193px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style16" valign="bottom">
<img src="红色1.jpg" alt="" id="Img4" height="<%=1.5*count1 %>"
width="20" /></td>
<td class="style10" valign="bottom">
<img src="黄色.jpg" alt="" id="Img1" height="<%=1.5*count2 %>"
width="20" /></td>
<td class="style12" valign="bottom" >
<img src="蓝色.jpg" alt="" id="Img2" height="<%=1.5*count3 %>"
width="20" /></td>
<td class="style18" valign="bottom">
<img src="绿色.jpg" alt="" id="Img3" height="<%=1.5*count4 %>"
width="20" /></td>
<td class="style18">
</td>
</tr>
<tr>
<td class="style15">
<asp:RadioButton ID="RadioButton1" runat="server" Text="很好" GroupName="1" />
</td>
<td class="style8" style="text-align: center">
<asp:RadioButton ID="RadioButton2" runat="server" Text="一般" GroupName="1" />
</td>
<td class="style17">
<asp:RadioButton ID="RadioButton3" runat="server" Text="差" GroupName="1" />
</td>
<td class="style17">
<asp:RadioButton ID="RadioButton4" runat="server" Text="很差" GroupName="1" />
</td>
<td class="style17">
标题:<asp:TextBox ID="TextBox2" runat="server" Width="177px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style15">
</td>
<td class="style9">
<asp:Button ID="Button1" runat="server" Text="提交" οnclick="Button1_Click" />
</td>
<td class="style17">
</td>
<td class="style17">
</td>
<td class="style17">
内容<asp:TextBox ID="TextBox3" runat="server" Height="46px"
TextMode="MultiLine" Width="191px"></asp:TextBox>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>