📄 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.ScaManage
{
/// <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()
{
string sql="";
sql="select * from Scasort order by Sid";
DataTable dt =SqlHelper.ExecuteDataset(BaseConfManager.GetConnectionStr(),CommandType.Text,sql).Tables[0];
this.DataGrid1.DataSource=dt;
this.DataGrid1.DataBind();
}
public void GetContent(string sid)
{
string sql="";
sql="select * from Scasort where Sid="+sid;
DataTable dt =SqlHelper.ExecuteDataset(BaseConfManager.GetConnectionStr(),CommandType.Text,sql).Tables[0];
if(dt.Rows.Count>0)
{
this.txName.Text=dt.Rows[0]["Hy_scasort"].ToString();
}
}
public void DelContent(string sid)
{
string sql="";
sql="delete from Scasort where Sid="+sid;
int row=SqlHelper.ExecuteNonQuery(BaseConfManager.GetConnectionStr(),CommandType.Text,sql);
if(row.Equals(1))
{
this.txSid.Text="";
Response.Write("<script>alert('删除成功!');window.location='TypeList.aspx';</script>");
}
}
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!="")
{
string sql="";
if(this.txEdit.Text=="")
{
sql="insert into Scasort values('"+this.txName.Text+"','"+DateTime.Now.ToString()+"')";
int row=SqlHelper.ExecuteNonQuery(BaseConfManager.GetConnectionStr(),CommandType.Text,sql);
if(row.Equals(1))
{
Response.Write("<script>alert('保存成功!');window.location='TypeList.aspx';</script>");
}
}
else
{
sql="update Scasort set Hy_scasort='"+this.txName.Text+"' where Sid="+ViewState["sid"].ToString();
int row=SqlHelper.ExecuteNonQuery(BaseConfManager.GetConnectionStr(),CommandType.Text,sql);
if(row.Equals(1))
{
this.txSid.Text=this.txName.Text=this.txEdit.Text="";
Response.Write("<script>alert('保存成功!');window.location='TypeList.aspx';</script>");
}
}
}
else
{
CommonDialog.Show("名称不能为空!");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -