⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commlistselect.aspx.cs

📁 通过配置表中的各列支持绝大部分的基础数据
💻 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 comm.include;
namespace comm
{
	/// <summary>
	/// commListselect 的摘要说明。
	/// </summary>
	public class commListselect : System.Web.UI.Page
	{
        protected System.Web.UI.WebControls.ImageButton imgbtn_go;
        protected System.Web.UI.WebControls.TextBox txt_page;
        protected System.Web.UI.WebControls.Label lbl_pagecnt;
        protected System.Web.UI.WebControls.Label lbl_currpage;
        protected System.Web.UI.WebControls.ImageButton imgbtn_end;
        protected System.Web.UI.WebControls.ImageButton imgbtn_next;
        protected System.Web.UI.WebControls.ImageButton imgbtn_pre;
        protected System.Web.UI.WebControls.ImageButton imgbtn_first;
        protected System.Web.UI.WebControls.Panel Panel_view;
        protected System.Web.UI.WebControls.Panel Panel_type;
        protected System.Web.UI.WebControls.ImageButton ibtn_search;
        protected System.Web.UI.WebControls.ImageButton ibtn_handin;
        protected System.Web.UI.WebControls.DataGrid dg;
        protected System.Web.UI.WebControls.DropDownList ddl_restype;
        protected System.Web.UI.WebControls.DropDownList ddl_iscomm;
        protected System.Web.UI.WebControls.Label lbl_sql;
        protected System.Web.UI.WebControls.DataGrid dg_apply;
        Db db=new Db();
		private void Page_Load(object sender, System.EventArgs e)
		{
            if(this.Session["system"]==null)
            {
                db.Msgbox("超时,请重新登陆!","",this.Page);
                return;
            }
            db.DataBase =this.Session["system"].ToString();
            db.IP =  this.Session["IP"].ToString();
            db.Usr=   this.Session["usr"].ToString();
            db.Pwd= this.Session["pwd"].ToString();
			// 在此处放置用户代码以初始化页面
            if(!this.IsPostBack)
            {
                this.Panel_view.Visible=false;
                this.Panel_type.Visible=true;
                db.LoadDdl(this.ddl_restype,"select bomtype_table_2,bomtype_table_1 from bomtype_table",false);
            }
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
            this.ibtn_search.Click += new System.Web.UI.ImageClickEventHandler(this.ibtn_search_Click);
            this.dg.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dg_ItemCommand);
            this.dg_apply.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.apply_dg_DeleteCommand);
            this.dg_apply.SelectedIndexChanged += new System.EventHandler(this.apply_dg_SelectedIndexChanged);
            this.ibtn_handin.Click += new System.Web.UI.ImageClickEventHandler(this.ibtn_handin_Click);
            this.Load += new System.EventHandler(this.Page_Load);

        }
		#endregion

        private void ibtn_search_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            string sql="";
            sql+="select b.material_table_1 as res_name,";
            sql+="b.material_table_2 as res_code, "; //np21编码
            sql+="b.material_table_4 as res_unit, "; //物料单位
            sql+="b.material_table_5 as price, "; //价格
            sql+="b.material_table_11 as res_size, "; //规格
            sql+="b.material_table_19 as descript, ";
            sql+="a.BOM_WORK_TABLE_2 ";
            sql+=" from BOM_WORK_TABLE a ";
            sql+=" inner join material_table b ";
            sql+=" on a.BOM_WORK_TABLE_1=material_table_2 ";// --工作表与物料主数据表物料编码相等的数据
            sql+=" left  join  ";
            sql+="(select * from recieve_apply  ";
            sql+="where 1=1 ";
            sql+="and recieve_apply_8=0 "; //未提交
            sql+="and recieve_apply_5='{0}'  ";//{0}当前用户编号
            sql+="and recieve_apply_20>={1} ";//{1}是否个人领用
            sql+=" and recieve_apply_3='{2}') d  ";//{2}物品类型
            sql+=" on a.BOM_WORK_TABLE_1=d.recieve_apply_1 ";
            sql+="where 1=1 ";
            sql+=" and d.recieve_apply_1 is null ";
            sql+=" and a.BOM_WORK_TABLE_2='{2}'";//{2}物品类型
            sql+=" and a.BOM_WORK_TABLE_5>={1}";//个人领用 1可个人 0只可集体
            sql+=" and a.BOM_WORK_TABLE_6=1";//可以公开
            sql+=" and a.BOM_WORK_TABLE_7=1";//集中管理物品
            sql=string.Format(sql,Session["username"].ToString().Trim(),
                            this.ddl_iscomm.SelectedValue.Trim(),
                            this.ddl_restype.SelectedValue.Trim());
            //db.Msgbox(sql,"",this.Page);
            DataSet ds=db.GetDataSet(sql);
            if(ds==null)
            {
                db.Msgbox("数据库连接错误!","",this.Page);
                return ;
            }
            this.dg.DataSource=ds;
            this.dg.DataBind();
            this.Panel_type.Visible =false;
            this.Panel_view.Visible=true;
//            this.lbl_sql.Text=sql;
            sql="select b.material_table_1 as res_name,";
            sql+=" a.recieve_apply_2 as res_cnt,"; //领用数量
            sql+=" a.recieve_apply_4 as res_sum,"; //总金额
            sql+=" material_table_11 as res_size,"; //规格
            sql+=" material_table_4 as res_unit ,"; //单位
            sql+=" a.recieve_apply_1 as res_code ";//np21物料编码
            sql+=" from recieve_apply  a ";
            sql+=" inner join material_table b on a.recieve_apply_1=b.material_table_2 ";
            sql+="where 1=1 ";
            sql+="and recieve_apply_8=0 "; //未提交
            sql+="and recieve_apply_5='{0}'  ";//{0}当前用户编号
            sql+="and recieve_apply_20>={1} ";//{1}是否个人领用
            sql+=" and recieve_apply_3='{2}' ";//{2}物品类型
            sql=string.Format(sql,Session["username"].ToString().Trim(),
                this.ddl_iscomm.SelectedValue.Trim(),
                this.ddl_restype.SelectedValue.Trim());
            ds=db.GetDataSet(sql);
            if(ds==null)
            {
                db.Msgbox("数据库连接错误!","",this.Page);
                return ;
            }
            this.dg_apply.DataSource=ds;
            this.dg_apply.DataBind();
//            this.lbl_sql.Text+="\r\n"+sql;
        }

        private void ibtn_handin_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
        
        }

        private void apply_dg_SelectedIndexChanged(object sender, System.EventArgs e)
        {
        
        }

        private void apply_dg_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
        
        }


        private void dg_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            if(((TextBox)e.Item.Cells[5].Controls[1]).Text.Trim()=="")
            {
                db.Msgbox("请填入数量","",this.Page);
                return;
            }
            string sql="";
            sql+="insert into recieve_apply(recieve_apply_1";//物料编码
            sql+=",recieve_apply_10 "; //已办理发放 0
            sql+=",recieve_apply_2 ";  //申领数量
            sql+=",recieve_apply_20 "; //是否个人领用
            sql+=",recieve_apply_3  "; //物料类型
            sql+=",recieve_apply_4 ";  //领用金额
            sql+=",recieve_apply_5 ";    //领用人  
            sql+=",recieve_apply_7 ";//是否经审批  
            sql+=",recieve_apply_8"; //已确认  
sql+=") values('";//
            sql+=e.Item.Cells[1].Text.Trim()+"'";//物料编码
            sql+=",0";//已办理发放
            sql+=","+((TextBox)e.Item.Cells[5].Controls[1]).Text.Trim();//申领数量
            sql+=","+this.ddl_iscomm.SelectedValue.Trim();//是否个人领用
            sql+=",'"+this.ddl_restype.SelectedValue.Trim()+"'";//物料类型
            sql+=","+float.Parse(((TextBox)e.Item.Cells[5].Controls[1]).Text.Trim())*float.Parse(e.Item.Cells[6].Text.Trim());//领用金额
            sql+=",'"+this.Session["username"].ToString().Trim()+"'";//领用人
            sql+=",0";//是否经审批
            sql+=",0)";//已确认
            this.lbl_sql.Text ="";
            this.lbl_sql.Text+="\r\n"+sql;
            try
            {
                db.ExecSQL(sql);
            }
            catch(Exception ce)
            {
                db.Msgbox(ce.Message.Trim(),"",this.Page);
                return;
            }
            this.ibtn_search_Click(null,null);
        }

        
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -