📄 typelist.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Huayou.Common;
using Huayou.Hyb2b.BaseClass;
using Huayou.Hyb2b.BN;
using Huayou.Hyb2b.DB;
using Huayou.Hyb2b.STRUCTURE;
namespace Huayou.Hyb2b.WebApp.Manage.NewsqManage
{
/// <summary>
/// TypeList 的摘要说明。
/// </summary>
public class TypeList : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button bnAdd;
protected System.Web.UI.WebControls.TextBox txProvince;
protected System.Web.UI.WebControls.TextBox txEdit;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.TextBox txSid;
protected System.Web.UI.WebControls.TextBox txName;
protected System.Web.UI.WebControls.Button bnSave;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
this.GetList();
if(Request["edit"]!=null)
{
this.txSid.Text=Request["sid"].ToString();
ViewState["sid"]=Request["sid"].ToString();
this.txEdit.Text="1";
this.GetContent(this.txSid.Text);
}
if(Request["del"]!=null)
{
this.txSid.Text=Request["sid"].ToString();
this.DelContent(this.txSid.Text);
}
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.bnAdd.Click += new System.EventHandler(this.bnAdd_Click);
this.bnSave.Click += new System.EventHandler(this.bnSave_Click);
}
#endregion
public void GetList()
{
NewssortBN bn=new NewssortBN(this.Page);
try
{
DataTable dt=bn.GetList();
this.DataGrid1.DataSource=dt;
this.DataGrid1.DataBind();
}
finally
{
bn.Dispose();
bn=null;
}
}
public void GetContent(string sid)
{
NewssortBN bn=new NewssortBN(this.Page);
try
{
NewssortDT dt=bn.Get(Convert.ToInt32(sid));
if(dt!=null)
{
this.txName.Text=dt.Hy_newssort;
}
}
finally
{
bn.Dispose();
bn=null;
}
}
public void DelContent(string sid)
{
NewssortBN bn=new NewssortBN(this.Page);
try
{
if(bn.Delete(Convert.ToInt32(sid)))
{
Response.Write("<script>alert('删除成功!');window.location='TypeList.aspx';</script>");
}
}
finally
{
bn.Dispose();
bn=null;
}
}
private void bnAdd_Click(object sender, System.EventArgs e)
{
this.txSid.Text="";
this.txName.Text="";
}
private void bnSave_Click(object sender, System.EventArgs e)
{
if(this.txName.Text!="")
{
NewssortBN bn=new NewssortBN(this.Page);
try
{
if(this.txEdit.Text=="")
{
NewssortDT dt=new NewssortDT();
dt.Hy_newssort=this.txName.Text;
dt.Hy_date=DateTime.Now;
if(bn.Add(dt))
{
Response.Write("<script>alert('保存成功!');window.location='TypeList.aspx';</script>");
}
}
else
{
NewssortDT dt=bn.Get(Convert.ToInt32(ViewState["sid"]));
dt.Hy_newssort=this.txName.Text;
if(bn.Edit(dt))
{
this.txSid.Text=this.txName.Text=this.txEdit.Text="";
Response.Write("<script>alert('保存成功!');window.location='TypeList.aspx';</script>");
}
}
}
finally
{
bn.Dispose();
bn=null;
}
}
else
{
CommonDialog.Show("名称不能为空!");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -