?? pz_view.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_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 + -