username@email.com
2025-05-15 6fe02a16e55f17e45a3997171e1b2284d45af25b
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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 DepositsCustomer : BasePage
    {
        OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = null;
        Sys_DictionaryBLL _Sys_DictionaryBLL = null;
        OA_AdvanceMoneyRecordBLL bll_OA_AdvanceMoneyRecordBLL = null;
        OA_SubjectSetBLL _OA_SubjectSetBLL = null;
        OA_FirmAccountBLL _OA_FirmAccountBLL = null;
        OA_FirmAccountRecordBLL _OA_FirmAccountRecordBLL = null;
 
        //初始化
        public DepositsCustomer()
        {
            _Sys_DictionaryBLL = new Sys_DictionaryBLL();
            bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
            bll_OA_AdvanceMoneyRecordBLL = new OA_AdvanceMoneyRecordBLL();
            _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();
            }
        }
 
        //绑定数据
        private void BindList()
        {
            try
            {
                //科目名称
                //selSubject.DataSource = _OA_SubjectSetBLL.getAllSubject(CurrentUser.MemberId, "借");
                //selSubject.DataBind();
                //selSubject.Items.Insert(0, new ListItem("请选择", ""));
 
                //账户类型
                this.selAcoountType.DataSource = _Sys_DictionaryBLL.GetDataByType("账户类型");
                this.selAcoountType.DataBind();
 
                //账户信息
                OA_CorporateClients m_OA_CorporateClients = bll_OA_CorporateClientsBLL.GetModel(Request["Keyid"].ToGuid2());
                this.spanCustomName.InnerText = m_OA_CorporateClients.CompanyName;
                this.spanCustomMoney.InnerText = "¥ " + m_OA_CorporateClients.Prepayments.ToDecimal2Yen();
 
                //分页信息
                Pagination pa = new Pagination();
                DateTime? beginTime = null;
                DateTime? endTime = null;
                pa.PageSize = UCPager1.AspNetPager.PageSize;
                pa.PageIndex = UCPager1.AspNetPager.CurrentPageIndex;
                this.RepClientList.DataSource = bll_OA_AdvanceMoneyRecordBLL.GetModelPageListForCustomer(pa, Request["Keyid"].ToGuid2(),
                    string.IsNullOrEmpty(this.txtRegTimeStart.Value) ? beginTime : Convert.ToDateTime(this.txtRegTimeStart.Value),
                    string.IsNullOrEmpty(this.txtRegTimeEnd.Value) ? endTime : Convert.ToDateTime(this.txtRegTimeEnd.Value),
                    spanMoneyw.Value.ToString());
                this.RepClientList.DataBind();
                UCPager1.AspNetPager.RecordCount = pa.RecordCount;
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
            }
        }
 
        //分页事件
        protected void AspNetPager1_PageChanged(object src, EventArgs e)
        {
            BindList();
        }
 
        //提交表单
        protected void btn_Submit_Deposits(object sender, EventArgs e)
        {
            try
            {
                int? SubjectId = 0; // 客户预付款
                string AccountType = this.selAcoountType.Value.ToString2();
                int? AccountId = Request["selAccountName"].ToInt32();
                decimal? money = this.txtOperatMoney.Value.ToDecimal2();
                if (SubjectId == null || string.IsNullOrEmpty(AccountType) || AccountId == null || money == null)
                    JavaScript.MessageBox("操作失败", this);
                else
                {
                    //OA_SubjectSet m_OA_SubjectSet = _OA_SubjectSetBLL.getSingleSubject(SubjectId);
 
                    OA_FirmAccount m_OA_FirmAccount = _OA_FirmAccountBLL.getSingleSubject(AccountId);
                    if (money > 0)
                    {
                        m_OA_FirmAccount.AllIncome += money;
                    }
                    else
                    {
                        m_OA_FirmAccount.AllExpenses += money;
                    }
                    m_OA_FirmAccount.Balance += money;
                    m_OA_FirmAccount.LastUpdateTime = DateTime.Now;
                    m_OA_FirmAccount.Operator = CurrentUser.ShortName;
 
                    OA_CorporateClients m_OA_CorporateClients = bll_OA_CorporateClientsBLL.GetModel(Request["Keyid"].ToGuid2());
                    m_OA_CorporateClients.Prepayments += money;
                    m_OA_CorporateClients.Operator = CurrentUser.ShortName;
                    m_OA_CorporateClients.LastUpdateTime = DateTime.Now;
 
                    OA_FirmAccountRecord m_OA_FirmAccountRecord = new OA_FirmAccountRecord();
                    m_OA_FirmAccountRecord.AccountId = m_OA_FirmAccount.Keyid;
                    m_OA_FirmAccountRecord.RecordTypeId = money > 0 ? 1 : 2;//收入
                    m_OA_FirmAccountRecord.Money = Math.Abs(money.Value);
                    m_OA_FirmAccountRecord.SubjectId = 0;
                    m_OA_FirmAccountRecord.OperationalMatters = money > 0 ? "客户预付款存入" : "客户预付款存入(负)";
                    m_OA_FirmAccountRecord.PaymentUnit = m_OA_CorporateClients.CompanyName;
                    m_OA_FirmAccountRecord.LastUpdateTime = DateTime.Now;
                    m_OA_FirmAccountRecord.Operator = CurrentUser.ShortName.ToString2();
                    m_OA_FirmAccountRecord.Remark = this.txtRemark.Value.ToString2();
                    m_OA_FirmAccountRecord.ResidualAmount = m_OA_FirmAccount.Balance;
                    m_OA_FirmAccountRecord.Department = "";
 
                    OA_AdvanceMoneyRecord m_OA_AdvanceMoneyRecord = new OA_AdvanceMoneyRecord();
                    m_OA_AdvanceMoneyRecord.CustomerId = m_OA_CorporateClients.Keyid;
                    m_OA_AdvanceMoneyRecord.OperatTypeId = _Sys_DictionaryBLL.GetNameByMeanValue(1, "客户预付款明细类型");
                    m_OA_AdvanceMoneyRecord.OperatMoney = money;
                    m_OA_AdvanceMoneyRecord.SubjectName = money > 0 ? "预付款收入" : "预付款收入(负)";
                    m_OA_AdvanceMoneyRecord.AccountType = AccountType;
                    m_OA_AdvanceMoneyRecord.AccountName = m_OA_FirmAccount.AccountName + "-" + m_OA_FirmAccount.UserName;
                    m_OA_AdvanceMoneyRecord.LastUpdateTime = DateTime.Now;
                    m_OA_AdvanceMoneyRecord.Operator = CurrentUser.ShortName.ToString2();
                    m_OA_AdvanceMoneyRecord.Remark = this.txtRemark.Value.ToString2();
 
                    if (bll_OA_AdvanceMoneyRecordBLL.DepositsMoney(m_OA_FirmAccount, m_OA_CorporateClients, m_OA_FirmAccountRecord, m_OA_AdvanceMoneyRecord))
                    {
                        BindList();
                        JavaScript.MessageBox("存入成功", this, true, true);
                    }
                    else
                        JavaScript.MessageBox("操作失败", this);
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
            }
        }
 
        protected void btn_Query_Deposits(object sender, EventArgs e)
        {
            try
            {
                BindList();
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
            }
        }
    }
}