示例#1
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Cms.Model.C_article_product model)
 {
     return(dal.Update(model));
 }
示例#2
0
    /// <summary>
    ///商品导入方法
    /// </summary>
    /// <param name="clientid"></param>
    /// <param name="CustTypeMax"></param>
    /// <param name="CustTypeMin"></param>
    /// <param name="CustTypeSub"></param>
    /// <returns></returns>
    public static string ExeclData(string clientid, string classid, string CustTypeMin, string CustTypeSub)
    {
        {
            //获取上传的菜单名称和路径
            string        tempMenPath = System.Web.HttpContext.Current.Server.MapPath("~") + "\\Upload\\file\\" + clientid;//
            StringBuilder sbResult    = new StringBuilder("");
            //string strconn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + tempMenPath + ";Extended Properties=\"Excel 8.0;HDR=No;IMEX=1\"";
            string          strconn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + tempMenPath + ";Extended Properties=\"Excel 12.0;HDR=YES;IMEX=1\"";
            OleDbConnection conn    = new OleDbConnection(strconn);
            conn.Open();
            string sql;
            sql = "SELECT * FROM [Sheet1$]";
            DataSet          objDS  = new DataSet();
            OleDbDataAdapter objadp = new OleDbDataAdapter(sql, conn);
            objadp.Fill(objDS);
            DataTable MenDt = objDS.Tables[0];
            conn.Close();
            int result = 0;
            foreach (DataRow dr in MenDt.Select())
            {
                try
                {
                    Cms.BLL.C_article   bllarticle   = new Cms.BLL.C_article();
                    Cms.Model.C_article modelarticle = new Cms.Model.C_article();
                    modelarticle.parentId     = Convert.ToInt32(classid); //栏目id
                    modelarticle.title        = dr[0].ToString();         //标题
                    modelarticle.englishtitle = "";                       //英文标题
                    modelarticle.orderNumber  = 0;                        //排序
                    modelarticle.photoUrl     = "";                       //缩略图
                    modelarticle.intro        = "";                       //简介
                    modelarticle.content      = dr[1].ToString();         //内容

                    modelarticle.seoTitle       = "";                     //seo标题
                    modelarticle.seoKeyword     = "";                     //seo关键词
                    modelarticle.seoDescription = "";                     //seo描述
                    modelarticle.isRecommend    = 0;                      //推荐
                    modelarticle.isChannel      = "";                     //栏目推荐
                    modelarticle.isHidden       = 0;                      //是否隐藏
                    modelarticle.isCheck        = 0;                      //是否审核发布
                    modelarticle.isHot          = 0;                      //是否热门文章
                    modelarticle.isTop          = 0;                      //是否置顶
                    modelarticle.is_msg         = 0;
                    modelarticle.is_slide       = 0;
                    modelarticle.hits           = 1;            //点击量
                    modelarticle.Attachment     = "";
                    modelarticle.expClass       = "";           //
                    modelarticle.editTime       = DateTime.Now; //最后编辑时间
                    modelarticle.updateTime     = DateTime.Now; //添加时间
                    modelarticle.txtLinkUrl     = "";
                    modelarticle.contentUrl     = "";
                    modelarticle.txtsource      = "";
                    modelarticle.txtauthor      = "";

                    #region 手机|英文信息
                    modelarticle.w_LinkUrl        = "";
                    modelarticle.w_contentUrl     = "";
                    modelarticle.w_intro          = "";
                    modelarticle.w_content        = "";
                    modelarticle.e_LinkUrl        = "";
                    modelarticle.e_contentUrl     = "";
                    modelarticle.e_source         = "";
                    modelarticle.e_author         = "";
                    modelarticle.e_intro          = "";
                    modelarticle.e_content        = "";
                    modelarticle.e_seoTitle       = "";
                    modelarticle.e_seoKeyword     = "";
                    modelarticle.e_seoDescription = "";
                    string channel_name             = new Cms.BLL.C_Column().GetModel(Convert.ToInt32(classid)).className.ToString();
                    Dictionary <string, string> dic = new Dictionary <string, string>();
                    dic.Add("sub_title", "");
                    modelarticle.fields = dic; //扩展字段赋值
                    #endregion
                    result = bllarticle.Add(modelarticle);
                    if (result > 1)
                    {
                        #region 产品信息
                        Cms.BLL.C_article_product   bll_product   = new Cms.BLL.C_article_product();
                        Cms.Model.C_article_product model_product = new Cms.Model.C_article_product();
                        model_product.article_id  = result;
                        model_product.price       = Convert.ToDecimal(dr[2].ToString());
                        model_product.marketPrice = Convert.ToDecimal(dr[3].ToString());
                        model_product.integral    = Convert.ToInt32(dr[4].ToString());
                        model_product.stock       = Convert.ToInt32(dr[5].ToString());
                        model_product.is_integral = Convert.ToInt32(0);
                        model_product.s_version   = Convert.ToInt32(0);


                        #endregion
                        sbResult.Append("导入成功! <br />");
                    }
                    else
                    {
                        sbResult.Append("导入失败! <br />");
                    }
                }
                catch
                {
                    continue;
                }
            }

            return(sbResult.ToString());

            //更新到数据库中
        }
    }
示例#3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Cms.Model.C_article_product model)
 {
     return(dal.Add(model));
 }