1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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);
            }
        }
    }
}