asp.net里的常用代码
来源:互联网 发布:线切割割梅花怎么编程 编辑:程序博客网 时间:2024/04/29 08:12
//在datagrid里删除
private void btn_Delete_Click(object sender, System.EventArgs e)
{
//选中删除
foreach(DataGridItem item in DataGrid1.Items )
{
CheckBox selection;
selection = (CheckBox)item.FindControl("chk");
if (selection.Checked)
{
string sCunCode=item.Cells[2].Text;
string sYear=item.Cells[3].Text;
try
{
WKR.DBSupport.WKR_T02_01_1Service objService=new WKR.DBSupport.WKR_T02_01_1Service();
objService.ExecutebySQL("delete WKR_T02_01_1 where B010301='"+sCunCode+"' and B000001='"+sYear+"'");
}
catch
{//出错处理
}
}
}
//显示村情
ShowData();
}
public void ShowData()
{
//显示村情
try
{
DataGrid1.DataSource=new WKR.DBSupport.WKR_T02_01_1Service().GetbySQL("Select WKR_T02_01_1.B010301 , WKR_T02_01_1.B000001 ,WKR_T01_03_1.B010302,WKR_T02_01_1.B000004,WKR_T02_01_1.B000005 from WKR_T02_01_1,WKR_T01_03_1 where WKR_T02_01_1.B010301 = WKR_T01_03_1.B010301 and WKR_T01_03_1.B010302 like '%"+TBCunName.Text.Trim().ToString()+"%'");
DataGrid1.DataBind();
LBPageCount.Text = "第"+((Int32) DataGrid1.CurrentPageIndex +1)+"页"+"/共"+DataGrid1.PageCount +"页";
}
catch
{//出错处理
}
//显示乡名称、民族和重点村
foreach(DataGridItem item in DataGrid1.Items )
{
string sCunCode=item.Cells[2].Text;
string sXiangCode=sCunCode.Substring(0,8);
//获取乡名称
try
{
WKR.DBSupport.WKR_T01_02_1Service objService=new WKR.DBSupport.WKR_T01_02_1Service();
WKR.DBSupport.WKR_T01_02_1Set ds=objService.GetbySQL("select * from WKR_T01_02_1 where B010201='"+sXiangCode+"'");
item.Cells[4].Text=ds.Tables[0].Rows[0][1].ToString();
}
catch
{
//错误处理
}
//获取村性质
try
{
WKR.DBSupport.WKR_T01_04_1Service objService2=new WKR.DBSupport.WKR_T01_04_1Service();
WKR.DBSupport.WKR_T01_04_1Set ds2=objService2.GetbySQL("select * from WKR_T01_04_1 where B010301='"+sCunCode+"'");
string sCunStyle=ds2.Tables[0].Rows[0][1].ToString();
if(sCunStyle.Substring(0,1)=="1")
item.Cells[5].Text="是";
else
item.Cells[5].Text="否";
if(sCunStyle.Substring(1,1)=="1")
item.Cells[6].Text="是";
else
item.Cells[6].Text="否";
}
catch
{
//错误处理
}
}
}
//分页显示
linkbutton按钮 <TD style="HEIGHT: 21px" align="right" colSpan="3"><FONT face="宋体"><asp:linkbutton id="PageFirst" onclick="PageButton" runat="server" Width="56px" CommandArgument="pagefirst">第一页</asp:linkbutton><asp:linkbutton id="PageNext" onclick="PageButton" runat="server" Width="56px" CommandArgument="pagenext">下一页</asp:linkbutton><asp:linkbutton id="PagePre" onclick="PageButton" runat="server" Width="56px" CommandArgument="pagepre">上一页</asp:linkbutton><asp:linkbutton id="PageLast" onclick="PageButton" runat="server" Width="56px" CommandArgument="pagelast">末一页</asp:linkbutton></FONT>
<asp:label id="LBPageCount" runat="server">第1页</asp:label></TD>
//
public void PageButton(object sender, System.EventArgs e)
{
//分页显示
string arg=((LinkButton)sender).CommandArgument;
switch(arg)
{
case ("pagefirst"):
DataGrid1.CurrentPageIndex=0;
break;
case ("pagenext"):
if(DataGrid1.CurrentPageIndex<(DataGrid1.PageCount -1))
DataGrid1.CurrentPageIndex ++;
break;
case ("pagepre"):
if(DataGrid1.CurrentPageIndex>0)
DataGrid1.CurrentPageIndex --;
break;
case ("pagelast"):
DataGrid1.CurrentPageIndex=DataGrid1.PageCount-1;
break;
}
ShowData();
}
//添加数据
private void Button1_Click(object sender, System.EventArgs e)
{
//添加数据
if((DDLYear.SelectedIndex==0)||(DDLCunCode.SelectedIndex==0))
Response.Write("<script>alert('未选择年份或者村名称!');</script>");
else
{
WKR.DBSupport.WKR_T02_01_1Service wkr_t02=new WKR.DBSupport.WKR_T02_01_1Service();
WKR.DBSupport.WKR_T02_01_1 drow=new WKR.DBSupport.WKR_T02_01_1();
//非空数据
WKR.LogicLib.User.UserInfo userinfo = (WKR.LogicLib.User.UserInfo)Session["UserInfo"];
string sRecorderName = userinfo.UserName;
drow.SetB010301(DDLCunCode.SelectedValue.ToString().Trim()); //村代码
drow.SetB000001(DDLYear.SelectedValue.ToString().Trim()); //日期(年份)
drow.SetB000004(System.DateTime.Today); //录入日期
drow.SetB000005(sRecorderName); //操作人员
drow.SetB000099(TextBox22.Text.Trim().ToString()); //备注
//其他数据
int i=0;
if(TextBox3.Text!="")
{
if(TextBox2.Text.Trim()=="")
{
Response.Write("<script language=javascript>alert('总户数为空时,少数民族户数不能有数!');</script>");
return;
}
else
drow.SetF020104(Convert.ToInt16(TextBox3.Text.Trim())); //其中:少数民族
}
else
i++;
i++;
if(TextBox8.Text!="")
if(TextBox7.Text.Trim()=="")
{
Response.Write("<script language=javascript>alert('总劳动力数为空时,妇女数不能有数!');</script>");
return;
}
else
drow.SetF020108(Convert.ToInt16(TextBox8.Text.Trim())); //其中:妇女人数
else
i++;
if(TextBox21.Text!="")
drow.SetF020121(Convert.ToInt16(TextBox21.Text.Trim())); //电话
else
i++;
//对未填写项进行处理
if(i>0)
{
CheckBox1.Visible=true;
CheckBox1.Text="有" +i.ToString() +"项未填写,是否继续提交? 是";
if(CheckBox1.Checked)
{
try
{
wkr_t02.InsertWKR_T02_01_1(drow);
Response.Write("<script>location='ManageCountryBasicInformation.aspx';</script>");
}
catch
{
//错误处理
Response.Write("<script>alert('该记录已经存在!');</script>");
}
}
else
{
return ;
}
}
else
{
try
{
wkr_t02.InsertWKR_T02_01_1(drow);
Response.Write("<script>location='ManageCountryBasicInformation.aspx';</script>");
}
catch
{
//错误处理
Response.Write("<script>alert('该记录已经存在!');</script>");
}
}
}
}
- asp.net里的常用代码
- ASP.NET里常用的JavaScript代码封装
- ASP.NET里最常用的三十三种代码
- asp.net常用的代码
- 常用的ASP.net代码
- asp.net的常用代码
- ASP.NET常用的代码
- Asp.net常用的代码
- ASP.NET里常用的JS
- ASP.NET里常用的JS
- ASP.NET里常用的JS
- ASP.NET里常用的JS
- ASP.NET里常用的JS
- 追踪ASP.NET代码里的bug
- 追踪ASP.NET代码里的bug
- 追踪ASP.NET代码里的bug
- 追踪ASP.NET代码里的bug
- ASP.NET常用代码
- 用spirng和hessian构建分布式应用(远程接口)的方法
- .NET 设计时示例
- Windows下如何彻底删除Oracle
- C语言: 按照格式返回系统时间的的函数
- Hibernate Iterator JCS分析
- asp.net里的常用代码
- 我是第三类人(转)
- 许巍 "礼物"
- 运用Raptor-V0.1做的论坛截图-已经更新
- 初学VC之路:引言
- [转]Mail服务器
- 著名的开源project社区
- 揭开Outlook Express编辑器的奥秘
- Windows下的字体名称集