📄 addpayment.aspx.cs
字号:
namespace PowerEasy.WebSite.Admin.Crm
{
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.Controls;
using PowerEasy.Crm;
using PowerEasy.Enumerations;
using PowerEasy.Model.Crm;
using PowerEasy.Model.Shop;
using PowerEasy.Shop;
using PowerEasy.Web.UI;
using System;
using System.Web.UI.WebControls;
public class AddPayment : AdminPage
{
protected Button BtnCancel;
protected HiddenField HdnClientId;
protected ExtendedSiteMapPath SmpNavigator;
protected TextBox TxtBalance;
protected TextBox TxtClientName;
protected TextBox TxtMemo;
protected TextBox TxtMoney;
protected TextBox TxtRemark;
protected Button TxtSave;
protected PowerEasy.Controls.RequiredFieldValidator ValrMoney;
protected PowerEasy.Controls.RequiredFieldValidator ValrRemark;
protected MoneyValidator VmoneyTxtMoney;
protected void BtnCancel_Click(object sender, EventArgs e)
{
BasePage.ResponseRedirect("ClientShow.aspx?ClientID=" + this.HdnClientId.Value);
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
int clientId = BasePage.RequestInt32("ClientID");
this.ShowInitialize(clientId);
}
}
protected void ShowInitialize(int clientId)
{
this.HdnClientId.Value = clientId.ToString();
ClientInfo clientById = Client.GetClientById(clientId);
if (!clientById.IsNull)
{
if (clientById.Balance <= 0M)
{
AdminPage.WriteErrMsg("该客户的资金余额不足!", "ClientShow.aspx?ClientID=" + clientId);
}
else
{
this.TxtClientName.Text = clientById.ClientName;
this.TxtBalance.Text = clientById.Balance.ToString();
}
int orderId = BasePage.RequestInt32("OrderID");
if (orderId > 0)
{
OrderInfo orderById = Order.GetOrderById(orderId);
this.ValidateOrder(orderById);
decimal balance = orderById.MoneyTotal - orderById.MoneyReceipt;
if (clientById.Balance <= balance)
{
balance = clientById.Balance;
}
this.TxtRemark.Text = "支付订单费用。订单号:" + orderById.OrderNum;
}
}
else
{
AdminPage.WriteErrMsg("未找到该客户的相关信息!", "ClientManage.aspx");
}
}
protected void TxtSave_Click(object sender, EventArgs e)
{
if (this.Page.IsValid)
{
int clientId = DataConverter.CLng(this.HdnClientId.Value);
decimal money = DataConverter.CDecimal(this.TxtMoney.Text);
decimal num3 = DataConverter.CDecimal(this.TxtBalance.Text);
if ((num3 != 0M) && (num3 >= money))
{
string text = this.TxtRemark.Text;
int orderId = BasePage.RequestInt32("OrderID");
if (orderId > 0)
{
OrderInfo orderInfo = new OrderInfo();
orderInfo = Order.GetOrderById(orderId);
this.ValidateOrder(orderInfo);
orderInfo.MoneyReceipt += money;
if (orderInfo.Status <= OrderStatus.WaitForConfirm)
{
orderInfo.Status = OrderStatus.Confirmed;
}
if (!Order.UserPayment(orderInfo.OrderId, orderInfo.MoneyReceipt, orderInfo.Status))
{
AdminPage.WriteErrMsg("<li>更改支出订单失败!</li>", "../Shop/OrderManage.aspx?OrderID=" + orderInfo.OrderId);
}
}
if (Client.Payment(clientId, money, text, PEContext.Current.Admin.AdminName, this.TxtMemo.Text))
{
AdminPage.WriteSuccessMsg("添加客户支出成功!", "ClientShow.aspx?ClientID=" + clientId + "&InfoType=3");
}
else
{
AdminPage.WriteErrMsg("<li>添加客户支出失败!</li>");
}
}
else
{
AdminPage.WriteErrMsg("<li>支出金额不能大于客户资金余额!</li>");
}
}
}
private void ValidateOrder(OrderInfo orderInfo)
{
if (orderInfo.IsNull)
{
AdminPage.WriteErrMsg("<li>找不到指定的订单!</li>", "../Shop/OrderManage.aspx?OrderID=" + orderInfo.OrderId);
}
else if (orderInfo.MoneyTotal <= orderInfo.MoneyReceipt)
{
AdminPage.WriteErrMsg("<li>此订单已经付清,无需再支付!</li>", "../Shop/OrderManage.aspx?OrderID=" + orderInfo.OrderId);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -