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

📄 pz_view.aspx.cs

📁 ASP.NET的一些开发实例,有论坛管理系统等
💻 CS
📖 第 1 页 / 共 2 页
字号:
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 com.unicafe.ui;
using com.unicafe.common;
using com.unicafe.security;
using com.ascs.plp.common;
using com.ascs.plp.publics;

namespace PLP.CWZZ.PZGL
{
	/// <summary>
	/// PZ_VIEW 的摘要说明。
	/// </summary>
	public class PZ_VIEW :com.unicafe.ui.UnicafePage
	{
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
		protected System.Web.UI.WebControls.LinkButton LinkButton5;
		protected System.Web.UI.WebControls.DropDownList DDL_KJND;
		protected System.Web.UI.WebControls.DropDownList DDL_KJQJBH;
		protected System.Web.UI.WebControls.DropDownList DropDownList1;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.LinkButton Linkbutton3;
		protected System.Web.UI.WebControls.LinkButton LinkButton1;
		protected System.Web.UI.HtmlControls.HtmlForm Form1;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.LinkButton Linkbutton2;

		SqlConnection cn = new SqlConnection (com.unicafe.common.Configuration.GetDBConnectionString());
		Com.Ascs.Plp.CW.CW_PZ CW_PZ = new Com.Ascs.Plp.CW.CW_PZ();
		Com.Ascs.Plp.CW.CW_PZ CW_PZYS = new Com.Ascs.Plp.CW.CW_PZ();
		Com.Ascs.Plp.CW.CW_PZMgr CW_PZMgr = new Com.Ascs.Plp.CW.CW_PZMgr();
		Com.Ascs.Plp.CW.CW_PZ CW_PZCX = new Com.Ascs.Plp.CW.CW_PZ();
		Com.Ascs.Plp.CW.CW_PZMgr CW_PZMgrCX = new Com.Ascs.Plp.CW.CW_PZMgr();
		Com.Ascs.Plp.CW.CW_PZXM CW_PZXM=new Com.Ascs.Plp.CW.CW_PZXM();
		Com.Ascs.Plp.CW.CW_PZXMMgr CW_PZXMMgr=new Com.Ascs.Plp.CW.CW_PZXMMgr();
		Com.Ascs.Plp.CW.CW_KJQJMgr CW_KJQJMgr = new Com.Ascs.Plp.CW.CW_KJQJMgr();
		Com.Ascs.Plp.CW.CW_KJQJ CW_KJQJ = new Com.Ascs.Plp.CW.CW_KJQJ();
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			try
			{
				// 在此处放置用户代码以初始化页面
				this.VerifyPage();
				this.VerifyPage("zz_pzgl_mgr");//登录检查
				ViewState["ADD"]="0";
				ViewState["URL"]="0";
				if(!this.IsPostBack)  //判断第一次显示
				{
					string strURl=this.Request.Url.ToString();
					this.Label1.Text=this.CurrentEmployee.EmplName;
					if(Session["MainURL"]==null)
					{
						ViewState["JGDM"]=this.CurrentJGXX.JGDM.ToString();
						string[] DQKJ=this.CW_KJQJMgr.GetDQKJQJ(this.CurrentJGXX.JGDM.ToString());
						ViewState["KJND"]=DQKJ[1];
						ViewState["KJQJBH"]=DQKJ[0];
						ViewState["PZBH"]="0";

					}
					else
					{
						ViewState["JGDM"]=this.Request.QueryString["JGDM"];
						ViewState["KJND"]=this.Request.QueryString["KJND"];
						ViewState["KJQJBH"]=this.Request.QueryString["KJQJBH"];
						ViewState["PZBH"]="0";
						Session.Remove("MainURL");
						if(Session["PZH"]!=null)
						{
							ViewState["ADD"]="1";
							ViewState["PZH"]=Session["PZH"].ToString();
							Session.Remove("PZH");
						}
					}
					this.DDL_KJQJBHBind();
					this.GetJZBJ(ViewState["JGDM"].ToString(),ViewState["KJND"].ToString(),ViewState["KJQJBH"].ToString());

					ViewState["sql"]= string.Format("select * from CW_PZ where JGDM='{0}' and KJND ='{1}' and KJQJ='{2}' order by PZBH DESC",ViewState["JGDM"].ToString(),ViewState["KJND"].ToString(),ViewState["KJQJBH"].ToString()) ;

					string sql = ViewState["sql"].ToString();


					//处理DataGrid控件(绑定DataGrid控件 -> 检查是否需要定位 -> 给导航文本赋值)
					if(CommonService.HandleDataGrid(this, sql, DataGrid1, "Data", Label2, Label3, Label4) == false)
						this.Response.Redirect("../../publics/Error.aspx?errmsg=在处理数据时发生错误。"); 

				}
				else
				{
					//检查回发的请求操作是否是要进入上页或下页
					if(CommonService.PageNavigate(this, DataGrid1, "Data", Label2, Label3, Label4) == false)
						this.Response.Redirect("../../publics/Error.aspx?errmsg=在处理数据时发生错误。");
				}
			}
			catch(Exception e1)
			{
				LogService.Write ("凭证显示时产生异常。");
				LogService.Write (e1.Message);
				Prompt.PromptError(this,"凭证显示时产生异常。");
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.DDL_KJND.SelectedIndexChanged += new System.EventHandler(this.DDL_KJND_SelectedIndexChanged);
			this.DDL_KJQJBH.SelectedIndexChanged += new System.EventHandler(this.DDL_KJQJBH_SelectedIndexChanged);
			this.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.DropDownList1_SelectedIndexChanged);
			this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
			this.Linkbutton2.Click += new System.EventHandler(this.Linkbutton2_Click);
			this.Linkbutton3.Click += new System.EventHandler(this.Linkbutton3_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		

		private void LinkButton1_Click(object sender, System.EventArgs e)
		{
			try
			{
				string[] DataTypes = {"string","string","string","string"};
				string[] pk = {"Hidden1","Hidden2","Hidden3","Hidden4"};

				//调用删除方法对选中的数据进行删除
				CommonService.DelSelectRecord(this,DataGrid1,ViewState["sql"].ToString(),"Data","CheckBox1",DataTypes,pk,"Com.Ascs.Plp.CW.CW_PZMgr","DelCW_PZ","系统自动生成的凭证或者已审核记账的凭证不能删除!");

				//对页面导航文本进行重新赋值
				CommonService.PageNavigatorText(DataGrid1,Label2, Label3, Label4);
			}
			catch(Exception e1)
			{
				LogService.Write ("删除会计凭证时产生异常。");
				LogService.Write (e1.Message);
				Prompt.PromptError(this,"删除会计凭证时产生异常。");
			}
		}

		private void Linkbutton3_Click(object sender, System.EventArgs e)
		{
			try
			{
				string[] DataTypes = {"string","string","string","string"};
				string[] pk = {"Hidden1","Hidden2","Hidden3","Hidden4"};
				ArrayList al=this.GetPk("CheckBox1",DataTypes,pk,this.DataGrid1);
				if(al.Count>0)
				{
					for(int i=0;i<al.Count;i++)
					{
						try
						{
							object[] obj=(object[])al[i];
							this.CW_PZ = this.CW_PZMgr.GetCW_PZ(obj[0].ToString(),obj[1].ToString(),obj[2].ToString(),obj[3].ToString());
							this.CW_PZ.BZ="3";
							this.cn.Open();//启动连接
							SqlCommand mySqlCommand = new SqlCommand();
							mySqlCommand.Connection=cn;
							SqlTransaction myTrans = this.cn.BeginTransaction();//建立事务
							mySqlCommand.Transaction = myTrans;//绑定事务
							bool flag=this.CW_PZMgr.UpdateCW_PZ(mySqlCommand,this.CW_PZ);
							if(flag)
							{
								myTrans.Commit();
							}
							else
							{
								myTrans.Rollback();
							}
							cn.Close();
						}
						catch(Exception e1)
						{
							LogService.Write(e1.Message);
							this.Response.Redirect("../../Publics/Error.aspx?errmsg=未能未能提交审核凭证。");  
							return;
						}
					}
				}
			
				//处理DataGrid控件(绑定DataGrid控件 -> 检查是否需要定位 -> 给导航文本赋值)
				if(CommonService.BindDataGrid(this, ViewState["sql"].ToString(),this.DataGrid1,"Data",true) == false)
					this.Response.Redirect("../../publics/Error.aspx?errmsg=在处理数据时发生错误。");
				//对页面导航文本进行重新赋值
				CommonService.PageNavigatorText(DataGrid1,Label2, Label3, Label4);
			}
			catch(Exception e1)
			{
				LogService.Write ("凭证提交审核时产生异常。");
				LogService.Write (e1.Message);
				Prompt.PromptError(this,"凭证提交审核时产生异常。");
			}
			
		}

		private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			try
			{
				if(this.DropDownList1.SelectedItem.Value.ToString()!="0")
				{
					ViewState["sql"]=string.Format("select * from CW_PZ where JGDM='{0}' and KJND ='{1}' and KJQJ='{2}' and PZLX='{3}' order by PZBH DESC",ViewState["JGDM"].ToString(),ViewState["KJND"].ToString(),ViewState["KJQJBH"].ToString(),this.DropDownList1.SelectedItem.Value.ToString()) ;
				}
				else
				{
					ViewState["sql"]=string.Format("select * from CW_PZ where JGDM='{0}' and KJND ='{1}' and KJQJ='{2}' order by PZBH DESC",ViewState["JGDM"].ToString(),ViewState["KJND"].ToString(),ViewState["KJQJBH"].ToString()) ;
				}
				//处理DataGrid控件(绑定DataGrid控件 -> 检查是否需要定位 -> 给导航文本赋值)
				if(CommonService.ReBindDataGrid(this, ViewState["sql"].ToString(), DataGrid1, "Data", Label2, Label3, Label4) == false)
					this.Response.Redirect("../../publics/Error.aspx?errmsg=在处理数据时发生错误。"); 
			}
			catch(Exception e1)
			{
				LogService.Write ("选择凭证类型时产生异常。");
				LogService.Write (e1.Message);
				Prompt.PromptError(this,"选择凭证类型时产生异常。");
			}
		}

		private void DDL_KJQJBHBind()
		{
			string strsql=string.Empty;
			if(ViewState["KJND"].ToString()!="NULL")
			{
				strsql=string.Format(" Select * from CW_KJQJ where KJND='{0}' and JGDM='{1}' order by KSRQ",ViewState["KJND"].ToString(),ViewState["JGDM"].ToString());
				this.DDL_KJNDBind(ViewState["KJND"].ToString());
			}
			else
			{
				//strsql=string.Format("Select * from CW_KJQJ where KJND='{0}' and JGDM='{1}'",System.DateTime.Now.Year.ToString(),ViewState["JGDM"].ToString());
				//this.DDL_KJNDBind(System.DateTime.Now.Year.ToString());
			}
			DataTable dt=new DataTable();
			if(strsql!=string.Empty)
				dt=this.CW_PZMgr.CreateDataTableFromSql(strsql);
			if(dt.Rows.Count>0)
			{
				this.DDL_KJQJBH.DataSource=dt;
				this.DDL_KJQJBH.DataTextField="KJQJBH";
				this.DDL_KJQJBH.DataValueField="KJQJBH";
				this.DDL_KJQJBH.DataBind();
				this.DDL_KJQJBH.SelectedIndex=-1;
				if(ViewState["KJQJBH"]!=null&&ViewState["KJQJBH"].ToString().Trim()!=string.Empty)
					this.DDL_KJQJBH.Items.FindByValue(ViewState["KJQJBH"].ToString().Trim()).Selected=true;
			}
			
		}

		private void DDL_KJNDBind(string KJND)
		{
			string strsql2=string.Format("SELECT distinct KJND FROM CW_KJQJ  where JGDM='{0}'",ViewState["JGDM"].ToString());
			DataTable dtKJND=this.CW_PZMgr.CreateDataTableFromSql(strsql2);
			this.DDL_KJND.DataSource=dtKJND;
			this.DDL_KJND.DataTextField="KJND";
			this.DDL_KJND.DataValueField="KJND";
			this.DDL_KJND.DataBind();
			this.DDL_KJND.SelectedIndex=-1;
			if(KJND.Trim()!=string.Empty)
				this.DDL_KJND.Items.FindByValue(KJND.Trim()).Selected=true;
		}

		private void DDL_KJND_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			try
			{
				ViewState["KJND"]=this.DDL_KJND.SelectedItem.Value.ToString();
				this.DDL_KJQJBH.SelectedIndex=0;
				ViewState["KJQJBH"]=this.DDL_KJQJBH.SelectedItem.Value.ToString();
				this.DDL_KJQJBHBind();

				ViewState["sql"]= string.Format("select * from CW_PZ where JGDM='{0}' and KJND ='{1}' and KJQJ='{2}' order by PZBH DESC",ViewState["JGDM"].ToString(),ViewState["KJND"].ToString(),ViewState["KJQJBH"].ToString()) ;

				string sql = ViewState["sql"].ToString();

⌨️ 快捷键说明

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