求各位大侠帮详细解释一下 答辩用 谢谢
protected void Page_Load(object sender, EventArgs e){
if (!IsPostBack)
{
string sql;
sql = "select bh from allpro order by id desc";
getdata(sql);
}
}
private void getdata(string sql)
{
DataSet result = new DataSet();
result = new Class1().hsggetdata(sql);
if (result != null)
{
if (result.Tables[0].Rows.Count > 0)
{
int k = 0;
for (k = 0; k < result.Tables[0].Rows.Count; k++)
{
bh.Items.Add(result.Tables[0].Rows[k]["bh"].ToString().Trim());
}
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string sql;
sql = "select * from kucun where bh='"+bh.SelectedItem.ToString().Trim()+"'";
DataSet result = new DataSet();
result = new Class1().hsggetdata(sql);
if (result != null)
{
if (result.Tables[0].Rows.Count > 0)
{
sql = "update kucun set shuliang=shuliang+"+shuliang.Text.ToString().Trim()+" where bh='"+bh.SelectedItem.ToString().Trim()+"'";
}
else
{
sql = "insert into kucun(bh,ggxh,dw,promc,price,shuliang,gys,rkprice) values('" + bh.SelectedItem.ToString().Trim() + "','" + ggxh.Text.ToString().Trim() + "','" + dw.Text.ToString().Trim() + "','" + promc.Text.ToString().Trim() + "'," + price.Text.ToString().Trim() + "," + shuliang.Text.ToString().Trim() + ",'" + gys.Text.ToString().Trim() + "'," + rkprice.Text.ToString().Trim() + ")";
}
}
int result2;
result2 = new Class1().hsgexucute(sql);
sql = "insert into ruku(bh,ggxh,dw,promc,price,shuliang,gys,rkprice) values('" + bh.SelectedItem.ToString().Trim() + "','" + ggxh.Text.ToString().Trim() + "','" + dw.Text.ToString().Trim() + "','" + promc.Text.ToString().Trim() + "'," + price.Text.ToString().Trim() + "," + shuliang.Text.ToString().Trim() + ",'" + gys.Text.ToString().Trim() + "'," + rkprice.Text.ToString().Trim() + ")";
result2 = new Class1().hsgexucute(sql);
if (result2 == 1)
{
Response.Write("<script>javascript:alert('操作成功');</script>");
}
else
{
Response.Write("<script>javascript:alert('系统错误,您输入了非法字符!');</script>");
}