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;
|
|
namespace CY.WebForm.Pages.financial
|
{
|
public partial class FirmAccountIncomeEdit : 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_CorporateClientsBLL _oA_CorporateClientsBLL = null;
|
OA_KaipiaoJineQuerenBLL _oA_KaipiaoJineQuerenBLL = null;
|
|
public FirmAccountIncomeEdit()
|
{
|
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_CorporateClientsBLL = new OA_CorporateClientsBLL();
|
_oA_KaipiaoJineQuerenBLL = new OA_KaipiaoJineQuerenBLL();
|
}
|
|
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()
|
{
|
//科目名称
|
this.selSubject.DataSource = _OA_SubjectSetBLL.getAllSubject(CurrentUser.MemberId, "借");
|
this.selSubject.DataBind();
|
this.selSubject.Items.Insert(0, new ListItem("请选择", ""));
|
this.selSubject.Value = "1";
|
|
///账户类型
|
this.selAcoountType.DataSource = _Sys_DictionaryBLL.GetDataByType("账户类型");
|
this.selAcoountType.DataBind();
|
|
IList<OA_CorporateClients> corporateClients = _oA_CorporateClientsBLL.SelectListByFirmId(CurrentUser.MemberId) as IList<OA_CorporateClients>;
|
if (null != corporateClients)
|
{
|
corporateClients.Where(cc => CurrentUser.MemberId.Equals(cc.MemberId) && corporateClients.Remove(cc));
|
}
|
this.selCustormer.DataSource = corporateClients;
|
this.selCustormer.DataBind();
|
this.selCustormer.Items.Insert(0, new ListItem("请选择", ""));
|
}
|
|
protected string reLoadAccountName(string selAcoountType)
|
{
|
return JsonHelper.GetJsonStringByObject(_OA_FirmAccountBLL.getAllSubject(CurrentUser.MemberId, selAcoountType));
|
}
|
|
protected void btn_Submit_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
var oA_SubjectSet = _OA_SubjectSetBLL.getAllSubject(CurrentUser.MemberId, "借").FirstOrDefault(x=>x.Keyid == selSubject.Value.ToInt32());
|
if(oA_SubjectSet!=null && oA_SubjectSet.SubjectName == "印刷业务收入")
|
{
|
if(!string.IsNullOrEmpty(this.selCustormer.Value) && txtMoney.Value.ToDecimal2() > 0)
|
{
|
//插入未确认收入
|
var a_KaipiaoJineQueren = new OA_KaipiaoJineQueren();
|
a_KaipiaoJineQueren.FirmId = CurrentUser.MemberId;
|
a_KaipiaoJineQueren.BuyerId = this.selCustormer.Value.ToGuid2();
|
var corporateClients = _oA_CorporateClientsBLL.GetModel(a_KaipiaoJineQueren.BuyerId);
|
{
|
if (corporateClients != null)
|
{
|
a_KaipiaoJineQueren.BusinessManagerId = corporateClients.BusinessManagerId;
|
}
|
}
|
|
a_KaipiaoJineQueren.Fukuanmoney = txtMoney.Value.ToDecimal2();
|
a_KaipiaoJineQueren.Hexiaomoney = 0;
|
a_KaipiaoJineQueren.OperationalMatters = txtOperationalMatters.Value;
|
a_KaipiaoJineQueren.Querenstatus = 0;
|
a_KaipiaoJineQueren.Creater = CurrentUser.ShortName;
|
a_KaipiaoJineQueren.CreateTime = DateTime.Now;
|
a_KaipiaoJineQueren.Updater = CurrentUser.ShortName;
|
a_KaipiaoJineQueren.LastUpdateTime = a_KaipiaoJineQueren.CreateTime;
|
|
var a = _oA_KaipiaoJineQuerenBLL.InsertModel(a_KaipiaoJineQueren);
|
}
|
}
|
|
|
firmAccount = _OA_FirmAccountBLL.getSingleSubject(Request["selAccountName"].ToInt32());
|
|
firmAccountRecord.AccountId = Request["selAccountName"].ToInt32();
|
firmAccountRecord.LastUpdateTime = DateTime.Now;
|
firmAccountRecord.Money = txtMoney.Value.ToDecimal2();
|
firmAccountRecord.OperationalMatters = txtOperationalMatters.Value;
|
firmAccountRecord.Operator = CurrentUser.ShortName;
|
firmAccountRecord.PaymentUnit = txtPaymentUnit.Value;
|
firmAccountRecord.RecordTypeId = 1;//收入
|
firmAccountRecord.Remark = txtRemark.Value;
|
firmAccountRecord.SubjectId = selSubject.Value.ToInt32();
|
firmAccountRecord.ResidualAmount = firmAccount.Balance + txtMoney.Value.ToDecimal2();
|
firmAccountRecord.Department = "";
|
|
firmAccount.AllIncome = txtMoney.Value.ToDecimal2() + firmAccount.AllIncome;
|
firmAccount.Balance = firmAccount.Balance + txtMoney.Value.ToDecimal2();
|
|
if (_OA_FirmAccountRecordBLL.AddModel(firmAccountRecord, firmAccount))
|
{
|
this.txtMoney.Value = "";
|
this.txtOperationalMatters.Value = "";
|
this.txtRemark.Value = "";
|
this.txtPaymentUnit.Value = "";
|
JavaScript.MessageBox("添加成功", this, false, true);
|
}
|
else
|
JavaScript.MessageBox("添加失败", this);
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
JavaScript.MessageBox("添加失败", this);
|
}
|
}
|
}
|
}
|