1.html代码

                               <asp:TemplateField HeaderText="操作">
<ItemTemplate>
<div style="width: 129px">
<asp:Button ID="btnPass" runat="server" Text="通过" OnCommand="pass" CommandArgument="<%# ((GridViewRow)Container).RowIndex %>" />
&nbsp;
<asp:Button ID="btnRefuse" runat="server" Text="不通过" OnCommand="refuse" CommandArgument="<%# ((GridViewRow)Container).RowIndex %>" />
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="删除">
<ItemTemplate>
<asp:Button ID="btnDelete" Width="60" runat="server" Text="删除" CommandName="Delete" />
</ItemTemplate>
</asp:TemplateField>

2.后台代码

     protected void gvAuthManagement_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int index = e.RowIndex;
string openId = ((Label)gvAuthManagement.Rows[index].Cells[].FindControl("Label4")).Text;
AuthorizationInfo authInfo = new AuthorizationInfo { OpenId = openId };
AuthorizationBiz.Delete(authInfo);
InfoList = AuthorizationBiz.Query(new AuthorizationInfo());
Bind(InfoList);
} //给微信用户授权
protected void pass(object sender, CommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
string lienceplate = ((Label)gvAuthManagement.Rows[index].Cells[].FindControl("Label1")).Text;
string status = ((Label)gvAuthManagement.Rows[index].Cells[].FindControl("Label6")).Text;
AuthorizationInfo authInfo = new AuthorizationInfo { LiencePlateNumber = lienceplate };
IList<AuthorizationInfo> list = AuthorizationBiz.Query(authInfo); //微信客服消息回复通过
string access_token = AccessTo.GetExistAccessToken();
string content = "{ \"touser\":\"" + list[].OpenId + "\",\"msgtype\":\"text\",\"text\":{ \"content\":\"亲\"}}";
string url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + access_token;//json格式的数据
RequestHelper.SendPost(content, url, "application/json");
if (status != "已授权")
{
authInfo.Status = "已授权";
AuthorizationBiz.Update(authInfo);
}
InfoList = AuthorizationBiz.Query(new AuthorizationInfo());
Bind(InfoList);
} //拒绝微信用户授权
protected void refuse(object sender, CommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
string lienceplate = ((Label)gvAuthManagement.Rows[index].Cells[].FindControl("Label1")).Text;
string status = ((Label)gvAuthManagement.Rows[index].Cells[].FindControl("Label6")).Text;
AuthorizationInfo authInfo = new AuthorizationInfo { LiencePlateNumber = lienceplate };
IList<AuthorizationInfo> list = AuthorizationBiz.Query(authInfo); //微信客服消息回复通过
string access_token = AccessTo.GetExistAccessToken();
string content = "{ \"touser\":\"" + list[].OpenId + "\",\"msgtype\":\"text\",\"text\":{ \"content\":\"您的微信号授权申请被拒绝\"}}";
string url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + access_token;//json格式的数据
RequestHelper.SendPost(content, url, "application/json");
if (status != "未授权")
{
authInfo.Status = "未授权";
AuthorizationBiz.Update(authInfo);
}
InfoList = AuthorizationBiz.Query(new AuthorizationInfo());
Bind(InfoList);
}

二、

1)html代码

                               <asp:TemplateField HeaderText="编辑" ItemStyle-Width="80">
<ItemTemplate>
<asp:Button ID="btn_edit" runat="server" Text="编辑" CommandName="Edit" ForeColor="#1C94C4"></asp:Button>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="btn_update" runat="server" CommandName="Update" Text="更新" /><%--OnClientClick="update()"--%>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="删除" ItemStyle-Width="80">
<ItemTemplate>
<asp:Button ID="btn_delete" runat="server" Text="删除" CommandName="Delete" ForeColor="#1C94C4"></asp:Button>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="btn_cancel" runat="server" CommandName="Cancel" Text="取消" />
</EditItemTemplate>
</asp:TemplateField>

2).

//行删除
protected void gvCenterMangerment_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
//此处只实现了单行的删除
int index = e.RowIndex;
string centerName = ((Label)gvCenterMangerment.Rows[index].Cells[].FindControl("Label2")).Text;
ContactInfo contactInfo = new ContactInfo { CenterName = centerName };
try
{
ContactBiz.Delete(contactInfo); }
catch (Exception ex)
{
Logger.Write("中心名称为:" + centerName + "的记录删除失败!原因:" + ex.Message);
throw ex;
}
InfoList = ContactBiz.Query(new ContactInfo());
Bind(InfoList);
} //行编辑
protected void gvCenterMangerment_RowEditing(object sender, GridViewEditEventArgs e)
{
try
{
gvCenterMangerment.EditIndex = e.NewEditIndex;
InfoList = ContactBiz.Query(new ContactInfo());
Bind(InfoList);
}
catch (Exception ex)
{
Logger.Write("中心管理行编辑失败" + ex.Message);
throw ex;
} } //行编辑修改数据
protected void btnModify_Click(object sender, GridViewUpdateEventArgs e)
{
int index = e.RowIndex;
ContactInfo contactInfo = new ContactInfo();
// System.Text.RegularExpressions.Regex.IsMatch("","");
//Regex.IsMatch(contactInfo.PhoneNumber,"^1[3456789]\\d{9}$|^0\\d{2,3}-?\\d{7,8}$");
contactInfo.CenterName = ((Label)gvCenterMangerment.Rows[index].Cells[].FindControl("Label2")).Text;
contactInfo.Name = ((TextBox)gvCenterMangerment.Rows[index].Cells[].FindControl("TextBox3")).Text;
if (contactInfo.Name == "")
{
ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), System.DateTime.Now.Ticks.ToString(), "alert('*联系人不能为空*');", true);
return;
}
contactInfo.PhoneNumber = ((TextBox)gvCenterMangerment.Rows[index].Cells[].FindControl("TextBox4")).Text;
if (contactInfo.PhoneNumber == "")
{
ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), System.DateTime.Now.Ticks.ToString(), "alert('*联系方式不能为空*');", true);
return;
}
else
{
if (!Regex.IsMatch(contactInfo.PhoneNumber, "^1[3456789]\\d{9}$|^0\\d{2,3}-?\\d{7,8}$"))
{
ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), System.DateTime.Now.Ticks.ToString(), "alert('*联系方式格式错误*');", true);
return;
}
}
contactInfo.Address = ((TextBox)gvCenterMangerment.Rows[index].Cells[].FindControl("TextBox5")).Text;
if (contactInfo.Address == "")
{
ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), System.DateTime.Now.Ticks.ToString(), "alert('*地址不能为空*');", true);
return;
}
ContactBiz.Update(contactInfo);
gvCenterMangerment.EditIndex = -;
InfoList = ContactBiz.Query(new ContactInfo());
Bind(InfoList);
errorWarning.Text = "";
} //行编辑取消
protected void gvCenterMangerment_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvCenterMangerment.EditIndex = -;
InfoList = ContactBiz.Query(new ContactInfo());
Bind(InfoList);
}

三、

1)html代码

<asp:ButtonField ButtonType="Button" CommandName="observe" HeaderText="操作" Text="查看" />

2)

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "observe")
{
try
{
int index = Convert.ToInt32(e.CommandArgument);
string LiencePlateNumber = ((Label)GridView1.Rows[index].Cells[].FindControl("label2")).Text.ToString().Trim();
string CreateTime = ((Label)GridView1.Rows[index].Cells[].FindControl("label8")).Text.ToString().Trim();
string url = "../Management/ExDetails.html?LiencePlateNumber=" + LiencePlateNumber + "&CreateTime=" + CreateTime;
string js = "window.open(\"../Management/ExDetails.html?LiencePlateNumber=" + LiencePlateNumber + "&CreateTime=" + CreateTime + "\",\"_blank\")";
ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), System.DateTime.Now.Ticks.ToString(), js, true);
}
catch (Exception ex)
{
Logger.Write("后台查看异常详情失败,原因:" + ex.Message);
throw ex;
} }
}

最新文章

  1. html img图片等比例缩放
  2. 通过寄生组合式继承创建js的异常类
  3. UVALive 7139 Rotation(矩阵前缀和)(2014 Asia Shanghai Regional Contest)
  4. MySQL索引原理及慢查询优化(转)
  5. 8月7号晚7点Autodesk北京办公室,我们来聊聊HTML5/ WebGL 3D 模型浏览技术
  6. Java学习随笔4:Java的IO操作
  7. PHP处理CSV表格文件的常用操作方法是怎么样呢
  8. 【源码下载】分享一个支持自安装自卸载的Windows服务
  9. SQL 存储过程中in
  10. C# 添加一个用户对文件或者文件夹的所有权限
  11. BZOJ1524: [POI2006]Pal
  12. apache SetEnv 设置
  13. thanks使用注意事项;
  14. springcloud(六):配置中心(一)
  15. JS分号 惹的坑
  16. 【unix网络编程第三版】阅读笔记(三):基本套接字编程
  17. linux 安装mysql相关和openjdk
  18. day9 九、函数
  19. PostgreSQL9.4如何指定数据库schema
  20. Python + logging 输出到屏幕,将log日志写入文件

热门文章

  1. java.lang.IllegalArgumentException: addChild: Child name &#39;/SSHE&#39; is not unique
  2. Java 集合系列 13 WeakHashMap
  3. Oracle11g中ORA-01790
  4. redis sort
  5. POJ 3299 Humidex 难度:0
  6. TopCoder SRM 583 TurnOnLamps
  7. Quartz 2D 图形上下文栈 矩阵 裁剪
  8. Problem C HDU 5224
  9. 如何利用SVN合并代码
  10. RPI学习--环境搭建_刷卡+wiringPi库安装