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 Ajax ;
using System.Data ;
using System.Collections ;
using System.Text ;
using System.Data.OleDb ;
public partial class Materiel_list : System . Web . UI . Page
{
//创建一个共用的物料bll
Maticsoft . BLL . nr_z_wuliao wuliaobll = new Maticsoft . BLL . nr_z_wuliao ( ) ;
//创建一个物料模板
Maticsoft . Model . nr_z_wuliao wuliaomd = new Maticsoft . Model . nr_z_wuliao ( ) ;
//创建一个操作记录模板
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 ( ) ;
int jsid = 0 ;
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
if ( Session [ "user" ] = = null )
{
Response . Redirect ( "../index.aspx" ) ;
}
}
Utility . RegisterTypeForAjax ( typeof ( Materiel_list ) ) ;
Maticsoft . Model . nr_z_yhzh user = ( Maticsoft . Model . nr_z_yhzh ) ( Session [ "user" ] ) ;
hiddenid . Value = user . juese . ToString ( ) ;
Hiddenname . Value = user . zhanghao ;
jsid = user . juese ;
pdquanxian ( jsid ) ;
}
#region 数 据 加 载 输 出
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
public string page_change ( int pg , int pageitem , string paixu , string tiaojian )
{
bool isyincang = tiaojian . Contains ( "客户纸库" ) ;
if ( tiaojian . Contains ( "kufang<>'客户纸库'" ) )
{
isyincang = false ;
}
Maticsoft . Model . nr_z_yhzh zhanghao = ( Maticsoft . Model . nr_z_yhzh ) Session [ "user" ] ;
string htmlcode = "" ;
string paixuselct = "" ;
if ( isyincang )
{
paixuselct = string . Format ( "select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and isxianshi={2} order by shuixu " , zhanghao . id , "view_nr_z_wuliao" , 1 ) ;
}
else
{
paixuselct = string . Format ( "select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and lieming!='kh_bh' and isxianshi={2} order by shuixu " , zhanghao . id , "view_nr_z_wuliao" , 1 ) ;
}
DataTable dtselect = DBHlper . Execute ( paixuselct ) . Tables [ 0 ] ;
if ( dtselect . Rows . Count > 0 )
{
string wherecode = string . Format ( "select top {0} " , pageitem ) ;
foreach ( DataRow dtr in dtselect . Rows )
{
wherecode + = dtr [ "lieming" ] + "," ;
}
wherecode + = "id" ;
wherecode + = string . Format ( " from view_nr_z_wuliao where " + tiaojian + " id not in(select top ({0}*{1}) id from view_nr_z_wuliao)" + paixu , pg , pageitem ) ;
DataTable dt_paixu = DBHlper . Execute ( wherecode ) . Tables [ 0 ] ;
if ( dt_paixu . Rows . Count = = 0 )
{
return "<tr><td>   没有数据</td></tr>" ;
}
for ( int i = 0 ; i < dt_paixu . Rows . Count ; i + + )
{
htmlcode + = "<tr ondblclick='check(" + dt_paixu . Rows [ i ] [ "id" ] + ")' onclick='select(this)' tag='" + dt_paixu . Rows [ i ] [ "id" ] + "' >" ;
htmlcode + = " <td style='width:20px'><img class='wlxz' src='../Images_Folder/checkOff1.png' onclick='check(" + dt_paixu . Rows [ i ] [ "id" ] + ")'></td>" ;
for ( int j = 0 ; j < dt_paixu . Columns . Count - 1 ; j + + )
{
htmlcode + = "<td>" + dt_paixu . Rows [ i ] [ j ] + "</td>" ;
}
htmlcode + = "</tr>" ;
}
return htmlcode ;
}
else
{
string lieselect = string . Format ( "select * from nr_sys_lieming where tblname='{0}' ORDER BY xh" , "view_nr_z_wuliao" ) ;
DataTable liedt = DBHlper . Execute ( lieselect ) . Tables [ 0 ] ;
int lieshuixu = 0 ;
foreach ( DataRow liedr in liedt . Rows )
{
lieshuixu + + ;
string cmdinsert = string . Format ( "insert into nr_lt_paixu values('{0}','{1}','{2}','{3}',{4},{5})" , zhanghao . id , "view_nr_z_wuliao" , liedr [ "ywlieming" ] , liedr [ "zwlieming" ] , lieshuixu , 1 ) ;
DBHlper . excutecmd ( cmdinsert ) ;
}
return "" ;
}
}
#endregion
#region 传 入 条 数 返 回 页 数 以 便 前 台 调 用
[Ajax.AjaxMethod]
public int maxpage ( int count , string tj )
{
int fanhuizhi = 0 ;
string cmd = string . Format ( "select count(*) from nr_z_wuliao " + tj ) ;
int sumcount = DBHlper . getcount ( cmd ) ;
if ( sumcount > count )
{
fanhuizhi = sumcount / count ;
}
return fanhuizhi ;
}
#endregion
#region 数 据 排 序
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
public void itempaixu ( string code )
{
Maticsoft . Model . nr_z_yhzh zhanghao = ( Maticsoft . Model . nr_z_yhzh ) Session [ "user" ] ;
string [ ] codezu = code . Split ( ',' ) ;
string cmdexits = string . Format ( "select id from nr_lt_paixu where userid='{0}' and tblname='{1}' and lieming='{2}'" , zhanghao . id , "view_nr_z_wuliao" , codezu [ 2 ] ) ;
DataTable paixutable = DBHlper . Execute ( cmdexits ) . Tables [ 0 ] ;
if ( paixutable . Rows . Count > 0 )
{
int idfanhui = Convert . ToInt32 ( paixutable . Rows [ 0 ] [ 0 ] ) ;
string updatepaixu = string . Format ( "update nr_lt_paixu set shuixu={0},isxianshi={1} where id={2}" , codezu [ 0 ] , codezu [ 3 ] , idfanhui ) ;
DBHlper . excutecmd ( updatepaixu ) ;
}
else
{
string paixuinsert = string . Format ( "insert into nr_paixu values('{0}','{1}','{2}','{3}',{4},{5})" , zhanghao . id , "nr_z_wuliao" , codezu [ 2 ] , codezu [ 1 ] , codezu [ 0 ] , codezu [ 3 ] ) ;
DBHlper . excutecmd ( paixuinsert ) ;
}
}
#endregion
#region 列 头 排 序
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
public string paixu ( )
{
Maticsoft . Model . nr_z_yhzh zhanghao = ( Maticsoft . Model . nr_z_yhzh ) Session [ "user" ] ;
string paixuselct = string . Format ( "select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and isxianshi={2} order by shuixu " , zhanghao . id , "view_nr_z_wuliao" , 1 ) ;
DataTable dtselect = DBHlper . Execute ( paixuselct ) . Tables [ 0 ] ;
string htmlcode = "<td style='width:20px'></td>" ;
foreach ( DataRow dr in dtselect . Rows )
{
if ( ( dr [ "lieming" ] ) . ToString ( ) = = "kh_bh" )
{
htmlcode + = string . Format ( "<td class='kh' style='display:none' tag='{0}'>{1}</td>" , dr [ "lieming" ] , dr [ "zhongwen" ] ) ;
}
else
{
htmlcode + = string . Format ( "<td tag='{0}'>{1}</td>" , dr [ "lieming" ] , dr [ "zhongwen" ] ) ;
}
}
return htmlcode ;
}
#endregion
#region 查 询 数 据 总 数
[Ajax.AjaxMethod]
public int sumitem ( string wheretj )
{
string cmd = string . Format ( "select count(*) from view_nr_z_wuliao " + wheretj ) ;
int sumcount = DBHlper . getcount ( cmd ) ;
return sumcount ;
}
#endregion
#region 敏 感 权 限 查 看
void pdquanxian ( int juese )
{
Maticsoft . Model . nr_z_yhzh user = ( Maticsoft . Model . nr_z_yhzh ) ( Session [ "user" ] ) ;
if ( DBHlper . getzt ( user . id ) = = 0 )
{
Response . Redirect ( "../index.aspx" ) ;
}
2024-05-21 15:05:24 +08:00
if ( DBHlper . GetPermission ( juese , "物料档案" , "nr_z_wuliao" , "添加" ) )
2024-05-18 15:28:29 +08:00
{
li_add . Visible = true ;
}
}
#endregion
#region 判 断 查 看 权 限
[Ajax.AjaxMethod]
public string isquanxian ( int uid )
{
2024-05-21 15:05:24 +08:00
if ( DBHlper . GetPermission ( uid , "物料档案" , "nr_z_wuliao" , "查看全部" ) )
2024-05-18 15:28:29 +08:00
{
return "1" ;
}
else
{
return "" ;
}
}
#endregion
string zhonglei = "" ;
void gongjuzhankai ( string tishi )
{
lbl_zerror . Text = tishi ;
Gjx . Style . Add ( "display" , "block" ) ;
div_daoru . Style . Add ( "display" , "block" ) ;
return ;
}
void testexits ( string code )
{
zhonglei = DBHlper . getfirstcolmn ( "select id from nr_sys_bianma where mingcheng='" + code . Trim ( ) + "'" ) ;
}
[Ajax.AjaxMethod]
public string wuliaoxinxi ( int id )
{
DataTable dtwuliao = DBHlper . Execute ( "select wlbh,mingcheng,changdu,kuandu,pinpai,danwei,kucun,zhonglei,kufang,dj,guige from view_nr_z_wuliao where id=" + id ) . Tables [ 0 ] ;
return dtwuliao . Rows [ 0 ] [ "wlbh" ] . ToString ( ) + ',' + dtwuliao . Rows [ 0 ] [ "mingcheng" ] . ToString ( ) + ',' + dtwuliao . Rows [ 0 ] [ "changdu" ] . ToString ( ) + ',' + dtwuliao . Rows [ 0 ] [ "kuandu" ] . ToString ( ) + ',' + dtwuliao . Rows [ 0 ] [ "pinpai" ] . ToString ( ) + ',' + dtwuliao . Rows [ 0 ] [ "danwei" ] . ToString ( ) + ',' + dtwuliao . Rows [ 0 ] [ "kucun" ] . ToString ( ) + ',' + dtwuliao . Rows [ 0 ] [ "zhonglei" ] . ToString ( ) + ',' + dtwuliao . Rows [ 0 ] [ "kufang" ] . ToString ( ) + ',' + dtwuliao . Rows [ 0 ] [ "dj" ] . ToString ( ) + ',' + dtwuliao . Rows [ 0 ] [ "guige" ] . ToString ( ) ;
}
//获取申购单大张数
[Ajax.AjaxMethod]
public string getscdmxdzs ( int id , string djbh )
{
string xqsl = DBHlper . getfirstcolmn ( "select sum(dzs) from view_nr_z_scd_mx where wlbh=(select wlbh from nr_z_wuliao where id=" + id + ") and bh='" + djbh + "'" ) ;
return xqsl . Replace ( ".0000" , "" ) ;
}
}