📄 ioproductmanage.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;
using SQLHelper;
namespace MisStock.DesktopModules.IOProduct
{
/// <summary>
/// IOProductManage 的摘要说明。
/// </summary>
public class IOProductManage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button SelectBtn;
protected System.Web.UI.WebControls.ListBox StoreInOutList;
protected System.Web.UI.WebControls.Label StoreInOutName;
protected System.Web.UI.WebControls.DataGrid IOProductList;
protected System.Web.UI.WebControls.Button AddBtn;
public int nStoreInOutID = -1;
private static string CurrentStoreInOutName = "";
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)
{
///绑定控件的数据
BindStoreInOutData();
///设置员工的选择项
MisSystem.SetListBoxItem(StoreInOutList,nStoreInOutID.ToString());
if(nStoreInOutID > -1)
{ ///显示操作前的信息
BindIOProductData(nStoreInOutID);
StoreInOutName.Text = CurrentStoreInOutName;
}
else
{ ///显示当前选择项的信息
if(StoreInOutList.SelectedIndex > -1)
{
BindIOProductData(Int32.Parse(StoreInOutList.SelectedValue));
StoreInOutName.Text = StoreInOutList.SelectedItem.Text;
}
else
{ ///显示第一项的信息
if(StoreInOutList.Items.Count > 0)
{
BindIOProductData(Int32.Parse(StoreInOutList.Items[0].Value));
StoreInOutName.Text = StoreInOutList.Items[0].Text;
StoreInOutList.SelectedIndex = 0;
}
}
}
}
///设置添加按钮的可用性
AddBtn.Enabled = (StoreInOutList.Items.Count <= 0) ? false : true;
}
private void BindStoreInOutData()
{
///定义获取数据的类
MisStock.Components.StoreInOut order = new MisStock.Components.StoreInOut();
SqlDataReader reco = order.GetStoreInOuts();
///设定控件的数据源
StoreInOutList.DataSource = reco;
///设定控件的Text属性和Value属性
StoreInOutList.DataTextField = "StoreInOutID";
StoreInOutList.DataValueField = "StoreInOutID";
///绑定控件的数据
StoreInOutList.DataBind();
///关闭数据读取器和数据库的连接
reco.Close();
}
private void BindIOProductData(int nStoreInOutID)
{
///定义获取数据的类
MisStock.Components.IOProduct product = new MisStock.Components.IOProduct();
SqlDataReader recp = product.GetProductByStoreInOut(nStoreInOutID);
///创建DataSet数据源
DataTable dataTable = SystemTools.ConvertDataReaderToDataTable(recp);
DataSet dataSet = new DataSet("IOProduct");
dataSet.Tables.Add(dataTable);
///设定控件的数据源
IOProductList.DataSource = dataSet;
///绑定控件的数据
IOProductList.DataBind();
}
public string FormatFlag(string flagString)
{
switch(flagString)
{
case "0":
return("采购入库");
case "1":
return("销售退货入库");
case "2":
return("销售出库");
case "3":
return("采购退货出库");
default:
return("类型错误");
}
}
public string FormatCheck(string checkString)
{
return(checkString == "0" ? "未审核" : "审核");
}
public string FormatString(string oldString)
{
return(oldString.Length > 50 ? oldString.Substring(0,50) + "..." : oldString);
}
private void SelectBtn_Click(object sender, System.EventArgs e)
{
///显示选择的信息
if(StoreInOutList.SelectedIndex > -1)
{
///显示信息,并显示名称
BindIOProductData(Int32.Parse(StoreInOutList.SelectedValue));
StoreInOutName.Text = StoreInOutList.SelectedItem.Text;
CurrentStoreInOutName = StoreInOutList.SelectedItem.Text;
}
else
{
///显示操作结果信息
Response.Write ("<script>window.alert('" + MisSystem.OPERATIONNOSELECTMESSAGE + "')</script>");
}
}
private void IOProductList_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
///显示选择员工的考评信息
if(StoreInOutList.SelectedIndex > -1)
{
///设置新的页码,并重新绑定数据
IOProductList.CurrentPageIndex = e.NewPageIndex;
///显示信息,并显示员工的名称
BindIOProductData(Int32.Parse(StoreInOutList.SelectedValue));
StoreInOutName.Text = StoreInOutList.SelectedItem.Text;
}
else
{
///显示操作结果信息
Response.Write ("<script>window.alert('" + MisSystem.OPERATIONNOSELECTMESSAGE + "')</script>");
}
}
private void AddBtn_Click(object sender, System.EventArgs e)
{
if(StoreInOutList.SelectedIndex > -1)
{
///跳转到添加页面
Response.Redirect("~/DesktopModules/IOProduct/AddIOProduct.aspx?StoreInOutID="
+ (StoreInOutList.SelectedIndex > -1 ? StoreInOutList.SelectedValue : "-1"));
}
else
{
///显示操作结果信息
Response.Write ("<script>window.alert('" + MisSystem.OPERATIONNOSELECTMESSAGE + "')</script>");
}
}
private void StoreInOutList_SelectedIndexChanged(object sender, System.EventArgs e)
{
SelectBtn_Click(sender,e);
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.StoreInOutList.SelectedIndexChanged += new System.EventHandler(this.StoreInOutList_SelectedIndexChanged);
this.SelectBtn.Click += new System.EventHandler(this.SelectBtn_Click);
this.AddBtn.Click += new System.EventHandler(this.AddBtn_Click);
this.IOProductList.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.IOProductList_PageIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -