实例介绍
【实例简介】
【实例截图】
【实例截图】
【核心代码】
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Web.sitemanager.hongbao
{
public partial class User_Hongbao : Administrator.UI.ManagerBaseUIPage
{
//页面功能
private string txtEditTitle = "会员管理";
//导航路径
public string txtManageTitle = "会员信息管理 > 会员信息";
//传值
public static string txtLocal = "";
public static List<CMS.Model.UserHongbao> list = new List<CMS.Model.UserHongbao>();
public static List<CMS.Security.User> listuser = new List<CMS.Security.User>();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
RptBind();
}
}
//数据绑定
private void RptBind()
{
//初始值
ToolsPannel.Visible = true;
ListPanel.Visible = true;
contentTab.Visible = false;
string SQLStr = "";
if (DropDownList1.SelectedValue != "")
SQLStr = " AND Type = " DropDownList1.SelectedValue;
list = CMS.BLL.UserHongbao.Search(0, SQLStr, "");
listuser_inf();
this.rptList.DataSource = list;
this.rptList.DataBind();
decimal summoney = 0;
for (int i = 0; i < list.Count; i )
{
summoney = list[i].MoneyAmount;
}
lbltext.Text = Math.Round(summoney, 2).ToString();
if (DropDownList1.SelectedValue == "")
{
Label2.Text = "";
}
else if (DropDownList1.SelectedValue == "1")
{
Label2.Text = "考试满分";
}
else if (DropDownList1.SelectedValue == "2")
{
Label2.Text = "关注有礼";
}
}
/// <summary>
/// 获取答题用户列表
/// </summary>
private void listuser_inf()
{
string list_userid = "";
if (list.Count > 0)
{
for (int i = 0; i < list.Count; i )
{
list_userid = list[i].UserId ",";
}
listuser = CMS.Security.User.get(" and UserId in (" list_userid.TrimEnd(',') ")");
}
}
/// <summary>
/// 根据用户ID获取用户姓名
/// </summary>
/// <param name="userid"></param>
/// <returns></returns>
public string getusername(int userid)
{
string result = "";
foreach (CMS.Security.User item in listuser)
{
if (item.UserId == userid)
{
result = item.Name;
break;
}
}
return result;
}
/// <summary>
/// 调出添加、编辑界面
/// </summary>
/// <param name="hidValue"></param>
public void GetAddEditPanel(int hideValue)
{
//控制界面
ObjectId.Value = hideValue.ToString();
ToolsPannel.Visible = false;
ListPanel.Visible = false;
contentTab.Visible = true;
if (hideValue == 0)
{
EditTitle.Text = txtEditTitle "新增";
//txtpassword.CssClass = "txtInput normal required";
}
else
{
EditTitle.Text = txtEditTitle "编辑";
//txtpassword.CssClass = "txtInput normal";
CMS.Security.User user = CMS.Security.User.GetUserByUserID(hideValue);
txtname.Text = user.Name;
txtTel.Text = user.Telephone;
}
}
//提交按钮
public void btnSubmit_Click(object sender, EventArgs e)
{
int intObjectId = Convert.ToInt32(ObjectId.Value);
if (intObjectId > 0)
{
CMS.Security.User editinfo = CMS.Security.User.GetUserByUserID(intObjectId);
editinfo.Name = txtname.Text;
editinfo.Telephone = txtTel.Text;
editinfo.Update();
JscriptMsg("修改成功啦!", "UserList.aspx", "Success");
}
else
{
CMS.Security.User addinfo = CMS.Security.User.GetUserByTelephone(txtTel.Text.Trim());
if (addinfo != null)
{
JscriptMsg("该手机号已经注册!", "", "Warning");
}
else
{
addinfo.Name = txtname.Text.Trim();
addinfo.Telephone = txtTel.Text.Trim();
addinfo.Joined = DateTime.Now;
addinfo.Create();
JscriptMsg("创建成功啦!", "UserList.aspx", "Success");
JscriptMsg("确认密码不正确!", "", "Warning");
}
}
}
//分页
protected void Repeater1_PageIndexChanged(object sender, DataGridPageChangedEventArgs e)
{
rptList.CurrentPageIndex = e.NewPageIndex;
RptBind();
}
//绑定操作按钮
protected void Repeater1_ItemCommand(object sender, RepeaterCommandEventArgs e)
{
if (e.CommandName == "edit")
{
GetAddEditPanel(Convert.ToInt32(e.CommandArgument));
}
}
//新增
protected void btnAdd_Click(object sender, EventArgs e)
{
GetAddEditPanel(0);
}
//保存排序
protected void btnSave_Click(object sender, EventArgs e)
{
}
//批量删除
protected void btnDelete_Click(object sender, EventArgs e)
{
for (int i = 0; i < rptList.Items.Count; i )
{
int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
if (cb.Checked)
{
CMS.Security.User delinfo = CMS.Security.User.GetUserByUserID(id);
delinfo.Delete();
}
}
JscriptMsg("批量删除成功啦!", "UserList.aspx", "Success");
}
public string GetOrderNumber(string v_mid)
{
string v_oid;
DateTime dt = DateTime.Now;
string v_ymd = dt.ToString("yyyyMMdd", DateTimeFormatInfo.InvariantInfo); // yyyyMMdd
string timeStr = dt.ToString("HHmmss", DateTimeFormatInfo.InvariantInfo); // HHmmss
v_oid = "SH" v_ymd v_mid timeStr;
return v_oid;
}
protected void GroupDropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
RptBind();
}
public void outExcel_Click(object sender, EventArgs e)
{
//string SQLStr = "";
//if (DropDownList1.SelectedValue != "")
// SQLStr = " AND Type = " DropDownList1.SelectedValue;
//list = CMS.BLL.UserHongbao.Search(0, SQLStr, "");
//listuser_inf();
string name = "/uploads/" DateTime.Now.ToString("yyyy-MM-dd") DateTime.Now.Millisecond ".csv";
FileStream fs = new FileStream(Server.MapPath(name), FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.GetEncoding("gb2312"));
sw.WriteLine("姓名,红包类型,红包金额,创建时间");
foreach (CMS.Model.UserHongbao item in list)
{
sw.WriteLine(getusername(item.UserId) "," (item.Type == 1 ? "满分试卷" : "关注有礼") "," Math.Round(Convert.ToDecimal(item.MoneyAmount), 2) "," item.CreateTime.ToString());
}
sw.Close();
HttpContext.Current.Response.Redirect(name);
}
}
}
好例子网口号:伸出你的我的手 — 分享!
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明


网友评论
我要评论