示例#1
0
    protected void btnEditProduct_Click(object sender, EventArgs e)
    {
        if (CountryCity2.CheckFill() == false)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请选择地址!')</script>");
            return;
        }
        if (Txtdz.Text.Trim() == "")
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请填写地址!')</script>");
            return;
        }

        string OrderId = Request.QueryString["OrderID"].ToString();
        string bianhao = Request.QueryString["Number"].ToString();

        SqlDataReader hydr       = DAL.DBHelper.ExecuteReader("select PayCurrency,DefrayType from MemberOrder where orderid='" + OrderId + "'");
        string        fukuanMode = "";
        int           bizhong    = 0;

        if (hydr.Read())
        {
            fukuanMode = hydr["DefrayType"].ToString();
            bizhong    = Convert.ToInt32(hydr["PayCurrency"]);

            hydr.Close();
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('订单不存在')</script>");
            return;
        }

        string error = "";
        //获取用户选择商品的集合

        IList <MemberDetailsModel> choseProList = AddMemberDetails();

        if (choseProList == null)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + this.GetTran("000294", "抱歉!购货数量必须输入数字!") + "');</script>", false);
            return;
        }
        if (choseProList.Count == 0 && Request.QueryString["tp"] == "-1")
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + this.GetTran("000296", "抱歉!您还没有选择商品!") + "');</script>", false);
            return;
        }
        if (Convert.ToBoolean(ViewState["StateCount"]))
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("007039", "对不起,您选择了停售产品,并且超出了店铺库存数量!") + "');</script>", false);
            return;
        }


        //获得总的购货金额和pv
        double TotalMoney = registermemberBLL.getZongJing(choseProList);
        double SumPv      = registermemberBLL.getZongPv(choseProList);

        double bottonLine = new BLL.Registration_declarations.AddOrderBLL().GetBottomLine();
        double ce         = TotalMoney - bottonLine;

        if (ce < 0)
        {
            ScriptHelper.SetAlert(Page, "报单金额必须大于" + bottonLine.ToString());
            return;
        }

        //无货总金额
        double notEnoughmoney = registermemberBLL.CheckMoneyIsEnough(choseProList, GetStoreID(), OrderId);

        //if (Ddzf.SelectedValue != "2")
        //{
        //    if (notEnoughmoney > Convert.ToDouble(ViewState["dpm"]))
        //    {
        //        ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('店铺报单额不够!')</script>");
        //        return;
        //    }
        //}
        if (this.Ddzf.SelectedValue.ToString() == "2")
        {
            string elcNumber      = this.txtdzbh.Text.Trim().ToLower();
            string elcPassword    = Encryption.Encryption.GetEncryptionPwd(this.txtdzmima.Text, elcNumber);
            string CheckEctResult = registermemberBLL.CheckEctPassWord(this.Ddzf.SelectedValue, elcNumber, elcPassword);
            if (CheckEctResult != null)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + CheckEctResult + "');</script>", false);
                return;
            }

            //需要修改
            double elcMoney = Convert.ToDouble(CommonDataBLL.EctBalance(txtdzbh.Text.Trim()));
            //如果电子金额少于用户订单总额
            if (elcMoney < Convert.ToDouble(TotalMoney))
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("001528", "用户") + this.txtdzbh.Text.Trim() + GetTran("001529", "的电子钱包不够本次报单!") + "');</script>", false);
                return;
            }
        }
        //有货总金额
        double EnoughProductMoney = 0.00;//Convert.ToDouble(registermemberBLL.getEnoughProductMoney(choseProList, GetStoreID()));

        int qs = BLL.CommonClass.CommonDataBLL.getMaxqishu();

        List <MemberDetailsModel> lmdm = new List <MemberDetailsModel>();

        lmdm = (List <MemberDetailsModel>)choseProList;

        if (Session["mim"] != null)
        {
            MemberInfoModel mim = (MemberInfoModel)Session["mim"];

            MemberOrderModel mom = new MemberOrderModel();
            mom.Number     = bianhao;
            mom.OrderId    = OrderId;
            mom.StoreId    = GetStoreID();
            mom.TotalMoney = Convert.ToDecimal(MemberOrderAgainBLL.GetBzMoney(GetStoreID(), Convert.ToDouble(TotalMoney)));// Convert.ToDecimal(TotalMoney);
            mom.TotalPv    = Convert.ToDecimal(SumPv);

            DataTable dtoinfo = RegistermemberBLL.Getmominfoofmember(OrderId);

            if (dtoinfo != null && dtoinfo.Rows.Count > 0)
            {
                mom.CarryMoney          = Convert.ToDecimal(dtoinfo.Rows[0]["CarryMoney"]);
                mom.OrderExpect         = Convert.ToInt32(dtoinfo.Rows[0]["OrderExpectNum"]);
                mom.PayExpect           = Convert.ToInt32(dtoinfo.Rows[0]["PayExpectNum"]);
                mom.Err                 = "";
                mom.IsAgain             = Convert.ToInt32(dtoinfo.Rows[0]["IsAgain"]);
                mom.OrderDate           = Convert.ToDateTime(dtoinfo.Rows[0]["OrderDate"]); //DateTime.Now;
                mom.Remark              = "";
                mom.DefrayState         = Convert.ToInt32(dtoinfo.Rows[0]["DefrayState"]);
                mom.Consignee           = dtoinfo.Rows[0]["Consignee"].ToString();
                mom.RemittancesId       = dtoinfo.Rows[0]["RemittancesId"].ToString();
                mom.ElectronicaccountId = dtoinfo.Rows[0]["ElectronicaccountId"].ToString();
                mom.OrderType           = Convert.ToInt32(dtoinfo.Rows[0]["OrderType"]);
                mom.IsreceiVables       = Convert.ToInt32(dtoinfo.Rows[0]["DefrayState"]);
            }

            CityModel cm = new CityModel();
            cm.Country  = CountryCity2.Country;
            cm.Province = CountryCity2.Province;
            cm.City     = CountryCity2.City;
            cm.Xian     = CountryCity2.Xian;

            mom.ConCity               = cm;
            mom.CCPCCode              = mim.CPCCode;
            mom.ConAddress            = Encryption.Encryption.GetEncryptionAddress(Txtdz.Text.Trim());
            mom.ConZipCode            = mim.PostalCode;
            mom.ConTelPhone           = mim.HomeTele;
            mom.ConMobilPhone         = mim.MobileTele;
            mom.ConPost               = mim.Email;
            mom.DefrayType            = Convert.ToInt32(Ddzf.SelectedValue);
            mom.DefrayType            = Convert.ToInt32(ViewState["DefrayType"]);
            mom.PayMoney              = Convert.ToDecimal(MemberOrderAgainBLL.GetBzMoney(GetStoreID(), Convert.ToDouble(TotalMoney)) / MemberOrderAgainBLL.GetBzHl(Convert.ToInt32(DropCurrency.SelectedValue)));//Convert.ToDecimal(TotalMoney);
            mom.PayCurrency           = Convert.ToInt32(DropCurrency.SelectedValue);
            mom.StandardCurrency      = MemberOrderAgainBLL.GetBzTypeId(GetStoreID());
            mom.StandardcurrencyMoney = Convert.ToDecimal(TotalMoney);
            mom.OperateIp             = Request.UserHostAddress;
            mom.OperateNumber         = GetStoreID();
            mom.SendType              = Convert.ToInt32(ddth.SelectedValue);

            if (mom.DefrayState == 0)
            {
                mom.PaymentMoney = 0;
            }
            else
            {
                mom.PaymentMoney = Convert.ToDecimal(MemberOrderAgainBLL.GetBzMoney(GetStoreID(), Convert.ToDouble(TotalMoney)) / MemberOrderAgainBLL.GetBzHl(Convert.ToInt32(DropCurrency.SelectedValue)));
            }
            mom.ReceivablesDate    = Convert.ToDateTime(DBHelper.ExecuteScalar("select ReceivablesDate from MemberOrder where OrderID='" + OrderId + "'")); //DateTime.Now;
            mom.EnoughProductMoney = Convert.ToDecimal(EnoughProductMoney);
            mom.LackProductMoney   = Convert.ToDecimal(MemberOrderAgainBLL.GetBzMoney(GetStoreID(), Convert.ToDouble(notEnoughmoney)));                     //获得标准币种Convert.ToDecimal(notEnoughmoney);
            mom.SendWay            = Convert.ToInt32(DDLSendType.SelectedValue);
            if (Ddzf.SelectedValue == "2")
            {
                mom.ElectronicaccountId = this.txtdzbh.Text.Trim();
            }
            if (mom.OperateNumber.Trim().Length == 0)
            {
                if (Session["Company"] != null)
                {
                    mom.OperateNumber = "管理员:" + Session["Company"].ToString();
                }
            }

            string aa = MemberOrderBLL.UpdateMemberOrder(OrderId, lmdm, mom, GetStoreID());

            if (aa == "1")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功');window.location.href=window.location.href+'&date='+new Date().getTime()</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改失败')</script>");
            }
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('登录超时,请重新登录');window.location.href='index.aspx'</script>");
        }
    }