添加商品信息(AddProduct.aspx.cs)的代码实现:
private void Page_Load(object sender, System.EventArgs e)
{ if (!Page.IsPostBack)
{ BindList();
}
}
private void Add_Click(object sender, System.EventArgs e)
{ AdminDB admin = new AdminDB();
try
{ admin.AddNewProduct(ProductName.Text.Trim(), decimal.Parse(Price.Text.Trim()), Intro.Text, int.Parse(ListCat.SelectedValue));
MyError.Text = "添加成功!";
AdminDB.InsertAction("添加新的商品"+ ProductName.Text.Trim(), System.DateTime.Now, User.Identity.Name);
}
catch
{ MyError.Text = "出错了";
}
}
void BindList()
{ ListCat.DataSource = eshop.BLL.Product.GetCategoryList();
ListCat.DataTextField = "CategoryName";
ListCat.DataValueField = "CategoryId";
ListCat.DataBind();
}
查询用户信息、添加用户账户存款(UserList.aspx.cs)的代码实现:
private void Page_Load(object sender, System.EventArgs e)
{ if (!Page.IsPostBack)
{ BindGrid();
AdminDB.InsertAction("查看用户列表", System.DateTime.Now,User.Identity.Name);
}
}
void BindGrid()
{ AdminDB admin = new AdminDB();
GridUsers.DataSource = admin.GetUserList();
GridUsers.DataBind();
}
private void GridUsers_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{ GridUsers.CurrentPageIndex = e.NewPageIndex;
BindGrid();
}
private void GridUsers_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
www.751com.cn
private void GridUsers_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{ GridUsers.EditItemIndex = -1;
BindGrid();
}
private void GridUsers_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{ //获得输入的预存款金额
decimal money = decimal.Parse(((TextBox)e.Item.FindControl("Acount")).Text.Trim());
//获得要更改的用户的UserId
int userId = Convert.ToInt32(GridUsers.DataKeys[e.Item.ItemIndex]);
AdminDB admin = new AdminDB();
//执行更新操作
admin.UpdateUserAcount(money, userId.ToString());
//插入日志
AdminDB.InsertAction("修改用户Id为" + userId.ToString() + "的帐户金额", System.DateTime.Now, User.Identity.Name);
//退出编辑状态
GridUsers.EditItemIndex = -1;
//绑定
BindGrid();
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>