?? pz_mod.aspx.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_MOD 的摘要說明。
/// </summary>
public class PZ_MOD : com.unicafe.ui.UnicafePage
{
protected System.Web.UI.WebControls.DropDownList DDL_PZLX;
protected System.Web.UI.WebControls.TextBox tb_FDS;
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.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 lb_JFYE;
protected System.Web.UI.WebControls.Label Label10;
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 datacheck;
protected System.Web.UI.WebControls.Label lb_ZDRQ;
protected bool credit =false;
private void Page_Load(object sender, System.EventArgs e)
{
try
{
// 在此處放置用戶代碼以初始化頁面
this.VerifyPage();
this.VerifyPage("zz_pzgl_mgr");
try
{
ViewState["EmployID"]=this.CurrentEmployee.EmplID;
this.CW_PZ.PZBH=this.Request.QueryString["PZBH"];
this.CW_PZ.KJND=this.Request.QueryString["KJND"];
this.CW_PZ.KJQJ=this.Request.QueryString["KJQJ"];
this.CW_PZ.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.CW_PZ=this.CW_PZMgr.GetCW_PZ(this.CW_PZ.PZBH,this.CW_PZ.KJND,this.CW_PZ.KJQJ,this.CW_PZ.JGDM);
}
catch(Exception e1)
{
LogService.Write(e1.Message);
this.Response.Redirect("../../Publics/Error.aspx?errmsg=未能獲取憑證的完整信息。");
return;
}
if(this.CW_PZ.KGLBJ=="1")
{
this.LinkButton1.Enabled=false;
this.Linkbutton3.Enabled=false;
}
if(!this.Page.IsPostBack)
{
ViewState["credit"] = credit; //首次加載時,將判斷標(biāo)志賦值給一個視圖狀態(tài)值保存在客戶端
ViewState["sql"]= string.Format("SELECT* FROM VIEW_PZXM where JGDM='{0}' and KJND='{1}' and KJQJ='{2}' and PZBH='{3}'",this.CW_PZ.JGDM.ToString(),this.CW_PZ.KJND.ToString(),this.CW_PZ.KJQJ.ToString(),this.CW_PZ.PZBH.ToString()) ;
//判斷改憑證是否借貸平衡標(biāo)記
this.JDPH(this.CW_PZ.KJND,this.CW_PZ.KJQJ,this.CW_PZ.JGDM,this.CW_PZ.PZBH);
//處理DataGrid控件(綁定DataGrid控件 -> 檢查是否需要定位 -> 給導(dǎo)航文本賦值)
if(CommonService.HandleDataGrid(this, ViewState["sql"].ToString(), DataGrid1, "Data2", Label2, Label3, Label4) == false)
this.Response.Redirect("../../publics/Error.aspx?errmsg=在處理數(shù)據(jù)時發(fā)生錯誤。");
this.lb_ZDRQ.Text=this.CW_PZ.ZDRQ.ToString("yyyy'-'M'-'d");
this.lb_ZDR.Text=CWZZ.PZGL.PZ_VIEW.GetToEmpName(this.CW_PZ.ZDR);
this.DDL_PZLX.SelectedIndex=-1;
if(this.CW_PZ.PZLX.ToString().Trim()!=string.Empty)
this.DDL_PZLX.Items.FindByValue(this.CW_PZ.PZLX.ToString().Trim()).Selected=true;
this.tb_FDS.Text=this.CW_PZ.FDS.ToString();
this.lb_SHR.Text=CWZZ.PZGL.PZ_VIEW.GetToEmpName(this.CW_PZ.SHR);
//進(jìn)入臨時憑證狀態(tài)
this.CW_PZ.BZ="1";
cn.Open();
//調(diào)用修改方法進(jìn)行修改
SqlCommand mySqlCommand = new SqlCommand();
mySqlCommand.Connection=cn;
SqlTransaction myTrans = this.cn.BeginTransaction();//建立事務(wù)
mySqlCommand.Transaction = myTrans;//綁定事務(wù)
bool Flag = this.CW_PZMgr.UpdateCW_PZ(mySqlCommand,this.CW_PZ);
//執(zhí)行完畢,提示后返回
if(Flag == true)
{
myTrans.Commit();
}
else
{
myTrans.Rollback();
}
}
else
{
//檢查回發(fā)的請求操作是否是要進(jìn)入上頁或下頁
if(CommonService.PageNavigate(this, DataGrid1, "Data2", Label2, Label3, Label4) == false)
this.Response.Redirect("../../publics/Error.aspx?errmsg=在處理數(shù)據(jù)時發(fā)生錯誤。");
}
}
catch(Exception e1)
{
LogService.Write ("顯示會計憑證時產(chǎn)生異常。");
LogService.Write (e1.Message);
Prompt.PromptError(this,"顯示會計憑證時產(chǎn)生異常。");
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:該調(diào)用是 ASP.NET Web 窗體設(shè)計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.Linkbutton3.Click += new System.EventHandler(this.Linkbutton3_Click);
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.datacheck.Click += new System.EventHandler(this.datacheck_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"};
//調(diào)用刪除方法對選中的數(shù)據(jù)進(jìn)行刪除
CommonService.DelSelectRecord(this,DataGrid1,ViewState["sql"].ToString(),"Data2","CheckBox1",DataTypes,pk,"Com.Ascs.Plp.CW.CW_PZXMMgr","DelCW_PZXM","該會計期間已使用不能刪除。");
//對頁面導(dǎo)航文本進(jìn)行重新賦值
CommonService.PageNavigatorText(DataGrid1,Label2, Label3, Label4);
//判斷改憑證是否借貸平衡標(biāo)記
this.JDPH(this.CW_PZ.KJND,this.CW_PZ.KJQJ,this.CW_PZ.JGDM,this.CW_PZ.PZBH);
}
catch(Exception e1)
{
LogService.Write ("刪除會計憑證細(xì)目時產(chǎn)生異常。");
LogService.Write (e1.Message);
Prompt.PromptError(this,"刪除會計憑證細(xì)目時產(chǎn)生異常。");
}
}
private void Linkbutton3_Click(object sender, System.EventArgs e)
{
try
{
string ReplaceURL="PZ_MOD.aspx";
int pagecount=this.DataGrid1.CurrentPageIndex+1;
string PageIndex= pagecount.ToString();
string KJND=this.CW_PZ.KJND;
string JGDM=this.CW_PZ.JGDM;
string KJQJBH=this.CW_PZ.KJQJ;
string PZBH=this.CW_PZ.PZBH;
this.Response.Write("<script language='javascript'>window.open('PZMX_ADD.aspx?ParentURL=" + ReplaceURL + "&PZBH=" + PZBH + "&KJND=" + KJND + "&KJQJBH=" + KJQJBH + "&JGDM=" + JGDM + "&PageIndex="+ PageIndex + "','','width=350px,height=350px,resizable=no');</script>");
}
catch(Exception e1)
{
LogService.Write ("新增會計憑證時產(chǎn)生異常。");
LogService.Write (e1.Message);
Prompt.PromptError(this,"新增會計憑證時產(chǎn)生異常。");
}
}
private void datacheck_Click(object sender, System.EventArgs e)
{
try
{
try
{
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.lb_ZDRQ.Text);
this.CW_PZ.BZ="2";
}
catch(Exception e1)
{
LogService.Write(e1.Message);
this.Response.Redirect("../../Publics/Error.aspx?errmsg=未能獲取憑證的完整信息。");
return;
}
cn.Open();
//調(diào)用修改方法進(jìn)行修改
SqlCommand mySqlCommand = new SqlCommand();
mySqlCommand.Connection=cn;
SqlTransaction myTrans = this.cn.BeginTransaction();//建立事務(wù)
mySqlCommand.Transaction = myTrans;//綁定事務(wù)
bool Flag = this.CW_PZMgr.UpdateCW_PZ(mySqlCommand,this.CW_PZ);
//執(zhí)行完畢,提示后返回
if(Flag == true)
{
myTrans.Commit();
string ReturnURL=string.Format("{0}?PageIndex={1}&JGDM={2}&KJND={3}&KJQJBH={4}",Session["ParentURLMain"],Session["PageIndexMain"],this.CW_PZ.JGDM,this.CW_PZ.KJND,this.CW_PZ.KJQJ);
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 ("保存會計科目時產(chǎn)生異常。");
LogService.Write (e1.Message);
Prompt.PromptError(this,"保存會計科目時產(chǎn)生異常。");
}
}
private void JDPH(string KJND,string KJQJ,string JGDM,string PZBH)
{
//判斷改憑證是否借貸平衡標(biāo)記
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;
}
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -