2024-05-18 15:28:29 +08:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Web ;
using System.Web.UI ;
using System.Web.UI.WebControls ;
using System.Data ;
public partial class Productout_browse : System . Web . UI . Page
{
Maticsoft . Model . nr_z_cpck cpckmodel = new Maticsoft . Model . nr_z_cpck ( ) ;
Maticsoft . BLL . nr_z_cpck cpckbll = new Maticsoft . BLL . nr_z_cpck ( ) ;
//创建一个操作记录模板
Maticsoft . Model . nr_sys_rizhi rizhi = new Maticsoft . Model . nr_sys_rizhi ( ) ;
//创建一个操作记录bll
Maticsoft . BLL . nr_sys_rizhi rizhibll = new Maticsoft . BLL . nr_sys_rizhi ( ) ;
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
if ( Session [ "user" ] = = null )
{
Response . Redirect ( "../index.aspx" ) ;
}
Maticsoft . Model . nr_z_yhzh user = ( Maticsoft . Model . nr_z_yhzh ) ( Session [ "user" ] ) ;
if ( Request . QueryString [ "uid" ] ! = null & & Request . QueryString [ "uid" ] ! = "" )
{
id . Value = Request . QueryString [ "uid" ] . ToString ( ) ;
}
initdata ( Convert . ToInt32 ( id . Value ) ) ;
2024-05-22 17:15:17 +08:00
pdquanxian ( user . juese ) ;
2024-05-18 15:28:29 +08:00
}
}
#region 获 取 真 正 数 据 值
private void initdata ( int did )
{
cpckmodel = cpckbll . GetModel ( did ) ;
ckdh . Text = cpckmodel . ckbh ;
riqi . Text = cpckmodel . riqi . ToString ( "yyyy-MM-dd" ) ;
scdh . Text = cpckmodel . scdh ;
khming . Text = cpckmodel . khmc ;
cpbh . Text = cpckmodel . cpbh ;
cpmc . Text = cpckmodel . cpmc ;
danjia . Text = cpckmodel . cpdj . ToString ( ) ;
guige . Text = cpckmodel . guige . ToString ( ) ;
zzshuliang . Text = cpckmodel . zzsl . ToString ( ) ;
lingtou . Text = cpckmodel . lt . ToString ( ) ;
shuliang . Text = cpckmodel . sl . ToString ( ) ;
danwei . Text = cpckmodel . danwei ;
lxr . Text = cpckmodel . lxr ;
zongjine . Text = cpckmodel . zje . ToString ( ) ;
lxdh . Text = cpckmodel . lxdh ;
jingshouren . Text = cpckmodel . jsr ;
shr . Text = cpckmodel . shr ;
dizhi . Text = cpckmodel . shdizhi ;
txt_beizhu . Text = cpckmodel . beizhu ;
zhuangtai . Text = cpckmodel . zt ;
}
#endregion
#region 敏 感 权 限 查 看
void pdquanxian ( int juese )
{
Maticsoft . Model . nr_z_yhzh user = ( Maticsoft . Model . nr_z_yhzh ) ( Session [ "user" ] ) ;
if ( DBHlper . getzt ( user . id ) ! = 1 )
{
Response . Redirect ( "../index.aspx" ) ;
}
2024-05-21 15:05:24 +08:00
if ( DBHlper . GetPermission ( juese , "成品出库" , "nr_z_cpck" , "查看全部" ) = = false & & DBHlper . GetPermission ( juese , "成品出库" , "nr_z_cpck" , "查看个人" ) = = false )
2024-05-18 15:28:29 +08:00
{
Response . Redirect ( "../Common/nopower.htm" ) ;
}
2024-05-21 15:05:24 +08:00
if ( DBHlper . GetPermission ( juese , "成品出库" , "nr_z_cpck" , "编辑个人" ) & & jingshouren . Text = = user . zhanghao )
2024-05-18 15:28:29 +08:00
{
bt_tj . Visible = true ;
}
2024-05-21 15:05:24 +08:00
if ( DBHlper . GetPermission ( juese , "成品出库" , "nr_z_cpck" , "编辑全部" ) )
2024-05-18 15:28:29 +08:00
{
bt_tj . Visible = true ;
}
2024-05-21 15:05:24 +08:00
if ( DBHlper . GetPermission ( juese , "成品出库" , "nr_z_cpck" , "删除个人" ) & & jingshouren . Text = = user . zhanghao )
2024-05-18 15:28:29 +08:00
{
shanchu . Visible = true ;
}
2024-05-21 15:05:24 +08:00
if ( DBHlper . GetPermission ( juese , "成品出库" , "nr_z_cpck" , "删除全部" ) )
2024-05-18 15:28:29 +08:00
{
shanchu . Visible = true ;
}
2024-05-21 15:05:24 +08:00
if ( DBHlper . GetPermission ( juese , "成品出库" , "nr_z_cpck" , "出库确认" ) )
2024-05-18 15:28:29 +08:00
{
ckqr . Visible = true ;
}
2024-05-21 15:05:24 +08:00
if ( DBHlper . GetPermission ( juese , "成品出库" , "nr_z_cpck" , "出库冲红" ) )
2024-05-18 15:28:29 +08:00
{
ckch . Visible = true ;
}
2024-05-21 15:05:24 +08:00
if ( DBHlper . GetPermission ( juese , "成品出库" , "nr_z_cpck" , "添加" ) )
2024-05-18 15:28:29 +08:00
{
bt_add . Visible = true ;
}
if ( zhuangtai . Text = = "已出库" )
{
ckqr . Enabled = false ;
ckqr . BackColor = System . Drawing . Color . Gray ;
shanchu . Enabled = false ;
shanchu . BackColor = System . Drawing . Color . Gray ;
bt_tj . Enabled = false ;
bt_tj . BackColor = System . Drawing . Color . Gray ;
}
if ( zhuangtai . Text = = "待确认" )
{
ckch . Enabled = false ;
ckch . BackColor = System . Drawing . Color . Gray ;
}
2024-05-21 15:05:24 +08:00
if ( DBHlper . GetPermission ( juese , "成品出库" , "nr_z_cpck" , "打印" ) )
2024-05-18 15:28:29 +08:00
{
dayin . Visible = true ;
}
}
#endregion
protected void bt_tj_Click ( object sender , EventArgs e )
{
Response . Redirect ( "Productout_Form.aspx?uid=" + id . Value ) ;
}
protected void Button1_Click ( object sender , EventArgs e )
{
if ( cpckbll . Delete ( Convert . ToInt32 ( id . Value ) ) )
{
//给日志模板赋值
rizhi . riqi = DateTime . Now ;
rizhi . leixing = "成品出库" ;
//将session转换对象取值
Maticsoft . Model . nr_z_yhzh zh = ( Maticsoft . Model . nr_z_yhzh ) Session [ "user" ] ;
//拼接字符串插入日志
rizhi . jilu = zh . zhanghao + "删除了成品出库,出库单号为:" + cpbh . Text . Trim ( ) ;
rizhi . yonghuming = zh . zhanghao . ToString ( ) ;
rizhibll . Add ( rizhi ) ;
Response . Redirect ( "Productout_list.aspx" , false ) ;
}
else
{
Response . Write ( "<script>alert('删除失败')</script>" ) ;
}
}
protected void btnchonghong_Click ( object sender , EventArgs e )
{
DataTable dt = DBHlper . Execute ( string . Format ( "select * from nr_z_cpkc where scdh='{0}' and xmmc='{1}' and khmc='{2}'" , scdh . Text , cpbh . Text , khming . Text ) ) . Tables [ 0 ] ;
double sl = Convert . ToDouble ( dt . Rows [ 0 ] [ "sl" ] ) ;
double nowsl = Convert . ToDouble ( shuliang . Text ) ;
2024-05-22 17:15:17 +08:00
int gxcount = DBHlper . excutecmd ( "update nr_z_cpkc set sl=" + ( sl + nowsl ) + " where id=" + dt . Rows [ 0 ] [ "id" ] ) ;
2024-05-18 15:28:29 +08:00
if ( gxcount > 0 )
{
DBHlper . excutecmd ( "update nr_z_cpck set zt='待确认' where id=" + id . Value ) ;
}
2024-05-22 17:15:17 +08:00
else
{
2024-05-18 15:28:29 +08:00
Response . Write ( "<script>alert('出库冲红失败')</script>" ) ;
}
//给日志模板赋值
rizhi . riqi = DateTime . Now ;
rizhi . leixing = "成品出库" ;
//将session转换对象取值
Maticsoft . Model . nr_z_yhzh zh = ( Maticsoft . Model . nr_z_yhzh ) Session [ "user" ] ;
//拼接字符串插入日志
2024-05-22 17:15:17 +08:00
rizhi . jilu = zh . zhanghao + "执行了出库冲红,出库单号为:" + ckdh . Text . Trim ( ) ;
2024-05-18 15:28:29 +08:00
rizhi . yonghuming = zh . zhanghao . ToString ( ) ;
rizhibll . Add ( rizhi ) ;
Response . Redirect ( "Productout_browse.aspx?uid=" + id . Value ) ;
2024-05-22 17:15:17 +08:00
}
2024-05-18 15:28:29 +08:00
protected void btn_chuku_Click ( object sender , EventArgs e )
{
2024-05-22 17:15:17 +08:00
var result = DBHlper . Execute ( string . Format ( "select * from view_nr_z_cpkc where scdh='{0}' and xmmc='{1}' and khmc='{2}'" , scdh . Text , cpbh . Text , khming . Text ) ) ;
DataTable dt = result . Tables [ 0 ] ;
2024-05-18 15:28:29 +08:00
if ( dt . Rows . Count = = 0 )
{
Response . Write ( "<script>alert('库存不足')</script>" ) ;
return ;
}
else
{
double sl = Convert . ToDouble ( dt . Rows [ 0 ] [ "sl" ] ) ;
double nowsl = Convert . ToDouble ( shuliang . Text ) ;
if ( sl < nowsl )
{
Response . Write ( "<script>alert('库存不足')</script>" ) ;
return ;
}
else
{
DBHlper . excutecmd ( "update nr_z_cpkc set sl=" + ( sl - nowsl ) + " where id=" + dt . Rows [ 0 ] [ "id" ] ) ;
DBHlper . excutecmd ( "update nr_z_cpck set zt='已出库' where id=" + id . Value ) ;
rizhi . riqi = DateTime . Now ;
rizhi . leixing = "成品出库" ;
//将session转换对象取值
Maticsoft . Model . nr_z_yhzh zh = ( Maticsoft . Model . nr_z_yhzh ) Session [ "user" ] ;
//拼接字符串插入日志
rizhi . jilu = zh . zhanghao + "执行了成品出库,成品出库号为:" + ckdh . Text . Trim ( ) ;
rizhi . yonghuming = zh . zhanghao . ToString ( ) ;
rizhibll . Add ( rizhi ) ;
Response . Redirect ( "Productout_browse.aspx?uid=" + id . Value ) ;
}
}
}
2024-05-22 17:15:17 +08:00
2024-05-18 15:28:29 +08:00
}
2024-05-22 17:15:17 +08:00