Ejemplo n.º 1
0
    /// <summary>
    /// 购物车商品
    /// </summary>
    public void ShopCart()
    {
        DataTable dt = new Hi.BLL.DIS_ShopCart().GetGoodsCart(" sc.[CompID]=" + this.CompID + " and sc.[DisID]=" + this.DisID + "and sc.dr=0", "sc.[CreateDate] desc ");

        if (dt != null && dt.Rows.Count > 0)
        {
            decimal TotalAmount = 0;
            string  html        = string.Empty;
            string  Digits      = OrderInfoType.rdoOrderAudit("订单下单数量是否取整", this.CompID); //小数位数
            string  str6        = IsInve == 0 ? "" : "display:none";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int goodsinfoid = Convert.ToInt32(dt.Rows[i]["GoodsinfoID"].ToString());
                Hi.Model.BD_GoodsInfo model3 = new Hi.BLL.BD_GoodsInfo().GetModel(goodsinfoid);
                Hi.Model.BD_Goods     model4 = new Hi.BLL.BD_Goods().GetModel(model3.GoodsID);
                string pic       = dt.Rows[i]["pic"].ToString();                                                                // new Hi.BLL.BD_Goods().GetModel(Convert.ToInt32(model2.GoodsID)).Pic;
                string inventory = string.Empty;
                BLL.Common.GetInevntory(this.CompID, goodsinfoid, 0, Convert.ToDecimal(dt.Rows[i]["GoodsNum"]), out inventory); // dt.Rows[i]["Inventory"].ToString();
                string str7 = string.Empty;                                                                                     //是否促销
                if (dt.Rows[i]["ProID"].ToString() != "0")
                {
                    str7 = SelectGoodsInfo.protitle(dt.Rows[i]["ProID"].ToString(), dt.Rows[i]["Unit"].ToString());
                }
                string  strremark = string.Empty;
                decimal zxprice   = BLL.Common.GetGoodsPrice(this.CompID, this.DisID, goodsinfoid);//最新价格
                decimal num       = decimal.Parse(string.Format("{0:N4}", Convert.ToDecimal(dt.Rows[i]["GoodsNum"]).ToString("#,####" + Digits)));
                TotalAmount += zxprice * num;
                html        += "<tr tip=\"" + goodsinfoid + "\" trindex=\"" + i + "\" trindex2=\"" + i + "\" id=\"\"><td class=\"t8\"><div class=\"addg\"><a href=\"javascript:;\" class=\"minus2\"></a><a href=\"javascript:;\" class=\"add2\"></a></div></td><td><div class=\"sPic\"><a class=\"opt-i2\"></a><span><a href=\"javascript:;\"><img src=\"" + Common.GetPicURL(pic, "resize200") + "\" width=\"60\" height=\"60\"></a></span><a href=\"javascript:;\" class=\"code\">商品编码:" + dt.Rows[i]["barCode"].ToString() + str7 + "</a><a href=\"javascript:;\" class=\"name\">" + GetGoodsName(model4.GoodsName, model3.ValueInfo, "1") + "<i>" + GetGoodsName(model4.GoodsName, model3.ValueInfo, "2") + "</i></a></div></td><td><div class=\"tc\">" + model4.Unit + "</div></td><td><div class=\"tc divprice" + i + "\" tip=\"" + decimal.Parse(string.Format("{0:N2}", zxprice)).ToString("0.00") + "\">¥" + decimal.Parse(string.Format("{0:N2}", zxprice)).ToString("0.00") + "</div><input type=\"hidden\" class=\"hidPrice\" value=\"" + zxprice + "\" /></td><td style=\"" + str6 + "\"><div class=\"tc\"><input type=\"hidden\" id=\"hidInventory_" + i + "\" value=\"" + decimal.Parse(string.Format("{0:N2}", inventory)).ToString(Digits) + "\" />" + decimal.Parse(string.Format("{0:N2}", inventory)).ToString(Digits) + "</div></td><td><div class=\"sl divnum\" tip=\"" + dt.Rows[i]["GoodsinfoID"].ToString() + "\" tip2=\"" + i + "\"><a href=\"javascript:void(0);\"  class=\"minus\">-</a><input type=\"text\" class=\"box txtGoodsNum txtGoodsNum" + i + "\" onfocus=\"InputFocus(this)\" onkeyup='KeyInt2(this)' maxlength=\"9\"  value=\"" + num + "\"><a href=\"javascript:void(0);\"  class=\"add\">+</a></div></td><td><div class=\"tc lblTotal_" + i + "\">¥" + decimal.Parse(string.Format("{0:N2}", zxprice * num)).ToString("0.00") + "</div></td><td><div class=\"tc alink\"><a href=\"javascript:;\" class=\"aremark" + i + "\">添加</a>" + strremark + "</div></td></tr>";
            }
            //查询购物车商品数量、总价
            // DataTable dtp = new Hi.BLL.DIS_ShopCart().SumCartNum(this.CompID.ToString(), this.DisID.ToString());
            // if (dtp != null && dtp.Rows.Count > 0)
            //{
            //TotalAmount = (dtp.Rows[0]["SumAmount"].ToString().ToDecimal(0));
            //订单总价
            this.lblTotalAmount.InnerText = decimal.Parse(string.Format("{0:N2}", TotalAmount.ToString())).ToString("0.00");//商品总额
            //订单促销
            decimal ProAmount = Common.GetProPrice(TotalAmount, out ProID, out ProIDD, out ProType, this.CompID);
            this.lblCux.InnerText = decimal.Parse(string.Format("{0:N2}", ProAmount.ToString())).ToString("0.00");
            //合计
            string str8 = (TotalAmount - ProAmount).ToString("N");
            ClientScript.RegisterStartupScript(this.GetType(), "adder", "<script>$(function(){disId=" + this.DisID + "; $(\".tabLine table tbody tr:last\").before(\"" + html.Replace("\"", "'") + "\");$(\"#lblYFPrice\").text(\"" + str8 + "\")})</script>");
            // }
        }
        else
        {
            Response.Redirect("/Distributor/Shop.aspx");
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 修改是绑定的数据
    /// </summary>
    public void Bind()
    {
        //判断是否有权限
        if (!Common.PageCompOperable("Order", KeyID, CompID))
        {
            Response.Redirect("../../NoOperable.aspx");
            return;
        }
        Hi.Model.DIS_Order OrderInfoModel = new Hi.BLL.DIS_Order().GetModel(KeyID);
        if (OrderInfoModel != null)
        {
            hidts.Value = OrderInfoModel.ts.ToString();                                                //时间戳
            this.divGoodsName.InnerText = disBing(CompID.ToString(), OrderInfoModel.DisID.ToString()); //筛选商品
            Hi.Model.BD_Distributor model = new Hi.BLL.BD_Distributor().GetModel(OrderInfoModel.DisID);
            this.txtDisName.Value    = model.DisName;                                                  //代理商名称
            this.txtDisName.Disabled = true;                                                           //只读
            this.hidDisID.Value      = OrderInfoModel.DisID.ToString();                                //代理商ID
            if (Request["type"] + "" != "2" || Fanli == 1)
            {
                this.txtRebate.Value = OrderInfoModel.bateAmount.ToString();                                                                                      //返利金额
            }
            this.txtDate.Value        = OrderInfoModel.ArriveDate.ToString("yyyy-MM-dd") == "0001-01-01" ? "" : OrderInfoModel.ArriveDate.ToString("yyyy-MM-dd"); //交货日期
            this.lblPsType.InnerText  = OrderInfoModel.GiveMode;                                                                                                  //配送方式
            this.lblPsType2.InnerText = OrderInfoModel.GiveMode == "送货" ? "自提" : "送货";
            this.hidPsType.Value      = OrderInfoModel.GiveMode;                                                                                                  //配送方式
            this.OrderNote.Value      = OrderInfoModel.Remark;                                                                                                    //订单备注
            this.hidAdder.Value       = OrderInfoModel.Address;                                                                                                   //地址
            this.hidAddName.Value     = OrderInfoModel.Principal;                                                                                                 //联系人
            this.hidAddPhone.Value    = OrderInfoModel.Phone;                                                                                                     //联系人电话
            this.hrAdder.Value        = OrderInfoModel.AddrID.ToString();                                                                                         //收货地址id
            this.hrOrderFj.Value      = OrderInfoModel.Atta;                                                                                                      //附件文件
            string str10 = decimal.Parse(string.Format("{0:N2}", OrderInfoModel.PostFee.ToString())).ToString("0.00");                                            //运费
            this.lblPostFee.InnerText = str10;                                                                                                                    //运费
            this.hidPostFree.Value    = str10;                                                                                                                    //运费
            //附件
            string str3 = string.Empty;                                                                                                                           //附件信息
            if (OrderInfoModel.Atta.ToString() != "")
            {
                StringBuilder li   = new StringBuilder();
                string[]      atta = OrderInfoModel.Atta.Split(new string[] { "@@" }, StringSplitOptions.RemoveEmptyEntries);
                if (atta.Length > 0)
                {
                    foreach (var item in atta)
                    {
                        string[] att = item.Split(new string[] { "^^" }, StringSplitOptions.RemoveEmptyEntries);

                        li.AppendFormat("<li> <a href=\"javascript:;\" class=\"name\">{0}(大小:{4}KB)</a><a href=\"javascript:;\"  class=\"bule del\" tip=\"{3}\" orderid=\"{1}\">删除</a><a href=\"{2}\" target=\"_blank\" class=\"bule\">下载</a></li>", att[0] + att[1].Substring(att[1].LastIndexOf(".")), KeyID, Common.GetWebConfigKey("ImgViewPath") + "OrderFJ/" + item, item, OrderType.GetSize(item));
                    }
                }
                str3 = li.ToString();
            }
            //收货信息
            string str   = "收货人:" + OrderInfoModel.Principal + ",联系电话:" + OrderInfoModel.Phone + ",收货地址:" + OrderInfoModel.Address;
            string price = string.Empty;//返利总金额
            if (Request.QueryString["type"] + "" == "2")
            {
                //再次购买时获取返利总金额
                price = OrderType.GetRebate(0, OrderInfoModel.DisID);
            }
            else
            {
                //其他获取返利总金额
                price = OrderType.GetRebate(KeyID, OrderInfoModel.DisID);
            }
            //可用返利金额
            string str4 = "可用返利¥ <label id=\"lblRebate\">" + string.Format("{0:N2}", price.ToString()) + "</label><i class=\"sus-i seebate\"></i>";
            List <Hi.Model.DIS_OrderDetail> ll = new Hi.BLL.DIS_OrderDetail().GetList("", "isnull(dr,0)=0 and orderId=" + KeyID, "");
            if (ll.Count > 0)
            {
                string html  = string.Empty; //绑定的商品数据
                int    index = 0;            //索引
                string str8  = "0.00";       //商品小计
                foreach (Hi.Model.DIS_OrderDetail obj in ll)
                {
                    Hi.Model.BD_GoodsInfo model2 = new Hi.BLL.BD_GoodsInfo().GetModel(obj.GoodsinfoID);
                    string  kc        = string.Empty;
                    decimal newprice  = obj.AuditAmount;                                           //判断修改和再次购买时的价格 显示的
                    decimal newprice2 = obj.GoodsPrice;                                            //判断修改和再次购买时的价格 隐藏的
                    str8 = decimal.Parse(string.Format("{0:N2}", obj.sumAmount)).ToString("0.00"); //判断修改和再次购买时的小计价格
                    // decimal str88 = 0;//判断修改和再次购买时的小计价格 隐藏的
                    if (Request.QueryString["type"] + "" == "2")
                    {
                        //再次 购买时获取库存
                        kc = model2.Inventory.ToString();
                        // newprice2 = newprice = BLL.Common.GetGoodsPrice(this.CompID, OrderInfoModel.DisID, obj.GoodsinfoID);
                        //  str8 = decimal.Parse(string.Format("{0:N2}", newprice * obj.GoodsNum)).ToString("0.00");
                    }
                    else
                    {
                        //其他获取库存
                        kc = (model2.Inventory + obj.GoodsNum + obj.ProNum.ToDecimal(0)).ToString();
                    }
                    string pic  = new Hi.BLL.BD_Goods().GetModel(Convert.ToInt32(model2.GoodsID)).Pic;                   //图片
                    string str6 = IsInve == 0 ? "" : "display:none";                                                     //是否显示库存
                    string str7 = string.Empty;                                                                          //是否促销
                    str7 = SelectGoodsInfo.protitle(obj.ProID, obj.Protype, obj.Unit);                                   // ConvertJson.IsCx(dt.Rows[0]["proTypes"].ToString(), dt.Rows[0]["proType"].ToString(), dt.Rows[0]["proGoodsPrice"].ToString(), dt.Rows[0]["proDiscount"].ToString(), dt.Rows[0]["unit"].ToString()); //SelectGoodsInfo.protitle(obj.ProID, obj.Protype, obj.Unit);
                    string  Digits = OrderInfoType.rdoOrderAudit("订单下单数量是否取整", this.CompID);                             //小数位数
                    decimal num    = decimal.Parse(string.Format("{0:N4}", (obj.GoodsNum).ToString("#,####" + Digits))); //购买数量
                    string  str9   = obj.Remark;                                                                         //goodsInfoid备注
                    if (obj.Remark != null && obj.Remark.Length > 6)
                    {
                        str9 = obj.Remark.Substring(0, 6) + "...";
                    }
                    string strremark = string.Empty;//鼠标移上去时显示的备注
                    if (obj.Remark != "")
                    {
                        strremark = "<div class=\"divremark" + index + "\">" + str9 + "</div><div class=\"cur\">" + obj.Remark + "</div>";
                    }
                    // decimal zxprice = BLL.Common.GetGoodsPrice(this.CompID, OrderInfoModel.DisID, obj.GoodsinfoID);
                    html += "<tr trindex=\"" + index + "\" trindex2=\"" + index + "\" id=\"" + obj.ID + "\" tip=\"" + obj.GoodsinfoID + "\"><td class=\"t8\"><div class=\"addg\"><a href=\"javascript:;\" class=\"minus2\"></a><a href=\"javascript:;\" class=\"add2\"></a></div></td><td><div class=\"sPic\"><a class=\"opt-i2\"></a><span><a href=\"javascript:;\"><img src=\"" + Common.GetPicURL(pic, "resize200") + "\" width=\"60\" height=\"60\"></a></span><a href=\"javascript:;\" class=\"code\">商品编码:" + obj.GoodsCode + str7 + "</a><a href=\"javascript:;\" class=\"name\">" + GetGoodsName(obj.GoodsName, obj.GoodsInfos, "1") + "<i>" + GetGoodsName(obj.GoodsName, obj.GoodsInfos, "2") + "</i></a></div></td><td><div class=\"tc\">" + obj.Unit + "</div></td><td><input type=\"text\" tip2=\"" + index + "\" class=\"boxs divprice" + index + "\"   value=\"" + decimal.Parse(string.Format("{0:N2}", newprice)).ToString("0.00") + "\" maxlength=\"9\" ><input type=\"hidden\" class=\"hidPrice\" value=\"" + decimal.Parse(string.Format("{0:N2}", newprice2)).ToString("0.00") + "\" /></td><td style=\"" + str6 + "\"><div class=\"tc\"><input type=\"hidden\" id=\"hidInventory_" + index + "\" value=\"" + decimal.Parse(string.Format("{0:N2}", kc)).ToString(Digits) + "\" />" + decimal.Parse(string.Format("{0:N2}", kc)).ToString(Digits) + "</div></td><td><div class=\"sl divnum\" tip=\"" + obj.GoodsinfoID + "\" tip2=\"" + index + "\"><a href=\"javascript:void(0);\"  class=\"minus\">-</a><input type=\"text\" class=\"box txtGoodsNum txtGoodsNum" + index + "\" onfocus=\"InputFocus(this)\" onkeyup='KeyInt2(this)' maxlength=\"9\"  value=\"" + num + "\"><a href=\"javascript:void(0);\"  class=\"add\">+</a></div></td><td><div class=\"tc lblTotal_" + index + "\">¥" + str8 + "</div></td><td><div class=\"tc alink\"><a href=\"javascript:;\" class=\"aremark" + index + "\">" + (obj.Remark == "" ? "添加" : "编辑") + "</a>" + strremark + "</div></td></tr>";
                    index++;
                }
                this.lblTotalAmount.InnerText = decimal.Parse(string.Format("{0:N2}", OrderInfoModel.TotalAmount)).ToString("0.00"); //商品总额
                string str2 = string.Empty;                                                                                          //开票信息
                List <Hi.Model.DIS_OrderExt> l = new Hi.BLL.DIS_OrderExt().GetList("", "orderID=" + KeyID, "");
                if (l.Count > 0)
                {
                    foreach (Hi.Model.DIS_OrderExt item in l)
                    {
                        this.hrOrderInv.Value = item.DisAccID; //开票Id
                        this.hidLookUp.Value  = item.Rise;     //发票抬头
                        this.hidBank.Value    = item.OBank;    //开会银行
                        this.hidContext.Value = item.Content;  //发票内容
                        this.hidAccount.Value = item.OAccount; //开户帐号
                        this.hidRegNo.Value   = item.TRNumber; //纳税人登记号
                        if (item.IsOBill == 0)
                        {
                            str2 = "不开票";
                            this.hidVal.Value = "0";
                        }
                        else if (item.IsOBill == 1 && item.OAccount == "" && item.TRNumber == "" && item.OBank == "")
                        {
                            str2 = "发票抬头:" + item.Rise + ",发票内容:" + item.Content;
                            this.hidVal.Value = "1";
                        }
                        else
                        {
                            str2 = "发票抬头:" + item.Rise + ",发票内容:" + item.Content + ",开户银行:" + item.OBank + ",开户账户:" + item.OAccount + ",纳税人登记号:" + item.TRNumber;
                            this.hidVal.Value = "2";
                        }

                        this.lblCux.InnerText = decimal.Parse(string.Format("{0:N2}", item.ProAmount.ToString())).ToString("0.00");//订单促销
                    }
                }
                if (Convert.ToDecimal(str8) < 0)
                {
                    str8 = "0.00";
                }
                if (Request["type"] + "" != "2" || Fanli == 1)
                {
                    this.lblFanl.InnerText = decimal.Parse(string.Format("{0:N2}", OrderInfoModel.bateAmount.ToString())).ToString("0.00");//返利金额
                }
                ClientScript.RegisterStartupScript(this.GetType(), "adder", "<script>$(function(){$(\".site .site-if\").text(\"" + str + "\");$(\".invoice .in-if\").text(\"" + str2 + "\");$(\".attach .list\").html(\"" + str3.Replace("\"", "'") + "\");$(\".edit-ok .txt\").html(\"" + str4.Replace("\"", "'") + "\");  $(\".tabLine table tbody\").html(\"" + html.Replace("\"", "'") + "\"); $(\"#lblYFPrice\").text(\"" + decimal.Parse(string.Format("{0:N2}", (Request["type"] + "" == "2" && Fanli == 0 ? OrderInfoModel.AuditAmount + OrderInfoModel.bateAmount : OrderInfoModel.AuditAmount))).ToString("0.00") + "\"); $(\".jxs-box .opt-i\").hide();})</script>");
            }
        }
    }