请问这段程序的最核心代码是哪一部分,我看不懂,求解释呀~
publicpartialclassManagehuo:System.Web.UI.Page{protectedvoidPage_Load(objectsender,Ev...
public partial class Managehuo : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
gridviewBind();
}
}
//gridview绑定
private voidgridviewBind()
{
String str= "select huoID,huoName,huoDanwei,cfck,rkdw,ckdw,yskc+isnull((selectSUM(shuliang) from ruku where ruku.huoName=huopin.huoName group byhuoName),0)"
+" -isnull((select SUM(shuliang) from chuku where chuku.huoName=huopin.huoNamegroup by huoName),0) as kc,dixian,gaoxian from huopin order by huoID desc";
SqlConnection scon = newSqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon);
DataSetds = new DataSet();
dbAdapter.Fill(ds);
scon.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataKeyNames = new string[] { "huoID" };
GridView1.DataBind();
}
////f分页
protectedvoid GridView1_PageIndexChanging1(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
gridviewBind();
}
protectedvoid GridView1_RowDeleting(object sender, GridViewDeleteEventArgse)
{
stringss = "delete from huopin where huoID='" +this.GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
SqlConnection scon = newSqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlCommand scmd = new SqlCommand(ss, scon);
scmd.ExecuteNonQuery();
scon.Close();
GridView1.DataBind();
gridviewBind();
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
stringstr = "select huoID,huoName,huoDanwei,cfck,rkdw,ckdw,yskc,dixian,gaoxianfrom huopin where yskc<dixian order by huoID desc";
SqlConnection scon = newSqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon);
DataSet ds = new DataSet();
dbAdapter.Fill(ds);
scon.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataKeyNames = new string[] { "huoID" };
GridView1.DataBind();
}
protectedvoid Button2_Click(object sender, EventArgs e)
{
stringstr = "select huoID,huoName,huoDanwei,cfck,rkdw,ckdw,yskc,dixian,gaoxianfrom huopin where yskc>gaoxian order by huoID desc";
SqlConnection scon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon);
DataSetds = new DataSet();
dbAdapter.Fill(ds);
scon.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataKeyNames = new string[] { "huoID" };
GridView1.DataBind(); 展开
{
protectedvoid Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
gridviewBind();
}
}
//gridview绑定
private voidgridviewBind()
{
String str= "select huoID,huoName,huoDanwei,cfck,rkdw,ckdw,yskc+isnull((selectSUM(shuliang) from ruku where ruku.huoName=huopin.huoName group byhuoName),0)"
+" -isnull((select SUM(shuliang) from chuku where chuku.huoName=huopin.huoNamegroup by huoName),0) as kc,dixian,gaoxian from huopin order by huoID desc";
SqlConnection scon = newSqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon);
DataSetds = new DataSet();
dbAdapter.Fill(ds);
scon.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataKeyNames = new string[] { "huoID" };
GridView1.DataBind();
}
////f分页
protectedvoid GridView1_PageIndexChanging1(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
gridviewBind();
}
protectedvoid GridView1_RowDeleting(object sender, GridViewDeleteEventArgse)
{
stringss = "delete from huopin where huoID='" +this.GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
SqlConnection scon = newSqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlCommand scmd = new SqlCommand(ss, scon);
scmd.ExecuteNonQuery();
scon.Close();
GridView1.DataBind();
gridviewBind();
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
stringstr = "select huoID,huoName,huoDanwei,cfck,rkdw,ckdw,yskc,dixian,gaoxianfrom huopin where yskc<dixian order by huoID desc";
SqlConnection scon = newSqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon);
DataSet ds = new DataSet();
dbAdapter.Fill(ds);
scon.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataKeyNames = new string[] { "huoID" };
GridView1.DataBind();
}
protectedvoid Button2_Click(object sender, EventArgs e)
{
stringstr = "select huoID,huoName,huoDanwei,cfck,rkdw,ckdw,yskc,dixian,gaoxianfrom huopin where yskc>gaoxian order by huoID desc";
SqlConnection scon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon);
DataSetds = new DataSet();
dbAdapter.Fill(ds);
scon.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataKeyNames = new string[] { "huoID" };
GridView1.DataBind(); 展开
1个回答
展开全部
代码没什么重不重点吧,少1句也可能运行不了。下面简略做了注释。哪句不明白的就再说吧
public partial class Managehuo : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
gridviewBind();//引用下面的绑定方法
}
}
//gridview绑定
private voidgridviewBind()
{
String str= "select huoID,huoName,huoDanwei,cfck,rkdw,ckdw,yskc+isnull((selectSUM(shuliang) from ruku where ruku.huoName=huopin.huoName group byhuoName),0)"
+" -isnull((select SUM(shuliang) from chuku where chuku.huoName=huopin.huoNamegroup by huoName),0) as kc,dixian,gaoxian from huopin order by huoID desc";
SqlConnection scon = newSqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon);
DataSetds = new DataSet();
dbAdapter.Fill(ds);//查出数据填充到dataset中
scon.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;//把gridview的数据源绑定为上面获取的的dataset表
GridView1.DataKeyNames = new string[] { "huoID" };//设置gridview的主键
GridView1.DataBind();
}
////f分页
protectedvoid GridView1_PageIndexChanging1(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
gridviewBind();
}
//删除行
protectedvoid GridView1_RowDeleting(object sender, GridViewDeleteEventArgse)
{
stringss = "delete from huopin where huoID='" +this.GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
SqlConnection scon = newSqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlCommand scmd = new SqlCommand(ss, scon);
scmd.ExecuteNonQuery();//执行删除
scon.Close();
GridView1.DataBind();
gridviewBind();//重新绑定数据源
}
//选出符合条件的行出来,现实到gridview中
protectedvoid Button1_Click(object sender, EventArgs e)
{
stringstr = "select huoID,huoName,huoDanwei,cfck,rkdw,ckdw,yskc,dixian,gaoxianfrom huopin where yskc<dixian order by huoID desc";
SqlConnection scon = newSqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon);
DataSet ds = new DataSet();
dbAdapter.Fill(ds);
scon.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataKeyNames = new string[] { "huoID" };
GridView1.DataBind();
}
//选出符合的行出来在gridview中显示
protectedvoid Button2_Click(object sender, EventArgs e)
{
stringstr = "select huoID,huoName,huoDanwei,cfck,rkdw,ckdw,yskc,dixian,gaoxianfrom huopin where yskc>gaoxian order by huoID desc";
SqlConnection scon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon);
DataSetds = new DataSet();
dbAdapter.Fill(ds);
scon.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataKeyNames = new string[] { "huoID" };
GridView1.DataBind();
public partial class Managehuo : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
gridviewBind();//引用下面的绑定方法
}
}
//gridview绑定
private voidgridviewBind()
{
String str= "select huoID,huoName,huoDanwei,cfck,rkdw,ckdw,yskc+isnull((selectSUM(shuliang) from ruku where ruku.huoName=huopin.huoName group byhuoName),0)"
+" -isnull((select SUM(shuliang) from chuku where chuku.huoName=huopin.huoNamegroup by huoName),0) as kc,dixian,gaoxian from huopin order by huoID desc";
SqlConnection scon = newSqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon);
DataSetds = new DataSet();
dbAdapter.Fill(ds);//查出数据填充到dataset中
scon.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;//把gridview的数据源绑定为上面获取的的dataset表
GridView1.DataKeyNames = new string[] { "huoID" };//设置gridview的主键
GridView1.DataBind();
}
////f分页
protectedvoid GridView1_PageIndexChanging1(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
gridviewBind();
}
//删除行
protectedvoid GridView1_RowDeleting(object sender, GridViewDeleteEventArgse)
{
stringss = "delete from huopin where huoID='" +this.GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
SqlConnection scon = newSqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlCommand scmd = new SqlCommand(ss, scon);
scmd.ExecuteNonQuery();//执行删除
scon.Close();
GridView1.DataBind();
gridviewBind();//重新绑定数据源
}
//选出符合条件的行出来,现实到gridview中
protectedvoid Button1_Click(object sender, EventArgs e)
{
stringstr = "select huoID,huoName,huoDanwei,cfck,rkdw,ckdw,yskc,dixian,gaoxianfrom huopin where yskc<dixian order by huoID desc";
SqlConnection scon = newSqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon);
DataSet ds = new DataSet();
dbAdapter.Fill(ds);
scon.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataKeyNames = new string[] { "huoID" };
GridView1.DataBind();
}
//选出符合的行出来在gridview中显示
protectedvoid Button2_Click(object sender, EventArgs e)
{
stringstr = "select huoID,huoName,huoDanwei,cfck,rkdw,ckdw,yskc,dixian,gaoxianfrom huopin where yskc>gaoxian order by huoID desc";
SqlConnection scon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon);
DataSetds = new DataSet();
dbAdapter.Fill(ds);
scon.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataKeyNames = new string[] { "huoID" };
GridView1.DataBind();
北京磐安云创科技有限公司_
2023-02-01 广告
2023-02-01 广告
价格只是购买产品或服务过程中的一项指标,如果单纯只比较价格,其实考虑并不是那么周到。价格、质量、服务、口碑、是否合适自己的情况等都需要一起考虑。以上回答如果还觉得不够详细,可以来咨询下北京磐安公司。北京磐安公司是一家专业从事高新软件的技术公...
点击进入详情页
本回答由北京磐安云创科技有限公司_提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询