?? pzmx_add.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>
/// PZMX_ADD 的摘要說明。
/// </summary>
public class PZMX_ADD : com.unicafe.ui.UnicafePage
{
protected System.Web.UI.WebControls.DropDownList DDL_WLHLX;
SqlConnection cn = new SqlConnection (com.unicafe.common.Configuration.GetDBConnectionString());
Com.Ascs.Plp.CW.CW_PZXM CW_PZXM = new Com.Ascs.Plp.CW.CW_PZXM();
protected System.Web.UI.WebControls.TextBox KJKM;
protected System.Web.UI.WebControls.TextBox TextChange;
protected System.Web.UI.WebControls.DropDownList gsyg;
protected System.Web.UI.WebControls.DropDownList wlh;
protected System.Web.UI.WebControls.DropDownList gsbm;
Com.Ascs.Plp.CW.CW_PZXMMgr CW_PZXMMgr = new Com.Ascs.Plp.CW.CW_PZXMMgr();
protected System.Web.UI.WebControls.LinkButton datacheck;
protected System.Web.UI.WebControls.TextBox KMMC;
protected System.Web.UI.WebControls.TextBox jfje;
protected System.Web.UI.WebControls.TextBox dfje;
protected System.Web.UI.WebControls.TextBox zy;
protected System.Web.UI.WebControls.RangeValidator RangeValidator1;
protected System.Web.UI.WebControls.RangeValidator RangeValidator2;
Com.Ascs.Plp.CW.CW_PZMgr CW_PZMgr = new Com.Ascs.Plp.CW.CW_PZMgr();
private void Page_Load(object sender, System.EventArgs e)
{
try
{
// 在此處放置用戶代碼以初始化頁面
this.VerifyPage(); //登錄檢查
this.VerifyPage("zz_pzgl_mgr");
ViewState["JGDM"]=this.CurrentJGXX.JGDM;
ViewState["KJND"]=this.Request.QueryString["KJND"];
ViewState["CD"]=this.CW_PZXMMgr.GetYJKMCD();
if (!this.IsPostBack) //判斷第一次顯示
{
this.DDLBind();
}
}
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_WLHLX.SelectedIndexChanged += new System.EventHandler(this.DDL_WLHLX_SelectedIndexChanged);
this.datacheck.Click += new System.EventHandler(this.datacheck_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void DDL_WLHLX_SelectedIndexChanged(object sender, System.EventArgs e)
{
try
{
string sql=string.Empty;
DataTable dt;
switch(this.DDL_WLHLX.SelectedItem.Value)
{
case "0":
this.wlh.Items.Clear();
this.wlh.Items.Insert(0,new ListItem("請選擇",""));
break;
case "1":
sql=string.Format("select KHDM,KHMC from KHXX where JGDM='{0}'",ViewState["JGDM"].ToString());
dt=this.CW_PZMgr.CreateDataTableFromSql(sql);
if(dt.Rows.Count>0)
{
this.wlh.DataSource=dt;
this.wlh.DataTextField="KHMC";
this.wlh.DataValueField="KHDM";
this.wlh.DataBind();
this.wlh.Items.Insert(0,new ListItem("請選擇",""));
}
break;
case "2":
sql=string.Format("select GYSDM,GYSMC from GYSXX where JGDM='{0}'",ViewState["JGDM"].ToString());
dt=this.CW_PZMgr.CreateDataTableFromSql(sql);
if(dt.Rows.Count>0)
{
this.wlh.DataSource=dt;
this.wlh.DataTextField="GYSMC";
this.wlh.DataValueField="GYSDM";
this.wlh.DataBind();
this.wlh.Items.Insert(0,new ListItem("請選擇",""));
}
break;
case "3":
sql=string.Format("select JGDM,JGMC from JGXX");
dt=this.CW_PZMgr.CreateDataTableFromSql(sql);
if(dt.Rows.Count>0)
{
this.wlh.DataSource=dt;
this.wlh.DataTextField="JGMC";
this.wlh.DataValueField="JGDM";
this.wlh.DataBind();
this.wlh.Items.Insert(0,new ListItem("請選擇",""));
}
break;
}
}
catch(Exception e1)
{
LogService.Write ("選擇往來戶類型時產生異常。");
LogService.Write (e1.Message);
Prompt.PromptError(this,"選擇往來戶類型時產生異常。");
}
}
private void DDLBind()
{
string sql=string.Empty;
sql=string.Format("select DeptID,DeptName from Departments where JGDM='{0}' or DeptID='0'",ViewState["JGDM"].ToString());
DataTable dt=this.CW_PZMgr.CreateDataTableFromSql(sql);
if(dt.Rows.Count>0)
{
this.gsbm.DataSource=dt;
this.gsbm.DataTextField="DeptName";
this.gsbm.DataValueField="DeptID";
this.gsbm.DataBind();
this.gsbm.Items.Insert(0,new ListItem("請選擇",""));
}
sql=string.Format("SELECT Employees.EmplID,Employees.EmplNameL + Employees.EmplNameF AS EmplNameL,Departments.JGDM, Employees.EmplEnabled FROM Employees INNER JOIN EmplDept ON Employees.EmplID = EmplDept.EmplID INNER JOIN Departments ON EmplDept.DeptID = Departments.DeptID where EmplEnabled='1'and JGDM='{0}'",ViewState["JGDM"].ToString());
DataTable dt1=this.CW_PZMgr.CreateDataTableFromSql(sql);
if(dt1.Rows.Count>0)
{
this.gsyg.DataSource=dt1;
this.gsyg.DataTextField="EmplNameL";
this.gsyg.DataValueField="EmplID";
this.gsyg.DataBind();
this.gsyg.Items.Insert(0,new ListItem("請選擇",""));
}
}
private void datacheck_Click(object sender, System.EventArgs e)
{
try
{
//需要增加數據檢測
try
{
ViewState["PZBH"]=this.Request.QueryString["PZBH"];
ViewState["KJND"]=this.Request.QueryString["KJND"];
this.CW_PZXM.PZBH=this.Request.QueryString["PZBH"];
this.CW_PZXM.KJND=this.Request.QueryString["KJND"];
this.CW_PZXM.KJQJ=this.Request.QueryString["KJQJBH"];
this.CW_PZXM.JGDM=this.Request.QueryString["JGDM"];
CW_PZXM.ZY = Request.Form["zy"];
this.CW_PZXM.KJKM=Request.Form["KMMC"];
string sReturn=this.CHECKKJKM(this.CW_PZXM.KJND,this.CW_PZXM.KJKM,this.gsbm.SelectedIndex,this.gsyg.SelectedIndex,this.wlh.SelectedIndex,this.DDL_WLHLX.SelectedIndex);
if(sReturn!=string.Empty)
{
this.Response.Write("<script>alert('"+sReturn+"')</script>");
return;
}
if(this.gsbm.SelectedIndex>-1)
{
CW_PZXM.BMBH=this.gsbm.SelectedItem.Value;
}
else
{
CW_PZXM.BMBH=string.Empty;
}
if(this.gsyg.SelectedIndex>-1)
{
CW_PZXM.YGBH=this.gsyg.SelectedItem.Value;
}
else
{
CW_PZXM.BMBH=string.Empty;
}
if(this.wlh.SelectedIndex>-1)
{
CW_PZXM.WLHBM = this.wlh.SelectedItem.Value;
}
else
{
CW_PZXM.WLHBM=string.Empty;
}
if(this.DDL_WLHLX.SelectedIndex>-1)
{
CW_PZXM.WLHLX = this.DDL_WLHLX.SelectedItem.Value;
}
else
{
CW_PZXM.WLHLX=string.Empty;
}
if(Request.Form["jfje"]!=string.Empty)
{
CW_PZXM.JFJE= Convert.ToDecimal(Request.Form["jfje"]);
}
else
{
CW_PZXM.JFJE=0;
}
if(Request.Form["dfje"]!=string.Empty)
{
CW_PZXM.DFJE= Convert.ToDecimal(Request.Form["dfje"]);
}
else
{
CW_PZXM.DFJE=0;
}
}
catch(Exception Err)
{
LogService.Write(Err.Message);
this.Response.Redirect("../../Publics/Error.aspx?errmsg=未能獲取憑證細目的完整信息。");
return;
}
cn.Open();
//新增會計科目
SqlCommand mySqlCommandXM = new SqlCommand();
mySqlCommandXM.Connection=cn;
SqlTransaction myTransXM = this.cn.BeginTransaction();//建立事務
mySqlCommandXM.Transaction = myTransXM;//綁定事務
if (CW_PZXMMgr.AddCW_PZXM(mySqlCommandXM,CW_PZXM))
{
myTransXM.Commit();
this.MODKJKM_SYBJ(this.CW_PZXM.KJND,this.CW_PZXM.KJKM);
string ReturnURL =PLP.CWZZ.PZGL.PZMX_ADD.PZXMADD_CreatReturnURL(this,CW_PZXM);
Response.Write("<script language=javascript>window.opener.location='" + ReturnURL + "';window.close();</script>");
}
else
{
myTransXM.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,"添加會計憑證細目時產生異常。");
}
}
private void MODKJKM_SYBJ(string KJND,string KJKM)
{
//cn.Open();
Com.Ascs.Plp.CW.CW_KJKM CW_KJKM=new Com.Ascs.Plp.CW.CW_KJKM();
Com.Ascs.Plp.CW.CW_KJKMMgr CW_KJKMMgr=new Com.Ascs.Plp.CW.CW_KJKMMgr();
CW_KJKM=CW_KJKMMgr.GetCW_KJKM(KJND,KJKM);
CW_KJKM.SFYJSY="1";
CW_KJKMMgr.UpdateCW_KJKM(cn,CW_KJKM);
//cn.Close();
}
private string CHECKKJKM(string KJND,string KJKM,int BMBM,int YGBM,int WLHBM,int WLHLX)
{
string sReturn=string.Empty;
string sql=string.Format("select * from CW_KJKM where KJND='{0}' and KMBM='{1}' and TYBJ='0' and SFMX='1'",KJND,KJKM);
DataTable dt=this.CW_PZMgr.CreateDataTableFromSql(sql);
if(dt.Rows.Count==1)
{
if(dt.Rows[0]["SFBMHS"].ToString()=="1"&&BMBM<1)
{
sReturn="該科目部門核算,請選擇部門!";
}
else if(dt.Rows[0]["SFBMHS"].ToString()=="0"&&BMBM>0)
{
sReturn="該科目沒有部門核算,請不要選擇部門!";
this.gsbm.SelectedIndex=0;
}
if(dt.Rows[0]["SFYGHS"].ToString()=="1"&&YGBM<1)
{
sReturn+="該科目員工核算,請選擇員工!";
}
else if(dt.Rows[0]["SFYGHS"].ToString()=="0"&&YGBM>0)
{
sReturn+="該科目沒有員工核算,請不要選擇員工!";
this.gsyg.SelectedIndex=0;
}
if(dt.Rows[0]["SFWLHHS"].ToString()=="1"&&WLHBM<1)
{
sReturn+="該科目往來戶核算,請選擇往來戶!";
}
else if(dt.Rows[0]["SFWLHHS"].ToString()=="0")
{
if(WLHBM>0||WLHLX>0)
{
sReturn+="該科目沒有往來戶核算,請不要選擇往來戶!";
this.DDL_WLHLX.SelectedIndex=0;
this.wlh.SelectedIndex=0;
}
}
}
else
{
sReturn="科目編碼書寫有誤請重新填寫!原因有可能是:1.該科目不存在。2.該科目不是末級科目。3.該科目已經停用。";
}
return sReturn;
}
public static string PZXMADD_CreatReturnURL(System.Web.UI.Page thePage,Com.Ascs.Plp.CW.CW_PZXM CW_PZXM)
{
//獲取父頁面的當前頁索引
string PageIndex = thePage.Request.QueryString["PageIndex"];
//獲取父頁面的URL
string ParentURL = thePage.Request.QueryString["ParentURL"];
ParentURL = string.Format("{0}?PageIndex={1}&JGDM={2}&KJQJ={3}&KJND={4}&PZBH={5}",ParentURL,PageIndex,CW_PZXM.JGDM,CW_PZXM.KJQJ,CW_PZXM.KJND,CW_PZXM.PZBH);
return ParentURL;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -