Ejemplo n.º 1
0
        /// <summary>
        /// 新增请款单数据
        /// </summary>
        /// <param name="id"></param>
        private void InsertPaymentRequstData(XMPurchase purchases)
        {
            XMPaymentApply paymentApply = new XMPaymentApply();

            paymentApply.PurchaseID       = purchases.Id;
            paymentApply.PayAmounts       = purchases.ProductsMoney.Value;
            paymentApply.PayMode          = purchases.PaymentType.Value;
            paymentApply.SupplierID       = purchases.SupplierId;
            paymentApply.RequstDate       = DateTime.Now;
            paymentApply.UserDate         = purchases.PurchaseDate;
            paymentApply.ApplicantID      = HozestERPContext.Current.User.CustomerID;
            paymentApply.UpdateDate       = DateTime.Now;
            paymentApply.UpdateID         = HozestERPContext.Current.User.CustomerID;
            paymentApply.IsAudit          = false;
            paymentApply.FinancialStatus  = false;
            paymentApply.FinancialConfirm = false;
            paymentApply.IsEnable         = false;
            base.XMPaymentApplyService.InsertXMPaymentApply(paymentApply);
        }
Ejemplo n.º 2
0
        public StringBuilder GetOrderPutJson(StringBuilder body, XMPurchase purchase, ref string msg)
        {
            try
            {
                int    a        = 0;
                string Zip      = "000000";
                string remark   = "";
                string shopName = "城市爱情";
                string WantID   = purchase.BuyMember == null ? "" : purchase.BuyMember;
                string Province = "";
                string City     = "";
                string County   = "";
                string Address  = "";

                if (!string.IsNullOrEmpty(purchase.DealAddress) && purchase.DealAddress.Length >= 8)
                {
                    string ybs = purchase.DealAddress.Substring(purchase.DealAddress.Length - 8).Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "");

                    if (ybs.Length == 6 && int.TryParse(ybs, out a))
                    {
                        Zip = ybs;
                    }
                }

                body.Append("{").Append("\"platOrderHeader\":{").Append("");
                body.Append("\"shopName\":").Append("\"" + shopName + "\",");
                body.Append("\"status\":").Append("\"WAIT_SELLER_SEND_GOODS\",");

                #region 修改卖家备注

                remark = purchase.SellerRemarks == null ? "" : purchase.SellerRemarks;

                if (remark.IndexOf("//赠品") != -1)
                {
                    remark = remark.Substring(0, remark.IndexOf("//赠品"));
                }
                if (remark.IndexOf("//更改尺寸为") > -1)
                {
                    remark = remark.Substring(0, remark.IndexOf("//更改尺寸为"));
                }
                else if (remark.IndexOf("//更改床垫地址") > -1)
                {
                    remark = remark.Substring(0, remark.IndexOf("//更改床垫地址"));
                }

                //var exist = purchase.XM_Delivery_Details.Where(x => x.PrdouctName.Contains("乳胶枕") || x.PrdouctName.Contains("喜米") || x.PrdouctName.Contains("U型枕")).ToList();
                //if (exist != null && exist.Count > 0)
                //{
                //    remark = "圆通速递/能发就发/小城///送货上门";
                //}

                #endregion

                body.Append("\"sellerMemo\":").Append("\"" + remark + "\",");
                body.Append("\"modified\":").Append("\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\",");
                body.Append("\"buyerNick\":").Append("\"" + WantID + "\",");
                body.Append("\"created\":").Append("\"" + ((DateTime)purchase.Date_Created).ToString("yyyy-MM-dd HH:mm:ss") + "\",");
                body.Append("\"num\":").Append(purchase.XM_PurchaseProductDetails.Sum(x => x.ProductCount) + ",");
                body.Append("\"tid\":").Append("\"" + purchase.PurchaseNumber + "\",");
                body.Append("\"payment\":").Append((purchase.ProductsMoney == null ? 0 : purchase.ProductsMoney) + ",");
                body.Append("\"payTime\":").Append("\"" + ((DateTime)purchase.PurchaseDate).ToString("yyyy-MM-dd HH:mm:ss") + "\",");
                body.Append("\"totalFee\":").Append((purchase.ProductsMoney == null ? 0 : purchase.ProductsMoney) + ",");
                body.Append("\"postFee\":").Append("0,");
                body.Append("\"receiverName\":").Append("\"" + purchase.Receiver + "\",");

                #region 省市区处理

                Address = purchase.DealAddress.Replace("\r", "").Replace("\n", "");
                if (Address.StartsWith("上海") || Address.StartsWith("北京") ||
                    Address.StartsWith("天津") || Address.StartsWith("重庆"))
                {
                    Province = Address.Substring(0, 2);
                    City     = Province + "市";
                    Address  = Address.Substring(2, Address.Length - 2);
                    if (Address.StartsWith("市"))
                    {
                        Address = Address.Substring(1, Address.Length - 1);
                    }

                    if (Address.Contains("区"))
                    {
                        int CountyIndex = Address.IndexOf("区");
                        County = Address.Substring(0, CountyIndex + 1);
                    }
                    else if (Address.Contains("县"))
                    {
                        int CountyIndex = Address.IndexOf("县");
                        County = Address.Substring(0, CountyIndex + 1);
                    }
                    Address = Address.Substring(County.Length, Address.Length - County.Length);
                }
                else
                {
                    if (Address.Contains("省") || Address.Contains("自治区"))
                    {
                        if (Address.Contains("省"))
                        {
                            int ProvinceIndex = Address.IndexOf("省");
                            Province = Address.Substring(0, ProvinceIndex + 1);
                            Address  = Address.Substring(Province.Length, Address.Length - Province.Length);
                        }
                        else if (Address.Contains("自治区"))
                        {
                            int ProvinceIndex = Address.IndexOf("自治区");
                            Province = Address.Substring(0, ProvinceIndex + 3);
                            Address  = Address.Substring(Province.Length, Address.Length - Province.Length);
                        }
                    }
                    if (Address.Contains("市"))
                    {
                        int CityIndex = Address.IndexOf("市");
                        City    = Address.Substring(0, CityIndex + 1);
                        Address = Address.Substring(City.Length, Address.Length - City.Length);
                    }
                    if (Address.Contains("区") || Address.Contains("县"))
                    {
                        if (Address.Contains("区"))
                        {
                            int CountyIndex = Address.IndexOf("区");
                            County = Address.Substring(0, CountyIndex + 1);
                        }
                        else if (Address.Contains("县"))
                        {
                            int CountyIndex = Address.IndexOf("县");
                            County = Address.Substring(0, CountyIndex + 1);
                        }
                        Address = Address.Substring(County.Length, Address.Length - County.Length);
                    }
                }

                #endregion

                body.Append("\"receiverState\":").Append("\"" + Province + "\",");
                body.Append("\"receiverCity\":").Append("\"" + City + "\",");
                body.Append("\"receiverDistrict\":").Append("\"" + County + "\",");

                #region 详细地址

                if (!Address.Contains(County))
                {
                    Address = County + Address;
                }

                #endregion

                body.Append("\"receiverAddress\":").Append("\"" + Address + "\",");

                body.Append("\"receiverZip\":").Append("\"" + Zip + "\",");
                body.Append("\"receiverMobile\":").Append("\"" + purchase.ReceiverMobile + "\",");
                body.Append("\"receiverPhone\":").Append("\"" + (purchase.Tel == null ? "" : (purchase.Tel == "" ? "0000-00000000" : purchase.Tel)) + "\",");
                body.Append("\"hasPostFee\":").Append("true},");

                //platOrderDetails
                body.Append("\"platOrderDetails\":[");

                var detailList = purchase.XM_PurchaseProductDetails.Where(p => p.IsEnable == false).ToList();

                for (int i = 0; i < detailList.Count; i++)
                {
                    decimal Price             = 0;
                    string  ManufacturersCode = "";
                    body.Append("{");
                    var detail = detailList[i];

                    //var Product = base.XMProductDetailsService.GetXMProductDetailsByPlatformMerchantCode(detail.PlatformMerchantCode, (int)detail.PlatformTypeId);
                    var Product = base.XMProductDetailsService.GetXMProductDetailsByProductIdAndPlatFormId((int)detail.ProductId, (int)detail.PlatformTypeId);
                    //if (Product != null && Product.Count > 0)
                    //{
                    //    var product = IoC.Resolve<IXMProductService>().GetXMProductById((int)Product[0].ProductId);
                    //    if (product != null)
                    //    {
                    //        Price = Product[0].Saleprice == null ? 0 : (decimal)Product[0].Saleprice;
                    //        ManufacturersCode = Product[0].ManufacturersCode;
                    //    }
                    //}
                    //if (ManufacturersCode == "")
                    //{
                    //    msg += "商品编码:" + detail.PlatformMerchantCode + ",不存在!<br/>";
                    //    return null;
                    //}
                    //Price = detail.ProductPrice;//取采购订单的单价

                    if (Product != null)
                    {
                        Price = decimal.Parse(Product.Saleprice.ToString());//取商品的单价
                    }
                    else //对应平台没有找通用
                    {
                        Product = base.XMProductDetailsService.GetXMProductDetailsByProductIdAndPlatFormId((int)detail.ProductId, 508);
                        Price   = decimal.Parse(Product.Saleprice.ToString());//取商品的单价
                    }
                    body.Append("\"totalFee\":").Append(Price * detail.ProductCount + ",");
                    body.Append("\"payment\":").Append(Price * detail.ProductCount + ",");
                    body.Append("\"modified\":").Append("\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\",");
                    body.Append("\"num\":").Append(detail.ProductCount + ",");
                    body.Append("\"price\":").Append(Price + ",");
                    body.Append("\"outerSkuId\":").Append("\"" + detail.PlatformMerchantCode + "\",");//数据库字段名声定义不准确,名称含义是商品编码,实际内容是厂家编码
                    body.Append("\"taxRate\":").Append("\"0.06\"}");
                    if (i != detailList.Count - 1)
                    {
                        body.Append(",");
                    }
                }
                body.Append("],");

                //platOrderPayTypes
                body.Append("\"platOrderPayTypes\":[{");
                body.Append("\"amount\":").Append((purchase.ProductsMoney == null ? 0 : purchase.ProductsMoney) + ",");
                body.Append("\"payType\":").Append("\"001\"}]}");

                return(body);
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        //保存功能(根据参数执行相关功能  true  更新业务员   false 不更新业务员)
        private void OperateSave(bool isUpdate)
        {
            decimal value = 0;

            if (this.type == 0)            //新增
            {
                string purChaseCode    = "";
                bool   isEmpty         = false;                //判断厂家编码是否填写(厂家编码必填)
                bool   isFalse         = false;                //判断采购数量(数量不能为0)
                string hiddjsonContent = hdfJsonContent.Value; //产品列表 json
                string ss     = hiddAutoID.Value;
                bool   isAuto = bool.Parse(hiddAutoID.Value);
                if (isAuto)              //只读  自动生成采购单号
                {
                    purChaseCode = AutoPurchaseNumber();
                }
                else
                {
                    purChaseCode = txtPurchaseNumber.Text.Trim();
                    if (string.IsNullOrEmpty(purChaseCode))
                    {
                        base.ShowMessage("采购单号必须填写!");
                        BindGrid(hiddjsonContent);
                        return;
                    }
                }
                var purchaseInfo = base.XMPurchaseService.GetXMPurchaseBypurChaseCode(purChaseCode);
                if (purchaseInfo != null && purchaseInfo.Count() > 0)
                {
                    base.ShowMessage("采购单号已存在 !");
                    BindGrid(hiddjsonContent);
                    return;
                }
                int      supplierId     = Convert.ToInt16(ddlSuppliers.SelectedValue);
                string   contacter      = txtContacter.Text.Trim();
                string   tel            = txtTel.Text.Trim();
                string   fax            = txtFax.Text.Trim();
                string   BuyMember      = txtBuyerName.Text.Trim();
                string   Receiver       = txtResiveName.Text.Trim();
                string   ReceiverMobile = txtRecivesMobile.Text.Trim();
                string   EmitFactory    = txtSendFactory.Text.Trim();
                string   SellerRemarks  = TextBox1.Text.Trim();
                int      BizUserId      = HozestERPContext.Current.User.CustomerID; //采购人
                DateTime PurchaseDate   = txtPurchaseDate.Value == "" ? DateTime.Parse(DateTime.Now.ToShortDateString()) : Convert.ToDateTime(txtPurchaseDate.Value);
                int      status         = 0;                                        //采购单初始状态待入库
                decimal  totalMoney     = 0;                                        //采购单总价
                if (hiddjsonContent != "")
                {
                    JArray ja_goods = (JArray)JsonConvert.DeserializeObject(hiddjsonContent);
                    for (int i = 0; i < ja_goods.Count; i++)
                    {
                        string productCode = ja_goods[i]["txtProductCode"].ToString().Replace('\"', ' ').Trim(); //厂家编码
                        if (productCode == "")                                                                   //厂家编码存在为空的
                        {
                            isEmpty = true;
                        }

                        string productPrice = ja_goods[i]["txtProductPrice"].ToString().Replace('\"', ' ').Trim() == "" ? value.ToString() : ja_goods[i]["txtProductPrice"].ToString().Replace('\"', ' ').Trim();      //采购单价
                        string productMoney = ja_goods[i]["txtProductMoney"].ToString().Replace('\"', ' ').Trim() == "" ? value.ToString() : ja_goods[i]["txtProductMoney"].ToString().Replace('\"', ' ').Trim();      //采购单价

                        bool t = IsNumeric(ja_goods[i]["txtProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? "0" : ja_goods[i]["txtProductCount"].ToString().Replace('\"', ' ').Trim());
                        if (!t || !IsFloat(productPrice) || !IsFloat(productMoney))
                        {
                            base.ShowMessage("输入格式不正确!");
                            BindGrid(hiddjsonContent);
                            return;
                        }
                        int productCount = ja_goods[i]["txtProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["txtProductCount"].ToString().Replace('\"', ' ').Trim());      //采购数量
                        if (productCount == 0)
                        {
                            isFalse = true;
                        }
                        totalMoney = totalMoney + decimal.Parse(productMoney);
                    }
                }
                if (isEmpty)
                {
                    base.ShowMessage("厂家编码不能为空!请输入厂家编码");
                    BindGrid(hiddjsonContent);
                    return;
                }
                if (isFalse)
                {
                    base.ShowMessage("商品采购数量不能为 0!");
                    BindGrid(hiddjsonContent);
                    return;
                }
                int      paymentType      = int.Parse(ddlPayType.SelectedValue);
                DateTime deliveryDate     = txtDeliveryDate.Value == "" ? DateTime.Parse(DateTime.Now.ToShortDateString()) : Convert.ToDateTime(txtDeliveryDate.Value);
                string   deliveryAddresss = txtDeliveryAddresss.Text.Trim();
                string   note             = txtNote.Text.Trim();

                XMPurchase purchase = new XMPurchase();
                purchase.PurchaseNumber = purChaseCode;
                purchase.SupplierId     = supplierId;
                purchase.Contact        = contacter;
                purchase.Tel            = tel;
                purchase.Fax            = fax;
                if (isUpdate)
                {
                    purchase.BizUserId = BizUserId;
                }
                purchase.PurchaseDate    = PurchaseDate;
                purchase.BillStatus      = status;
                purchase.ProductsMoney   = totalMoney;
                purchase.PaymentType     = paymentType;
                purchase.DealDate        = deliveryDate;
                purchase.DealAddress     = deliveryAddresss;
                purchase.InputUserId     = HozestERPContext.Current.User.CustomerID;
                purchase.Date_Created    = DateTime.Now;
                purchase.UpdateDate      = DateTime.Now;
                purchase.UpdateID        = HozestERPContext.Current.User.CustomerID;
                purchase.BillMemo        = note;
                purchase.IsEnable        = false;
                purchase.IsAudit         = false;
                purchase.FinancialStatus = false;
                purchase.LogisticsFee    = string.IsNullOrEmpty(txtLogisticsFee.Text.Trim()) ? 0 : decimal.Parse(txtLogisticsFee.Text.Trim());

                purchase.BuyMember      = BuyMember;
                purchase.Receiver       = Receiver;
                purchase.ReceiverMobile = ReceiverMobile;
                purchase.EmitFactory    = EmitFactory;
                purchase.SellerRemarks  = SellerRemarks;

                base.XMPurchaseService.InsertXMPurchase(purchase);
                int purchaseId = purchase.Id;
                if (hiddjsonContent != "")
                {
                    JArray ja_goods = (JArray)JsonConvert.DeserializeObject(hiddjsonContent);
                    for (int i = 0; i < ja_goods.Count; i++)
                    {
                        string  productCode    = ja_goods[i]["txtProductCode"].ToString().Replace('\"', ' ').Trim();                                                                                                     //厂家编码
                        string  productName    = ja_goods[i]["txtProductName"].ToString().Replace('\"', ' ').Trim();                                                                                                     //商品名称
                        string  specifications = ja_goods[i]["lblSpecifications"].ToString().Replace('\"', ' ').Trim();                                                                                                  //商品规格
                        int     productCount   = ja_goods[i]["txtProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["txtProductCount"].ToString().Replace('\"', ' ').Trim());         //采购数量
                        string  unit           = ja_goods[i]["txtUnit"].ToString().Replace('\"', ' ').Trim();                                                                                                            //单位
                        decimal productPrice   = ja_goods[i]["txtProductPrice"].ToString().Replace('\"', ' ').Trim() == "" ? value : decimal.Parse(ja_goods[i]["txtProductPrice"].ToString().Replace('\"', ' ').Trim()); //采购单价
                        decimal productMoney   = ja_goods[i]["txtProductMoney"].ToString().Replace('\"', ' ').Trim() == "" ? value : decimal.Parse(ja_goods[i]["txtProductMoney"].ToString().Replace('\"', ' ').Trim()); //采购单价

                        int platFormId = ja_goods[i]["PlatformTypeId"].ToString().Replace('\"', ' ').Trim() == "" ? 251 : int.Parse(ja_goods[i]["PlatformTypeId"].ToString().Replace('\"', ' ').Trim());                 //平台
                        XMPurchaseProductDetails details = new XMPurchaseProductDetails();
                        details.PurchaseId = purchaseId;
                        var product = base.XMProductService.getXMProductByManufacturersCode(productCode);
                        if (product != null)
                        {
                            details.ProductId = product.Id;
                        }
                        details.PlatformTypeId       = platFormId;
                        details.PlatformMerchantCode = productCode;
                        details.ProductCount         = productCount;
                        details.ProductMoney         = productMoney;
                        details.ProductPrice         = productPrice;
                        details.CreateID             = HozestERPContext.Current.User.CustomerID;
                        details.CreateDate           = DateTime.Now;
                        details.UpdateDate           = DateTime.Now;
                        details.UpdateID             = HozestERPContext.Current.User.CustomerID;
                        details.IsEnable             = false;
                        base.XMPurchaseProductDetailsService.InsertXMPurchaseProductDetails(details);
                    }
                }
                base.ShowMessage("操作成功!");
                BindGrid(purchaseId);
            }
            else                                 //编辑
            {
                bool    isEmpty         = false; //判断厂家编码是否填写(厂家编码必填)
                bool    isFalse         = false; //判断采购数量(数量不能为0)
                int     id              = this.scid;
                string  BuyMember       = txtBuyerName.Text.Trim();
                string  Receiver        = txtResiveName.Text.Trim();
                string  ReceiverMobile  = txtRecivesMobile.Text.Trim();
                string  EmitFactory     = txtSendFactory.Text.Trim();
                string  SellerRemarks   = TextBox1.Text.Trim();
                decimal totalMoney      = 0;                    //采购单总价
                string  hiddjsonContent = hdfJsonContent.Value; //产品列表 json
                var     purchase        = base.XMPurchaseService.GetXMPurchaseById(id);
                if (purchase != null)
                {
                    var purchaseDetails = base.XMPurchaseProductDetailsService.GetXMPurchaseProductDetailsByPurchaseID(purchase.Id);
                    purchase.SupplierId = Convert.ToInt16(ddlSuppliers.SelectedValue);
                    purchase.Contact    = txtContacter.Text.Trim();
                    purchase.Tel        = txtTel.Text.Trim();
                    purchase.Fax        = txtFax.Text.Trim();
                    if (isUpdate)
                    {
                        purchase.BizUserId = HozestERPContext.Current.User.CustomerID;
                    }
                    purchase.PurchaseDate = txtPurchaseDate.Value == "" ? DateTime.Now : Convert.ToDateTime(txtPurchaseDate.Value);
                    purchase.BillStatus   = 0;
                    if (hiddjsonContent != "")
                    {
                        JArray ja_goods = (JArray)JsonConvert.DeserializeObject(hiddjsonContent);
                        for (int i = 0; i < ja_goods.Count; i++)
                        {
                            string productCode = ja_goods[i]["txtProductCode"].ToString().Replace('\"', ' ').Trim(); //厂家编码
                            if (productCode == "")                                                                   //厂家编码存在为空的
                            {
                                isEmpty = true;
                            }
                            bool   t            = IsNumeric(ja_goods[i]["txtProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? "0" : ja_goods[i]["txtProductCount"].ToString().Replace('\"', ' ').Trim());
                            string productPrice = ja_goods[i]["txtProductPrice"].ToString().Replace('\"', ' ').Trim() == "" ? value.ToString() : ja_goods[i]["txtProductPrice"].ToString().Replace('\"', ' ').Trim();      //采购单价

                            string productMoney = ja_goods[i]["txtProductMoney"].ToString().Replace('\"', ' ').Trim() == "" ? value.ToString() : ja_goods[i]["txtProductMoney"].ToString().Replace('\"', ' ').Trim();      //采购单价
                            if (!t || !IsFloat(productPrice) || !IsFloat(productMoney))
                            {
                                base.ShowMessage("输入格式不正确!");
                                BindGrid(hiddjsonContent);
                                return;
                            }
                            int productCount = ja_goods[i]["txtProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["txtProductCount"].ToString().Replace('\"', ' ').Trim());      //采购数量
                            if (productCount == 0)
                            {
                                isFalse = true;
                            }
                            totalMoney = totalMoney + decimal.Parse(productMoney);
                        }
                    }
                    if (isEmpty)
                    {
                        base.ShowMessage("厂家编码不能为空!请输入厂家编码");
                        BindGrid(hiddjsonContent);
                        return;
                    }
                    if (isFalse)
                    {
                        base.ShowMessage("商品采购数量不能为 0  !");
                        BindGrid(hiddjsonContent);
                        return;
                    }
                    purchase.BuyMember      = BuyMember;
                    purchase.Receiver       = Receiver;
                    purchase.ReceiverMobile = ReceiverMobile;
                    purchase.EmitFactory    = EmitFactory;
                    purchase.SellerRemarks  = SellerRemarks;
                    purchase.LogisticsFee   = string.IsNullOrEmpty(txtLogisticsFee.Text.Trim()) ? 0 : decimal.Parse(txtLogisticsFee.Text.Trim());

                    purchase.ProductsMoney = totalMoney;
                    purchase.PaymentType   = int.Parse(ddlPayType.SelectedValue);
                    purchase.DealDate      = txtDeliveryDate.Value == "" ? DateTime.Now : Convert.ToDateTime(txtDeliveryDate.Value);
                    purchase.DealAddress   = txtDeliveryAddresss.Text.Trim();
                    purchase.UpdateDate    = DateTime.Now;
                    purchase.UpdateID      = HozestERPContext.Current.User.CustomerID;
                    purchase.BillMemo      = txtNote.Text.Trim();
                    base.XMPurchaseService.UpdateXMPurchase(purchase);
                    if (hiddjsonContent != "")
                    {
                        JArray ja_goods = (JArray)JsonConvert.DeserializeObject(hiddjsonContent);
                        for (int i = 0; i < ja_goods.Count; i++)
                        {
                            bool    isExsit        = false;                                                                                                                                                                  //判断厂家编码是否存在
                            string  productCode    = ja_goods[i]["txtProductCode"].ToString().Replace('\"', ' ').Trim();                                                                                                     //厂家编码
                            string  productName    = ja_goods[i]["txtProductName"].ToString().Replace('\"', ' ').Trim();                                                                                                     //商品名称
                            string  specifications = ja_goods[i]["lblSpecifications"].ToString().Replace('\"', ' ').Trim();                                                                                                  //商品规格
                            int     productCount   = ja_goods[i]["txtProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["txtProductCount"].ToString().Replace('\"', ' ').Trim());         //采购数量
                            string  unit           = ja_goods[i]["txtUnit"].ToString().Replace('\"', ' ').Trim();                                                                                                            //单位
                            decimal productPrice   = ja_goods[i]["txtProductPrice"].ToString().Replace('\"', ' ').Trim() == "" ? value : decimal.Parse(ja_goods[i]["txtProductPrice"].ToString().Replace('\"', ' ').Trim()); //采购单价
                            decimal productMoney   = ja_goods[i]["txtProductMoney"].ToString().Replace('\"', ' ').Trim() == "" ? value : decimal.Parse(ja_goods[i]["txtProductMoney"].ToString().Replace('\"', ' ').Trim()); //采购单价
                            int     platFormId     = ja_goods[i]["PlatformTypeId"].ToString().Replace('\"', ' ').Trim() == "" ? 251 : int.Parse(ja_goods[i]["PlatformTypeId"].ToString().Replace('\"', ' ').Trim());         //平台
                            foreach (XMPurchaseProductDetails info in purchaseDetails)
                            {
                                if (productCode == info.PlatformMerchantCode)
                                {
                                    isExsit             = true;
                                    info.ProductCount   = productCount;
                                    info.PlatformTypeId = platFormId;
                                    info.ProductMoney   = productMoney;
                                    info.ProductPrice   = productPrice;
                                    info.UpdateID       = HozestERPContext.Current.User.CustomerID;
                                    info.UpdateDate     = DateTime.Now;
                                    base.XMPurchaseProductDetailsService.UpdateXMPurchaseProductDetails(info);
                                }
                            }
                            if (ja_goods.Count > purchaseDetails.Count && isExsit == false)             //不存在新增
                            {
                                XMPurchaseProductDetails detail = new XMPurchaseProductDetails();
                                detail.PurchaseId = purchase.Id;
                                var product = base.XMProductService.getXMProductByManufacturersCode(productCode);
                                if (product != null)
                                {
                                    detail.ProductId = product.Id;
                                }
                                detail.PlatformTypeId       = platFormId;
                                detail.PlatformMerchantCode = productCode;
                                detail.ProductCount         = productCount;
                                detail.ProductMoney         = productMoney;
                                detail.ProductPrice         = productPrice;
                                detail.CreateDate           = DateTime.Now;
                                detail.CreateID             = HozestERPContext.Current.User.CustomerID;
                                detail.UpdateDate           = DateTime.Now;
                                detail.UpdateID             = HozestERPContext.Current.User.CustomerID;
                                detail.IsEnable             = false;
                                base.XMPurchaseProductDetailsService.InsertXMPurchaseProductDetails(detail);
                            }
                        }
                    }

                    if (purchaseDetails != null && purchaseDetails.Count > 0)
                    {
                        foreach (XMPurchaseProductDetails info in purchaseDetails)
                        {
                            bool isDelete = true;
                            if (hiddjsonContent != "")
                            {
                                JArray ja_goods = (JArray)JsonConvert.DeserializeObject(hiddjsonContent);
                                for (int i = 0; i < ja_goods.Count; i++)
                                {
                                    string productCode = ja_goods[i]["txtProductCode"].ToString().Replace('\"', ' ').Trim();       //厂家编码
                                    if (productCode == info.PlatformMerchantCode)
                                    {
                                        isDelete = false;
                                        break;
                                    }
                                }
                            }
                            if (isDelete)
                            {
                                info.IsEnable   = true;
                                info.UpdateID   = HozestERPContext.Current.User.CustomerID;
                                info.UpdateDate = DateTime.Now;
                                base.XMPurchaseProductDetailsService.UpdateXMPurchaseProductDetails(info);
                            }
                        }
                    }
                }
                base.ShowMessage("操作成功!");
                BindGrid(purchase.Id);
            }
        }