Example #1
0
    /// <summary>
    /// 生成订单
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string  ReceiptNo   = string.Empty;
        string  Otype       = string.Empty;
        string  ArriveDate  = string.Empty;
        decimal TotalAmount = 0;
        decimal OtherAmount = 0;
        string  DisUser     = string.Empty;
        string  DisUserId   = string.Empty;
        string  LogRemark   = string.Empty; //日志备注

        string Remark = string.Empty;
        string str    = string.Empty;

        if (this.DisListID.Disid == "")
        {
            str += " - 代理商不能为空。\\r\\n";
        }
        if (this.txtunit.Value == "")
        {
            str += " - 费用名称不能为空。\\r\\n";
        }
        if (this.txtOtherAmount.Value.ToDecimal(0) <= 0)
        {
            str += " - 账单金额不能为0。\\r\\n";
        }

        if (this.txtRemark.Value != "")
        {
            Remark = Common.NoHTML(this.txtRemark.Value.Trim().ToString());
            if (Remark.Length > 400)
            {
                str += " - 账单备注不能大于400个字符。\\r\\n";
            }
        }

        if (str != "")
        {
            JScript.AlertMsgOne(this, str, JScript.IconOption.错误, 2500);
            return;
        }

        try
        {
            Hi.Model.DIS_Order OrderInfoModel = null;
            DisId = Convert.ToInt32(this.DisListID.Disid);

            decimal Amount = Convert.ToDecimal(this.txtOtherAmount.Value);
            TotalAmount = Amount;

            if (this.txtArriveDate.Value.Trim() != "")
            {
                ArriveDate = Common.NoHTML(this.txtArriveDate.Value.Trim().ToString());
            }
            else
            {
                ArriveDate = DateTime.MinValue.ToString();
            }
            DisUser   = Common.NoHTML(this.txtDisUser.InnerText.Trim().ToString());
            DisUserId = Common.NoHTML(this.hidDisUserId.Value.Trim().ToString());

            OrderInfoModel = OrderInfoBll.GetModel(KeyID);

            LogRemark += " 账单总价:" + Amount.ToString("N");



            #region 新增订单

            //新增订单
            String guid = Guid.NewGuid().ToString().Replace("-", "");

            ReceiptNo = SysCode.GetZD_NewCode("账单", 1);

            OrderInfoModel = new Hi.Model.DIS_Order();

            OrderInfoModel.GUID      = guid;
            OrderInfoModel.CompID    = this.CompID;
            OrderInfoModel.DisID     = DisId;
            OrderInfoModel.ReceiptNo = ReceiptNo;


            int OState = 1;

            //无需审核
            OState = (int)Enums.OrderState.已审;
            OrderInfoModel.IsAudit = 1;

            OrderInfoModel.OState       = OState;
            OrderInfoModel.Remark       = Remark;
            OrderInfoModel.CreateUserID = this.UserID;
            OrderInfoModel.CreateDate   = DateTime.Now;

            //总价
            OrderInfoModel.TotalAmount = TotalAmount;
            OrderInfoModel.AuditAmount = TotalAmount;
            OrderInfoModel.OtherAmount = OtherAmount;

            OrderInfoModel.ArriveDate = ArriveDate.ToDateTime();
            OrderInfoModel.DisUserID  = DisUserId.ToInt(0);

            OrderInfoModel.Otype   = (int)Enums.OType.推送账单;
            OrderInfoModel.AddType = (int)Enums.AddType.网页下单;

            OrderInfoModel.ts = DateTime.Now;
            //OrderInfoModel.vdef9 = "0";

            OrderInfoModel.vdef2 = this.txtunit.Value.Trim();//费用科目



            int OrderId = new Hi.BLL.DIS_Order().Add(OrderInfoModel);

            if (OrderId > 0)
            {
                Utils.AddSysBusinessLog(this.CompID, "Order", OrderId.ToString(), "账单新增", LogRemark);

                //代理商手机号
                string Phone = Common.GetDis(DisId, "Phone");
                string msg   = "您的账单:" + ReceiptNo + "已经生成," + this.txtunit.Value.Trim() + ":" + TotalAmount + "元,请尽快完成付款![ " + Common.GetCompValue(CompID, "CompName") + " ]";

                //账单推送向代理商推送信息提示
                Common.GetPhone(Phone, msg);

                string Id = Common.DesEncrypt(OrderId.ToString(), Common.EncryptKey);

                ClientScript.RegisterStartupScript(this.GetType(), "add", "<script>window.location.href ='OrderZdtsInfo.aspx?KeyID=" + Id + "';</script>");
            }

            #endregion
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }