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

📄 pz_add.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 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_ADD 的摘要说明。
	/// </summary>
	public class PZ_ADD : com.unicafe.ui.UnicafePage
	{
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
		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.Label Label5;
		protected System.Web.UI.WebControls.Label lb_ZDR;
		protected System.Web.UI.WebControls.Label Label6;
		protected System.Web.UI.WebControls.Label lb_SHR;		
		protected System.Web.UI.WebControls.DropDownList DDL_PZLX;
		protected System.Web.UI.WebControls.TextBox tb_ZDRQ;
		protected System.Web.UI.WebControls.TextBox tb_FDS;		
		protected System.Web.UI.WebControls.LinkButton Linkbutton3;
		protected System.Web.UI.WebControls.LinkButton LinkButton1;
		protected System.Web.UI.WebControls.Label Label7;
		protected System.Web.UI.WebControls.Label Label8;
		protected System.Web.UI.WebControls.Label Label10;
		protected System.Web.UI.WebControls.Label lb_JFYE;
		protected System.Web.UI.WebControls.Label lb_DFYE;

		SqlConnection cn = new SqlConnection (com.unicafe.common.Configuration.GetDBConnectionString());
		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_PZ CW_PZ = new Com.Ascs.Plp.CW.CW_PZ();
		Com.Ascs.Plp.CW.CW_PZMgr CW_PZMgr = new Com.Ascs.Plp.CW.CW_PZMgr();
		protected System.Web.UI.WebControls.LinkButton Linkbutton4;
		protected System.Web.UI.WebControls.LinkButton Linkbutton2;
		protected bool credit =false;
			
		private void Page_Load(object sender, System.EventArgs e)
		{
			try
			{
				this.VerifyPage();
				this.VerifyPage("zz_pzgl_mgr");
				// 在此处放置用户代码以初始化页面
				if(!this.Page.IsPostBack)
				{	
					ViewState["EmployID"]=this.CurrentEmployee.EmplID;
					ViewState["PZBH"]=this.Request.QueryString["PZBH"];
					ViewState["KJND"]=this.Request.QueryString["KJND"];
					ViewState["KJQJBH"]=this.Request.QueryString["KJQJ"];
					ViewState["JGDM"]=this.Request.QueryString["JGDM"];
					if(this.Request.QueryString["ParentURLMain"]!=null)
					{
						Session["ParentURLMain"]=this.Request.QueryString["ParentURLMain"];
				
					}
					if(this.Request.QueryString["PageIndexMain"]!=null)
					{
						Session["PageIndexMain"]=this.Request.QueryString["PageIndexMain"];
					}
					//判断改凭证是否借贷平衡标记
					this.JDPH(ViewState["KJND"].ToString(),ViewState["KJQJBH"].ToString(),ViewState["JGDM"].ToString(),ViewState["PZBH"].ToString());
					ViewState["sql"]= string.Format("SELECT * FROM VIEW_PZXM where JGDM='{0}' and KJND='{1}' and KJQJ='{2}' and PZBH='{3}'",ViewState["JGDM"].ToString(),ViewState["KJND"].ToString(),ViewState["KJQJBH"].ToString(),ViewState["PZBH"].ToString()) ;

					//处理DataGrid控件(绑定DataGrid控件 -> 检查是否需要定位 -> 给导航文本赋值)
					if(CommonService.HandleDataGrid(this, ViewState["sql"].ToString(), DataGrid1, "Data1", Label2, Label3, Label4) == false)
						this.Response.Redirect("../../publics/Error.aspx?errmsg=在处理数据时发生错误。"); 
			
					this.tb_ZDRQ.Text=System.DateTime.Now.ToString("yyyy'-'M'-'d");
					this.lb_ZDR.Text=this.CurrentEmployee.EmplNameL+this.CurrentEmployee.EmplNameF;
					this.tb_FDS.Text="0";
				}
				else
				{
					//检查回发的请求操作是否是要进入上页或下页
					if(CommonService.PageNavigate(this, DataGrid1, "Data1", 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.Linkbutton3.Click += new System.EventHandler(this.Linkbutton3_Click);
			this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
			this.Linkbutton2.Click += new System.EventHandler(this.Linkbutton2_Click);
			this.Linkbutton4.Click += new System.EventHandler(this.Linkbutton4_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","int"};
				string[] pk = {"Hidden1","Hidden2","Hidden3","Hidden4","Hidden5"};

				//调用删除方法对选中的数据进行删除
				CommonService.DelSelectRecord(this,DataGrid1,ViewState["sql"].ToString(),"Data1","CheckBox1",DataTypes,pk,"Com.Ascs.Plp.CW.CW_PZXMMgr","DelCW_PZXM","该细目不能删除。");

				//对页面导航文本进行重新赋值
				CommonService.PageNavigatorText(DataGrid1,Label2, Label3, Label4);
			
				//判断改凭证是否借贷平衡标记
				this.JDPH(ViewState["KJND"].ToString(),ViewState["KJQJBH"].ToString(),ViewState["JGDM"].ToString(),ViewState["PZBH"].ToString());
			}
			catch(Exception e1)
			{
				LogService.Write ("删除会计凭证细目时产生异常。");
				LogService.Write (e1.Message);
				Prompt.PromptError(this,"删除会计凭证细目时产生异常。");
			}
			
		}

		private void Linkbutton3_Click(object sender, System.EventArgs e)
		{
			try
			{
				string ReplaceURL="PZ_ADD.aspx";
				string PZBH=string.Empty;
				int pagecount=this.DataGrid1.CurrentPageIndex+1;
				string PageIndex= pagecount.ToString();
				if(ViewState["PZBH"].ToString()=="0")
				{
					cn.Open();
					//调用修改方法进行修改
					SqlCommand cmd = new SqlCommand();
					cmd.Connection=cn;
					PZBH=this.CW_PZMgr.Create_PZBH(cmd,ViewState["JGDM"].ToString(),ViewState["KJND"].ToString(),ViewState["KJQJBH"].ToString());
					cn.Close();
					ViewState["PZBH"]=PZBH;
					CW_PZ.PZBH = PZBH;
					CW_PZ.KJND = ViewState["KJND"].ToString();
					CW_PZ.KJQJ = ViewState["KJQJBH"].ToString();
					CW_PZ.JGDM = ViewState["JGDM"].ToString();
					CW_PZ.PZLX = this.DDL_PZLX.SelectedItem.Value;
					CW_PZ.BZ="1";
					this.CW_PZ.ZDR=ViewState["EmployID"].ToString();
					this.CW_PZ.ZDRQ=Convert.ToDateTime(this.tb_ZDRQ.Text);
					this.CW_PZ.FDS=Convert.ToInt16(this.tb_FDS.Text);

				
					this.cn.Open();//启动连接
					SqlCommand mySqlCommand = new SqlCommand();
					mySqlCommand.Connection=cn;
					SqlTransaction myTrans = this.cn.BeginTransaction();//建立事务
					mySqlCommand.Transaction = myTrans;//绑定事务
				
					//新增会计凭证
				
					if (CW_PZMgr.AddCW_PZ(mySqlCommand,CW_PZ))
					{
						myTrans.Commit();
						//刷新父页面并关闭本窗口
						string ReturnURL=string.Format("{0}?PageIndex={1}&JGDM={2}&KJND={3}&KJQJBH={4}",Session["ParentURLMain"],Session["PageIndexMain"],ViewState["JGDM"],ViewState["KJND"],ViewState["KJQJBH"]);
						Response.Write("<script language=javascript>window.parent.location='"+ReturnURL+"';</script>");
						//this.Response.Write("<script language='javascript'>window.open('PZMX_ADD.aspx?ParentURL=" + ReplaceURL + "&PZBH=" + ViewState["PZBH"].ToString() + "&KJND=" + ViewState["KJND"].ToString() + "&KJQJBH=" + ViewState["KJQJBH"].ToString() + "&JGDM=" + ViewState["JGDM"].ToString() + "&PageIndex="+ PageIndex + "','','width=350px,height=350px,resizable=no,left='+ (screen.availWidth-620)/2 +',top=' + (screen.availHeight-470)/2);</script>");
						Session["MainURL"]=string.Empty;
						Session["PZH"]=ViewState["PZBH"].ToString();
					}
					else	
					{
						myTrans.Rollback();
						//使用时将下面代码中的"MainModel_1.aspx"改到特定页面的打开页面的URL
						Response.Write("<script language=javascript>window.opener.location='../../Publics/Error.aspx?errmsg=该凭证未能增加成功。';window.close();</script>");  
					}

					cn.Close();			
				}
				else
				{
					PZBH=ViewState["PZBH"].ToString();
					this.Response.Write("<script language='javascript'>window.open('PZMX_ADD.aspx?ParentURL=" + ReplaceURL + "&PZBH=" + PZBH + "&KJND=" + ViewState["KJND"].ToString() + "&KJQJBH=" +ViewState["KJQJBH"].ToString() + "&JGDM=" + ViewState["JGDM"].ToString() + "&PageIndex="+ PageIndex + "','','width=350px,height=350px,resizable=no,left='+ (screen.availWidth-620)/2 +',top=' + (screen.availHeight-470)/2);</script>");
				}
			}
			catch(Exception e1)
			{
				LogService.Write ("新增会计凭证时产生异常。");
				LogService.Write (e1.Message);
				Prompt.PromptError(this,"新增会计凭证时产生异常。");
			}
			
		}


		private void Linkbutton4_Click(object sender, System.EventArgs e)
		{
			try
			{
				bool bDel=true;
				if(ViewState["PZBH"].ToString()!="0")
				{
					this.cn.Open();//启动连接
					SqlCommand mySqlCommand=new SqlCommand();
					mySqlCommand.Connection=cn;
					SqlTransaction myTrans = this.cn.BeginTransaction();//建立事务
					mySqlCommand.Transaction = myTrans;//绑定事务
					try
					{
						bDel=this.CW_PZMgr.DelCW_PZ(mySqlCommand,ViewState["PZBH"].ToString(),ViewState["KJND"].ToString(),ViewState["KJQJBH"].ToString(),ViewState["JGDM"].ToString());
					}
					catch
					{}
					//执行完毕,提示后返回
					if(bDel == true)
					{
						myTrans.Commit();
						string ReturnURL=string.Format("{0}?PageIndex={1}&JGDM={2}&KJND={3}&KJQJBH={4}",Session["ParentURLMain"],Session["PageIndexMain"],ViewState["JGDM"],ViewState["KJND"],ViewState["KJQJBH"]);
						Session.Remove("ParentURLMain");
						Session.Remove("PageIndexMain");
						Response.Write("<script language=javascript>window.parent.location='"+ReturnURL+"';</script>");
						Response.Write("<script language=javascript>window.location= \"../../CSS/blank.aspx\";</script>");
						Session["MainURL"]=string.Empty;
					}
					else
					{
						myTrans.Rollback();
						//重定向到错误页面
						Response.Write("<script language=javascript>window.opener.location='../../Publics/Error.aspx?errmsg=凭证未能成功修改。';</script>");  
					}
					cn.Close();				
				}
			}
			catch(Exception e1)
			{
				LogService.Write ("放弃会计科目时产生异常。");
				LogService.Write (e1.Message);
				Prompt.PromptError(this,"放弃会计科目时产生异常。");
			}
			
			
		}

	
		private void Linkbutton2_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(ViewState["PZBH"].ToString()!="0")
				{
					try
					{
						CW_PZ.PZBH = ViewState["PZBH"].ToString();
						CW_PZ.KJND = ViewState["KJND"].ToString();
						CW_PZ.KJQJ = ViewState["KJQJBH"].ToString();
						CW_PZ.JGDM = ViewState["JGDM"].ToString();
						this.CW_PZ=this.CW_PZMgr.GetCW_PZ(this.CW_PZ.PZBH,this.CW_PZ.KJND,this.CW_PZ.KJQJ,this.CW_PZ.JGDM);
						CW_PZ.PZLX = this.DDL_PZLX.SelectedItem.Value;
						if(this.tb_FDS.Text.Trim()!=string.Empty)
						{
							CW_PZ.FDS=Convert.ToInt32(this.tb_FDS.Text.Trim());
						}
						this.CW_PZ.ZDR=ViewState["EmployID"].ToString();
						this.CW_PZ.ZDRQ=Convert.ToDateTime(this.tb_ZDRQ.Text);
						this.CW_PZ.BZ="2";
					}
					catch(Exception e1)
					{
						LogService.Write(e1.Message);
						this.Response.Redirect("../../Publics/Error.aspx?errmsg=该凭证没有增加成功。");  
						return;
					}
			
					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 == true)
					{
						myTrans.Commit();
						//刷新父页面并关闭本窗口
						string ReturnURL=string.Format("{0}?PageIndex={1}&JGDM={2}&KJND={3}&KJQJBH={4}",Session["ParentURLMain"],Session["PageIndexMain"],ViewState["JGDM"],ViewState["KJND"],ViewState["KJQJBH"]);
						Session.Remove("ParentURLMain");
						Session.Remove("PageIndexMain");
						Response.Write("<script language=javascript>window.parent.location='"+ReturnURL+"';</script>");
						Response.Write("<script language=javascript>window.location= \"../../CSS/blank.aspx\";</script>");
						Session["MainURL"]=string.Empty;
					}
					else
					{
						myTrans.Rollback();
						//重定向到错误页面
						Response.Write("<script language=javascript>window.opener.location='../../Publics/Error.aspx?errmsg=凭证未能成功修改。';</script>");  
					}
					cn.Close();
				}
			}
			catch(Exception e1)
			{
				LogService.Write ("保存会计科目时产生异常。");
				LogService.Write (e1.Message);
				Prompt.PromptError(this,"保存会计科目时产生异常。");
			}
			
		}

		private void JDPH(string KJND,string KJQJ,string JGDM,string PZBH)
		{
			//判断改凭证是否借贷平衡标记
			string[] sReturns=this.CW_PZMgr.PZJDPH(KJND,KJQJ,JGDM,PZBH);
			ViewState["JDPH"]=sReturns[0];
			ViewState["Mes"]=sReturns[1];
			if(sReturns[0]!="NULL")
			{
				if(sReturns[2]!="NULL")
				{
					this.lb_JFYE.Text=sReturns[2];
				}
				else
				{
					this.lb_JFYE.Text=string.Empty;
				}
				if(sReturns[3]!="NULL")
				{
					this.lb_DFYE.Text=sReturns[3];
				}
				else
				{
					this.lb_DFYE.Text=string.Empty;
				}
			}
		}
	}
}

⌨️ 快捷键说明

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