Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ProductImgM model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update productImage set ");
            strSql.Append("productid=@productid,");
            strSql.Append("imgName=@imgName,");
            strSql.Append("imgexplain=@imgexplain");
            strSql.Append(" where Imgid=@Imgid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Imgid",      SqlDbType.Int,        4),
                new SqlParameter("@productid",  SqlDbType.Int,        4),
                new SqlParameter("@imgName",    SqlDbType.VarChar,  120),
                new SqlParameter("@imgexplain", SqlDbType.NVarChar, 500)
            };
            parameters[0].Value = model.Imgid;
            parameters[1].Value = model.productid;
            parameters[2].Value = model.imgName;
            parameters[3].Value = model.imgexplain;

            int rows = DBHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ProductImgM model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into productImage(");
            strSql.Append("productid,imgName,imgexplain)");
            strSql.Append(" values (");
            strSql.Append("@productid,@imgName,@imgexplain)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@productid",  SqlDbType.Int,        4),
                new SqlParameter("@imgName",    SqlDbType.VarChar,  120),
                new SqlParameter("@imgexplain", SqlDbType.NVarChar, 500)
            };
            parameters[0].Value = model.productid;
            parameters[1].Value = model.imgName;
            parameters[2].Value = model.imgexplain;

            object obj = DBHelper.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ProductImgM GetModel(int Imgid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Imgid,productid,imgName,imgexplain from productImage ");
            strSql.Append(" where Imgid=@Imgid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Imgid", SqlDbType.Int, 4)
            };
            parameters[0].Value = Imgid;

            ProductImgM model = new ProductImgM();
            DataSet     ds    = DBHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Imgid"].ToString() != "")
                {
                    model.Imgid = int.Parse(ds.Tables[0].Rows[0]["Imgid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["productid"].ToString() != "")
                {
                    model.productid = int.Parse(ds.Tables[0].Rows[0]["productid"].ToString());
                }
                model.imgName    = ds.Tables[0].Rows[0]["imgName"].ToString();
                model.imgexplain = ds.Tables[0].Rows[0]["imgexplain"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <ProductImgM> DataTableToList(DataTable dt)
        {
            List <ProductImgM> modelList = new List <ProductImgM>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                ProductImgM model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ProductImgM();
                    if (dt.Rows[n]["Imgid"].ToString() != "")
                    {
                        model.Imgid = int.Parse(dt.Rows[n]["Imgid"].ToString());
                    }
                    if (dt.Rows[n]["productid"].ToString() != "")
                    {
                        model.productid = int.Parse(dt.Rows[n]["productid"].ToString());
                    }
                    model.imgName    = dt.Rows[n]["imgName"].ToString();
                    model.imgexplain = dt.Rows[n]["imgexplain"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemplo n.º 5
0
 private void BindShow(string str)
 {
     if (str != "")
     {
         List <ProductImgM> list = new List <ProductImgM>();
         string[]           num  = str.Split('%');
         for (int i = 0; i < num.Length; i++)
         {
             if (num[i].Trim() != "")
             {
                 ProductImgM imagemodel = new ProductImgM();
                 imagemodel.imgName = num[i].ToString().Trim();//图片URL
                 list.Add(imagemodel);
             }
         }
         photo.Attributes.Add("style", "display:''");
         this.DataList1.DataSource = list;
         this.DataList1.DataBind();
     }
     else
     {
         photo.Attributes.Add("style", "display:none");
         this.DataList1.DataSource = null;
         this.DataList1.DataBind();
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ProductImgM model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(ProductImgM model)
 {
     return(dal.Add(model));
 }
Exemplo n.º 8
0
        private string content(string id, string loginName)
        {
            StringBuilder str = new StringBuilder();

            string[] strId = id.Split(',');
            for (int j = 0; j < strId.Length - 1; j++)
            {
                doM = doBll.GetModel(int.Parse(strId[j]));
                if (doM != null)
                {
                    str.Append("<div id=\"cy_con_" + strId[j] + "\">");
                    str.Append("<div class=\"industry-con1\">");
                    str.Append(doM.Chineseintroduced.ToString() + "</div>");
                    str.Append("<div class=\"industry-con2\">");
                    str.Append(doM.Englishintroduction.ToString() + "</div>");
                    ProductImgBLL imbll = new ProductImgBLL();
                    ProductImgM   imM   = new ProductImgM();
                    if (doM.productid > 0)
                    {
                        DataSet ds = imbll.GetList(" productid=" + doM.productid);
                        if ((ds != null) && ds.Tables[0].Rows.Count > 0)
                        {
                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            {
                                DataRow dr = ds.Tables[0].Rows[i];
                                if (i == 0)
                                {
                                    str.Append("<div class=\"industry-img-left\">");//大图width=\"651\" height=\"399\"
                                    str.Append("<img src=\"http://dp.topfo.com/img/" + loginName + "/" + dr["imgName"].ToString() + "\"  id=\"placeholder" + doM.productid + "\" />");
                                    str.Append("</div>");
                                }
                                else
                                {
                                    str.Append("<div style='display:none;' class=\"industry-img-left\">");//大图width=\"651\" height=\"399\"
                                    str.Append("<img src=\"http://dp.topfo.com/img/" + loginName + "/" + dr["imgName"].ToString() + "\"  style=\"display:none\"  id=\"placeholder" + doM.productid + "\" />");
                                    str.Append("</div>");
                                }
                            }
                        }
                        if ((ds != null) && ds.Tables[0].Rows.Count > 0)
                        {
                            str.Append("<div class=\"industry-img-right\" id=\"ISL_Cont_1\"> <ul>");
                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            {
                                DataRow dr = ds.Tables[0].Rows[i];
                                str.Append("<li>");
                                str.Append("<a href=\"http://dp.topfo.com/img/" + loginName + "/" + dr["imgName"].ToString() + "\"  onmouseover=\"showPic(this," + doM.productid + ");return false;\" alt='点击查看大图' target=\"_blank\">");
                                str.Append("<img alt='点击查看大图' src=\"http://dp.topfo.com/img/" + loginName + "/" + dr["imgName"].ToString() + "\" />");
                                str.Append("</a></li>");
                            }
                            str.Append("</ul></div>");
                        }
                    }
                    str.Append("</div>");
                }
                else
                {
                    str.Append("<div id=\"cy_con_" + strId[j] + "\">");
                    str.Append("暂无数据");
                    str.Append("</div>");
                }
            }
            return(str.ToString());
        }