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

📄 sendconsignment.aspx.cs

📁 易想商城系统
💻 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 Shop.Web.UI;
using System.Collections.Generic;

namespace YXShop.Web.Membercenter.Dynamic
{
    public partial class SendConsignment : System.Web.UI.Page
    {
        public static string orderId = "";
        private static decimal orderPrice = 0, remiPrice = 0, paymPrice = 0, prepPrice = 0;
        YXShop.BLL.Orders bll = new YXShop.BLL.Orders();
        YXShop.BLL.YXShop_Deliver deliBll = new YXShop.BLL.YXShop_Deliver();
        YXShop.BLL.Consignment consBll = new YXShop.BLL.Consignment();
        BasePage bp = new BasePage();
        YXShop.BLL.RemittanceInfo Remibll = new YXShop.BLL.RemittanceInfo();//银行支付
        YXShop.BLL.PaymentMoney paymbll = new YXShop.BLL.PaymentMoney();//现金支付
        YXShop.BLL.PrepayMoney prepbll = new YXShop.BLL.PrepayMoney();//预付款支付
        protected void Page_Load(object sender, EventArgs e)
        {
            //是不是管理员
            YXShop.DBUtility.ExitMemberCenter.ExitDynamic();

            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);
                    bindSendMethod(DropDownList2, "");
                    saveInfo.Attributes.Add("onclick", this.GoodsMoney(orderId) == true ? "confirm('你确定录入发货信息吗?')" : "confirm('该订单未付添,你确定录入发货信息吗?')");
                }
                else
                {
                    Response.Redirect("orderList.aspx");
                }
            }
        }
        #region 判断货款是否结清
        protected bool GoodsMoney(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);
                if ((remiPrice + paymPrice + prepPrice) < orderPrice)
                {
                    return false;
                }
            }
            return true;
        }
        #endregion
        /// <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);

                //if ((remiPrice + paymPrice + prepPrice) < orderPrice) 
                //{
                //    YXShop.Common.alert.ShowAndRedirectgo(this, "订单未结清,请结清后再发货!", "orderInfo.aspx?OrderID=" + orderId);
                //}
                int UserID = Convert.ToInt32(li[0].UserId);
                Label1.Text = UserReal(UserID);
                //Label2.Text = li[0].ConsigneeRealName;
                myuser.Text = UserName(UserID);
                Label3.Text = li[0].OrderId;
                Label4.Text = orderPrice.ToString();
                Label5.Text = (remiPrice + paymPrice + prepPrice).ToString();//已经支付
                Label7.Text = this.Deliver(Convert.ToInt32(li[0].Courier));
                TextBox2.Text = li[0].Remark;
                TextBox7.Text = Session["MemberName"].ToString();
            }
        }
        #region 客户信息查询
        protected string UserName(int UserID)
        {
            string str = "";
            YXShop.BLL.UserCommon ucBll = new YXShop.BLL.UserCommon();
            List<YXShop.Model.UserCommon> ucList = ucBll.GetListByColumn("UID", UserID);
            if (ucList.Count == 1)
            {
                str = ucList[0].UserName;
            }
            return str;
        }
        protected string UserReal(int UserID)
        {
            string str = "";
            YXShop.BLL.MemberInfo data = new YXShop.BLL.MemberInfo();
            List<YXShop.Model.MemberInfo> dataStr = data.GetListByColumn("UID", UserID);
            if (dataStr.Count > 0)
            {
                str = dataStr[0].cTrueName;
            }
            return str;
        }
        #endregion
        #region 配送方式
        protected string Deliver(int id)
        {
            List<YXShop.Model.YXShop_Deliver> data = deliBll.GetList(" D_ID=" + id + "");
            if (data.Count > 0)
            {
                return data[0].D_Name;
            }
            return string.Empty;
        }
        #endregion
        /// <summary>
        /// 快递公司
        /// <param name="ddl"></param>
        /// </summary>
        private void bindSendMethod(DropDownList ddl, string value)
        {
            YXShop.BLL.Express data = new YXShop.BLL.Express();
            List<YXShop.Model.Express> list = data.GetList();
            if (list.Count > 0)
            {
                ListItem li = null;
                foreach (YXShop.Model.Express deliModel in list)
                {
                    li = new ListItem();
                    li.Value = deliModel.EX_Id.ToString();
                    li.Text = deliModel.EX_Name.ToString();
                    if (value == li.Text)
                    {
                        li.Selected = true;
                    }
                    ddl.Items.Add(li);
                }
            }
        }

        protected void saveInfo_Click(object sender, EventArgs e)
        {
            YXShop.Model.Consignment consModel = new YXShop.Model.Consignment();

            #region 发货
            consModel.OrderID = Label3.Text;
            consModel.UserName = myuser.Text;
            consModel.ConsignmentDate = getMoneyDate.Date;
            consModel.ExpressCompany = DropDownList2.SelectedItem.Text;
            consModel.ExpressOddNumbers = YXShop.Common.WebUtility.replaceStr(TextBox6.Text);
            consModel.ConsignmentPeople = Label6.Text;
            consModel.Remark = YXShop.Common.WebUtility.replaceStr(TextBox2.Text.Trim()) == string.Empty ? "给订单发货。订单号:" + orderId + "" : YXShop.Common.WebUtility.replaceStr(TextBox2.Text.Trim());
            consModel.BosomNote = YXShop.Common.WebUtility.replaceStr(TextBox5.Text);
            consModel.InformMode = GetInforMode(CheckBoxList1)["txt"];
            consModel.NoteDate = DateTime.Now;
            consModel.NoteName = Session["MemberName"].ToString();
            consModel.Received = YXShop.Common.StatuEnum.OgisticsStatus.已发货.GetHashCode();
            consModel.ConsignmentType = 0;
            #endregion

            try
            {
                consBll.Add(consModel);
                bll.UpdateOrders("OgisticsStatus", YXShop.Common.StatuEnum.OgisticsStatus.已发货.GetHashCode(), orderId);
            }
            catch (Exception ex)
            {
                bp.PageError(ex.Message, "OrdersInfo.aspx?OrderId=" + orderId + "");
                Response.End();
            }
            finally
            {
                bp.PageRight("发货成功!", "OrdersInfo.aspx?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 + -