Пример #1
0
    /// <summary>
    /// 复制订单
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCopy_Click(object sender, EventArgs e)
    {
        decimal TotalAmount = 0;            //订单总价
        string  LogRemark   = string.Empty; //日志备注
        int     Audit       = 0;            //是否审核

        Hi.Model.DIS_Order OrderInfoModel = null;
        try
        {
            OrderInfoModel = OrderBll.GetModel(KeyID);

            if (OrderInfoModel != null)
            {
                String guid = Guid.NewGuid().ToString().Replace("-", "");
                OrderInfoModel.GUID      = guid;
                OrderInfoModel.ReceiptNo = SysCode.GetNewCode("销售单");

                Audit = OrderInfoType.OrderEnAudit((int)Enums.AddType.网页下单, OrderInfoModel.DisID, OrderInfoModel.Otype);
                OrderInfoModel.IsAudit = Audit;

                //收货地址
                Hi.Model.BD_DisAddr DisAddr = new Hi.BLL.BD_DisAddr().GetModel(OrderInfoModel.AddrID);
                if (DisAddr != null)
                {
                    OrderInfoModel.AddrID    = OrderInfoModel.AddrID;
                    OrderInfoModel.Principal = DisAddr.Principal;
                    OrderInfoModel.Phone     = DisAddr.Phone;
                    OrderInfoModel.Address   = DisAddr.Address;
                }

                OrderInfoModel.PayState     = (int)Enums.PayState.未支付;
                OrderInfoModel.OState       = (int)Enums.OrderState.未提交;
                OrderInfoModel.PayedAmount  = 0;
                OrderInfoModel.ReturnState  = 0;
                OrderInfoModel.ArriveDate   = DateTime.MinValue;
                OrderInfoModel.DisUserID    = this.UserID;
                OrderInfoModel.CreateUserID = this.UserID;
                OrderInfoModel.CreateDate   = DateTime.Now;

                OrderInfoModel.AuditUserID       = 0;
                OrderInfoModel.AuditDate         = DateTime.MinValue;
                OrderInfoModel.AuditRemark       = "";
                OrderInfoModel.ReturnMoneyDate   = DateTime.MinValue;
                OrderInfoModel.ReturnMoneyUserId = 0;
                OrderInfoModel.ReturnMoneyUser   = "";
                OrderInfoModel.ts         = DateTime.Now;
                OrderInfoModel.dr         = 0;
                OrderInfoModel.modifyuser = 0;

                //订单商品明细
                List <Hi.Model.DIS_OrderDetail> l = OrderDetailBll.GetList("", " OrderId=" + KeyID, "");

                List <Hi.Model.DIS_OrderDetail> dl = new List <Hi.Model.DIS_OrderDetail>();

                foreach (Hi.Model.DIS_OrderDetail item in l)
                {
                    //获取商品最新价格
                    decimal Price = SelectGoods.GoodsNewPrice(item.GoodsinfoID, this.DisID, CompID);
                    item.Price       = Price;
                    item.AuditAmount = Price;
                    item.sumAmount   = Price * item.GoodsNum;

                    TotalAmount += item.sumAmount;

                    item.ts         = DateTime.Now;
                    item.dr         = 0;
                    item.modifyuser = 0;

                    dl.Add(item);
                }
                OrderInfoModel.TotalAmount = TotalAmount;
                OrderInfoModel.AuditAmount = TotalAmount;
                //OrderInfoModel.OtherAmount = 0;
                LogRemark += " 下单总价:" + TotalAmount.ToString("N");
                int OrderId = OrderInfoType.TansOrder(OrderInfoModel, dl);

                if (OrderId > 0)
                {
                    Utils.AddSysBusinessLog(this.CompID, "Order", OrderId.ToString(), "订单新增", LogRemark);
                    JScript.AlertMethod(this, "复制成功", JScript.IconOption.正确, "function (){ location.replace('" + ("neworder/orderdetail.aspx?KeyID=" + Common.DesEncrypt(OrderId.ToString(), Common.EncryptKey)) + "'); }");
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }