using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Chukutext : System.Web.UI.UserControl
{
static string A = "GetRecordFromPage";
static string RetColumns = "*";
static string Orderfld = "Goods_data";
static string PageSize = "5";
static string IsCount = "0";
static string OrderType = "1";
static string PageIndex = "1";
static string tbName = "Goods";
static string strWhere = "Goods_Danweibh=1";
static int int_Count = 0;
// static string Name = "";
//static string L="";
//申明变量
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["Name"] = "xujing";
SqlData da = new SqlData();
SqlDataReader read = da.ExceRead("select * from UserName where User_USER='" + Session["Name"].ToString() + "'");
read.Read();
if (read.HasRows)
{
Session["User_AUTHORITY"] = read["User_AUTHORITY"].ToString();
Session["User_UNIT"] = read["User_UNIT"].ToString();
Session["User_NAME"] = read["User_NAME"].ToString();
//保存用户权限;确定用户登录状态
}
read.Close();
this.Text_data.Text = DateTime.Now.ToString();
this.Text_Chukuren.Text = Session["User_NAME"].ToString();
this.Text_Danwei.SelectedValue = Session["User_UNIT"].ToString();
}
this.LinkButton2_Click(sender, e);
}
protected void Chuku_Click(object sender, EventArgs e)
{
if (this.Text_Names.ToString() != null)
{
if (Convert.ToInt32(Session["User_AUTHORITY"]) < 3)
{
Response.Write("<script language=javascript>alert('您的权限不够,不能出库');location='Chuku.aspx'</script>");
}
else
{
if (this.Text_Danwei.SelectedValue != Session["User_UNIT"].ToString())
{ Response.Write("<script language=javascript>alert('单位选择不符,不能出库');location='Chuku.aspx'</script>");
}
else
{
int I = 0;
I = int_Count - Convert.ToInt16(this.Text_Count.Text);
if (I < 0)
{
Response.Write("<script language=javascript>alert('库存数量不足!');location='Chuku.aspx'</script>");
}
else
{
string sqlstr = "insert into Chuku "
+ "(Chuku_Danwei,Chuku_Name,Chuku_Xinghao,Chuku_Count,Chuku_Shebeidanwei,Chuku_Jiage,Chuku_Changjia,Chuku_Bumeng,Chuku_Lingyongren,Chuku_Data,Chuku_Chukuren)"
+ "values('"
+ this.Text_Danwei.SelectedValue + "','"
+ this.Text_Names.Text.ToString() + "','"
+ this.Text_Xinghao.Text.ToString() + "','"
+ this.Text_Count.Text.ToString() + "','"
+ this.Text_SDanwei.Text.ToString() + "','"
+ this.Text_Jiage.Text.ToString() + "','"
+ this.Text_Changjia.ToString() + "','"
+ this.Text_Bumeng.ToString() + "','"
+ this.Text_Linyongren.ToString() + "','"
+ DateTime.Now.ToString() + "','"
+ this.Text_Chukuren.Text.ToString() + "')";
Insert.dataBind(dl, sqlstr);
//增加出库数据表中记录
//库存数量-出库数量,修改库存数据时使用
SqlData da = new SqlData();
string P_str_Com = "update Goods set Goods_Shuliang='" + I + "' where Goods_id='" + this.Label1.Text.ToString() + "'";
bool add = da.ExceSQL(P_str_Com);
//修改库存数据表 Response.Write("<script language=javascript>alert('出库成功!');location='Chuku.aspx'</script>");
}
}
}
}
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
if (this.Text_Names.Text.Trim().ToString() != "")
{
strWhere = "Goods_danwei='" + Session["User_UNIT"].ToString() + "' and Goods_hpmingc like '%" + this.Text_Names.Text.ToString() + "%'";
string[] Str1 = new string[] { tbName, strWhere };
int Count = GetRecordCount.Int_Count(Str1);
this.Label_Count.Text = Count.ToString();
//查询记录总数
if (Count != 0)
{
this.Chuku.Visible = true;
if (Request.QueryString["ID"] != null)
{
PageIndex = Request.QueryString["ID"];
}
string[] Str = new string[] { A, tbName, RetColumns, Orderfld, PageSize, PageIndex, IsCount, OrderType, strWhere };
GetRecordFromPage.Page(DataList1, Str);
//分页显示
if (Count > Convert.ToInt32(PageSize))
{
int Page_Count = Count / Convert.ToInt32(PageSize) + 1;
if (PageIndex == null || PageIndex == "1")
{
this.Page_Index.Enabled = false;
this.Paga_S.Enabled = false;
}
if (Convert.ToInt32(Request.QueryString["ID"]) == Page_Count)
{
this.Paga_X.Enabled = false;
this.Paga_H.Enabled = false;
}
}
else
{
this.Page_Index.Enabled = false;
this.Paga_S.Enabled = false;
this.Paga_X.Enabled = false;
this.Paga_H.Enabled = false;
}
}
else
{
this.Page_Index.Enabled = false;
this.Paga_S.Enabled = false;
this.Paga_X.Enabled = false;
this.Paga_H.Enabled = false;
} }
else
{
Response.Write("<script language=javascript>alert('设备名称为空!');location='javascript:history.go(-1)'</script>");
}
} protected void Page_Index_Click(object sender, EventArgs e)
{
Page.Response.Redirect("Chuku.aspx?ID=1");
}
protected void Paga_S_Click(object sender, EventArgs e)
{
int ID = Convert.ToInt32(Request.QueryString["ID"]);
ID = ID - 1;
Page.Response.Redirect("Chuku.aspx?ID=" + ID);
//上一页
}
protected void Paga_X_Click(object sender, EventArgs e)
{
Session["tbName"] = this.Text_Names.Text;
if (Request.QueryString["ID"] == null)
{
Page.Response.Redirect("Chuku.aspx?ID=2");
}
else
{
int ID = Convert.ToInt32(Request.QueryString["ID"]);
ID = ID + 1;
Page.Response.Redirect("Chuku.aspx?ID=" + ID );
//Response.Redirect("Chuku.aspx?ID=" + ID + " && Name=" + this.Text_Names.Text); }
//下一页
}
protected void Paga_H_Click(object sender, EventArgs e)
{
// strWhere = "Goods_hpmingc like '%" + this.Text_Name.ToString() + "%'";
strWhere = "Goods_danwei='" + Session["User_UNIT"].ToString() + "' and Goods_hpmingc like '%" + this.Text_Names.Text.ToString() + "%'";
string[] Str1 = new string[] { tbName, strWhere };
int Count = GetRecordCount.Int_Count(Str1);
Page.Response.Redirect("Chuku.aspx?ID=" + (Count / Convert.ToInt32(PageSize) + 1));
//最后一页
}
protected void LinkButton_xuanze_Click(object sender, EventArgs e)
{
int index = ((DataListItem)((LinkButton)sender).NamingContainer).ItemIndex;
Label Label_bianhao = DataList1.Items[index].FindControl("Label_bianhao") as Label;
Label Label_shebeimingc = DataList1.Items[index].FindControl("Label_shebeimingc") as Label;
Label Label_shebeixinghao = DataList1.Items[index].FindControl("Label_shebeixinghao") as Label;
Label Label_shuliang = DataList1.Items[index].FindControl("Label_shuliang") as Label;
//获取用户选择的参数
Label Label_jiage = DataList1.Items[index].FindControl("Label_jiage") as Label;
Label Label_danwei = DataList1.Items[index].FindControl("Label_danwei") as Label;
Label Label_changjia = DataList1.Items[index].FindControl("Label_changjia") as Label;
this.Label1.Text = Label_bianhao.Text;
this.Text_Names.Text = Label_shebeimingc.Text;
this.Text_Xinghao.Text = Label_shebeixinghao.Text;
//this.Text_Count.Text = Label_shuliang.Text;
int_Count =Convert.ToInt16(Label_shuliang.Text);
//传递到用户文本框内。减少输入内容
this.Text_SDanwei.Text = Label_danwei.Text;
this.Text_Jiage.Text = Label_jiage.Text;
this.Text_Changjia.Text = Label_changjia.Text;
if (Label_bianhao.Text != null)
{
this.Chuku.Visible = true;
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Chukutext : System.Web.UI.UserControl
{
static string A = "GetRecordFromPage";
static string RetColumns = "*";
static string Orderfld = "Goods_data";
static string PageSize = "5";
static string IsCount = "0";
static string OrderType = "1";
static string PageIndex = "1";
static string tbName = "Goods";
static string strWhere = "Goods_Danweibh=1";
static int int_Count = 0;
// static string Name = "";
//static string L="";
//申明变量
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["Name"] = "xujing";
SqlData da = new SqlData();
SqlDataReader read = da.ExceRead("select * from UserName where User_USER='" + Session["Name"].ToString() + "'");
read.Read();
if (read.HasRows)
{
Session["User_AUTHORITY"] = read["User_AUTHORITY"].ToString();
Session["User_UNIT"] = read["User_UNIT"].ToString();
Session["User_NAME"] = read["User_NAME"].ToString();
//保存用户权限;确定用户登录状态
}
read.Close();
this.Text_data.Text = DateTime.Now.ToString();
this.Text_Chukuren.Text = Session["User_NAME"].ToString();
this.Text_Danwei.SelectedValue = Session["User_UNIT"].ToString();
}
this.LinkButton2_Click(sender, e);
}
protected void Chuku_Click(object sender, EventArgs e)
{
if (this.Text_Names.ToString() != null)
{
if (Convert.ToInt32(Session["User_AUTHORITY"]) < 3)
{
Response.Write("<script language=javascript>alert('您的权限不够,不能出库');location='Chuku.aspx'</script>");
}
else
{
if (this.Text_Danwei.SelectedValue != Session["User_UNIT"].ToString())
{ Response.Write("<script language=javascript>alert('单位选择不符,不能出库');location='Chuku.aspx'</script>");
}
else
{
int I = 0;
I = int_Count - Convert.ToInt16(this.Text_Count.Text);
if (I < 0)
{
Response.Write("<script language=javascript>alert('库存数量不足!');location='Chuku.aspx'</script>");
}
else
{
string sqlstr = "insert into Chuku "
+ "(Chuku_Danwei,Chuku_Name,Chuku_Xinghao,Chuku_Count,Chuku_Shebeidanwei,Chuku_Jiage,Chuku_Changjia,Chuku_Bumeng,Chuku_Lingyongren,Chuku_Data,Chuku_Chukuren)"
+ "values('"
+ this.Text_Danwei.SelectedValue + "','"
+ this.Text_Names.Text.ToString() + "','"
+ this.Text_Xinghao.Text.ToString() + "','"
+ this.Text_Count.Text.ToString() + "','"
+ this.Text_SDanwei.Text.ToString() + "','"
+ this.Text_Jiage.Text.ToString() + "','"
+ this.Text_Changjia.ToString() + "','"
+ this.Text_Bumeng.ToString() + "','"
+ this.Text_Linyongren.ToString() + "','"
+ DateTime.Now.ToString() + "','"
+ this.Text_Chukuren.Text.ToString() + "')";
Insert.dataBind(dl, sqlstr);
//增加出库数据表中记录
//库存数量-出库数量,修改库存数据时使用
SqlData da = new SqlData();
string P_str_Com = "update Goods set Goods_Shuliang='" + I + "' where Goods_id='" + this.Label1.Text.ToString() + "'";
bool add = da.ExceSQL(P_str_Com);
//修改库存数据表 Response.Write("<script language=javascript>alert('出库成功!');location='Chuku.aspx'</script>");
}
}
}
}
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
if (this.Text_Names.Text.Trim().ToString() != "")
{
strWhere = "Goods_danwei='" + Session["User_UNIT"].ToString() + "' and Goods_hpmingc like '%" + this.Text_Names.Text.ToString() + "%'";
string[] Str1 = new string[] { tbName, strWhere };
int Count = GetRecordCount.Int_Count(Str1);
this.Label_Count.Text = Count.ToString();
//查询记录总数
if (Count != 0)
{
this.Chuku.Visible = true;
if (Request.QueryString["ID"] != null)
{
PageIndex = Request.QueryString["ID"];
}
string[] Str = new string[] { A, tbName, RetColumns, Orderfld, PageSize, PageIndex, IsCount, OrderType, strWhere };
GetRecordFromPage.Page(DataList1, Str);
//分页显示
if (Count > Convert.ToInt32(PageSize))
{
int Page_Count = Count / Convert.ToInt32(PageSize) + 1;
if (PageIndex == null || PageIndex == "1")
{
this.Page_Index.Enabled = false;
this.Paga_S.Enabled = false;
}
if (Convert.ToInt32(Request.QueryString["ID"]) == Page_Count)
{
this.Paga_X.Enabled = false;
this.Paga_H.Enabled = false;
}
}
else
{
this.Page_Index.Enabled = false;
this.Paga_S.Enabled = false;
this.Paga_X.Enabled = false;
this.Paga_H.Enabled = false;
}
}
else
{
this.Page_Index.Enabled = false;
this.Paga_S.Enabled = false;
this.Paga_X.Enabled = false;
this.Paga_H.Enabled = false;
} }
else
{
Response.Write("<script language=javascript>alert('设备名称为空!');location='javascript:history.go(-1)'</script>");
}
} protected void Page_Index_Click(object sender, EventArgs e)
{
Page.Response.Redirect("Chuku.aspx?ID=1");
}
protected void Paga_S_Click(object sender, EventArgs e)
{
int ID = Convert.ToInt32(Request.QueryString["ID"]);
ID = ID - 1;
Page.Response.Redirect("Chuku.aspx?ID=" + ID);
//上一页
}
protected void Paga_X_Click(object sender, EventArgs e)
{
Session["tbName"] = this.Text_Names.Text;
if (Request.QueryString["ID"] == null)
{
Page.Response.Redirect("Chuku.aspx?ID=2");
}
else
{
int ID = Convert.ToInt32(Request.QueryString["ID"]);
ID = ID + 1;
Page.Response.Redirect("Chuku.aspx?ID=" + ID );
//Response.Redirect("Chuku.aspx?ID=" + ID + " && Name=" + this.Text_Names.Text); }
//下一页
}
protected void Paga_H_Click(object sender, EventArgs e)
{
// strWhere = "Goods_hpmingc like '%" + this.Text_Name.ToString() + "%'";
strWhere = "Goods_danwei='" + Session["User_UNIT"].ToString() + "' and Goods_hpmingc like '%" + this.Text_Names.Text.ToString() + "%'";
string[] Str1 = new string[] { tbName, strWhere };
int Count = GetRecordCount.Int_Count(Str1);
Page.Response.Redirect("Chuku.aspx?ID=" + (Count / Convert.ToInt32(PageSize) + 1));
//最后一页
}
protected void LinkButton_xuanze_Click(object sender, EventArgs e)
{
int index = ((DataListItem)((LinkButton)sender).NamingContainer).ItemIndex;
Label Label_bianhao = DataList1.Items[index].FindControl("Label_bianhao") as Label;
Label Label_shebeimingc = DataList1.Items[index].FindControl("Label_shebeimingc") as Label;
Label Label_shebeixinghao = DataList1.Items[index].FindControl("Label_shebeixinghao") as Label;
Label Label_shuliang = DataList1.Items[index].FindControl("Label_shuliang") as Label;
//获取用户选择的参数
Label Label_jiage = DataList1.Items[index].FindControl("Label_jiage") as Label;
Label Label_danwei = DataList1.Items[index].FindControl("Label_danwei") as Label;
Label Label_changjia = DataList1.Items[index].FindControl("Label_changjia") as Label;
this.Label1.Text = Label_bianhao.Text;
this.Text_Names.Text = Label_shebeimingc.Text;
this.Text_Xinghao.Text = Label_shebeixinghao.Text;
//this.Text_Count.Text = Label_shuliang.Text;
int_Count =Convert.ToInt16(Label_shuliang.Text);
//传递到用户文本框内。减少输入内容
this.Text_SDanwei.Text = Label_danwei.Text;
this.Text_Jiage.Text = Label_jiage.Text;
this.Text_Changjia.Text = Label_changjia.Text;
if (Label_bianhao.Text != null)
{
this.Chuku.Visible = true;
}
}
}
aspnetgpage