using System; using System.Collections; using System.Configuration; using System.Data; 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 DSWeb.Models; using DSWeb.EntityDA; using System.Collections.Generic; namespace DSWeb.Settlements { public partial class CommonRecvApplicationSettlement : System.Web.UI.Page { private string strAppID;//收费申请表GID private string strBillNO;//申请单号 private string strUserID;//用户GID private int iSettleStatus = 0;//结算状态 值为1表示进行本次收费结算 private string strModuleName;//模块名称 private string strCompanyID;//公司GID private string strShowName;//用户显示名 private string strDeptName;//部门名称 protected void Page_Load(object sender, EventArgs e) { if (Session["USERID"] != null) { strUserID = Session["USERID"].ToString(); } if (Session["SHOWNAME"] != null) { strShowName = Session["SHOWNAME"].ToString(); } if (Session["COMPANYID"] != null) { strCompanyID = Session["COMPANYID"].ToString(); } if (Session["DEPTNAME"] != null) { strDeptName = Session["DEPTNAME"].ToString(); } if (Request.QueryString["id"] != null) { strAppID = Request.QueryString["id"].ToString(); this.h_id.Value = strAppID; ChFeeRecvApplicationDA ChFeeRecvApplicationDA = new ChFeeRecvApplicationDA(); ChFeeRecvApplicationEntity ChFeeRecvApplicationEntity = new ChFeeRecvApplicationEntity(); ChFeeRecvApplicationEntity = ChFeeRecvApplicationDA.GetModel(strAppID); if (ChFeeRecvApplicationEntity.GID != null) { int iBillStatus = ChFeeRecvApplicationEntity.BILLSTATUS; string strBillStatus = ""; switch (iBillStatus) { case 1: strBillStatus = "未提交"; break; case 2: strBillStatus = "已提交"; break; case 3: strBillStatus = "审批中"; break; case 4: strBillStatus = "已结算"; break; case 5: strBillStatus = "部分结算"; break; case 6: strBillStatus = "审核驳回"; break; default: strBillStatus = "已审批"; break; } this.txt_billStatus.Value = strBillStatus; this.txt_applyTime.Value = ChFeeRecvApplicationEntity.APPLYTIME.ToString();//申请时间 UserDA UserDA = new UserDA(); UserEntity userEntity = UserDA.GetUserSignByID(ChFeeRecvApplicationEntity.APPLICANT); this.txt_applicant.Value = userEntity.ShowName;//申请人 this.txt_customerName.Value = ChFeeRecvApplicationEntity.CUSTOMERNAME;//结算单位 this.txt_chequePayable.Value = ChFeeRecvApplicationEntity.INVOICETITLE;//发票抬头 this.sel_settlemode.Value = ChFeeRecvApplicationEntity.SETTLETYPE.ToString();//结算方式 this.txt_payableDate.Value = ChFeeRecvApplicationEntity.RECVTIME == DateTime.MinValue ? "" : ChFeeRecvApplicationEntity.RECVTIME.ToString("yyyy-MM-dd");//要求结算时间 } } if (Request.QueryString["billno"] != null) { strBillNO = Request.QueryString["billno"].ToString(); this.txt_billNO.Value = strBillNO; this.h_billno.Value = strBillNO; } if (Request.QueryString["mod"] != null) { strModuleName = Request.QueryString["mod"].ToString(); h_mod.Value = strModuleName; } if (Session["USERID"] != null) { strUserID = Session["USERID"].ToString(); this.h_user.Value = strUserID; } if (!this.h_settle.Value.Trim().Equals("")) { int iResult = 0; iSettleStatus = int.Parse(this.h_settle.Value.Trim()); if (iSettleStatus == 1) { string strSettleBillNO = this.h_billno.Value.Trim(); //先获取所有申请费用信息,通过ch_fee_do表获取BILLNO下所有费用信息到实体类 FeeDoDA feeDoDA = new FeeDoDA(); IList feeDoEntities = new List(); feeDoEntities = feeDoDA.GetFeeDoByBillNO(strSettleBillNO); if (feeDoEntities.Count > 0) { ChFeeRecvApplicationEntity ChFeeRecvApplicationEntity = new ChFeeRecvApplicationEntity(); ChFeeRecvApplicationDA ChFeeRecvApplicationDA = new ChFeeRecvApplicationDA(); ChFeeRecvApplicationEntity = ChFeeRecvApplicationDA.GetModel(strSettleBillNO, strCompanyID); FeeSettlementEntity feeSettlementEntity = new FeeSettlementEntity(); if (ChFeeRecvApplicationEntity.GID != null) { //ch_fee_payapplication ChFeeRecvApplicationEntity.SETTLERMB = ChFeeRecvApplicationEntity.AMOUNTRMB; ChFeeRecvApplicationEntity.SETTLEUSD = ChFeeRecvApplicationEntity.AMOUNTUSD; ChFeeRecvApplicationEntity.SETTLERATE = ChFeeRecvApplicationEntity.RATE; ChFeeRecvApplicationEntity.SETTLEUSER = strUserID; if (this.txt_applyTime.Value.Trim() != "" && this.txt_applyTime.Value.Trim().IndexOf("0001") < 0) { ChFeeRecvApplicationEntity.SETTLETIME = DateTime.Parse(this.txt_applyTime.Value.Trim()); } ChFeeRecvApplicationEntity.BILLSTATUS = 4; //ch_fee_settlement feeSettlementEntity.GID = Guid.NewGuid().ToString(); feeSettlementEntity.BillNO = strSettleBillNO; feeSettlementEntity.SettleMode = 2; feeSettlementEntity.CustomerName = this.txt_customerName.Value.Trim(); feeSettlementEntity.AmountRMB = ChFeeRecvApplicationEntity.AMOUNTRMB; feeSettlementEntity.Rate = ChFeeRecvApplicationEntity.RATE; feeSettlementEntity.AmountUSD = ChFeeRecvApplicationEntity.AMOUNTUSD; feeSettlementEntity.BillType = 2; feeSettlementEntity.SettleUser = strUserID; feeSettlementEntity.BillStatus = 1; feeSettlementEntity.CompanyID = strCompanyID; feeSettlementEntity.AuditUser = strUserID; //预收预付自由结算时,赋值 feeSettlementEntity.ACCOUNTS_CURRENCY = (feeSettlementEntity.AmountUSD == 0) ? "RMB" : "USD";//记账资料_币别 feeSettlementEntity.ACCOUNTS_RATE = feeSettlementEntity.Rate;//记账资料_汇率 feeSettlementEntity.ACCOUNTS_MONEY = (feeSettlementEntity.AmountUSD == 0) ? feeSettlementEntity.AmountRMB : feeSettlementEntity.AmountUSD;//记账资料_金额 feeSettlementEntity.PREPAY_CURRENCY = (feeSettlementEntity.AmountUSD == 0) ? "RMB" : "USD";//预付支资料_币别 feeSettlementEntity.PREPAY_RATE = feeSettlementEntity.Rate;//预付支资料_汇率 feeSettlementEntity.PREPAY_MONEY = 0;//预付支资料_金额 feeSettlementEntity.AHSR_CURRENCY = (feeSettlementEntity.AmountUSD == 0) ? "RMB" : "USD";//实付支资料_币别 feeSettlementEntity.AHSR_RATE = feeSettlementEntity.Rate;//实付支资料_汇率 feeSettlementEntity.AHSR_MONEY = (feeSettlementEntity.AmountUSD == 0) ? feeSettlementEntity.AmountRMB : feeSettlementEntity.AmountUSD;//实付支资料_金额 feeSettlementEntity.FINANCIAL_CURRENCY = (feeSettlementEntity.AmountUSD == 0) ? "RMB" : "USD";//财务费用_币别 feeSettlementEntity.FINANCIAL_RATE = feeSettlementEntity.Rate;//财务费用_汇率 feeSettlementEntity.FINANCIAL_MONEY = 0;//财务费用_金额 feeSettlementEntity.ADVANCE_CURRENCY = (feeSettlementEntity.AmountUSD == 0) ? "RMB" : "USD";//预付支取用资料_币别 feeSettlementEntity.ADVANCE_RATE = feeSettlementEntity.Rate;//预付支取用资料_汇率 feeSettlementEntity.ADVANCE_MONEY = 0;//预付支取用资料_金额 } FeeDA feeDA = new FeeDA(); IList feeEntities = new List(); foreach (FeeDoEntity tempFeeDoEntity in feeDoEntities) { FeeEntity feeEntity = new FeeEntity(); feeEntity = feeDA.GetFeeByID(tempFeeDoEntity.FeeID); feeEntities.Add(feeEntity); } FeeRecvSettleDA FeeRecvSettleDA = new EntityDA.FeeRecvSettleDA(); iResult = FeeRecvSettleDA.SettleFeeRecvApplication(feeSettlementEntity, ChFeeRecvApplicationEntity, feeDoEntities, strCompanyID, strUserID, null, null); } if (iResult > 0) { this.btn_settle.Disabled = true; this.h_settle.Value = "0"; } } } } } }