在一个BUTTONCLICK里边,主题功能是页面问卷调查,几十个问题,用户分别打分。我有这么几个功能:
1 判断用户是否对每个选项都进行了评分,如果没有,进行提示。然后从新刷新页面进行评分。
2 如果都评分完成了,程序将数据存储到数据库。
3 之前评测过的用户名,不能再进行评分。
现在有一个问题,就是如果判断了用户没有对所有选项进行评分,提示刷新页面之后,我发现数据已经存储到了数据库中了。而程序中又一个功能,就是如果之前这个用户名已经评分了,就不能再评分。所以就无法从新完整的评分了。
这个问题怎么解决呢?
1 判断用户是否对每个选项都进行了评分,如果没有,进行提示。然后从新刷新页面进行评分。
2 如果都评分完成了,程序将数据存储到数据库。
3 之前评测过的用户名,不能再进行评分。
现在有一个问题,就是如果判断了用户没有对所有选项进行评分,提示刷新页面之后,我发现数据已经存储到了数据库中了。而程序中又一个功能,就是如果之前这个用户名已经评分了,就不能再评分。所以就无法从新完整的评分了。
这个问题怎么解决呢?
解决方案 »
- SQL安数量排序
- notifyIcon怎么显示
- 如何改变treeview控件选中节点的高亮颜色,就是大家都熟悉的深蓝色。
- 如何给 private void timer1_Tick(object sender, EventArgs e)建个独立线程?
- fastReport .net 控件的自定义纸张高度
- c#新手提问 -- C#连接oracle报错:ORA-12560: TNS:protocol adapter error,有经验进来指点一下,up有分.
- 如何用正则获取一串字符串里的数字
- winform程序datagridview中鼠标滚轮事件的问题
- 关于循环(只有20分了)
- 请问如何将日期时间格式化?
- [求助]C#访问远程主机资源
- C#新手,关于bindingnavigator中添加一个SaveButton保存的问题?
protected void Button1_Click(object sender, EventArgs e)
{
//判断是否全部打分完成
for (int h = 1; h <= 10; h++)
{
ContentPlaceHolder cph = this.Form.FindControl("ContentPlaceHolder2") as ContentPlaceHolder;
DropDownList ddl = cph.FindControl("DropDownList" + h) as DropDownList;
float a = float.Parse(ddl.SelectedValue);
if (a == 10)
{
Response.Write("<script>alert('评分没有完成,请从新评分');location='FMtjqrx.aspx'</script>"); }
}
//插入新的一行
string ID = TextBox2.Text;
string dw = DropDownList15.SelectedValue;
int y = Convert.ToInt32(TextBox1.Text);
string time = Label4.Text;
SqlConnection conn = new SqlConnection("Server=.;database=QINXINJITUAN;uid=sa;pwd=179425532;");
try
{
conn.Open();
string inst1 = "insert into FMtjqrx(year,department,editor,edit_time) values('" + y + "','" + dw +"','" + ID + "','" + time + "')"; SqlCommand cmd = new SqlCommand(string.Format(inst1), conn);
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{ conn.Close();
}
protected void TextBox2_TextChanged(object sender, EventArgs e)
{
//消除同一年份,同一部门,同一专家打多次分的情况
string dw = DropDownList15.SelectedValue;
int y = Convert.ToInt32(TextBox1.Text);
string zj = TextBox2.Text;
SqlConnection com3 = new SqlConnection("Server=.;database=QINXINJITUAN;uid=sa;pwd=179425532;");
SqlDataReader dr3 = null;
try
{
com3.Open();
string select_count = "select count(*) from FMtjqrx where editor='" + zj + "'AND department='" + dw + "'AND year= " + y.ToString();
SqlCommand cmd3 = new SqlCommand(select_count, com3); dr3 = cmd3.ExecuteReader();
if (dr3.Read() && Convert.ToInt32(dr3[0]) > 0)
Response.Write("<script>alert('您已经进行过评测了!');location='FMtjqrx.aspx'</script>");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
if (dr3 != null) dr3.Close();
com3.Close();
}