Example #1
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Hi.Model.BD_GoodsInfo model)
 {
     return(dal.Update(model));
 }
Example #2
0
    /// <summary>
    /// 确定导入
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnImport_Click(object sender, EventArgs e)
    {
        if (HttpContext.Current.Session["GoodsTable"] != null)
        {
            SqlTransaction Tran       = null;
            SqlConnection  Connection = new SqlConnection(SqlHelper.LocalSqlServer);
            Connection.Open();
            Tran = Connection.BeginTransaction();
            try
            {
                DataTable dt = HttpContext.Current.Session["GoodsTable"] as DataTable;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["chkstr"].ToString() == "数据正确!")
                    {
                        Hi.Model.BD_Goods model = new Hi.Model.BD_Goods();
                        model.CompID     = this.CompID;
                        model.GoodsName  = dt.Rows[i]["goodsname"].ToString();
                        model.GoodsCode  = "";// dt.Rows[i]["barcode"].ToString(); ;
                        model.CategoryID = Convert.ToInt32(dt.Rows[i]["categoryid"].ToString());
                        model.Unit       = CheckGoodsUnit(dt.Rows[i]["unit"].ToString(), "计量单位", Tran);
                        model.SalePrice  = Convert.ToDecimal(dt.Rows[i]["price"].ToString());
                        //if (dt.Rows[i]["isoffline"] == null)
                        //{
                        //    model.IsOffline = 1;
                        //}
                        //else
                        //{
                        model.IsOffline = dt.Rows[i]["isoffline"].ToString() == "是" || dt.Rows[i]["isoffline"].ToString() == "" ? 1 : 0;
                        // }
                        model.IsSale = 0;
                        //if (dt.Rows[i]["isrecommended"] == null)
                        //{
                        //    model.IsRecommended = 1;
                        //}
                        //else
                        //{
                        model.IsRecommended = dt.Rows[i]["isrecommended"].ToString() == "是" || dt.Rows[i]["isrecommended"].ToString() == "" ? 1 : 0;
                        // }
                        model.IsIndex      = 0;
                        model.Title        = dt.Rows[i]["title"].ToString();
                        model.CreateUserID = this.UserID;
                        model.CreateDate   = DateTime.Now;
                        model.IsEnabled    = 1;
                        model.modifyuser   = this.UserID;
                        model.memo         = dt.Rows[i]["details"].ToString();
                        model.ts           = DateTime.Now;

                        int      goodsId = new Hi.BLL.BD_Goods().Add(model, Tran);
                        string[] spec    = (string[])dt.Rows[i]["spec"];

                        if (spec.Length == 0)
                        {
                            Hi.Model.BD_GoodsInfo model4 = new Hi.Model.BD_GoodsInfo();
                            model4.CompID = this.CompID;
                            if (dt.Rows[i]["barcode"].ToString() == "")
                            {
                                model4.BarCode = GoodsCode(Tran);
                            }
                            else
                            {
                                model4.BarCode = dt.Rows[i]["barcode"].ToString();
                            }
                            model4.GoodsID = goodsId;
                            if (dt.Rows[i]["inventory"].ToString() != "")
                            {
                                model4.Inventory = Convert.ToDecimal(dt.Rows[i]["inventory"].ToString());
                            }

                            model4.IsOffline    = 1;
                            model4.ValueInfo    = "";
                            model4.SalePrice    = Convert.ToDecimal(dt.Rows[i]["price"].ToString());
                            model4.TinkerPrice  = Convert.ToDecimal(dt.Rows[i]["price"].ToString());
                            model4.IsEnabled    = true;
                            model4.CreateDate   = DateTime.Now;
                            model4.CreateUserID = this.UserID;
                            model4.ts           = DateTime.Now;
                            model4.modifyuser   = this.UserID;
                            int goodsInfoId = new Hi.BLL.BD_GoodsInfo().Add(model4, Tran);

                            model.ID         = goodsId;
                            model.ViewInfoID = goodsInfoId;
                            model.ts         = DateTime.Now;
                            model.modifyuser = this.UserID;
                            new Hi.BLL.BD_Goods().Update(model, Tran);
                        }
                        else
                        {
                            List <List <string> > valueList = new List <List <string> >();
                            for (int v = 0; v < spec.Length; v++)
                            {
                                //添加商品属性数据
                                Hi.Model.BD_GoodsAttrs attr = new Hi.Model.BD_GoodsAttrs();
                                attr.GoodsID    = goodsId;
                                attr.CompID     = CompID;
                                attr.dr         = 0;
                                attr.ts         = DateTime.Now;
                                attr.modifyuser = UserID;
                                attr.AttrsName  = spec[v].Trim();
                                int attrid = new Hi.BLL.BD_GoodsAttrs().Add(attr, Tran);

                                List <string> valueList2 = new List <string>();
                                string[]      values     = dt.Rows[i]["value" + (v + 1) + ""].ToString().Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                                foreach (string value in values)
                                {
                                    valueList2.Add(value);

                                    //添加商品属性值明细数据
                                    Hi.Model.BD_GoodsAttrsInfo attrinfo = new Hi.Model.BD_GoodsAttrsInfo();
                                    attrinfo.AttrsID       = attrid;
                                    attrinfo.GoodsID       = goodsId;
                                    attrinfo.CompID        = CompID;
                                    attrinfo.ts            = DateTime.Now;
                                    attrinfo.modifyuser    = UserID;
                                    attrinfo.AttrsInfoName = value.Trim();
                                    new Hi.BLL.BD_GoodsAttrsInfo().Add(attrinfo, Tran);
                                }
                                valueList.Add(valueList2);
                            }

                            string[] valueInfos  = makeValueInfo(valueList, spec); //生成商品ValueInfo
                            int      firstInfoId = 0;
                            foreach (string valueinfo in valueInfos)
                            {
                                Hi.Model.BD_GoodsInfo goodsinfo = new Hi.Model.BD_GoodsInfo();
                                goodsinfo.IsOffline    = 1;
                                goodsinfo.ValueInfo    = "";
                                goodsinfo.SalePrice    = dt.Rows[i]["price"].ToString().ToDecimal(0);
                                goodsinfo.TinkerPrice  = dt.Rows[i]["price"].ToString().ToDecimal(0);
                                goodsinfo.IsEnabled    = true;
                                goodsinfo.CreateDate   = DateTime.Now;
                                goodsinfo.CreateUserID = this.UserID;
                                goodsinfo.ts           = DateTime.Now;
                                goodsinfo.modifyuser   = this.UserID;
                                goodsinfo.GoodsID      = goodsId;
                                if (dt.Rows[i]["inventory"].ToString() != "")
                                {
                                    goodsinfo.Inventory = Convert.ToDecimal(dt.Rows[i]["inventory"].ToString());
                                }
                                goodsinfo.BarCode   = GoodsCode(Tran);
                                goodsinfo.CompID    = this.CompID;
                                goodsinfo.ValueInfo = valueinfo;

                                string[] infos = valueinfo.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                                for (int index = 0; index < infos.Length; index++)
                                {
                                    goodsinfo.GetType().GetProperty("Value" + (index + 1) + "").SetValue(goodsinfo, infos[index].Split(new char[] { ':' })[1], null);
                                }

                                int goodsInfoId = new Hi.BLL.BD_GoodsInfo().Add(goodsinfo, Tran);
                                if (firstInfoId == 0)
                                {
                                    firstInfoId = goodsInfoId;
                                }
                            }

                            model.ID         = goodsId;
                            model.ViewInfoID = firstInfoId;
                            model.ts         = DateTime.Now;
                            model.modifyuser = this.UserID;
                            new Hi.BLL.BD_Goods().Update(model, Tran);
                        }
                    }
                }
                Tran.Commit();
                Response.Redirect("ImportGoods3.aspx", false);
                //ClientScript.RegisterStartupScript(this.GetType(), "Add", "<script>addlis(" + count + "," + count2 + ",'" + str + "');</script>");
            }
            catch (Exception ex)
            {
                if (Tran != null)
                {
                    if (Tran.Connection != null)
                    {
                        Tran.Rollback();
                    }
                }
                HttpContext.Current.Session["GoodsTable"] = null;
                JScript.AlertMethod(this, "系统错误,导入商品失败!", JScript.IconOption.错误, "function(){location.href='ImportGoods.aspx'}");
            }
        }
        else
        {
            JScript.AlertMethod(this, "Excel没有数据,请重新导入", JScript.IconOption.错误, "function(){location.href='ImportGoods.aspx'}");
        }
    }
Example #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hi.Model.BD_GoodsInfo model)
 {
     return(dal.Add(model));
 }
Example #4
0
    /// <summary>
    /// 新增
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            List <string> l = new List <string>();

            string infoid = this.info.Value;
            l = new List <string>(infoid.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));

            foreach (RepeaterItem row in this.rptGoodsInfo.Items)
            {
                CheckBox cb = row.FindControl("CB_SelItem") as CheckBox;
                if (cb != null && cb.Checked)
                {
                    HiddenField fld  = row.FindControl("HF_Id") as HiddenField;
                    TextBox     fld3 = row.FindControl("txtPrice") as TextBox;
                    if (fld != null)
                    {
                        int id = Convert.ToInt32(fld.Value);
                        l.Add(id.ToString());
                    }
                }
            }

            if (l.Count == 0)
            {
                JScript.AlertMsgOne(this, "请勾选商品!", JScript.IconOption.错误);
                return;
            }
            List <Hi.Model.BD_GoodsInfo> lll = null;
            if (Session["GoodsPrice"] == null)
            {
                lll = new List <Hi.Model.BD_GoodsInfo>();
            }
            else
            {
                lll = Session["GoodsPrice"] as List <Hi.Model.BD_GoodsInfo>;
            }
            for (int j = 0; j < l.Count; j++)
            {
                Hi.Model.BD_GoodsInfo model2 = new Hi.Model.BD_GoodsInfo();
                model2.CompID = this.CompID;
                // model2.DisID = Convert.ToInt32(list[i]);
                model2.IsEnabled    = true;
                model2.CreateUserID = this.UserID;
                model2.CreateDate   = DateTime.Now;
                model2.ts           = DateTime.Now;
                model2.modifyuser   = this.UserID;
                model2.ID           = l[j].ToInt(0);
                Hi.Model.BD_GoodsInfo model3 = new Hi.BLL.BD_GoodsInfo().GetModel(Convert.ToInt32(l[j].ToString()));
                if (model3 != null)
                {
                    model2.GoodsID     = model3.GoodsID;
                    model2.TinkerPrice = model3.SalePrice;
                    model2.SalePrice   = model3.SalePrice;
                }
                int xy = 0;
                if (lll.Count != 0)
                {
                    foreach (Hi.Model.BD_GoodsInfo item in lll)
                    {
                        if (item.ID == l[j].ToInt(0))
                        {
                            xy++;
                        }
                    }
                }
                if (xy == 0)
                {
                    lll.Add(model2);
                }
            }
            if (lll.Count > 0)
            {
                Session["GoodsPrice"] = lll as List <Hi.Model.BD_GoodsInfo>;
                ClientScript.RegisterStartupScript(this.GetType(), "msg2", "<script>$(function(){window.parent.GbGoods();})</script>");
            }
        }
        catch (Exception ex)
        {
            JScript.AlertMsgOne(this, "出错了!", JScript.IconOption.错误);
            return;
        }
    }
Example #5
0
    public void btnAddList_Click(object sender, EventArgs e)
    {
        string         path   = "";
        int            count  = 0;
        int            count2 = 0;
        int            index  = 0;
        SqlTransaction Tran   = null;

        try
        {
            if (FileUpload1.HasFile == false)//HasFile用来检查FileUpload是否有指定文件
            {
                JScript.AlertMethod(this, "请您选择Excel文件", JScript.IconOption.错误);
                return;                                                                            //当无文件时,返回
            }
            string IsXls = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower(); //System.IO.Path.GetExtension获得文件的扩展名
            if (IsXls != ".xls" && IsXls != ".xlsx")
            {
                JScript.AlertMethod(this, "只可以选择Excel文件", JScript.IconOption.错误);
                return;//当选择的不是Excel文件时,返回
            }
            if (!Directory.Exists(Server.MapPath("TemplateFile")))
            {
                Directory.CreateDirectory(Server.MapPath("TemplateFile"));
            }
            string filename = FileUpload1.FileName;
            string name     = filename.Replace(IsXls, "");
            path = Server.MapPath("TemplateFile/") + name + "-" + DateTime.Now.ToString("yyyyMMddhhmmssffff") + IsXls;
            FileUpload1.SaveAs(path);
            System.Data.DataTable dt = Common.ExcelToDataTable(path, TitleIndex);
            if (dt == null)
            {
                throw new Exception("Excel表中无数据");
            }
            if (dt.Rows.Count == 0)
            {
                throw new Exception("Excel表中无数据");
            }

            string    goodsName    = string.Empty;
            string    goodsPrice   = string.Empty;
            string    goodsUnit    = string.Empty;
            string    goodsRemark  = string.Empty;
            string    goodsKuc     = string.Empty;
            string    goodsBarCode = string.Empty;
            string    goodsCate    = string.Empty;
            string    goodsCate2   = string.Empty;
            string    goodsCate3   = string.Empty;
            DataRow[] rows         = dt.Select();
            Tran       = DBUtility.SqlHelper.CreateStoreTranSaction();
            Eroor      = false;
            TitleError = string.Empty;
            int goodsId = 0;
            foreach (DataRow row in rows)
            {
                List <string[]> al             = new List <string[]>();
                string          goodsAttrValue = string.Empty;
                string          goodsAttr      = string.Empty;
                try
                {
                    if (row["分类*(必填项,“/”号分割分类)"].ToString().Trim() == "" && row["商品名称*(必填项,不能重复,不超过30个汉字)"].ToString().Trim() == "" && row["计量单位*(必填项,例如:件、个)"].ToString().Trim() == "" && row["价格*(必填项,最多两位小数)"].ToString().Trim() == "")
                    {
                        continue;
                    }
                    index++;
                    if (row["分类*(必填项,“/”号分割分类)"].ToString().Trim() == "示例:食品/面包" || row["分类*(必填项,“/”号分割分类)"].ToString().Trim() == "示例:食品/牛奶/伊利" || row["分类*(必填项,“/”号分割分类)"].ToString().Trim() == "示例:食品/牛奶/伊利")
                    {
                        continue;
                    }
                    string str = string.Empty;//几级商品分类
                    if (Util.IsEmpty(row["分类*(必填项,“/”号分割分类)"].ToString().Trim()))
                    {
                        CheckVal(row["分类*(必填项,“/”号分割分类)"].ToString().Trim(), "分类", index);
                    }
                    else
                    {
                        goodsCate  = CheckGoodsCate(CheckVal(row["分类*(必填项,“/”号分割分类)"].ToString().Trim(), "分类", index), "", index, Tran);
                        categoryId = goodsCate.Split('@')[1];
                    }
                }
                catch (Exception ex)
                {
                    if (ex is ApplicationException)
                    {
                        Eroor       = true;
                        TitleError += ex.Message;
                        continue;
                    }
                    else
                    {
                        throw new Exception("商品Excel模版格式错误,请重新下载模版填入数据后导入。");
                    }
                }
                goodsName    = GoodsObjExists(CheckVal(row["商品名称*(必填项,不能重复,不超过30个汉字)"].ToString().Trim(), "商品名称", index), "商品名称", index, Tran);
                goodsBarCode = GoodsObjExists(CheckVal(row["商品编码(非必填项,允许为空。如果填了,不能重复,不超过15个字符)"].ToString().Trim(), "商品编码", index), "商品编码", index, Tran);
                //if (goodsName == "ycz" || goodsBarCode == "ycz")
                //{ //已存在的数据,则跳过
                //    count2++;
                //    continue;
                //}
                goodsUnit   = CheckGoodsUnit(CheckVal(row["计量单位*(必填项,例如:件、个)"].ToString().Trim(), "计量单位", index), "计量单位", index, Tran);
                goodsPrice  = CheckPrice(CheckVal(row["价格*(必填项,最多两位小数)"].ToString().Trim(), "价格", index), "价格", index);
                goodsKuc    = CheckVal(row["库存(可设置是否启用)"].ToString().Trim(), "商品库存", index);
                goodsRemark = row["卖点/关键词(可不填,所填内容用来简单描述商品卖点信息)"].ToString().Trim();
                Hi.Model.BD_Goods model = new Hi.Model.BD_Goods();
                model.CompID        = this.CompID;
                model.GoodsName     = goodsName;
                model.GoodsCode     = goodsBarCode;
                model.CategoryID    = Convert.ToInt32(categoryId);
                model.Unit          = goodsUnit;
                model.SalePrice     = Convert.ToDecimal(goodsPrice);
                model.IsOffline     = 1;
                model.IsSale        = 0;
                model.IsRecommended = 1;
                model.IsIndex       = 0;
                model.Title         = goodsRemark;
                model.CreateUserID  = this.UserID;
                model.CreateDate    = DateTime.Now;
                model.IsEnabled     = 1;
                model.modifyuser    = this.UserID;
                model.ts            = DateTime.Now;

                goodsId = new Hi.BLL.BD_Goods().Add(model, Tran);

                Hi.Model.BD_GoodsInfo model4 = new Hi.Model.BD_GoodsInfo();
                model4.CompID  = this.CompID;
                model4.BarCode = goodsBarCode;
                model4.GoodsID = goodsId;
                if (!Util.IsEmpty(goodsKuc))
                {
                    model4.Inventory = Convert.ToDecimal(goodsKuc);
                }
                model4.IsOffline    = 1;
                model4.ValueInfo    = "";
                model4.SalePrice    = Convert.ToDecimal(goodsPrice);
                model4.TinkerPrice  = Convert.ToDecimal(goodsPrice);
                model4.IsEnabled    = true;
                model4.CreateDate   = DateTime.Now;
                model4.CreateUserID = this.UserID;
                model4.ts           = DateTime.Now;
                model4.modifyuser   = this.UserID;
                int goodsInfoId = new Hi.BLL.BD_GoodsInfo().Add(model4, Tran);

                Hi.Model.BD_Goods goodsModel = new Hi.BLL.BD_Goods().GetModel(goodsId, Tran);
                goodsModel.ViewInfoID = goodsInfoId;
                goodsModel.ts         = DateTime.Now;
                goodsModel.modifyuser = this.UserID;
                new Hi.BLL.BD_Goods().Update(goodsModel, Tran);
                //}
                count++;
            }
            if (!Eroor)
            {
                Tran.Commit();
                string str = string.Empty;
                if (count2 != 0)
                {
                    str = ",剩余" + count2 + "条为重复数据";
                }
                ClientScript.RegisterStartupScript(this.GetType(), "Add", "<script>addlis(" + count + "," + count2 + ",'" + str + "');</script>");
            }
            else
            {
                Tran.Rollback();
                JScript.AlertMethod(this, TitleError, JScript.IconOption.错误, "function(){ addList(); }");
            }
        }
        catch (Exception ex)
        {
            if (Tran != null)
            {
                if (Tran.Connection != null)
                {
                    Tran.Rollback();
                }
            }
            JScript.AlertMethod(this, ex.Message, JScript.IconOption.错误, "function(){ addList(); }");
        }
        finally
        {
            if (!Util.IsEmpty(path))
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
            }
        }
    }
Example #6
0
    /// <summary>
    /// 获取某一分类产品信息,兼容了无属性的值,分类传-1
    /// </summary>
    /// <param name="JSon"></param>
    /// <returns></returns>
    public BD_GoodsCategory.ResultProductList GetProductsList(string JSon, string version)
    {
        try
        {
            #region JSon取值
            //Common.WriteLog(@"D:\u8\json.txt", JSon);
            string userID            = string.Empty;
            string disID             = string.Empty;
            string categoryID        = string.Empty; //分类ID
            string criticalProductID = string.Empty; //当前列表最临界点产品ID:初始-1
            string getType           = string.Empty; //方向
            string rows     = string.Empty;
            string sortType = string.Empty;
            string compid   = "";
            string sort     = string.Empty;
            Hi.Model.BD_GoodsInfo goods_viewinfo = null;
            Hi.BLL.BD_GoodsInfo   bll_goodsinfo  = new Hi.BLL.BD_GoodsInfo();
            BLL.Common            bll_common     = new BLL.Common();

            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (version.ToLower() == "android" || version.ToLower() == "ios" || float.Parse(version) < 5)//版本号1及之前的版本只传经销商id
            {
                if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["ResellerID"].ToString() != "" &&
                    JInfo["CriticalProductID"].ToString() != "" &&
                    JInfo["GetType"].ToString() != "" && JInfo["Rows"].ToString() != "" &&
                    JInfo["SortType"].ToString() != "" && JInfo["Sort"].ToString() != "")
                {
                    userID            = JInfo["UserID"].ToString();
                    disID             = JInfo["ResellerID"].ToString();
                    categoryID        = JInfo["ClassifyID"].ToString();
                    criticalProductID = JInfo["CriticalProductID"].ToString();
                    getType           = JInfo["GetType"].ToString();
                    rows     = JInfo["Rows"].ToString();
                    sortType = JInfo["SortType"].ToString();
                    sort     = JInfo["Sort"].ToString();
                }
                else
                {
                    return(new BD_GoodsCategory.ResultProductList()
                    {
                        Result = "F", Description = "参数异常"
                    });
                }
            }
            else if (float.Parse(version) >= 5)//版本号2及以后的版本经销商查询传经销商id,核心企业查询传核心企业id
            {
                if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" &&
                    ClsSystem.gnvl(JInfo["CompID"], "") != "" &&
                    JInfo["CriticalProductID"].ToString() != "" &&
                    JInfo["GetType"].ToString() != "" && JInfo["Rows"].ToString() != "" &&
                    JInfo["SortType"].ToString() != "" && JInfo["Sort"].ToString() != "")
                {
                    userID            = JInfo["UserID"].ToString();
                    disID             = ClsSystem.gnvl(JInfo["ResellerID"], "");
                    compid            = ClsSystem.gnvl(JInfo["CompID"], "");
                    categoryID        = JInfo["ClassifyID"].ToString();
                    criticalProductID = JInfo["CriticalProductID"].ToString();
                    getType           = JInfo["GetType"].ToString();
                    rows     = JInfo["Rows"].ToString();
                    sortType = JInfo["SortType"].ToString();
                    sort     = JInfo["Sort"].ToString();
                }
                else
                {
                    return(new BD_GoodsCategory.ResultProductList()
                    {
                        Result = "F", Description = "参数异常"
                    });
                }
            }

            Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
            if (disID != "")
            {
                if (!new Common().IsLegitUser(int.Parse(userID), out user, 0, disID: int.Parse(disID == "" ? "0" : disID)))
                {
                    return new BD_GoodsCategory.ResultProductList()
                           {
                               Result = "F", Description = "参数异常"
                           }
                }
                ;
            }
            else
            {
                if (!new Common().IsLegitUser(int.Parse(userID), out user, compID: int.Parse(compid == "" ? "0" : compid)))
                {
                    return new BD_GoodsCategory.ResultProductList()
                           {
                               Result = "F", Description = "参数异常"
                           }
                }
                ;
            }



            #endregion

            #region 模拟分页

            string strsql   = string.Empty; //搜索sql
            string strWhere = string.Empty;
            if (disID != "")                //查询经销商的商品需要判断经销商是否存在,还要判断商品的可销售区域
            {
                Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(int.Parse(disID));
                if (dis == null || dis.dr == 1 || dis.IsEnabled == 0)
                {
                    return new BD_GoodsCategory.ResultProductList()
                           {
                               Result = "F", Description = "未找到经销商"
                           }
                }
                ;
                compid = compid;
                List <Common.GoodsID> list = Common.DisEnAreaGoodsID(disID, compid);
                if (list != null)
                {
                    strWhere += " and ID not in ( -1 ";

                    strWhere = list.Aggregate(strWhere, (current, goods) => current + ("," + goods.goodsID)) + ")";
                }
            }
            else //查询核心企业的商品需要判断核心企业是否存在
            {
                Hi.Model.BD_Company com = new Hi.BLL.BD_Company().GetModel(int.Parse(compid));
                if (com == null || com.dr == 1 || com.IsEnabled == 0)
                {
                    return new BD_GoodsCategory.ResultProductList()
                           {
                               Result = "F", Description = "未找到核心企业"
                           }
                }
                ;
            }
            const string tabName = " [dbo].[BD_Goods]";      //表名
            sortType = sortType == "2" ? "SalePrice" : "ID"; //价格排序



            switch (categoryID)
            {
            case "-2":     //促销列表
            {
                List <Hi.Model.BD_Promotion> promotionList = new Hi.BLL.BD_Promotion().GetList("",
                                                                                               " compID=" + compid.ToInt() + " and ProStartTime<='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and ProEndTime >='" +
                                                                                               DateTime.Now.ToString("yyyy-MM-dd") + "' and IsEnabled=1", "");

                List <Hi.Model.BD_PromotionDetail> detailList = new List <BD_PromotionDetail>();
                if (promotionList != null && promotionList.Count > 0)
                {
                    detailList = new Hi.BLL.BD_PromotionDetail().GetList("",
                                                                         " ProID in(" + string.Join(",", promotionList.Select(p => p.ID)) + ")", "");
                }
                if (promotionList.Count == 0)
                {
                    return new BD_GoodsCategory.ResultProductList()
                           {
                               Result = "F", Description = "今天无促销"
                           }
                }
                ;
                if (detailList.Count == 0)
                {
                    return new BD_GoodsCategory.ResultProductList()
                           {
                               Result = "F", Description = "今天无促销"
                           }
                }
                ;
                var ienum = detailList.Select(p => p.GoodsID);
                if (ienum.Count() > 0)
                {
                    strWhere += " and ID in ( " + string.Join(",", ienum) + ")";
                }
            }
            break;

            case "-3":     //收藏列表
            {
                List <Hi.Model.BD_DisCollect> collects = new Hi.BLL.BD_DisCollect().GetList("",
                                                                                            "disID=" + disID + " and dr=0", "");
                if (collects != null)
                {
                    strWhere += " and ID not in ( -1 ";
                    strWhere  = collects.Aggregate(strWhere, (current, goods) => current + ("," + goods.GoodsID)) +
                                ")";
                }
            }
            break;

            default:
                if (categoryID != "0" && categoryID != "-1")     //全部
                {
                    strWhere += " and CategoryID in (" + Common.AllCategory(int.Parse(categoryID)) + ")";
                }
                break;
            }

            ////商品可售区域判断
            //if (version.ToLower() == "android" || version.ToLower() == "ios" || version == "1")//版本号1及之前的版本需要
            //{
            //    List<Common.GoodsID> list = Common.DisEnAreaGoodsID(disID, compid);
            //    if (list != null)
            //    {
            //        strWhere += " and ID not in ( -1 ";
            //        strWhere = list.Aggregate(strWhere, (current, goods) => current + ("," + goods.goodsID)) + ")";
            //    }
            //}
            if (disID == "")
            {
                strWhere += " and ISNULL(dr,0)=0  and IsEnabled = 1 and compid=" + compid;
            }
            else
            {
                strWhere += " and isnull(isoffline,0)=1 and   ISNULL(dr,0)=0  and IsEnabled = 1 and compid=" + compid;
            }

            strsql = new Common().PageSqlString(criticalProductID, "ID", tabName, sortType,
                                                sort, strWhere, getType, rows);

            #endregion
            List <Hi.Model.BD_DisCollect> Colist = new List <Hi.Model.BD_DisCollect>();
            if (disID != "")
            {
                Colist = Common.GetDataSource <BD_DisCollect>("",
                                                              " and disID='" + disID + "' and compID=" + compid.ToInt() + " and IsEnabled =1 and ISNULL(dr,0)=0");
            }
            else
            {
                Colist = Common.GetDataSource <BD_DisCollect>("",
                                                              "  and compID=" + compid.ToInt() + " and IsEnabled =1 and ISNULL(dr,0)=0");
            }
            List <Hi.Model.BD_GoodsInfo> infoAllList = new Hi.BLL.BD_GoodsInfo().GetList("",
                                                                                         " CompID=" + compid.ToInt() + " and ISNULL(dr,0)=0 and IsEnabled=1 ", "");

            #region 赋值

            int CategoryID = 0;

            List <BD_GoodsCategory.Product> ProductList = new List <BD_GoodsCategory.Product>();
            DataTable dsList = SqlHelper.Query(SqlHelper.LocalSqlServer, strsql).Tables[0];
            //Common.WriteLog(@"D:\u8\sql.txt", strsql);
            if (dsList != null)
            {
                if (dsList.Rows.Count == 0)
                {
                    return new BD_GoodsCategory.ResultProductList()
                           {
                               Result = "F", Description = "没有更多数据"
                           }
                }
                ;
                foreach (DataRow row in dsList.Rows)
                {
                    string SKUName = string.Empty;

                    BD_GoodsCategory.Product product = new BD_GoodsCategory.Product();
                    product.ProductID   = row["ID"].ToString(); //商品ID
                    product.ProductName = row["GoodsName"].ToString();
                    SKUName            += product.ProductName;
                    //list中的商品价格是goods表中的viewinfoid字段所存的goodsinfoid对应的商品价格
                    //product.SalePrice = decimal.Parse(row["SalePrice"].ToString()).ToString("0.00");
                    if (disID != "")
                    {
                        product.SalePrice = BLL.Common.GetGoodsPrice(Convert.ToInt32(compid), Convert.ToInt32(disID), Convert.ToInt32(ClsSystem.gnvl(row["ViewInfoID"], "0"))).ToString("0.00");
                    }
                    else
                    {
                        product.SalePrice = BLL.Common.GetGoodsPrice(Convert.ToInt32(compid), 0, Convert.ToInt32(ClsSystem.gnvl(row["ViewInfoID"], "0"))).ToString("0.00");
                    }
                    product.IsSale = row["IsSale"].ToString();

                    List <Hi.Model.BD_DisCollect> alist = Colist != null && Colist.Count > 0
                        ? Colist.Where(p => p.GoodsID.ToString() == product.ProductID).ToList()
                        : null;
                    product.IsCollect = alist != null && alist.Count > 0 ? "1" : "0";
                    product.Title     = row["Title"].ToString();
                    //product.Details = row["Details"].ToString();
                    product.Title      = row["Title"].ToString();
                    product.Unit       = row["Unit"].ToString();
                    product.ClassifyID = row["CategoryID"].ToString();
                    CategoryID         = int.Parse(row["CategoryID"].ToString()); //类别ID

                    List <BD_GoodsCategory.Pic> Pic = new List <BD_GoodsCategory.Pic>();

                    #region List<Pic> Pic

                    if (row["Pic"].ToString() != "" && row["Pic"].ToString() != "X")
                    {
                        BD_GoodsCategory.Pic pic = new BD_GoodsCategory.Pic();
                        pic.ProductID = row["ID"].ToString();
                        pic.IsDeafult = "1";
                        pic.PicUrl    = ConfigurationManager.AppSettings["ImgViewPath"].ToString().Trim() + "GoodsImg/" +
                                        row["Pic"].ToString();
                        Pic.Add(pic);
                    }

                    Pic.AddRange(GetPicList(row["ID"].ToString()));

                    #endregion

                    product.ProductPicUrlList = Pic;

                    List <BD_GoodsCategory.SKU> SKUList = new List <BD_GoodsCategory.SKU>();
                    string strID = "0";

                    #region 通过 商品ID和属性值ID关联表,找到属性值

                    List <Hi.Model.BD_GoodsInfo> goodsInfoList = infoAllList != null && infoAllList.Count > 0
                        ? infoAllList.Where(p => p.GoodsID.ToString() == row["ID"].ToString()).ToList()
                        : null;
                    foreach (Hi.Model.BD_GoodsInfo goodsInfo in goodsInfoList)
                    {
                        if (!Common.IsOffline(goodsInfo.ID))
                        {
                            continue;
                        }

                        BD_GoodsCategory.SKU SKU = new BD_GoodsCategory.SKU();
                        //SKUID是GoodsInfoID,SKUName是GoodsName+各种属性值
                        SKU.SKUID     = goodsInfo.ID.ToString();
                        SKU.ProductID = goodsInfo.GoodsID.ToString();
                        SKU.BarCode   = goodsInfo.BarCode;
                        //SKUName = GoodsName + ValueInfo
                        SKU.SKUName = SKUName + " " + goodsInfo.ValueInfo;

                        SKU.ValueInfo = goodsInfo.ValueInfo;
                        SKU.SalePrice = goodsInfo.SalePrice.ToString("0.00");


                        SKU.ProductName = row["GoodsName"].ToString();
                        SKU.ProductCode = ClsSystem.gnvl(row["GoodsCode"], "");

                        int ProID = 0;   //暂时未用到 促销ID
                        SKU.IsPro = "0"; //默认不是促销价
                        decimal price = Common.GetProPrice(goodsInfo.GoodsID.ToString(), goodsInfo.ID.ToString(),
                                                           goodsInfo.CompID.ToString(), out ProID);
                        if (price != 0)
                        {
                            SKU.IsPro   = "1";
                            SKU.ProInfo = GetProInfo(ProID, goodsInfo.ID);
                        }
                        //if (price == 0)
                        //{
                        //    if (disID != "")
                        //    {
                        //        List<Hi.Model.BD_GoodsPrice> goodsPrice = new Hi.BLL.BD_GoodsPrice().GetList("",
                        //            " GoodsInfoID='" + goodsInfo.ID + "' and ISNULL(dr,0)=0 and compid='" + goodsInfo.CompID +
                        //            "' and DisID = " + disID + " and isnull(IsEnabled,0)=1", "");
                        //        SKU.TinkerPrice = goodsPrice.Count != 0
                        //            ? goodsPrice[0].TinkerPrice.ToString("0.00")
                        //            : goodsInfo.TinkerPrice.ToString("0.00");
                        //    }
                        //    else
                        //    {
                        //        SKU.TinkerPrice = goodsInfo.TinkerPrice.ToString("0.00");
                        //    }
                        //}
                        //else
                        //{
                        //    SKU.IsPro = "1"; //是促销价
                        //    SKU.ProInfo = GetProInfo(ProID, goodsInfo.ID);
                        //    SKU.TinkerPrice = price.ToString("0.00");
                        //}
                        if (disID == "")
                        {
                            SKU.TinkerPrice = BLL.Common.GetGoodsPrice(Convert.ToInt32(compid), 0, goodsInfo.ID).ToString("0.00");
                        }
                        else
                        {
                            SKU.TinkerPrice = BLL.Common.GetGoodsPrice(Convert.ToInt32(compid), Convert.ToInt32(disID), goodsInfo.ID).ToString("0.00");
                        }
                        //获取特定属性商品的库存
                        SKU.Inventory = goodsInfo.Inventory.ToString();


                        List <BD_GoodsCategory.ProductAttValueID> ProductAttValueIDList = new List <BD_GoodsCategory.ProductAttValueID>();

                        List <Hi.Model.BD_GoodsAttrsInfo> attrList = new Hi.BLL.BD_GoodsAttrsInfo().GetList("", " GoodsID='" + goodsInfo.GoodsID + "' and ISNULL(dr,0)=0", "");
                        if (attrList == null)
                        {
                            return new BD_GoodsCategory.ResultProductList()
                                   {
                                       Result = "F", Description = "未找到商品属性名字"
                                   }
                        }
                        ;
                        List <Hi.Model.BD_GoodsAttrs> attrValList = new Hi.BLL.BD_GoodsAttrs().GetList("*", " CompID =" + compid.ToInt() + "", "");
                        foreach (Hi.Model.BD_GoodsAttrsInfo attribute in attrList)
                        {
                            strID += "," + attribute.AttrsID;

                            string[] args  = new[] { goodsInfo.ValueInfo };
                            string[] items = args[0].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (string item in items)
                            {
                                string[] strs = item.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

                                if (strs[1] == attribute.AttrsInfoName)
                                {
                                    BD_GoodsCategory.ProductAttValueID productAttValueID = new BD_GoodsCategory.ProductAttValueID()
                                    {
                                        ProductAttributeValueID = attribute.ID.ToString()//
                                    };
                                    ProductAttValueIDList.Add(productAttValueID);
                                }
                            }
                        }

                        SKU.ProductAttValueIDList = ProductAttValueIDList;
                        SKUList.Add(SKU);
                    }

                    #endregion

                    product.SKUList = SKUList;

                    List <BD_GoodsCategory.ProductAttribute> ProductAttributeList = new List <BD_GoodsCategory.ProductAttribute>();

                    #region 通过商品类别ID和属性ID关联表,找到属性ID

                    List <Hi.Model.BD_GoodsAttrs> val = new Hi.BLL.BD_GoodsAttrs().GetList("", " ID in (" + strID + ") and CompID=" + compid.ToInt() + " and ISNULL(dr,0)=0", "");
                    if (val == null)
                    {
                        return new BD_GoodsCategory.ResultProductList()
                               {
                                   Result = "F", Description = "未找到商品属性"
                               }
                    }
                    ;

                    foreach (Hi.Model.BD_GoodsAttrs goodsAttr in val)
                    {
                        BD_GoodsCategory.ProductAttribute proAttr = new BD_GoodsCategory.ProductAttribute();

                        proAttr.ProductID            = row["ID"].ToString();
                        proAttr.ProductAttributeID   = goodsAttr.ID.ToString(); //属性ID
                        proAttr.ProductAttributeName = goodsAttr.AttrsName;     //属性名称

                        List <BD_GoodsCategory.ProductAttValue> ProductAttValueList = new List <BD_GoodsCategory.ProductAttValue>();

                        List <Hi.Model.BD_GoodsAttrsInfo> attrList = new Hi.BLL.BD_GoodsAttrsInfo().GetList("",
                                                                                                            " AttrsID='" + goodsAttr.ID + "' and CompID=" + compid.ToInt() + " and ISNULL(dr,0)=0" +
                                                                                                            " and AttrsID in (" + strID + ")", "ID"); //todo:商品属性表修改咨询商品结构
                        if (attrList == null)
                        {
                            return new BD_GoodsCategory.ResultProductList()
                                   {
                                       Result = "F", Description = "未找到商品属性名字"
                                   }
                        }
                        ;
                        foreach (Hi.Model.BD_GoodsAttrsInfo attribute in attrList)
                        {
                            BD_GoodsCategory.ProductAttValue productAttValue = new BD_GoodsCategory.ProductAttValue();

                            productAttValue.ProductID           = row["ID"].ToString();
                            productAttValue.ProductAttributeID  = goodsAttr.ID.ToString();
                            productAttValue.ProductAttValueID   = attribute.ID.ToString();
                            productAttValue.ProductAttValueName = attribute.AttrsInfoName;

                            ProductAttValueList.Add(productAttValue);
                        }
                        proAttr.ProductAttValueList = ProductAttValueList;
                        ProductAttributeList.Add(proAttr);
                    }

                    #endregion

                    product.ProductAttributeList = ProductAttributeList;

                    ProductList.Add(product);
                }
            }

            #endregion

            return(new BD_GoodsCategory.ResultProductList()
            {
                Result = "T",
                Description = "获取成功",
                ClassifyID = categoryID,
                ProductList = ProductList
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetResellerProductList :" + JSon);
            return(new BD_GoodsCategory.ResultProductList()
            {
                Result = "F", Description = "异常"
            });
        }
    }
Example #7
0
    public void Bind()
    {
        //首次进行页面清除Session
        Session.Remove("GoodsPrice");
        if (KeyID != 0)
        {
            string Digits = OrderInfoType.rdoOrderAudit("订单下单数量是否取整", CompID);
            Hi.Model.BD_Promotion ProModel = ProBll.GetModel(KeyID);

            //促销公告
            List <Hi.Model.BD_CompNews> newsl = new Hi.BLL.BD_CompNews().GetList("", " PMID=" + KeyID + "and isnull(IsEnabled,0)=1", "");

            if (ProModel != null)
            {
                this.txtPromotiontitle.Value = ProModel.ProTitle;
                this.txtPromotionDate.Value  = ProModel.ProStartTime == DateTime.MinValue ? "" : ProModel.ProStartTime.ToString("yyyy-MM-dd");
                this.txtPromotionDate1.Value = ProModel.ProEndTime == DateTime.MinValue ? "" : ProModel.ProEndTime.ToString("yyyy-MM-dd");
                this.txtProInfos.Value       = ProModel.ProInfos;

                if (newsl != null && newsl.Count > 0)
                {
                    this.isOkComNews.Checked = true;
                    this.isNoComNews.Checked = false;
                }
                else
                {
                    this.isOkComNews.Checked = false;
                    this.isNoComNews.Checked = true;
                }

                //促销方式
                if (ProModel.ProType == 3)
                {
                    this.promotionType3.Checked = true;
                    this.txtSendFull.Value      = string.Format("{0:N4}", ProModel.Discount.ToString("#,####" + Digits));
                }
                else
                {
                    this.promotionType4.Checked = true;
                    this.txtDiscount.Value      = string.Format("{0:N4}", ProModel.Discount.ToString("#,####" + Digits));
                }
                //促销禁用
                if (ProModel.IsEnabled == 0)
                {
                    this.IsEnabled0.Checked = true;
                }
                else
                {
                    this.IsEnabled1.Checked = true;
                }

                decimal count = 0;
                //促销活动商品明细
                List <Hi.Model.BD_PromotionDetail> gl = ProDBll.GetList("", " CompId=" + this.CompID + " and ProID=" + KeyID, "");
                if (gl != null && gl.Count > 0)
                {
                    List <Hi.Model.BD_GoodsInfo> ll = new List <Hi.Model.BD_GoodsInfo>();

                    Hi.Model.BD_GoodsInfo model = null;
                    foreach (var item in gl)
                    {
                        model              = new Hi.Model.BD_GoodsInfo();
                        model.CompID       = this.CompID;
                        model.IsEnabled    = true;
                        model.CreateUserID = this.UserID;
                        model.CreateDate   = DateTime.Now;
                        model.ts           = DateTime.Now;
                        model.modifyuser   = this.UserID;
                        model.ID           = item.GoodInfoID;
                        model.GoodsID      = item.GoodsID;
                        model.SalePrice    = GoodsPrice(item.GoodInfoID.ToString());
                        model.TinkerPrice  = item.GoodsPrice; //促销价
                        count              = item.GoodsPrice;
                        ll.Add(model);
                    }
                    if (ProModel.ProType == 3)
                    {
                        //满送
                        this.txtSendNum.Value = string.Format("{0:N4}", count.ToString("#,####" + Digits));
                    }
                    Session["GoodsPrice"] = ll;
                    this.rpDtl.DataSource = ll;
                    this.rpDtl.DataBind();
                }
            }
        }
        else
        {
            this.rpDtl.DataSource = "";
            this.rpDtl.DataBind();
        }
    }
Example #8
0
    protected void btnGoodsTransfer_Click(object sender, EventArgs e)
    {
        SqlTransaction TranSaction = null;
        string         ShowStr     = "<i style='color:red;'>{0}</i>";
        int            GoodsAdd    = 0;
        int            GoodsTB     = 0;
        int            CategoryAdd = 0;
        int            CategoryTB  = 0;
        int            PayAdd      = 0;
        int            PayTB       = 0;

        try
        {
            #region 商品分类新增/同步方法
            XmlDocument xml    = null;//ImportDisProD.GetServiceXmlStr(Enum.GetName(typeof(Enums.Erptype), Erptype), "GetInvClass", "获取产品分类");
            XmlElement  elment = xml.DocumentElement;
            if (!string.IsNullOrEmpty(elment.GetAttribute("err")))
            {
                lblGoodsIpResult.InnerText = elment.GetAttribute("err");
                return;
            }
            TranSaction = DBUtility.SqlHelper.CreateStoreTranSaction();
            XmlNodeList xmllist = xml.DocumentElement.SelectNodes("bill");
            foreach (XmlNode xmlbill in xmllist)
            {
                XmlNode xmlheader                 = xmlbill.SelectSingleNode("header");
                string  goodsflcode               = xmlheader.SelectSingleNode("inventoryclasscode").InnerText;
                string  goodsflname               = xmlheader.SelectSingleNode("inventoryclassname").InnerText;
                string  goodsflprecode            = xmlheader.SelectSingleNode("inventoryclassprecode").InnerText;
                Hi.Model.BD_GoodsCategory goodsfl = null;
                DataTable dt = ImportDisProD.GetDataSource("", "BD_GoodsCategory", "and CategoryCode=" + goodsflcode + " and compid=" + CompID, "", TranSaction);
                if (dt.Rows.Count > 0)
                {
                    if (string.IsNullOrEmpty(goodsflname))
                    {
                        SetErrorTb("商品分类(同步)", "分类名称不能为空。分类编码:" + goodsflcode);
                        continue;
                    }
                    DataTable dt1 = ImportDisProD.GetDataSource("", "BD_GoodsCategory", " and CategoryName='" + goodsflname + "' and ParentId=" + goodsflprecode.ToInt(0) + " and compid=" + CompID, "", TranSaction);
                    if (dt1.Rows.Count > 0)
                    {
                        continue;
                    }
                    else
                    {
                        goodsfl = Common.GetEntity <Hi.Model.BD_GoodsCategory>(dt);
                        goodsfl.CategoryName = goodsflname;
                        goodsfl.ParentId     = goodsflprecode == "" ? 0 : int.Parse(goodsflprecode);
                        goodsfl.ts           = DateTime.Now;
                        goodsfl.modifyuser   = UserID;
                        if (new Hi.BLL.BD_GoodsCategory().Update(goodsfl, TranSaction))
                        {
                            CategoryTB++;
                        }
                    }
                }
                else
                {
                    goodsfl              = new Hi.Model.BD_GoodsCategory();
                    goodsfl.CompID       = CompID;
                    goodsfl.GoodsTypeID  = 17;
                    goodsfl.CategoryCode = goodsflcode;
                    goodsfl.CategoryName = goodsflname;
                    goodsfl.ParentId     = goodsflprecode == "" ? 0 : int.Parse(goodsflprecode);
                    goodsfl.IsEnabled    = 1;
                    goodsfl.CreateUserID = UserID;
                    goodsfl.CreateDate   = DateTime.Now;
                    goodsfl.ts           = DateTime.Now;
                    goodsfl.dr           = 0;
                    goodsfl.modifyuser   = UserID;
                    if (new Hi.BLL.BD_GoodsCategory().Add(goodsfl) > 0)
                    {
                        CategoryAdd++;
                    }
                }
            }
            #endregion

            #region 商品基本信息、商品详情新增/同步
            xml    = null;//ImportDisProD.GetServiceXmlStr(Enum.GetName(typeof(Enums.Erptype), Erptype), "GetInv", "获取产品档案");
            elment = xml.DocumentElement;
            if (!string.IsNullOrEmpty(elment.GetAttribute("err")))
            {
                lblGoodsIpResult.InnerText = elment.GetAttribute("err");
                return;
            }
            xmllist = xml.DocumentElement.SelectNodes("bill");
            foreach (XmlNode xmlbill in xmllist)
            {
                XmlNode           xmlheader     = xmlbill.SelectSingleNode("header");
                string            goodscode     = xmlheader.SelectSingleNode("inventorycode").InnerText;
                string            goodsname     = xmlheader.SelectSingleNode("customername").InnerText;
                string            goodstypecode = xmlheader.SelectSingleNode("inventoryclasscode").InnerText;
                string            unit          = xmlheader.SelectSingleNode("unit").InnerText;
                string            startdate     = xmlheader.SelectSingleNode("startdate").InnerText;
                string            enddate       = xmlheader.SelectSingleNode("enddate").InnerText;
                Hi.Model.BD_Goods goods         = null;
                DataTable         dt            = ImportDisProD.GetDataSource("", "BD_Goods", " and goodscode='" + goodscode + "' and compid=" + CompID, "", TranSaction);
                if (dt.Rows.Count > 0)
                {
                    if (string.IsNullOrEmpty(goodsname))
                    {
                        SetErrorTb("商品(同步)", "商品名称不能为空。产品编码:" + goodscode);
                        continue;
                    }
                    else
                    if (string.IsNullOrEmpty(unit))
                    {
                        SetErrorTb("商品(同步)", "商品单位不能为空。产品编码:" + unit);
                        continue;
                    }
                    DataTable dt1 = ImportDisProD.GetDataSource("top 1 *", "BD_GoodsCategory", "and CategoryCode=" + goodstypecode + " and compid=" + CompID, "", TranSaction);
                    goods           = Common.GetEntity <Hi.Model.BD_Goods>(dt);
                    goods.GoodsName = goodsname;
                    if (dt1.Rows.Count > 0)
                    {
                        goods.CategoryID = (int)dt1.Rows[0]["id"];
                    }
                    else
                    {
                        goods.CategoryID = 0;
                    }
                    goods.Unit = unit;
                    if (!string.IsNullOrEmpty(startdate))
                    {
                        goods.OfflineStateDate = DateTime.Parse(startdate);
                    }
                    if (!string.IsNullOrEmpty(enddate))
                    {
                        goods.OfflineEndDate = DateTime.Parse(enddate);
                    }
                    if (DateTime.Now >= goods.OfflineStateDate && DateTime.Now <= goods.OfflineEndDate)
                    {
                        goods.IsOffline = 1;
                    }
                    else
                    {
                        goods.IsOffline = 0;
                    }
                    xml    = null;//ImportDisProD.GetServiceXmlStr(Enum.GetName(typeof(Enums.Erptype), Erptype), "GetInvPrice", "获取产品价格", "<bill><header><inventorycode>" + goodscode + "</inventorycode></header></bill>");
                    elment = xml.DocumentElement;
                    if (!string.IsNullOrEmpty(elment.GetAttribute("err")))
                    {
                        lblGoodsIpResult.InnerText = elment.GetAttribute("err");
                        return;
                    }
                    xmllist = xml.DocumentElement.SelectNodes("bill");

                    XmlNode xmlheaderinfo = xmllist[0].SelectSingleNode("header");
                    string  goodsprice    = xmlheaderinfo.SelectSingleNode("price").InnerText;
                    if (string.IsNullOrEmpty(goodsprice))
                    {
                        SetErrorTb("商品(同步)", "商品价格不能为空。产品编码:" + goodscode);
                        continue;
                    }
                    goods.SalePrice = decimal.Parse(goodsprice);
                    Hi.Model.BD_GoodsInfo goodsinfo = null;
                    DataTable             dt2       = ImportDisProD.GetDataSource("top 1 *", "BD_GoodsInfo", "and value1=" + goods.GoodsCode + " and compid=" + CompID, "", TranSaction);
                    if (dt2.Rows.Count > 0)
                    {
                        goodsinfo             = Common.GetEntity <Hi.Model.BD_GoodsInfo>(dt2);
                        goodsinfo.SalePrice   = decimal.Parse(goodsprice);
                        goodsinfo.TinkerPrice = decimal.Parse(goodsprice);
                        goodsinfo.IsEnabled   = true;
                        goodsinfo.ts          = DateTime.Now;
                        goodsinfo.modifyuser  = UserID;
                        goods.ts         = DateTime.Now;
                        goods.modifyuser = UserID;
                        if (new Hi.BLL.BD_Goods().Update(goods, TranSaction))
                        {
                            GoodsTB++;
                        }
                        if (new Hi.BLL.BD_GoodsInfo().Update(goodsinfo, TranSaction))
                        {
                            PayTB++;
                        }
                    }
                    else
                    {
                        goodsinfo              = new Hi.Model.BD_GoodsInfo();
                        goodsinfo.CompID       = CompID;
                        goodsinfo.GoodsID      = goods.ID;
                        goodsinfo.Value1       = goods.GoodsCode;
                        goodsinfo.SalePrice    = decimal.Parse(goodsprice);
                        goodsinfo.TinkerPrice  = decimal.Parse(goodsprice);
                        goodsinfo.IsEnabled    = true;
                        goodsinfo.CreateUserID = UserID;
                        goodsinfo.CreateDate   = DateTime.Now;
                        goodsinfo.ts           = DateTime.Now;
                        goodsinfo.modifyuser   = UserID;
                        goods.ts         = DateTime.Now;
                        goods.modifyuser = UserID;
                        if (new Hi.BLL.BD_Goods().Update(goods, TranSaction))
                        {
                            GoodsTB++;
                        }
                        if (new Hi.BLL.BD_GoodsInfo().Add(goodsinfo, TranSaction) > 0)
                        {
                            PayAdd++;
                        }
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(goodsname))
                    {
                        SetErrorTb("商品(添加)", "商品名称不能为空。产品编码:" + goodscode);
                        continue;
                    }
                    else
                    if (string.IsNullOrEmpty(unit))
                    {
                        SetErrorTb("商品(添加)", "商品单位不能为空。产品编码:" + unit);
                        continue;
                    }
                    DataTable dt1 = ImportDisProD.GetDataSource("top 1 *", "BD_GoodsCategory", "and CategoryCode=" + goodstypecode + " and compid=" + CompID, "", TranSaction);
                    goods = new Hi.Model.BD_Goods();
                    if (dt1.Rows.Count > 0)
                    {
                        goods.CategoryID = (int)dt1.Rows[0]["id"];
                    }
                    else
                    {
                        goods.CategoryID = 0;
                    }
                    goods.CompID    = CompID;
                    goods.GoodsName = goodsname;
                    goods.GoodsCode = goodscode;
                    goods.Unit      = unit;
                    if (DateTime.Now >= goods.OfflineStateDate && DateTime.Now <= goods.OfflineEndDate)
                    {
                        goods.IsOffline = 1;
                    }
                    else
                    {
                        goods.IsOffline = 0;
                    }
                    goods.IsIndex       = 0;
                    goods.IsSale        = 0;
                    goods.IsRecommended = 1;
                    goods.IsEnabled     = 1;
                    goods.CreateUserID  = UserID;
                    goods.CreateDate    = DateTime.Now;
                    goods.ts            = DateTime.Now;
                    goods.modifyuser    = UserID;
                    xml    = null;// ImportDisProD.GetServiceXmlStr(Enum.GetName(typeof(Enums.Erptype), Erptype), "GetInvPrice", "获取产品价格", "<bill><header><inventorycode>" + goodscode + "</inventorycode></header></bill>");
                    elment = xml.DocumentElement;
                    if (!string.IsNullOrEmpty(elment.GetAttribute("err")))
                    {
                        lblGoodsIpResult.InnerText = elment.GetAttribute("err");
                        return;
                    }
                    xmllist = xml.DocumentElement.SelectNodes("bill");
                    XmlNode xmlheaderinfo = xmllist[0].SelectSingleNode("header");
                    string  goodsprice    = xmlheaderinfo.SelectSingleNode("price").InnerText;
                    if (string.IsNullOrEmpty(goodsprice))
                    {
                        SetErrorTb("商品(添加)", "商品价格不能为空。产品编码:" + goodscode);
                        continue;
                    }
                    goods.SalePrice = decimal.Parse(goodsprice);
                    int goodsid = new Hi.BLL.BD_Goods().Add(goods, TranSaction);
                    if (goodsid > 0)
                    {
                        GoodsAdd++;
                        Hi.Model.BD_GoodsInfo goodsinfo = new Hi.Model.BD_GoodsInfo();
                        goodsinfo.CompID       = CompID;
                        goodsinfo.GoodsID      = goodsid;
                        goodsinfo.Value1       = goodscode;
                        goodsinfo.SalePrice    = decimal.Parse(goodsprice);
                        goodsinfo.TinkerPrice  = decimal.Parse(goodsprice);
                        goodsinfo.IsEnabled    = true;
                        goodsinfo.CreateDate   = DateTime.Now;
                        goodsinfo.CreateUserID = UserID;
                        goodsinfo.ts           = DateTime.Now;
                        goodsinfo.modifyuser   = UserID;
                        if (new Hi.BLL.BD_GoodsInfo().Add(goodsinfo, TranSaction) > 0)
                        {
                            PayAdd++;
                        }
                    }
                }
            }
            #endregion
        }
        catch
        {
            lblGoodsIpResult.InnerText = "读取文件错误,请联系管理员";
        }
        finally
        {
            if (ErrTb.Rows.Count > 0)
            {
                HERCount.InnerText   = ErrTb.Rows.Count.ToString();
                DivError.Visible     = true;
                Rpt_Error.DataSource = ErrTb;
                Rpt_Error.DataBind();
            }
        }
    }