📄 invoice.aspx.cs
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using Shop.Web.UI;
namespace YXShop.Web.Admin.Orders
{
public partial class invoice : System.Web.UI.Page
{
public static string orderId = "";
private static decimal orderPrice = 0;
private decimal outPrice = 0;
private static decimal remiPrice = 0;
private static decimal paymPrice = 0;
private static decimal prepPrice = 0;
YXShop.BLL.Orders bll = new YXShop.BLL.Orders();
YXShop.BLL.InvoiceItem invoBll = new YXShop.BLL.InvoiceItem();
YXShop.BLL.InvoiceManage invoMBll = new YXShop.BLL.InvoiceManage();
YXShop.BLL.RemittanceInfo Remibll = new YXShop.BLL.RemittanceInfo();//银行支付
YXShop.BLL.PaymentMoney paymbll = new YXShop.BLL.PaymentMoney();//现金支付
YXShop.BLL.PrepayMoney prepbll = new YXShop.BLL.PrepayMoney();//预付款支付
BasePage bp = null;
protected void Page_Load(object sender, EventArgs e)
{
//是不是管理员
if (!PowerTree.PowerPass.isPass("003003002", PowerTree.PowerPanel.PowerType.add))
{
bp = new BasePage();
bp.PageError("对不起,你没有开发票的权限!", "../index.aspx");
}
saveInfo.Attributes.Add("onclick", "confirm('你确定保存发票信息吗?')");
if ((!IsPostBack) || ((Request["Event"] != null) && (Request["Event"] != "")))
{
//初始化信息(订单信息,银行信息,支付信息)
if (!string.IsNullOrEmpty(Request.QueryString["OrderID"]))
{
//bindOrderInfo(YXShop.Common.WebUtility.replaceStr(Request.QueryString["OrderID"]));
orderId = YXShop.Common.WebUtility.replaceStr(Request.QueryString["OrderID"]);
bindOrderInfo(orderId);
bindInvoice(DropDownList1);
}
else
{
Response.Redirect("orderList.aspx");
}
}
}
/// <summary>
/// 绑定订单数据及其它
/// </summary>
/// <param name="orderID"></param>
private void bindOrderInfo(string orderID)
{
List<YXShop.Model.Orders> li = bll.GetListByColumn("OrderID", orderID);
YXShop.Model.RemittanceInfo bankModel = Remibll.GetModel(orderId);
YXShop.Model.PaymentMoney paymModel = paymbll.GetModel(orderId);
YXShop.Model.PrepayMoney prepModel = prepbll.GetModel(orderId);
if (li.Count == 1)
{
orderPrice = Convert.ToDecimal(li[0].FactPrice);//实际订单价
remiPrice = Convert.ToDecimal(bankModel != null ? bankModel.RemittanceMoney : 0);
paymPrice = Convert.ToDecimal(paymModel != null ? paymModel.GatheringMoney : 0);
prepPrice = Convert.ToDecimal(prepModel != null ? prepModel.PayoutMoney : 0);
Label1.Text = li[0].ConsigneeName;
//Label2.Text = li[0].ConsigneeRealName;
myuser.Text = li[0].ConsigneeRealName;
myuser.NavigateUrl = "~/Admin/Consumer/MemberInfo.aspx?Pro_ID=" + li[0].UserId;
Label3.Text = li[0].OrderId;
Label4.Text = orderPrice.ToString();
Label5.Text = (remiPrice + paymPrice + prepPrice).ToString();//已经支付
TextBox2.Text = li[0].Remark;
TextBox8.Text = string.Format("发票抬头: 我的发票\n商品名称: 商品名称\n发票金额:" + orderPrice + "元");
TextBox10.Text = Session["AdminName"].ToString();
}
}
private void bindInvoice(DropDownList ddl)
{
List<YXShop.Model.InvoiceManage> invoModel = invoMBll.GetAll();
ListItem lItem = null;
foreach (YXShop.Model.InvoiceManage invoM in invoModel)
{
lItem = new ListItem();
lItem.Value = invoM.IM_ID.ToString();
lItem.Text = invoM.IM_Type;
ddl.Items.Add(lItem);
}
}
protected void saveInfo_Click(object sender, EventArgs e)
{
#region 发票信息
YXShop.Model.InvoiceItem invoModel = new YXShop.Model.InvoiceItem();
invoModel.OrderID = Label3.Text;
invoModel.UserName = myuser.Text;
invoModel.InvoiceDate = getMoneyDate.Date;
invoModel.InvoiceContent = YXShop.Common.WebUtility.replaceStr(TextBox8.Text);
invoModel.InvoiceMoney = decimal.Parse(string.IsNullOrEmpty(TextBox9.Text) ? "0" : TextBox9.Text);
invoModel.InvoiceName = TextBox10.Text;
invoModel.InvoiceType = DropDownList1.SelectedItem.Text;
invoModel.InvoiceNumber = YXShop.Common.WebUtility.replaceStr(TextBox6.Text);
invoModel.InvoiceRise = TextBox7.Text;
invoModel.BosomNote = YXShop.Common.WebUtility.replaceStr(TextBox5.Text);
invoModel.InformMode = GetInforMode(CheckBoxList1)["txt"];
invoModel.NoteDate = DateTime.Now;
invoModel.NoteName = Session["AdminName"].ToString();
#endregion
try
{
invoBll.Add(invoModel);
}
catch (Exception ex)
{
Response.Redirect("../Succeed/ErrorOrder.aspx?Key=" + ex.Message + "&OrderId=" + orderId + "");
}
finally
{
Response.Redirect("../Succeed/SueeccdOrder.aspx?Key=发票&OrderId=" + orderId + "");
}
}
private Dictionary<string, string> GetInforMode(CheckBoxList CbList)
{
string val = string.Empty;
string txt = string.Empty;
foreach (ListItem lItem in CbList.Items)
{
if (lItem.Selected)
{
val += lItem.Value + ",";
txt += lItem.Text + ",";
}
}
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("val", val.TrimEnd(','));
dic.Add("txt", val.TrimEnd(','));
return dic;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -