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

📄 kjqj_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 Com.Ascs.Plp.CW;
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.KJQJ
{
	/// <summary>
	/// KJQJ_ADD 的摘要说明。
	/// </summary>
	public class KJQJ_ADD : com.unicafe.ui.UnicafePage
	{
		protected System.Web.UI.WebControls.TextBox TextBox1;
		protected System.Web.UI.WebControls.TextBox tb_JSRQ;
		SqlConnection cn = new SqlConnection (com.unicafe.common.Configuration.GetDBConnectionString());
		Com.Ascs.Plp.CW.CW_KJQJ  CW_KJQJ= new Com.Ascs.Plp.CW.CW_KJQJ();
		protected System.Web.UI.WebControls.Label lb_JGDM;
		protected System.Web.UI.WebControls.Label lb_KJND;
		protected System.Web.UI.WebControls.Label lb_KJQJBH;
		protected System.Web.UI.WebControls.Label lb_KSRQ;
		protected System.Web.UI.WebControls.TextBox tb_KSRQ;
		protected System.Web.UI.WebControls.Label lb;
		protected System.Web.UI.WebControls.LinkButton datacheck;
		Com.Ascs.Plp.CW.CW_KJQJMgr CW_KJQJMgr = new Com.Ascs.Plp.CW.CW_KJQJMgr();

		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			
			try
			{
				this.VerifyPage();
				this.VerifyPage("zt_kjqj_mgr");
			
				if (!this.IsPostBack)  //判断第一次显示
				{
					this.lb_JGDM.Text=this.CurrentJGXX.JGDM;
					this.lb_KJND.Text=this.Request.QueryString["KJND"].ToString();
					ViewState["JSRQ"]=string.Empty;
					string sJSRQ=string.Empty;
					string sMaxKJQJBH=this.CW_KJQJMgr.GetMaxKJQJBH(this.CurrentJGXX.JGDM,this.lb_KJND.Text.Trim(),ref sJSRQ);
					ViewState["JSRQ"]=sJSRQ;

					//增加的判断标记
					string sReturn=string.Empty;
					ViewState["bAddKJQJ"]=this.CW_KJQJMgr.sADDKJQJ(this.lb_JGDM.Text.Trim(),this.lb_KJND.Text.Trim(),ref sReturn);
					ViewState["sReturn"]=sReturn;

					if(sMaxKJQJBH=="1")
					{
						this.lb_KJQJBH.Text="1";
						if(ViewState["sReturn"].ToString()==string.Empty)
						{
							this.lb_KSRQ.Visible=false;
							this.tb_KSRQ.Visible=true;
							this.tb_KSRQ.Text=this.lb_KJND.Text.Trim()+"-1-1";
							this.tb_JSRQ.Text=Convert.ToDateTime(this.tb_KSRQ.Text.Trim()).AddMonths(1).AddDays(-1).ToString("yyyy'-'M'-'d");
							lb.Visible=true;
						}
						else
						{
							this.lb_KSRQ.Visible=true;
							this.tb_KSRQ.Visible=false;
							this.lb_KSRQ.Text=Convert.ToDateTime(ViewState["sReturn"].ToString()).ToString("yyyy'-'M'-'d");;
							this.tb_JSRQ.Text=Convert.ToDateTime(this.lb_KSRQ.Text.Trim()).AddMonths(1).AddDays(-1).ToString("yyyy'-'M'-'d");
							lb.Visible=false;
						}
					
					}
					else
					{
						this.lb_KJQJBH.Text=sMaxKJQJBH.ToString();
						this.lb_KSRQ.Visible=true;
						this.tb_KSRQ.Visible=false;
						this.lb_KSRQ.Text=Convert.ToDateTime(sJSRQ).ToString("yyyy'-'M'-'d");
						this.tb_JSRQ.Text=Convert.ToDateTime(sJSRQ).AddMonths(1).AddDays(-1).ToString("yyyy'-'M'-'d");
					}
				}
			}
			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.datacheck.Click += new System.EventHandler(this.datacheck_Click);
			this.ID = "KJQJ_ADD";
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void datacheck_Click(object sender, System.EventArgs e)
		{
			//需要增加数据检测

			//获取数据
			try
			{
				CW_KJQJ.JGDM=this.lb_JGDM.Text.Trim();
				CW_KJQJ.KJND = this.lb_KJND.Text.Trim();
				CW_KJQJ.KJQJBH = this.lb_KJQJBH.Text.Trim();
				if(this.lb_KJQJBH.Text.Trim()=="1")
				{
					if(ViewState["sReturn"].ToString()==String.Empty)
					{
						//第一年的第一个会计期间的开始日期
						CW_KJQJ.KSRQ = Convert.ToDateTime(this.tb_KSRQ.Text.Trim());
					}
					else
					{
						//其他年份的第一个会计期间的开始日期
						CW_KJQJ.KSRQ = Convert.ToDateTime(ViewState["sReturn"].ToString());
					}
				}
				else
				{
					//非第一个会计期间的开始日期
					CW_KJQJ.KSRQ = Convert.ToDateTime(ViewState["JSRQ"].ToString());
				}
				CW_KJQJ.JSRQ = Convert.ToDateTime(this.tb_JSRQ.Text.Trim()).AddDays(1);
				int nCompare=DateTime.Compare(this.CW_KJQJ.KSRQ,this.CW_KJQJ.JSRQ);
				if(nCompare>=0)
				{
					this.Response.Write("<script>alert('会计期间的结束时间必须大于开始时间,请重新输入!');</script>");
					return;
				}
				CW_KJQJ.ZTQYBJ ="0";
				CW_KJQJ.JZBJ ="0";
				CW_KJQJ.DQQJBJ ="0";
				
				
				this.cn.Open();//启动连接
				SqlCommand mySqlCommand=new SqlCommand();
				mySqlCommand.Connection=cn;
				SqlTransaction myTrans = this.cn.BeginTransaction();//建立事务
				mySqlCommand.Transaction = myTrans;//绑定事务

				if (CW_KJQJMgr.AddCW_KJQJ( mySqlCommand,CW_KJQJ))
				{
					myTrans.Commit();
					//获取父页面的当前页索引
					string PageIndex = this.Request.QueryString["PageIndex"];
					//获取父页面的URL
					string ReturnURL=string.Format("KJQJ_View.aspx?KJND={0}&PageIndex={1}",this.lb_KJND.Text, PageIndex);
					Response.Write("<script language=javascript>window.opener.location='" + ReturnURL + 	"';window.close();</script>");  

					
				}
				else	
				{
					myTrans.Rollback();
					//使用时将下面代码中的"MainModel_1.aspx"改到特定页面的打开页面的URL
					Response.Write("<script language=javascript>window.opener.location='../../Publics/Error.aspx?errmsg=该项未能成功修改。';window.close();</script>");  
							
				}

				cn.Close();
			}
			catch(Exception e1)
			{
				LogService.Write ("添加会计期间时产生异常。");
				LogService.Write (e1.Message);
				Prompt.PromptError(this,"添加会计期间时产生异常。");
			}
			
		}

	}
}

⌨️ 快捷键说明

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