using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Web;
|
using System.Web.UI;
|
using System.Web.UI.WebControls;
|
using CY.Model;
|
using CY.Infrastructure.Common;
|
using CY.BLL.OA;
|
using CY.BLL.Sys;
|
using CY.BLL;
|
using System.Transactions;
|
|
namespace CY.WebForm.Pages.financial
|
{
|
public partial class BaoxiaoFukuanPiliang : BasePage
|
{
|
Sys_DictionaryBLL _Sys_DictionaryBLL = null;
|
OA_SubjectSetBLL _OA_SubjectSetBLL = null;
|
OA_FirmAccountBLL _OA_FirmAccountBLL = null;
|
OA_FirmAccountRecordBLL _OA_FirmAccountRecordBLL = null;
|
OA_FirmAccountRecord firmAccountRecord = null;
|
OA_FirmAccount firmAccount = null;
|
OA_BaozhengjinBLL oA_BaozhengjinBLL = null;
|
OA_StaffBLL staffBLL = null;
|
OA_WorkPlanBll bll_OA_WorkPlanBll = null;
|
OA_DepartmentBll oA_DepartmentBll = null;
|
public BaoxiaoFukuanPiliang()
|
{
|
firmAccount = new OA_FirmAccount();
|
_Sys_DictionaryBLL = new Sys_DictionaryBLL();
|
_OA_FirmAccountBLL = new OA_FirmAccountBLL();
|
_OA_FirmAccountRecordBLL = new OA_FirmAccountRecordBLL();
|
_OA_SubjectSetBLL = new OA_SubjectSetBLL();
|
firmAccountRecord = new OA_FirmAccountRecord();
|
oA_BaozhengjinBLL = new OA_BaozhengjinBLL();
|
staffBLL = new OA_StaffBLL();
|
bll_OA_WorkPlanBll = new OA_WorkPlanBll();
|
oA_DepartmentBll = new OA_DepartmentBll();
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
{
|
try
|
{
|
switch (Request["DataType"])
|
{
|
case "change":
|
Response.Write(reLoadAccountName(Request["TypeName"].ToString2()));
|
break;
|
default://一般情况不处理
|
if (IsPostBack || IsCallback)
|
return;
|
else
|
{
|
InitialData();
|
}
|
return;
|
}
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
Response.Clear();
|
Response.Write("-1");
|
}
|
Response.End();
|
}
|
|
protected void InitialData()
|
{
|
var keyids = Request["keyids"].Trim(',').Split(',');
|
|
///账户类型
|
selAcoountType.DataSource = _Sys_DictionaryBLL.GetDataByType("账户类型");
|
selAcoountType.DataBind();
|
|
|
|
if (keyids.Length > 0)
|
{
|
decimal PlanMoney = 0;
|
foreach (var keyid in keyids)
|
{
|
var oA_WorkPlan = bll_OA_WorkPlanBll.GetModelByKeyid(keyid.ToInt32());
|
PlanMoney += oA_WorkPlan.PlanMoney.Value;
|
}
|
|
|
//this.selSubject.Value = oA_WorkPlan.RewardResult;
|
//this.selSubjectName.Value = oA_WorkPlan.RewardContent;
|
this.txtMoney.Value = PlanMoney.ToString("0.00");
|
//this.txtPaymentUnit.Value = oA_WorkPlan.PlanPeople;
|
//var oA_Department = oA_DepartmentBll.GetModelByKeyid(oA_WorkPlan.DepartId);
|
//if (oA_Department != null)
|
// this.txtDepartment.Value = oA_Department.Name;
|
//this.txtOperationalMatters.Value = oA_WorkPlan.PlanContent;
|
}
|
|
}
|
|
protected string reLoadAccountName(string selAcoountType)
|
{
|
return JsonHelper.GetJsonStringByObject(_OA_FirmAccountBLL.getAllSubject(CurrentUser.MemberId, selAcoountType));
|
}
|
|
protected void btn_Submit_Click(object sender, EventArgs e)
|
{
|
var keyids = Request["keyids"].Trim(',').Split(',');
|
|
|
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required,
|
new TransactionOptions
|
{
|
IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted,
|
Timeout = TransactionManager.MaximumTimeout
|
}
|
)
|
)
|
{
|
|
try
|
{
|
firmAccount = _OA_FirmAccountBLL.getSingleSubject(Request["selAccountName"].ToInt32());
|
foreach (var keyid in keyids)
|
{
|
var oA_WorkPlan = bll_OA_WorkPlanBll.GetModelByKeyid(keyid.ToInt32());
|
if (oA_WorkPlan.EvaluationStatus == 1)
|
{
|
JavaScript.MessageBox(oA_WorkPlan.EvaluationContent + "该报销已经付款,不能重复付款", this);
|
return;
|
}
|
firmAccountRecord = new OA_FirmAccountRecord();
|
|
firmAccountRecord.AccountId = Request["selAccountName"].ToInt32();
|
firmAccountRecord.LastUpdateTime = DateTime.Now;
|
firmAccountRecord.Money = oA_WorkPlan.PlanMoney;//this.txtMoney.Value.ToDecimal2();
|
firmAccountRecord.OperationalMatters = oA_WorkPlan.PlanContent;// this.txtOperationalMatters.Value;
|
firmAccountRecord.Operator = CurrentUser.ShortName;
|
firmAccountRecord.PaymentUnit = oA_WorkPlan.PlanPeople; //this.txtPaymentUnit.Value;
|
firmAccountRecord.RecordTypeId = 2;//支出
|
firmAccountRecord.Remark = this.txtRemark.Value;
|
firmAccountRecord.SubjectId = oA_WorkPlan.RewardResult.ToInt32(); //this.selSubject.Value.ToInt32();
|
firmAccountRecord.ResidualAmount = firmAccount.Balance - oA_WorkPlan.PlanMoney; //this.txtMoney.Value.ToDecimal2();
|
var oA_Department = oA_DepartmentBll.GetModelByKeyid(oA_WorkPlan.DepartId);
|
if (oA_Department != null)
|
firmAccountRecord.Department = oA_Department.Name; //this.txtDepartment.Value;
|
|
firmAccount.AllExpenses = oA_WorkPlan.PlanMoney/*this.txtMoney.Value.ToDecimal2()*/ + firmAccount.AllExpenses;
|
firmAccount.Balance = firmAccount.Balance - oA_WorkPlan.PlanMoney;// this.txtMoney.Value.ToDecimal2();
|
|
if (_OA_FirmAccountRecordBLL.AddModel(firmAccountRecord, firmAccount))
|
{
|
//修改OA_WorkPlan的状态未已报销
|
|
if (keyid.ToInt32() > 0)
|
{
|
|
oA_WorkPlan.EvaluationStatus = 1;
|
oA_WorkPlan.Operator = CurrentUser.ShortName;
|
oA_WorkPlan.LastUpdateTime = DateTime.Now;
|
var res = bll_OA_WorkPlanBll.UpdateModel(oA_WorkPlan);
|
}
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
scope.Complete();
|
JavaScript.MessageBox("添加成功", this, true, true);
|
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
JavaScript.MessageBox("添加失败", this);
|
}
|
finally
|
{
|
// 释放资源
|
scope.Dispose();
|
}
|
}
|
}
|
}
|
}
|