📄 viewstoreinout.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 System.Data.SqlClient;
using MisStock.Components;
namespace MisStock.DesktopModules.StoreInOut
{
/// <summary>
/// ViewStoreInOut 的摘要说明。
/// </summary>
public class ViewStoreInOut : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label8;
protected System.Web.UI.WebControls.DropDownList FlagList;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox TotalSum;
protected System.Web.UI.WebControls.Label Label9;
protected System.Web.UI.WebControls.TextBox InOutNo;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.DropDownList StatusList;
protected System.Web.UI.WebControls.Label Label7;
protected System.Web.UI.WebControls.TextBox PubDate;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox PubName;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.TextBox Remark;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.DropDownList StoreList;
protected System.Web.UI.WebControls.Button ReturnBtn;
private int nStoreInOutID = -1;
private void Page_Load(object sender, System.EventArgs e)
{
///判断用户是否登陆
if(Session["UserID"] == null)
{
Response.Redirect("~/Default.aspx");
}
///判断用户是否是超级管理员
if(Components.User.IsAuthorityAdmin(Session["UserID"].ToString()) >= Components.User.USERTYPENORMAL)
{
Response.Write("<script>alert(\"你没有权限,请与管理员联系!\")</script>");
Response.Write("<script>history.back();</script>");
}
if(Request.Params["StoreInOutID"] != null)
{
nStoreInOutID = Int32.Parse(Request.Params["StoreInOutID"].ToString());
}
if(!Page.IsPostBack)
{
///绑定控件的数据
BindStoreData();
if(nStoreInOutID > -1)
{
BindStoreInOutData(nStoreInOutID);
}
}
}
private void BindStoreData()
{
///定义获取数据的类
MisStock.Components.Store store = new MisStock.Components.Store();
SqlDataReader recs = store.GetStores();
///设定控件的数据源
StoreList.DataSource = recs;
///设定控件的Text属性和Value属性
StoreList.DataTextField = "Name";
StoreList.DataValueField = "StoreID";
///绑定控件的数据
StoreList.DataBind();
///关闭数据读取器和数据库的连接
recs.Close();
}
private void BindStoreInOutData(int nStoreInOutID)
{
///定义获取数据的类
MisStock.Components.StoreInOut storeIO = new MisStock.Components.StoreInOut();
SqlDataReader recs = storeIO.GetSingleStoreInOut(nStoreInOutID);
///从获取的数据中读取数据
if(recs.Read())
{
TotalSum.Text = recs["TotalSum"].ToString();
InOutNo.Text = recs["InOutNo"].ToString();
PubDate.Text = recs["PubDate"].ToString();
PubName.Text = recs["PubName"].ToString();
Remark.Text = recs["Remark"].ToString();
///设置列表控件的数据
MisSystem.SetListBoxItem(FlagList,recs["Flag"].ToString());
MisSystem.SetListBoxItem(StoreList,recs["StoreID"].ToString());
MisSystem.SetListBoxItem(StatusList,recs["Status"].ToString());
}
///关闭数据读取器和数据库的连接
recs.Close();
}
private void ReturnBtn_Click(object sender, System.EventArgs e)
{
///跳转到管理页面
Response.Redirect("~/DesktopModules/StoreInOut/StoreInOutManage.aspx");
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ReturnBtn.Click += new System.EventHandler(this.ReturnBtn_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -