You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
D7QUANTAI/DSWeb/CW/CwVouchersInfo.aspx.cs

1151 lines
53 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using DSWeb.DataAccess;
using System.Data.SqlClient;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Web.Script.Serialization;
using System.ComponentModel;
using System.Drawing;
using System.Web.SessionState;
using System.Web.Mail;
using System.IO;
using System.Data.OleDb;
using JsonHelper;
using DSWeb.Log;
using DSWeb.Attributes;
namespace DSWeb.CW
{
public partial class CwVouchersInfo : System.Web.UI.Page
{
public string sSQL = String.Empty;
public string gvid = String.Empty;
public string strRQ;
public string strdate;//用户GID
public string strUserID;//登录用户GID
public string strCompanyID;//公司GID
public string strShowName;//用户显示名
public string strDeptName;//部门名称
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString();
this.hdUserID.Value = strUserID;
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
//strUserID = "";
//hdUserID.Value = "";
}
if (Session["SHOWNAME"] != null)
{
strShowName = Session["SHOWNAME"].ToString();
}
if (Session["COMPANYID"] != null)
{
strCompanyID = Session["COMPANYID"].ToString();
this.hdCOMPANYID.Value = strCompanyID;
}
if (Session["DEPTNAME"] != null)
{
strDeptName = Session["DEPTNAME"].ToString();
}
//页面是否只读
if (Request.QueryString["hdenabled"] != null)
{
if (Request.QueryString["hdenabled"].ToString() == "false")
{
this.hdEnabled.Value = Request.QueryString["hdenabled"].ToString();
getEnabled();
}
else
{
this.hdEnabled.Value = "true";
getEnabledTrue();
}
}
else
{
this.hdEnabled.Value = "true";
getEnabledTrue();
}
if (Request.QueryString["ordno"] != null)
{
this.hdORDNO.Value = Request.QueryString["ordno"].ToString();//"CwVouitemsusername129481962859531250";
}
//
T_ALL_DA T_ALL_DA = new T_ALL_DA();
strRQ = T_ALL_DA.GetStrSQL("rq", "select convert(char(10),getdate(),20) as rq");
//
if (!IsPostBack)
{
if (Request.QueryString["handle"] != null)
{
this.hdHandle.Value = Request.QueryString["handle"].ToString().Trim();
//
if (Request.QueryString["id"] != null)
{
ViewState["GID"] = Request.QueryString["id"].ToString();//"CwVouitemsusername129481962859531250";
this.hdGid.Value = ViewState["GID"].ToString().Trim();
}
//
getNull();
//
CwVouitemsDA CwVouitemsDA = new CwVouitemsDA();
CwVouitemsEntity CwVouitemsEntity = new CwVouitemsEntity();
switch (this.hdHandle.Value)
{
case "add"://新增
//ViewState["GID"] = getGID();
//this.hdGid.Value = ViewState["GID"].ToString().Trim();
//
getNull();
//
ibDel.Enabled = false;
break;
case "addfull"://新增
CwVouitemsEntity = CwVouitemsDA.GetModel(ViewState["GID"].ToString().Trim());
if (CwVouitemsEntity.GID != null)
{
tbITEMNO.Text = CwVouitemsEntity.ITEMNO.ToString().Trim();
tbEXPLAN.Text = CwVouitemsEntity.EXPLAN.ToString().Trim();
//ddlACCID
this.hd_comboACCID.Value = CwVouitemsEntity.ACCID.ToString().Trim();
tbACCNAME.Text = CwVouitemsEntity.ACCNAME.ToString().Trim();
//ddlCUSTOMERNAME
this.hd_comboCUSTOMERNAME.Value = CwVouitemsEntity.CUSTOMERNAME.ToString().Trim();
tbCORPID.Text = CwVouitemsEntity.CORPID.ToString().Trim();
tbAMTDR.Text = CwVouitemsEntity.AMTDR.ToString().Trim();
tbAMTCR.Text = CwVouitemsEntity.AMTCR.ToString().Trim();
tbFCYDR.Text = CwVouitemsEntity.FCYDR.ToString().Trim();
tbFCYCR.Text = CwVouitemsEntity.FCYCR.ToString().Trim();
tbFCYEXRATE.Text = CwVouitemsEntity.FCYEXRATE.ToString().Trim();
tbBLNO.Text = CwVouitemsEntity.BLNO.ToString().Trim();
//ddlSALE
this.hd_comboSALE.Value = CwVouitemsEntity.SALE.ToString().Trim();
//
//ViewState["GID"] = getGID();
//this.hdGid.Value = ViewState["GID"].ToString().Trim();
//
ibDel.Enabled = false;
//ibAdd.Enabled = false;
//ibFullAdd.Enabled = false;
}
break;
case "edit"://录入
CwVouitemsEntity = CwVouitemsDA.GetModel(ViewState["GID"].ToString().Trim());
if (CwVouitemsEntity.GID != null)
{
tbITEMNO.Text = CwVouitemsEntity.ITEMNO.ToString().Trim();
tbEXPLAN.Text = CwVouitemsEntity.EXPLAN.ToString().Trim();
//ddlACCID
this.hd_comboACCID.Value = CwVouitemsEntity.ACCID.ToString().Trim();
tbACCNAME.Text = CwVouitemsEntity.ACCNAME.ToString().Trim();
//ddlCUSTOMERNAME
this.hd_comboCUSTOMERNAME.Value = CwVouitemsEntity.CUSTOMERNAME.ToString().Trim();
tbCORPID.Text = CwVouitemsEntity.CORPID.ToString().Trim();
tbAMTDR.Text = CwVouitemsEntity.AMTDR.ToString().Trim();
tbAMTCR.Text = CwVouitemsEntity.AMTCR.ToString().Trim();
tbFCYDR.Text = CwVouitemsEntity.FCYDR.ToString().Trim();
tbFCYCR.Text = CwVouitemsEntity.FCYCR.ToString().Trim();
tbFCYEXRATE.Text = CwVouitemsEntity.FCYEXRATE.ToString().Trim();
tbBLNO.Text = CwVouitemsEntity.BLNO.ToString().Trim();
//ddlSALE
this.hd_comboSALE.Value = CwVouitemsEntity.SALE.ToString().Trim();
}
//
if (this.hdEnabled.Value == "true")
{
ibDel.Enabled = true;
ibAdd.Enabled = true;
ibFullAdd.Enabled = true;
}
break;
}
}
else
{
}
//
RangeDA RangeDA = new RangeDA();
if (this.hdEnabled.Value == "true")
{
//if (this.hdHandle.Value.Trim() == "edit")
//{
//string strV = RangeDA.GetVISIBLERANGE(this.hdUserID.Value.Trim(), "modSeaImportList");//海运进口委托管理列表
//string strO = RangeDA.GetOPERATERANGE(this.hdUserID.Value.Trim(), "modSeaImportList");//海运进口委托管理列表
//string alt = "";
//if (strV.Trim() != strO.Trim())
//{
// if (strO.Trim().Equals("0"))//全部
// {
// }
// else if (strO.Trim().Equals("1"))//分公司
// {
// alt = RangeDA.GetSeaImportListCompany(this.hdUserID.Value.Trim(), ViewState["GID"].ToString().Trim());
// if (alt == "")
// {
// getEnabled();
// }
// ibAdd.Enabled = true;
// ibFullAdd.Enabled = true;
// }
// else if (strO.Trim().Equals("2"))//部门
// {
// alt = RangeDA.GetSeaImportListDEPT(this.hdUserID.Value.Trim(), ViewState["GID"].ToString().Trim());
// if (alt == "")
// {
// getEnabled();
// }
// ibAdd.Enabled = true;
// ibFullAdd.Enabled = true;
// }
// else if (strO.Trim().Equals("3"))//个人
// {
// alt = RangeDA.GetSeaImportListPerson(this.hdUserID.Value.Trim(), ViewState["GID"].ToString().Trim());
// if (alt == "")
// {
// getEnabled();
// }
// ibAdd.Enabled = true;
// ibFullAdd.Enabled = true;
// }
// else if (strO.Trim().Equals("4"))//无
// {
// getEnabled();
// }
//}
//}
//else
//{
// getEnabledTrue();
//}
getEnabledTrue();
}
else
{
getEnabled();
}
//
}
//保存
//if (ViewState["GID"] != null)
//{
if (this.hdEnter.Value == "0")
{
getEnter("");
}
//}
//else
//{
//Response.Write("-1");
//Response.End();
//}
//加载下拉框
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>initComboSALE();initComboCUSTOMERNAME();initComboACCID();</script>");
}
protected void getNull()
{
tbITEMNO.Text = "";
tbEXPLAN.Text = "";
//ddlACCID
this.hd_comboACCID.Value = "";
tbACCNAME.Text = "";
//ddlCUSTOMERNAME
this.hd_comboCUSTOMERNAME.Value = "";
tbCORPID.Text = "";
tbAMTDR.Text = "0";
tbAMTCR.Text = "0";
tbFCYDR.Text = "0";
tbFCYCR.Text = "0";
tbFCYEXRATE.Text = "1";
//ddlSALE
this.hd_comboSALE.Value = "";
tbBLNO.Text = "";
}
protected void getEnabled()
{
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
this.ibEnter.Disabled = true;
this.imgFresh.Disabled = true;
ibDel.Enabled = false;
//this.ibPrint.Disabled = true;
//
this.hdEnabled.Value = "false";
//
tbITEMNO.Enabled = false;
tbEXPLAN.Enabled = false;
//ddlACCID
//this.hd_comboACCID.Value = "";
tbACCNAME.Enabled = false;
//ddlCUSTOMERNAME
//this.hd_comboCUSTOMERNAME.Value = "";
tbCORPID.Enabled = false;
tbAMTDR.Enabled = false;
tbAMTCR.Enabled = false;
tbFCYDR.Enabled = false;
tbFCYCR.Enabled = false;
tbFCYEXRATE.Enabled = false;
tbBLNO.Enabled = false;
//ddlSALE
//this.hd_comboSALE.Value = "";
}
protected void getEnabledTrue()
{
ibAdd.Enabled = true;
ibFullAdd.Enabled = true;
this.ibEnter.Disabled = false;
this.imgFresh.Disabled = false;
ibDel.Enabled = true;
//this.ibPrint.Disabled = false
//
this.hdEnabled.Value = "true";
//
tbITEMNO.Enabled = true;
tbEXPLAN.Enabled = true;
//ddlACCID
//this.hd_comboACCID.Value = "";
tbACCNAME.Enabled = true;
//ddlCUSTOMERNAME
//this.hd_comboCUSTOMERNAME.Value = "";
tbCORPID.Enabled = true;
tbAMTDR.Enabled = true;
tbAMTCR.Enabled = true;
tbFCYDR.Enabled = true;
tbFCYCR.Enabled = true;
tbFCYEXRATE.Enabled = true;
tbBLNO.Enabled = true;
//ddlSALE
//this.hd_comboSALE.Value = "";
}
/// <summary>
/// 获取数据库顺序递增的行号
/// </summary>
/// <returns></returns>
private string GetITEMNO()
{
CwVouitemsDA CwVouitemsDA = new CwVouitemsDA();
string strITEMNO = CwVouitemsDA.GetStrSQL("hh", "select isnull(max(ITEMNO),0)+1 as hh from Cw_Vouitems where ORDNO='" + this.hdORDNO.Value.ToString().Trim() + "'");
return strITEMNO;
}
protected String getGID()
{
string strGID = Guid.NewGuid().ToString();
strGID = strGID.Replace("-", "");
strGID = "VOUS" + strGID;
return strGID;
}
protected bool getAdd()
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
//帐套设置
sSQL = "SELECT top 1 * from cw_design";
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应收RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["AR"].ToString().Trim() + "'";
DataSet ds2 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应付RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["AP"].ToString().Trim() + "'";
DataSet ds3 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应收USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["ARFC"].ToString().Trim() + "'";
DataSet ds6 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应付USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["APFC"].ToString().Trim() + "'";
DataSet ds7 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 付费结算借方默认科目代码
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["APMBSPENDING"].ToString().Trim() + "'";
DataSet ds8 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 付费结算外币借方默认科目代码
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["APTMSFC"].ToString().Trim() + "'";
DataSet ds9 = T_ALL_DA.GetAllSQL(sSQL);
//
CwVouitemsDA CwVouitemsDA = new CwVouitemsDA();
CwVouitemsEntity model = new CwVouitemsEntity();
ViewState["GID"] = getGID();
this.hdGid.Value = ViewState["GID"].ToString().Trim();
model.GID = this.hdGid.Value.Trim();
//
if (tbAMTDR.Text.Trim() == "" || tbAMTDR.Text.Trim() == "0" || tbAMTDR.Text.Trim() == "0.00")
{
model.AMTDR = 0;
}
else
{
model.AMTDR = Decimal.Parse(Decimal.Parse(tbAMTDR.Text.Trim()).ToString("F2"));
model.AMTCR = 0;
}
//
if (tbAMTCR.Text.Trim() == "" || tbAMTCR.Text.Trim() == "0" || tbAMTCR.Text.Trim() == "0.00")
{
model.AMTCR = 0;
}
else
{
model.AMTCR = Decimal.Parse(Decimal.Parse(tbAMTCR.Text.Trim()).ToString("F2"));
model.AMTDR = 0;
}
//
if ((tbFCYDR.Text.Trim() != "0" && tbFCYDR.Text.Trim() != "" && tbFCYDR.Text.Trim() != "0.00") && (tbFCYEXRATE.Text.Trim() != "" || tbFCYEXRATE.Text.Trim() != "0" || tbFCYEXRATE.Text.Trim() != "0.00" || tbFCYEXRATE.Text.Trim() != "0.000" || tbFCYEXRATE.Text.Trim() != "0.0000"))
{
tbAMTDR.Text = (Decimal.Parse(tbFCYDR.Text.Trim()) * Decimal.Parse(tbFCYEXRATE.Text.Trim())).ToString("F2");
model.AMTDR = Decimal.Parse((Decimal.Parse(tbFCYDR.Text.Trim()) * Decimal.Parse(tbFCYEXRATE.Text.Trim())).ToString("F2"));
tbAMTCR.Text = "0";
model.AMTCR = 0;
}
//
if ((tbFCYCR.Text.Trim() != "0" && tbFCYCR.Text.Trim() != "" && tbFCYCR.Text.Trim() != "0.00") && (tbFCYEXRATE.Text.Trim() != "" || tbFCYEXRATE.Text.Trim() != "0" || tbFCYEXRATE.Text.Trim() != "0.00" || tbFCYEXRATE.Text.Trim() != "0.000" || tbFCYEXRATE.Text.Trim() != "0.0000"))
{
tbAMTCR.Text = (Decimal.Parse(tbFCYCR.Text.Trim()) * Decimal.Parse(tbFCYEXRATE.Text.Trim())).ToString("F2");
model.AMTCR = Decimal.Parse((Decimal.Parse(tbFCYCR.Text.Trim()) * Decimal.Parse(tbFCYEXRATE.Text.Trim())).ToString("F2"));
tbAMTDR.Text = "0";
model.AMTDR = 0;
}
//
if (tbFCYEXRATE.Text.Trim() == "" || tbFCYEXRATE.Text.Trim() == "0" || tbFCYEXRATE.Text.Trim() == "0.00" || tbFCYEXRATE.Text.Trim() == "0.000" || tbFCYEXRATE.Text.Trim() == "0.0000")
{
model.FCYEXRATE = 1;
tbFCYEXRATE.Text = "1";
}
else
{
model.FCYEXRATE = Decimal.Parse(Decimal.Parse(tbFCYEXRATE.Text.Trim()).ToString("#.####"));
}
//
if (tbFCYDR.Text.Trim() == "" || tbFCYDR.Text.Trim() == "0" || tbFCYDR.Text.Trim() == "0.00")
{
tbFCYDR.Text = "0";
model.FCYDR = 0;
}
else
{
model.FCYDR = Decimal.Parse(Decimal.Parse(tbFCYDR.Text.Trim()).ToString("F2"));
//tbFCYCR.Text = "0";
model.FCYCR = 0;
}
//
if (tbFCYCR.Text.Trim() == "" || tbFCYCR.Text.Trim() == "0" || tbFCYCR.Text.Trim() == "0.00")
{
tbFCYCR.Text = "0";
model.FCYCR = 0;
}
else
{
model.FCYCR = Decimal.Parse(Decimal.Parse(tbFCYCR.Text.Trim()).ToString("F2"));
//tbFCYDR.Text = "0";
model.FCYDR = 0;
}
//
if ((tbFCYCR.Text.Trim() != "0" && tbFCYCR.Text.Trim() != "" && tbFCYCR.Text.Trim() != "0.00") || (tbFCYDR.Text.Trim() != "0" && tbFCYDR.Text.Trim() != "" && tbFCYDR.Text.Trim() != "0.00"))
{
model.ISFCY = true;
model.FCYNO = "USD";
}
else
{
model.ISFCY = false;
model.FCYNO = "RMB";
}
//
//插入明细表
if (ds.Tables[0].Rows[0]["AR"].ToString().Trim() == this.hd_comboACCID.Value.Trim())//应收
{
if (model.FCYNO.ToString().Trim() == "RMB")
{
if (ds2 == null)
{
model.ISDEPTACC = false;//核算部门,按规则设置生成
model.ISEMPLACC = false;//核算人员,按规则设置生成
model.ISCORPACC = false;//核算客户,按规则设置生成
model.ISITEMACC = false;//核算项目,按规则设置生成
model.DC = "D";//贷方向
}
else
{
model.ISDEPTACC = Boolean.Parse(ds2.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
model.ISEMPLACC = Boolean.Parse(ds2.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
model.ISCORPACC = Boolean.Parse(ds2.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
model.ISITEMACC = Boolean.Parse(ds2.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds2.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
model.DC = "D";//借方向
}
else
{
model.DC = "C";//贷方向
}
}
}
else if (model.FCYNO.ToString().Trim() == "USD")
{
if (ds6 == null)
{
model.ISDEPTACC = false;//核算部门,按规则设置生成
model.ISEMPLACC = false;//核算人员,按规则设置生成
model.ISCORPACC = false;//核算客户,按规则设置生成
model.ISITEMACC = false;//核算项目,按规则设置生成
model.DC = "C";//贷方向
}
else
{
model.ISDEPTACC = Boolean.Parse(ds6.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
model.ISEMPLACC = Boolean.Parse(ds6.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
model.ISCORPACC = Boolean.Parse(ds6.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
model.ISITEMACC = Boolean.Parse(ds6.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds6.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
model.DC = "D";//借方向
}
else
{
model.DC = "C";//贷方向
}
}
}
model.CORPID = tbCORPID.Text.Trim();//客户(系统)
model.CUSTOMERNAME = this.hd_comboCUSTOMERNAME.Value.Trim();//客户(系统)
}
else if (ds.Tables[0].Rows[0]["AP"].ToString().Trim() == this.hd_comboACCID.Value.Trim())//应付
{
if (model.FCYNO.ToString().Trim() == "RMB")
{
if (ds3 == null)
{
model.CORPID = "";//客户(系统)
model.CUSTOMERNAME = "";//客户(系统)
model.ISDEPTACC = false;//核算部门,按规则设置生成
model.ISEMPLACC = false;//核算人员,按规则设置生成
model.ISCORPACC = false;//核算客户,按规则设置生成
model.ISITEMACC = false;//核算项目,按规则设置生成
model.DC = "C";//贷方向
}
else
{
model.CORPID = tbCORPID.Text.Trim();//客户(系统)
model.CUSTOMERNAME = this.hd_comboCUSTOMERNAME.Value.Trim();//客户(系统)
model.ISCORPACC = Boolean.Parse(ds3.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
model.ISDEPTACC = Boolean.Parse(ds3.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
model.ISEMPLACC = Boolean.Parse(ds3.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
model.ISITEMACC = Boolean.Parse(ds3.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds3.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
model.DC = "D";//借方向
}
else
{
model.DC = "C";//贷方向
}
}
}
else if (model.FCYNO.ToString().Trim() == "USD")
{
if (ds7 == null)
{
model.CORPID = "";//客户(系统)
model.CUSTOMERNAME = "";//客户(系统)
model.ISDEPTACC = false;//核算部门,按规则设置生成
model.ISEMPLACC = false;//核算人员,按规则设置生成
model.ISCORPACC = false;//核算客户,按规则设置生成
model.ISITEMACC = false;//核算项目,按规则设置生成
model.DC = "C";//贷方向
}
else
{
model.CORPID = tbCORPID.Text.Trim();//客户(系统)
model.CUSTOMERNAME = this.hd_comboCUSTOMERNAME.Value.Trim();//客户(系统)
model.ISCORPACC = Boolean.Parse(ds7.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
model.ISDEPTACC = Boolean.Parse(ds7.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
model.ISEMPLACC = Boolean.Parse(ds7.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
model.ISITEMACC = Boolean.Parse(ds7.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds7.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
model.DC = "D";//借方向
}
else
{
model.DC = "C";//贷方向
}
}
}
}
else
{
model.CORPID = tbCORPID.Text.Trim();//客户(系统)
model.CUSTOMERNAME = this.hd_comboCUSTOMERNAME.Value.Trim();//客户(系统)
model.ISDEPTACC = false;//核算部门,按规则设置生成
model.ISEMPLACC = false;//核算人员,按规则设置生成
model.ISCORPACC = false;//核算客户,按规则设置生成
model.ISITEMACC = false;//核算项目,按规则设置生成
model.DC = "C";//贷方向
}
//
model.ORDNO = this.hdORDNO.Value.Trim();
model.ITEMNO = int.Parse(tbITEMNO.Text.Trim());
//model.CORPID=tbCORPID.Text.Trim();
//model.CUSTOMERNAME=this.hd_comboCUSTOMERNAME.Value.Trim();
model.EXPLAN = tbEXPLAN.Text.Trim();
model.ACCID = this.hd_comboACCID.Value.Trim();
model.ACCNAME = tbACCNAME.Text.Trim();
model.SALE = this.hd_comboSALE.Value.Trim();
model.BLNO = tbBLNO.Text.Trim();
model.ISSYS=true;
model.MODIFIEDUSER = strUserID;
//
model.QTYUNIT="";
model.QTYDR=0;
model.QTYCR=0;
//model.ISDEPTACC=false;
//model.ISEMPLACC = false;
//model.ISCORPACC = false;
//model.ISITEMACC = false;
model.DEPTID="";
model.EMPLID="";
model.PITEMID=0;
model.ITEMID="0";
model.FIELD10="";
model.FIELD9="";
model.FIELD8="";
model.FIELD7="";
model.FIELD6="";
model.FIELD5="";
model.FIELD4="";
model.FIELD3="";
model.FIELD2="";
model.FIELD1="";
model.FSETTLCODE="";
model.FSETTLENO="";
model.PACCID="";
model.PROPERTY=0;
model.GRADE=0;
//model.DC="";
//
int iResult = CwVouitemsDA.AddAll(model);
if (iResult > 0)
{
CwVouchersDA CwVouchersDA = new CwVouchersDA();
CwVouchersEntity CwVouchersEntity = new CwVouchersEntity();
//
CwVouchersEntity.ORDNO = this.hdORDNO.Value.Trim();
//
string strAMTDR = T_ALL_DA.GetStrSQL("AMTDR", "select sum(AMTDR) as AMTDR from cw_vouitems where ORDNO='" + this.hdORDNO.Value.Trim() + "'");
string strAMTCR = T_ALL_DA.GetStrSQL("AMTCR", "select sum(AMTCR) as AMTCR from cw_vouitems where ORDNO='" + this.hdORDNO.Value.Trim() + "'");
//
if ((strAMTDR.Trim() != "0" && strAMTDR.Trim() != "" && strAMTDR.Trim() != "0.00"))
{
CwVouchersEntity.AMTDR = Decimal.Parse(Decimal.Parse(strAMTDR.Trim()).ToString("F2"));
}
else
{
CwVouchersEntity.AMTDR = 0;
}
//
if ((strAMTCR.Trim() != "0" && strAMTCR.Trim() != "" && strAMTCR.Trim() != "0.00"))
{
CwVouchersEntity.AMTCR = Decimal.Parse(Decimal.Parse(strAMTCR.Trim()).ToString("F2"));
}
else
{
CwVouchersEntity.AMTDR = 0;
}
//
iResult = CwVouchersDA.UpdateAMT(CwVouchersEntity);
//
return true;
}
else
{
return false;
}
}
protected bool getEdit()
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
//帐套设置
sSQL = "SELECT top 1 * from cw_design";
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应收RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["AR"].ToString().Trim() + "'";
DataSet ds2 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应付RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["AP"].ToString().Trim() + "'";
DataSet ds3 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应收USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["ARFC"].ToString().Trim() + "'";
DataSet ds6 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应付USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["APFC"].ToString().Trim() + "'";
DataSet ds7 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 付费结算借方默认科目代码
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["APMBSPENDING"].ToString().Trim() + "'";
DataSet ds8 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 付费结算外币借方默认科目代码
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["APTMSFC"].ToString().Trim() + "'";
DataSet ds9 = T_ALL_DA.GetAllSQL(sSQL);
//
CwVouitemsDA CwVouitemsDA = new CwVouitemsDA();
CwVouitemsEntity model = new CwVouitemsEntity();
this.hdGid.Value = ViewState["GID"].ToString().Trim();
model.GID = this.hdGid.Value.Trim();
//
if (tbAMTDR.Text.Trim() == "" || tbAMTDR.Text.Trim() == "0" || tbAMTDR.Text.Trim() == "0.00")
{
model.AMTDR = 0;
}
else
{
model.AMTDR = Decimal.Parse(Decimal.Parse(tbAMTDR.Text.Trim()).ToString("F2"));
model.AMTCR = 0;
}
//
if (tbAMTCR.Text.Trim() == "" || tbAMTCR.Text.Trim() == "0" || tbAMTCR.Text.Trim() == "0.00")
{
model.AMTCR = 0;
}
else
{
model.AMTCR = Decimal.Parse(Decimal.Parse(tbAMTCR.Text.Trim()).ToString("F2"));
model.AMTDR = 0;
}
//
if ((tbFCYDR.Text.Trim() != "0" && tbFCYDR.Text.Trim() != "" && tbFCYDR.Text.Trim() != "0.00") && (tbFCYEXRATE.Text.Trim() != "" || tbFCYEXRATE.Text.Trim() != "0" || tbFCYEXRATE.Text.Trim() != "0.00" || tbFCYEXRATE.Text.Trim() != "0.000" || tbFCYEXRATE.Text.Trim() != "0.0000"))
{
tbAMTDR.Text = (Decimal.Parse(tbFCYDR.Text.Trim()) * Decimal.Parse(tbFCYEXRATE.Text.Trim())).ToString("F2");
model.AMTDR = Decimal.Parse((Decimal.Parse(tbFCYDR.Text.Trim()) * Decimal.Parse(tbFCYEXRATE.Text.Trim())).ToString("F2"));
tbAMTCR.Text = "0";
model.AMTCR = 0;
}
//
if ((tbFCYCR.Text.Trim() != "0" && tbFCYCR.Text.Trim() != "" && tbFCYCR.Text.Trim() != "0.00") && (tbFCYEXRATE.Text.Trim() != "" || tbFCYEXRATE.Text.Trim() != "0" || tbFCYEXRATE.Text.Trim() != "0.00" || tbFCYEXRATE.Text.Trim() != "0.000" || tbFCYEXRATE.Text.Trim() != "0.0000"))
{
tbAMTCR.Text = (Decimal.Parse(tbFCYCR.Text.Trim()) * Decimal.Parse(tbFCYEXRATE.Text.Trim())).ToString("F2");
model.AMTCR = Decimal.Parse((Decimal.Parse(tbFCYCR.Text.Trim()) * Decimal.Parse(tbFCYEXRATE.Text.Trim())).ToString("F2"));
tbAMTDR.Text = "0";
model.AMTDR = 0;
}
//
if (tbFCYEXRATE.Text.Trim() == "" || tbFCYEXRATE.Text.Trim() == "0" || tbFCYEXRATE.Text.Trim() == "0.00" || tbFCYEXRATE.Text.Trim() == "0.000" || tbFCYEXRATE.Text.Trim() == "0.0000")
{
model.FCYEXRATE = 1;
tbFCYEXRATE.Text = "1";
}
else
{
model.FCYEXRATE = Decimal.Parse(Decimal.Parse(tbFCYEXRATE.Text.Trim()).ToString("#.####"));
}
//
if (tbFCYDR.Text.Trim() == "" || tbFCYDR.Text.Trim() == "0" || tbFCYDR.Text.Trim() == "0.00")
{
tbFCYDR.Text = "0";
model.FCYDR = 0;
}
else
{
model.FCYDR = Decimal.Parse(Decimal.Parse(tbFCYDR.Text.Trim()).ToString("F2"));
//tbFCYCR.Text = "0";
model.FCYCR = 0;
}
//
if (tbFCYCR.Text.Trim() == "" || tbFCYCR.Text.Trim() == "0" || tbFCYCR.Text.Trim() == "0.00")
{
tbFCYCR.Text = "0";
model.FCYCR = 0;
}
else
{
model.FCYCR = Decimal.Parse(Decimal.Parse(tbFCYCR.Text.Trim()).ToString("F2"));
//tbFCYDR.Text = "0";
model.FCYDR = 0;
}
//
if ((tbFCYCR.Text.Trim() != "0" && tbFCYCR.Text.Trim() != "" && tbFCYCR.Text.Trim() != "0.00") || (tbFCYDR.Text.Trim() != "0" && tbFCYDR.Text.Trim() != "" && tbFCYDR.Text.Trim() != "0.00"))
{
model.ISFCY = true;
model.FCYNO = "USD";
}
else
{
model.ISFCY = false;
model.FCYNO = "RMB";
}
//
//插入明细表
if (ds.Tables[0].Rows[0]["AR"].ToString().Trim() == this.hd_comboACCID.Value.Trim())//应收
{
if (model.FCYNO.ToString().Trim() == "RMB")
{
if (ds2 == null)
{
model.ISDEPTACC = false;//核算部门,按规则设置生成
model.ISEMPLACC = false;//核算人员,按规则设置生成
model.ISCORPACC = false;//核算客户,按规则设置生成
model.ISITEMACC = false;//核算项目,按规则设置生成
model.DC = "D";//贷方向
}
else
{
model.ISDEPTACC = Boolean.Parse(ds2.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
model.ISEMPLACC = Boolean.Parse(ds2.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
model.ISCORPACC = Boolean.Parse(ds2.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
model.ISITEMACC = Boolean.Parse(ds2.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds2.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
model.DC = "D";//借方向
}
else
{
model.DC = "C";//贷方向
}
}
}
else if (model.FCYNO.ToString().Trim() == "USD")
{
if (ds6 == null)
{
model.ISDEPTACC = false;//核算部门,按规则设置生成
model.ISEMPLACC = false;//核算人员,按规则设置生成
model.ISCORPACC = false;//核算客户,按规则设置生成
model.ISITEMACC = false;//核算项目,按规则设置生成
model.DC = "C";//贷方向
}
else
{
model.ISDEPTACC = Boolean.Parse(ds6.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
model.ISEMPLACC = Boolean.Parse(ds6.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
model.ISCORPACC = Boolean.Parse(ds6.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
model.ISITEMACC = Boolean.Parse(ds6.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds6.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
model.DC = "D";//借方向
}
else
{
model.DC = "C";//贷方向
}
}
}
model.CORPID = tbCORPID.Text.Trim();//客户(系统)
model.CUSTOMERNAME = this.hd_comboCUSTOMERNAME.Value.Trim();//客户(系统)
}
else if (ds.Tables[0].Rows[0]["AP"].ToString().Trim() == this.hd_comboACCID.Value.Trim())//应付
{
if (model.FCYNO.ToString().Trim() == "RMB")
{
if (ds3 == null)
{
model.CORPID = "";//客户(系统)
model.CUSTOMERNAME = "";//客户(系统)
model.ISDEPTACC = false;//核算部门,按规则设置生成
model.ISEMPLACC = false;//核算人员,按规则设置生成
model.ISCORPACC = false;//核算客户,按规则设置生成
model.ISITEMACC = false;//核算项目,按规则设置生成
model.DC = "C";//贷方向
}
else
{
model.CORPID = tbCORPID.Text.Trim();//客户(系统)
model.CUSTOMERNAME = this.hd_comboCUSTOMERNAME.Value.Trim();//客户(系统)
model.ISCORPACC = Boolean.Parse(ds3.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
model.ISDEPTACC = Boolean.Parse(ds3.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
model.ISEMPLACC = Boolean.Parse(ds3.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
model.ISITEMACC = Boolean.Parse(ds3.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds3.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
model.DC = "D";//借方向
}
else
{
model.DC = "C";//贷方向
}
}
}
else if (model.FCYNO.ToString().Trim() == "USD")
{
if (ds7 == null)
{
model.CORPID = "";//客户(系统)
model.CUSTOMERNAME = "";//客户(系统)
model.ISDEPTACC = false;//核算部门,按规则设置生成
model.ISEMPLACC = false;//核算人员,按规则设置生成
model.ISCORPACC = false;//核算客户,按规则设置生成
model.ISITEMACC = false;//核算项目,按规则设置生成
model.DC = "C";//贷方向
}
else
{
model.CORPID = tbCORPID.Text.Trim();//客户(系统)
model.CUSTOMERNAME = this.hd_comboCUSTOMERNAME.Value.Trim();//客户(系统)
model.ISCORPACC = Boolean.Parse(ds7.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
model.ISDEPTACC = Boolean.Parse(ds7.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
model.ISEMPLACC = Boolean.Parse(ds7.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
model.ISITEMACC = Boolean.Parse(ds7.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds7.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
model.DC = "D";//借方向
}
else
{
model.DC = "C";//贷方向
}
}
}
}
else
{
model.CORPID = tbCORPID.Text.Trim();//客户(系统)
model.CUSTOMERNAME = this.hd_comboCUSTOMERNAME.Value.Trim();//客户(系统)
model.ISDEPTACC = false;//核算部门,按规则设置生成
model.ISEMPLACC = false;//核算人员,按规则设置生成
model.ISCORPACC = false;//核算客户,按规则设置生成
model.ISITEMACC = false;//核算项目,按规则设置生成
model.DC = "C";//贷方向
}
//
model.ORDNO = this.hdORDNO.Value.Trim();
model.ITEMNO = int.Parse(tbITEMNO.Text.Trim());
//model.CORPID = tbCORPID.Text.Trim();
//model.CUSTOMERNAME = this.hd_comboCUSTOMERNAME.Value.Trim();
model.EXPLAN = tbEXPLAN.Text.Trim();
model.ACCID = this.hd_comboACCID.Value.Trim();
model.ACCNAME = tbACCNAME.Text.Trim();
model.SALE = this.hd_comboSALE.Value.Trim();
model.BLNO = tbBLNO.Text.Trim();
//model.ISSYS = true;
model.MODIFIEDUSER = strUserID;
//
model.QTYUNIT = "";
model.QTYDR = 0;
model.QTYCR = 0;
//model.ISDEPTACC = false;
//model.ISEMPLACC = false;
//model.ISCORPACC = false;
//model.ISITEMACC = false;
model.DEPTID = "";
model.EMPLID = "";
model.PITEMID = 0;
model.ITEMID = "0";
model.FIELD10 = "";
model.FIELD9 = "";
model.FIELD8 = "";
model.FIELD7 = "";
model.FIELD6 = "";
model.FIELD5 = "";
model.FIELD4 = "";
model.FIELD3 = "";
model.FIELD2 = "";
model.FIELD1 = "";
model.FSETTLCODE = "";
model.FSETTLENO = "";
model.PACCID = "";
model.PROPERTY = 0;
model.GRADE = 0;
//model.DC = "";
//
int iResult = CwVouitemsDA.Update(model);
if (iResult > 0)
{
CwVouchersDA CwVouchersDA = new CwVouchersDA();
CwVouchersEntity CwVouchersEntity = new CwVouchersEntity();
//
CwVouchersEntity.ORDNO = this.hdORDNO.Value.Trim();
//
string strAMTDR = T_ALL_DA.GetStrSQL("AMTDR", "select sum(AMTDR) as AMTDR from cw_vouitems where ORDNO='" + this.hdORDNO.Value.Trim() + "'");
string strAMTCR = T_ALL_DA.GetStrSQL("AMTCR", "select sum(AMTCR) as AMTCR from cw_vouitems where ORDNO='" + this.hdORDNO.Value.Trim() + "'");
//
if ((strAMTDR.Trim() != "0" && strAMTDR.Trim() != "" && strAMTDR.Trim() != "0.00"))
{
CwVouchersEntity.AMTDR = Decimal.Parse(Decimal.Parse(strAMTDR.Trim()).ToString("F2"));
}
else
{
CwVouchersEntity.AMTDR = 0;
}
//
if ((strAMTCR.Trim() != "0" && strAMTCR.Trim() != "" && strAMTCR.Trim() != "0.00"))
{
CwVouchersEntity.AMTCR = Decimal.Parse(Decimal.Parse(strAMTCR.Trim()).ToString("F2"));
}
else
{
CwVouchersEntity.AMTDR = 0;
}
//
iResult = CwVouchersDA.UpdateAMT(CwVouchersEntity);
//
return true;
}
else
{
return false;
}
}
protected void getEnter(string strF)
{
bool bl = false;
string alt = "";
if (this.hdHandle.Value.Equals("add"))//新增
{
AttributeManage attributeManager = new AttributeManage();
//行号规则
if (tbITEMNO.Text.Trim() == "")
{
tbITEMNO.Text = GetITEMNO();//调用编码规则
}
T_ALL_DA T_ALL_DA = new T_ALL_DA();
alt = T_ALL_DA.GetStrSQL("GID", "select GID from Cw_Vouitems where ORDNO='" + this.hdORDNO.Value.ToString().Trim() + "' and ITEMNO='" + tbITEMNO.Text.Trim() + "'");
if (alt.Trim() != "")
{
tbITEMNO.Text = GetITEMNO();//调用编码规则
}
//
bl = getAdd();
}
else if (this.hdHandle.Value.Equals("addfull"))//新增
{
AttributeManage attributeManager = new AttributeManage();
//行号规则
if (tbITEMNO.Text.Trim() == "")
{
tbITEMNO.Text = GetITEMNO();//调用编码规则
}
T_ALL_DA T_ALL_DA = new T_ALL_DA();
alt = T_ALL_DA.GetStrSQL("GID", "select GID from Cw_Vouitems where ORDNO='" + this.hdORDNO.Value.ToString().Trim() + "' and ITEMNO='" + tbITEMNO.Text.Trim() + "'");
if (alt.Trim() != "")
{
tbITEMNO.Text = GetITEMNO();//调用编码规则
}
//
bl = getAdd();
}
else if (this.hdHandle.Value.Equals("edit"))//录入
{
AttributeManage attributeManager = new AttributeManage();
//行号规则
if (tbITEMNO.Text.Trim() == "")
{
tbITEMNO.Text = GetITEMNO();//调用编码规则
}
T_ALL_DA T_ALL_DA = new T_ALL_DA();
alt = T_ALL_DA.GetStrSQL("GID", "select GID from Cw_Vouitems where ORDNO='" + this.hdORDNO.Value.ToString().Trim() + "' and ITEMNO='" + tbITEMNO.Text.Trim() + "' and GID<>'" + ViewState["GID"].ToString().Trim() + "'");
if (alt.Trim() != "")
{
tbITEMNO.Text = GetITEMNO();//调用编码规则
}
//
bl = getEdit();
}
this.hdEnter.Value = "1";
//
if (bl)
{
ibDel.Enabled = true;
ibAdd.Enabled = true;
ibFullAdd.Enabled = true;
//
if (strF == "adds")
{
string strls = ViewState["GID"].ToString().Trim() + "','" + this.hdHandle.Value.Trim();
Page.ClientScript.RegisterStartupScript(this.GetType(), "key7", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "','adds');</script>");
}
else
{
string strls = ViewState["GID"].ToString().Trim() + "','" + this.hdHandle.Value.Trim();
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "','" + this.hdHandle.Value.Trim() + "');</script>");
}
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key8", "<script>alert('出错,请重新填写!');</script>");
}
}
protected void ibFullAdd_Click(object sender, EventArgs e)
{
getEnter("adds");
this.hdHandle.Value = "addfull";
//ViewState["GID"] = getGID();
//this.hdGid.Value = ViewState["GID"].ToString().Trim();
//
tbITEMNO.Text = "";//调用编码规则
//
ibDel.Enabled = false;
}
protected void ibAdd_Click(object sender, EventArgs e)
{
getEnter("adds");
this.hdHandle.Value = "add";
//ViewState["GID"] = getGID();
//this.hdGid.Value = ViewState["GID"].ToString().Trim();
//
getNull();
//
ibDel.Enabled = false;
}
protected void ibDel_Click(object sender, EventArgs e)
{
CwVouitemsDA CwVouitemsDA = new CwVouitemsDA();
int iResult = CwVouitemsDA.DeleteAll("'"+ViewState["GID"].ToString().Trim()+"'");
if (iResult<0)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key9", "<script>alert('操作出错!');history.back();</script>");
return;
}
//
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = T_ALL_DA.GetStrSQL("gid", "select top 1 gid from [Cw_Vouitems] where GID<>'" + ViewState["GID"].ToString().Trim() + "'");
if (alt.Trim() != "")
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>reloadParent('" + alt + "','del');</script>");
return;
}
//
this.hdHandle.Value = "add";
//ViewState["GID"] = getGID();
//this.hdGid.Value = ViewState["GID"].ToString().Trim();
//
getNull();
//
ibDel.Enabled = false;
}
public bool IsNumeric(string s)
{
int inum = 0;
bool bReturn = true;
try
{
inum = int.Parse(s);
}
catch
{
inum = 0;
bReturn = false;
}
return bReturn;
}
//
}
}