using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Web;
|
using System.Web.UI;
|
using System.Web.UI.WebControls;
|
using CY.BLL;
|
using CY.BLL.Sys;
|
using CY.Infrastructure.Query;
|
using CY.Infrastructure.Common;
|
using CY.Model;
|
using CY.BLL.OA;
|
|
namespace CY.WebForm.Pages.financial
|
{
|
//吴辉
|
//账户转账
|
public partial class AccountOtoO : BasePage
|
{
|
Sys_DictionaryBLL _Sys_DictionaryBLL = null;
|
OA_SubjectSetBLL _OA_SubjectSetBLL = null;
|
OA_FirmAccountBLL _OA_FirmAccountBLL = null;
|
OA_FirmAccountRecordBLL _OA_FirmAccountRecordBLL = null;
|
|
//初始化
|
public AccountOtoO()
|
{
|
_Sys_DictionaryBLL = new Sys_DictionaryBLL();
|
_Sys_DictionaryBLL = new Sys_DictionaryBLL();
|
_OA_FirmAccountBLL = new OA_FirmAccountBLL();
|
_OA_FirmAccountRecordBLL = new OA_FirmAccountRecordBLL();
|
_OA_SubjectSetBLL = new OA_SubjectSetBLL();
|
}
|
|
//页面加载
|
protected void Page_Load(object sender, EventArgs e)
|
{
|
if (!IsPostBack)
|
{
|
BindList();
|
}
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
private void BindList()
|
{
|
try
|
{
|
//科目名称
|
this.selSubject.DataSource = _OA_SubjectSetBLL.getAllSubject(CurrentUser.MemberId, "");
|
this.selSubject.DataBind();
|
this.selSubject.Items.Insert(0, new ListItem("请选择", ""));
|
|
//账户类型
|
this.selAcoountTypeOut.DataSource = _Sys_DictionaryBLL.GetDataByType("账户类型");
|
this.selAcoountTypeOut.DataBind();
|
|
//账户类型
|
this.selAcoountTypeIn.DataSource = _Sys_DictionaryBLL.GetDataByType("账户类型");
|
this.selAcoountTypeIn.DataBind();
|
|
this.txtOperatMoney.Value = "";
|
this.txtRemark.Value = "";
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
}
|
}
|
|
//提交表单
|
protected void btn_Submit_form(object sender, EventArgs e)
|
{
|
try
|
{
|
int? SubjectId = this.selSubject.Value.ToInt32();
|
decimal? money = this.txtOperatMoney.Value.ToDecimal2();
|
|
int? AccountIdIn = Request["selAccountNameIn"].ToInt32();
|
|
int? AccountIdOut = Request["selAccountNameOut"].ToInt32();
|
|
if (SubjectId == null || money == null || AccountIdIn == null || AccountIdOut == null)
|
JavaScript.MessageBox("操作失败", this);
|
else if(AccountIdIn == AccountIdOut)
|
JavaScript.MessageBox("同一账户不能转账",this);
|
else
|
{
|
DateTime nowTime = DateTime.Now;
|
OA_SubjectSet m_OA_SubjectSet = _OA_SubjectSetBLL.getSingleSubject(SubjectId);
|
|
OA_FirmAccount m_OA_FirmAccountIn = _OA_FirmAccountBLL.getSingleSubject(AccountIdIn);
|
OA_FirmAccount m_OA_FirmAccountOut = _OA_FirmAccountBLL.getSingleSubject(AccountIdOut);
|
|
if (m_OA_FirmAccountOut.Balance < money)
|
{
|
JavaScript.MessageBox("转出金额不能大于转出账户的余额", this);
|
|
}
|
else
|
{
|
m_OA_FirmAccountIn.AllIncome += money;
|
m_OA_FirmAccountIn.Balance += money;
|
m_OA_FirmAccountIn.LastUpdateTime = nowTime;
|
m_OA_FirmAccountIn.Operator = CurrentUser.ShortName;
|
|
m_OA_FirmAccountOut.AllExpenses += money;
|
m_OA_FirmAccountOut.Balance -= money;
|
m_OA_FirmAccountOut.LastUpdateTime = nowTime;
|
m_OA_FirmAccountOut.Operator = CurrentUser.ShortName;
|
|
|
|
OA_FirmAccountRecord m_OA_FirmAccountRecordIn = new OA_FirmAccountRecord();
|
m_OA_FirmAccountRecordIn.AccountId = m_OA_FirmAccountIn.Keyid;
|
m_OA_FirmAccountRecordIn.RecordTypeId = 1;//支出
|
m_OA_FirmAccountRecordIn.Money = money;
|
m_OA_FirmAccountRecordIn.SubjectId = m_OA_SubjectSet.Keyid;
|
m_OA_FirmAccountRecordIn.OperationalMatters = "账户转账";
|
m_OA_FirmAccountRecordIn.PaymentUnit = m_OA_FirmAccountOut.AccountName + "-" + m_OA_FirmAccountOut.UserName;
|
m_OA_FirmAccountRecordIn.LastUpdateTime = nowTime;
|
m_OA_FirmAccountRecordIn.Operator = CurrentUser.ShortName.ToString2();
|
m_OA_FirmAccountRecordIn.Remark = this.txtRemark.Value.ToString2();
|
m_OA_FirmAccountRecordIn.ResidualAmount = m_OA_FirmAccountIn.Balance;
|
m_OA_FirmAccountRecordIn.Department = "";
|
|
OA_FirmAccountRecord m_OA_FirmAccountRecordOut = new OA_FirmAccountRecord();
|
m_OA_FirmAccountRecordOut.AccountId = m_OA_FirmAccountOut.Keyid;
|
m_OA_FirmAccountRecordOut.RecordTypeId = 2;//支出
|
m_OA_FirmAccountRecordOut.Money = money;
|
m_OA_FirmAccountRecordOut.SubjectId = m_OA_SubjectSet.Keyid;
|
m_OA_FirmAccountRecordOut.OperationalMatters = "账户转账";
|
m_OA_FirmAccountRecordOut.PaymentUnit = m_OA_FirmAccountIn.AccountName + "-" + m_OA_FirmAccountIn.UserName;
|
m_OA_FirmAccountRecordOut.LastUpdateTime = nowTime;
|
m_OA_FirmAccountRecordOut.Operator = CurrentUser.ShortName.ToString2();
|
m_OA_FirmAccountRecordOut.Remark = this.txtRemark.Value.ToString2();
|
m_OA_FirmAccountRecordOut.ResidualAmount = m_OA_FirmAccountOut.Balance;
|
m_OA_FirmAccountRecordOut.Department = "";
|
|
if (_OA_FirmAccountRecordBLL.AccountOToO(m_OA_FirmAccountIn, m_OA_FirmAccountOut, m_OA_FirmAccountRecordIn, m_OA_FirmAccountRecordOut))
|
{
|
BindList();
|
JavaScript.MessageBox("操作成功", this);
|
}
|
else
|
JavaScript.MessageBox("操作失败", this);
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
JavaScript.MessageBox("操作失败", this);
|
}
|
}
|
}
|
}
|