C#平时记载.docx
- 文档编号:25168897
- 上传时间:2023-06-05
- 格式:DOCX
- 页数:29
- 大小:22.20KB
C#平时记载.docx
《C#平时记载.docx》由会员分享,可在线阅读,更多相关《C#平时记载.docx(29页珍藏版)》请在冰豆网上搜索。
C#平时记载
目录
XMLDeleteTime2
gridview各种绑定(增删改查)2
定义控件,gv显示数据5
字符串转换成整数8
排序9
导入Excel9
导出Excel13
方113
方214
DDL绑定数据15
利用循环定义控件15
获取立项批复年月字符串15
连接数据库字符串16
XMLDeleteTime
Gpi_DeleteTimeISNOTNULL
Gpi_DeleteTimeISNULL
gridview各种绑定(增删改查)
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingMyOffice.BLL;
usingMyOffice.Model;
usingMyOffice.Framework;
//gridview各种绑定(增删改查)
publicpartialclassPeoPleManage_Default:
System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
if(!
IsPostBack)
{
DataBound();
}
}
protectedvoidButton1_Click(objectsender,EventArgse)
{
if(TextBox1.Text!
=""&&TextBox2.Text!
="")
{
BranchInfobi=newBranchInfo();
bi.BranchName=TextBox1.Text;
bi.BranchShortName=TextBox2.Text;
BllProvider.BranchInfoManageP.InsertBranch(bi);
}
}
privatevoidDataBound()
{
List
list=BllProvider.BranchInfoManageP.GetAllBrachInfos();
if(list.Count!
=0)
{
this.GridView1.DataSource=list;
this.GridView1.DataBind();
}
}
protectedvoidButton1_Click1(objectsender,EventArgse)
{
//ui上已经做了验证
BranchInfobi=newBranchInfo();
bi.BranchName=TextBox1.Text.Trim();
bi.BranchShortName=TextBox2.Text.Trim();
boolresult=BllProvider.BranchInfoManageP.InsertBranch(bi);
if(result)
{
DataBound();
}
else
{
//失败!
}
}
protectedvoidGridView1_RowDeleting(objectsender,GridViewDeleteEventArgse)
{
intno=Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
boolb=BllProvider.BranchInfoManageP.DeleteBranchInfoById(no);
if(b)
{
DataBound();
}
}
protectedvoidGridView1_SelectedIndexChanged(objectsender,EventArgse)
{
}
protectedvoidGridView1_PageIndexChanging(objectsender,GridViewPageEventArgse)
{
this.GridView1.PageIndex=e.NewPageIndex;
DataBound();
}
protectedvoidGridView1_RowEditing(objectsender,GridViewEditEventArgse)
{
GridView1.EditIndex=e.NewEditIndex;
DataBound();
}
protectedvoidGridView1_RowUpdating(objectsender,GridViewUpdateEventArgse)
{
//不好用:
可以findcotrol方法;
intstuno=Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
stringnewBranchName=((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox3")).Text;
stringnewBranchShortName=((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox4")).Text;
BranchInfobi=newBranchInfo();
bi.BranchName=newBranchName;
bi.BranchShortName=newBranchShortName;
bi.BranchId=stuno;
GridView1.EditIndex=-1;
if(BllProvider.BranchInfoManageP.UpdateBranchInfoById(bi))
{
//成功!
DataBound();
//DataBind();
}
else
{
//失败!
}
}
protectedvoidGridView1_RowCancelingEdit(objectsender,GridViewCancelEditEventArgse)
{
GridView1.EditIndex=-1;
DataBound();
}
protectedvoidButton2_Click(objectsender,EventArgse)
{
}
protectedvoidGridView1_RowDataBound(objectsender,GridViewRowEventArgse)
{
if(e.Row.RowType==DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover","cc=this.style.backgroundColor;this.style.backgroundColor='#ecf6fc'");
e.Row.Attributes.Add("onmouseout","this.style.backgroundColor=cc");
}
}
protectedvoidChanging(objectsender,GridViewPageEventArgse)
{
}
protectedvoidaBound(objectsender,GridViewRowEventArgse)
{
}
}
定义控件,gv显示数据
#region行操作
privatevoidSetRowData(IList
{
gv.DataSource=CommonHelper.BuildIntArray(1,list.Count);
gv.DataBind();
for(inti=0;i { LabelilblProject=(Label)gv.Rows[i].FindControl("ilblProject"); HiddenFieldihfProjectNumber=(HiddenField)gv.Rows[i].FindControl("ihfProjectNumber"); LabelilblRegion=(Label)gv.Rows[i].FindControl("ilblRegion"); HiddenFieldihfRegionCode=(HiddenField)gv.Rows[i].FindControl("ihfRegionCode"); TextBoxitbReplyMoney=(TextBox)gv.Rows[i].FindControl("itbReplyMoney"); TextBoxitbReplyUser=(TextBox)gv.Rows[i].FindControl("itbReplyUser"); TextBoxitbDesignSupplier=(TextBox)gv.Rows[i].FindControl("itbDesignSupplier"); TextBoxitbDesignManager=(TextBox)gv.Rows[i].FindControl("itbDesignManager"); TextBoxitbDesignPhone=(TextBox)gv.Rows[i].FindControl("itbDesignPhone"); TextBoxitbConstructionSupplier=(TextBox)gv.Rows[i].FindControl("itbConstructionSupplier"); TextBoxitbConstructionManager=(TextBox)gv.Rows[i].FindControl("itbConstructionManager"); TextBoxitbConstructionPhone=(TextBox)gv.Rows[i].FindControl("itbConstructionPhone"); TextBoxitbSupervisionSupplier=(TextBox)gv.Rows[i].FindControl("itbSupervisionSupplier"); TextBoxitbSupervisionManager=(TextBox)gv.Rows[i].FindControl("itbSupervisionManager"); TextBoxitbSupervisionPhone=(TextBox)gv.Rows[i].FindControl("itbSupervisionPhone"); DocumentRowDataZYrowData=list[i]; ilblProject.Text=rowData.ProjectNumber+IoCContainer.Get ihfProjectNumber.Value=rowData.ProjectNumber; ilblRegion.Text=IoCContainer.Get ihfRegionCode.Value=rowData.RegionCode; itbReplyMoney.Text=rowData.ReplyMoney.ToString("#.##"); itbReplyUser.Text=rowData.ReplyUser; itbDesignSupplier.Text=rowData.DesignSupplier; itbDesignManager.Text=rowData.DesignManager; itbDesignPhone.Text=rowData.DesignPhone; itbConstructionSupplier.Text=rowData.ConstructionSupplier; itbConstructionManager.Text=rowData.ConstructionManager; itbConstructionPhone.Text=rowData.ConstructionPhone; itbSupervisionSupplier.Text=rowData.SupervisionSupplier; itbSupervisionManager.Text=rowData.SupervisionManager; itbSupervisionPhone.Text=rowData.SupervisionPhone; } if(gv.Rows.Count>0) divReplyDetail.Visible=true; else divReplyDetail.Visible=false; } privateIList { IList foreach(GridViewRowrowingv.Rows) { HiddenFieldihfProjectNumber=(HiddenField)row.FindControl("ihfProjectNumber"); HiddenFieldihfRegionCode=(HiddenField)row.FindControl("ihfRegionCode"); TextBoxitbReplyMoney=(TextBox)row.FindControl("itbReplyMoney"); TextBoxitbReplyUser=(TextBox)row.FindControl("itbReplyUser"); TextBoxitbDesignSupplier=(TextBox)row.FindControl("itbDesignSupplier"); TextBoxitbDesignManager=(TextBox)row.FindControl("itbDesignManager"); TextBoxitbDesignPhone=(TextBox)row.FindControl("itbDesignPhone"); TextBoxitbConstructionSupplier=(TextBox)row.FindControl("itbConstructionSupplier"); TextBoxitbConstructionManager=(TextBox)row.FindControl("itbConstructionManager"); TextBoxitbConstructionPhone=(TextBox)row.FindControl("itbConstructionPhone"); TextBoxitbSupervisionSupplier=(TextBox)row.FindControl("itbSupervisionSupplier"); TextBoxitbSupervisionManager=(TextBox)row.FindControl("itbSupervisionManager"); TextBoxitbSupervisionPhone=(TextBox)row.FindControl("itbSupervisionPhone"); DocumentRowDataZYrowData=newDocumentRowDataZY(); rowData.ProjectNumber=ihfProjectNumber.Value; rowData.RegionCode=ihfRegionCode.Value; rowData.ReplyMoney=itbReplyMoney.Text.ToDecimal(); rowData.ReplyUser=itbReplyUser.Text; rowData.DesignSupplier=itbDesignSupplier.Text; rowData.DesignManager=itbDesignManager.Text; rowData.DesignPhone=itbDesignPhone.Text; rowData.ConstructionSupplier=itbConstructionSupplier.Text; rowData.ConstructionManager=itbConstructionManager.Text; rowData.ConstructionPhone=itbConstructionPhone.Text; rowData.SupervisionSupplier=itbSupervisionSupplier.Text; rowData.SupervisionManager=itbSupervisionManager.Text; rowData.SupervisionPhone=itbSupervisionPhone.Text; list.Add(rowData); } returnlist; } #endregion privatevoidBindProject(IList { IList IList UserV2currentUser=CurrentUserV2.GetReq(); foreach(stringprojectNumberinprojectNumbers) { IList IDictionary foreach(varsubprojectinsubprojects) { DocumentRowDataZYrowData=newDocumentRowDataZY(); rowData.ProjectNumber=projectNumber; rowData.RegionCode=subproject.RegionCode; DocumentRowDataZYdata=existedRowDataList.Where(s=>s.ProjectNumber==projectNumber&&s.RegionCode==subproject.RegionCode).FirstOrDefault(); if(data! =null) { rowData.ReplyMoney=data.ReplyMoney; rowData.ReplyUser=data.ReplyUser; rowData.DesignSupplier=data.DesignSupplier; rowData.DesignManager=data.DesignManager; rowData.DesignPhone=data.DesignPhone; rowData.ConstructionSupplier=data.ConstructionSupplier; rowData.ConstructionManager=data.ConstructionManager; rowData.ConstructionPhone=data.ConstructionPhone; rowData.SupervisionSupplier=data.SupervisionSupplier; rowData.SupervisionManager=data.SupervisionManager; rowData.SupervisionPhone=data.SupervisionPhone; } else { if(dictPaZz.Keys.Contains(subproject.RegionCode)) rowData.ReplyMoney=decimal.Parse(dictPaZz[subproject.RegionCode].ToString("n")); rowData.ReplyUser=currentUser.ChineseName; }
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C# 平时 记载