59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.Remoting.Messaging;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
public partial class admin_guadan_guadantime_timeindex : MyWeb.config
|
|
{
|
|
private Model.ezEntities _db = new Model.ezEntities();
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
BindTimeSettings();
|
|
}
|
|
}
|
|
private void BindTimeSettings()
|
|
{
|
|
{
|
|
// 取得最近所有挂单时间设置
|
|
var list = _db.GuadanTimeSetting
|
|
.OrderByDescending(x => x.CreatedAt)
|
|
.ToList();
|
|
|
|
gvTimeSettings.DataSource = list;
|
|
gvTimeSettings.DataBind();
|
|
}
|
|
}
|
|
protected void gvTimeSettings_RowCommand(object sender, GridViewCommandEventArgs e)
|
|
{
|
|
if (e.CommandName == "DeleteItem")
|
|
{
|
|
Guid id = Guid.Parse(e.CommandArgument.ToString());
|
|
|
|
try
|
|
{
|
|
{
|
|
var setting = _db.GuadanTimeSetting.FirstOrDefault(x => x.Id == id);
|
|
if (setting != null)
|
|
{
|
|
_db.GuadanTimeSetting.Remove(setting);
|
|
_db.SaveChanges();
|
|
}
|
|
}
|
|
|
|
// 重新绑定列表
|
|
BindTimeSettings();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// 显示错误信息
|
|
divMessage.InnerText = "删除失败:" + ex.Message;
|
|
}
|
|
}
|
|
}
|
|
|
|
} |