⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 invoiceadd.aspx.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.WebSite.Admin.Shop
{
    using PowerEasy.Common;
    using PowerEasy.Components;
    using PowerEasy.Controls;
    using PowerEasy.ExtendedControls;
    using PowerEasy.Model.Shop;
    using PowerEasy.Shop;
    using PowerEasy.Web.UI;
    using PowerEasy.WebSite.Controls;
    using PowerEasy.WebSite.Controls.Shop;
    using System;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Web.UI.WebControls;

    public class InvoiceAdd : AdminPage
    {
        protected Button BtnReturn;
        protected ExtendedButton BtnSaveInvoice;
        protected DatePicker DpkInvoiceDate;
        protected DropDownList DropInvoiceType;
        protected HiddenField HdnAdminName;
        protected HiddenField HdnClientId;
        protected HiddenField HdnOrderId;
        protected Label LblClientName;
        protected Label LblMoneyReceipt;
        protected Label LblMoneyTotal;
        protected Label LblOrderNum;
        protected Label LblUserName;
        protected SendMessageOfOrder SendMessageOfOrder1;
        protected ExtendedSiteMapPath SmpNavigator;
        protected TextBox TxtDrawer;
        protected TextBox TxtInvoiceContent;
        protected TextBox TxtInvoiceNum;
        protected TextBox TxtInvoiceTitle;
        protected TextBox TxtMemo;
        protected TextBox TxtTotalMoney;
        protected PowerEasy.Controls.RequiredFieldValidator ValrInvoiceDate;
        protected PowerEasy.Controls.RequiredFieldValidator ValrTotalMoney;
        protected DateValidator VdateInvoiceDate;
        protected MoneyValidator VmoneyTotalMoney;

        protected void BtnReturn_Click(object sender, EventArgs e)
        {
            BasePage.ResponseRedirect("OrderManage.aspx?OrderID=" + BasePage.RequestInt32("OrderID"));
        }

        protected void BtnSaveInvoice_Click(object sender, EventArgs e)
        {
            if (base.IsValid)
            {
                decimal num = DataConverter.CDecimal(this.TxtTotalMoney.Text);
                if (num <= 0M)
                {
                    AdminPage.WriteErrMsg("请输入发票总金额!", "");
                }
                else
                {
                    InvoiceInfo invoiceInfo = new InvoiceInfo();
                    int orderId = DataConverter.CLng(this.HdnOrderId.Value);
                    invoiceInfo.ClientId = Convert.ToInt32(this.HdnClientId.Value);
                    invoiceInfo.OrderId = orderId;
                    invoiceInfo.UserName = this.LblUserName.Text;
                    invoiceInfo.InvoiceDate = Convert.ToDateTime(this.DpkInvoiceDate.Text);
                    invoiceInfo.InvoiceType = Convert.ToInt32(this.DropInvoiceType.SelectedValue);
                    invoiceInfo.InvoiceNum = this.TxtInvoiceNum.Text;
                    invoiceInfo.InvoiceTitle = this.TxtInvoiceTitle.Text;
                    invoiceInfo.InvoiceContent = this.TxtInvoiceContent.Text;
                    invoiceInfo.TotalMoney = Convert.ToDecimal(num);
                    invoiceInfo.Drawer = this.TxtDrawer.Text;
                    invoiceInfo.Inputer = this.HdnAdminName.Value;
                    invoiceInfo.Memo = this.TxtMemo.Text;
                    if (Invoice.Add(invoiceInfo))
                    {
                        StringBuilder builder = new StringBuilder();
                        StringBuilder builder2 = new StringBuilder();
                        if (this.SendMessageOfOrder1.NeedSendMessage)
                        {
                            OrderInfo orderById = Order.GetOrderById(orderId);
                            string userName = "";
                            string email = "";
                            StringBuilder builder3 = new StringBuilder();
                            ShowOrderDetail detail = (ShowOrderDetail) this.Page.LoadControl("~/Controls/ShowOrderDetail.ascx");
                            detail.ShowInfo(orderById);
                            builder3.Append(detail.OrderDetailHtml);
                            string orderDetail = builder3.ToString();
                            if (!orderById.IsNull)
                            {
                                userName = orderById.UserName;
                                email = orderById.Email;
                            }
                            if (this.SendMessageOfOrder1.SendMessageToUser)
                            {
                                AbstractMessageOfOrder order = new MessageOfOrder(this.HdnAdminName.Value, userName);
                                order.Implementor = new OrderInvoiceAdd(orderById, orderDetail);
                                order.Send();
                                builder.Append(order.SuccessMsgList);
                                builder2.Append(order.ErrMsgList);
                            }
                            if (this.SendMessageOfOrder1.SendEmailToUser)
                            {
                                AbstractMessageOfOrder order2 = new EmailOfOrder(userName);
                                order2.Implementor = new OrderInvoiceAdd(orderById, orderDetail);
                                order2.Send();
                                builder.Append(order2.SuccessMsgList);
                                builder2.Append(order2.ErrMsgList);
                            }
                            if (this.SendMessageOfOrder1.SendEmailToContacter)
                            {
                                AbstractMessageOfOrder order3 = new EmailOfOrder(SendType.SendToContacter, email);
                                order3.Implementor = new OrderInvoiceAdd(orderById, orderDetail);
                                order3.Send();
                                builder.Append(order3.SuccessMsgList);
                                builder2.Append(order3.ErrMsgList);
                            }
                            if (this.SendMessageOfOrder1.SendSmsToUser)
                            {
                                AbstractMessageOfOrder order4 = new SmsOfOrder("管理员ID:" + PEContext.Current.Admin.AdministratorInfo.AdminId, SendType.SendToUser, orderById);
                                order4.Implementor = new OrderInvoiceAdd(orderById, string.Empty);
                                order4.Send();
                                builder.Append(order4.SuccessMsgList);
                                builder2.Append(order4.ErrMsgList);
                            }
                            if (this.SendMessageOfOrder1.SendSmsToContacter)
                            {
                                AbstractMessageOfOrder order5 = new SmsOfOrder("管理员ID:" + PEContext.Current.Admin.AdministratorInfo.AdminId, SendType.SendToContacter, orderById);
                                order5.Implementor = new OrderInvoiceAdd(orderById, string.Empty);
                                order5.Send();
                                builder.Append(order5.SuccessMsgList);
                                builder2.Append(order5.ErrMsgList);
                            }
                        }
                        string str4 = builder2.ToString();
                        string str5 = builder.ToString();
                        if (!string.IsNullOrEmpty(str4))
                        {
                            AdminPage.WriteErrMsg(str4, "OrderManage.aspx?OrderID=" + orderId);
                        }
                        else
                        {
                            AdminPage.WriteSuccessMsg("成功开具发票!" + str5, "OrderManage.aspx?OrderID=" + orderId);
                        }
                    }
                    else
                    {
                        AdminPage.WriteErrMsg("添加发票记录不成功!");
                    }
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                int orderId = BasePage.RequestInt32("OrderID");
                InvoiceInfo invoiceInfoByOrderId = Invoice.GetInvoiceInfoByOrderId(orderId);
                if (!invoiceInfoByOrderId.IsNull)
                {
                    this.HdnAdminName.Value = PEContext.Current.Admin.AdminName;
                    this.LblClientName.Text = invoiceInfoByOrderId.ClientName;
                    this.HdnClientId.Value = invoiceInfoByOrderId.ClientId.ToString();
                    this.LblUserName.Text = invoiceInfoByOrderId.UserName;
                    this.LblOrderNum.Text = invoiceInfoByOrderId.OrderNum;
                    this.HdnOrderId.Value = Convert.ToString(orderId);
                    this.LblMoneyTotal.Text = invoiceInfoByOrderId.MoneyTotal.ToString("0.00");
                    this.LblMoneyReceipt.Text = invoiceInfoByOrderId.MoneyReceipt.ToString("0.00");
                    this.DpkInvoiceDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
                    this.TxtInvoiceNum.Text = invoiceInfoByOrderId.InvoiceNum;
                    string str = Regex.Match(invoiceInfoByOrderId.InvoiceContent, "发票抬头:(.*)", 3).Groups[1].Value.Replace("发票抬头:", "").Trim();
                    this.TxtInvoiceTitle.Text = string.IsNullOrEmpty(str) ? invoiceInfoByOrderId.ClientName : str;
                    this.TxtInvoiceContent.Text = invoiceInfoByOrderId.InvoiceContent;
                    this.TxtTotalMoney.Text = invoiceInfoByOrderId.MoneyReceipt.ToString("0.00");
                    this.TxtDrawer.Text = this.HdnAdminName.Value;
                    this.ViewState["Email"] = invoiceInfoByOrderId.Email;
                }
                else
                {
                    AdminPage.WriteErrMsg("找不到指定的订单或此订单不需要开发票!", "OrderList.aspx");
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -