Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static Hashtable Insert(Model.GoodsPic model, Hashtable MyHs)
        {
            string        guid   = Guid.NewGuid().ToString();
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into GoodsPic(");
            strSql.Append("GId,Code,PicURL,PicSize,IsMain,Decription,IsDeleted,Status");
            strSql.Append(") values (");
            strSql.Append("@GId,@Code,@PicURL,@PicSize,@IsMain,@Decription,@IsDeleted,@Status");
            strSql.Append(") ");
            strSql.AppendFormat(";select '{0}'", guid);
            SqlParameter[] parameters =
            {
                new SqlParameter("@GId",        SqlDbType.VarChar,   50),
                new SqlParameter("@Code",       SqlDbType.VarChar,   50),
                new SqlParameter("@PicURL",     SqlDbType.VarChar,  500),
                new SqlParameter("@PicSize",    SqlDbType.Int,        4),
                new SqlParameter("@IsMain",     SqlDbType.Bit,        1),
                new SqlParameter("@Decription", SqlDbType.NVarChar, 500),
                new SqlParameter("@IsDeleted",  SqlDbType.Bit,        1),
                new SqlParameter("@Status",     SqlDbType.Int, 4)
            };

            parameters[0].Value = model.GId;
            parameters[1].Value = model.Code;
            parameters[2].Value = model.PicURL;
            parameters[3].Value = model.PicSize;
            parameters[4].Value = model.IsMain;
            parameters[5].Value = model.Decription;
            parameters[6].Value = model.IsDeleted;
            parameters[7].Value = model.Status;
            MyHs.Add(strSql.ToString(), parameters);
            return(MyHs);
        }
Ejemplo n.º 2
0
        protected void SaveImgs(string saleId, Hashtable hs)
        {
            string imgsUrl = Request.Form["uploadPic"];

            if (!string.IsNullOrEmpty(imgsUrl))
            {
                string[] array = imgsUrl.Split(',');
                List <Model.GoodsPic> listInsert = new List <Model.GoodsPic>();
                List <Model.GoodsPic> listUpdate = new List <Model.GoodsPic>();
                //int mainCount = 0;
                foreach (string arr in array)
                {
                    Model.GoodsPic obj = new Model.GoodsPic();
                    obj.IsMain    = false;
                    obj.PicURL    = arr;
                    obj.GId       = saleId;
                    obj.Code      = Guid.NewGuid().ToString();
                    obj.IsDeleted = false;
                    obj.Status    = 1;
                    if (obj.PicURL == Request.Form["hidMainPic"])
                    {
                        obj.IsMain = true;
                    }
                    //查看这个图片是否在数据库中存在,存在就不添加
                    var listHas = BLL.GoodsPic.GetList("PicURL='" + obj.PicURL + "'");
                    if (listHas != null && listHas.Count > 0)
                    { //存在,就修改,主要是修改IsMain
                        Model.GoodsPic objU = listHas[0];
                        if (objU.IsMain != obj.IsMain)
                        {
                            objU.IsMain = obj.IsMain;
                            listUpdate.Add(objU);
                        }
                    }
                    else
                    {//不存在,就添加
                        listInsert.Add(obj);
                    }
                }
                foreach (Model.GoodsPic obj in listInsert)
                {
                    BLL.GoodsPic.Insert(obj, hs);
                }
                foreach (Model.GoodsPic obj in listUpdate)
                {
                    BLL.GoodsPic.Update(obj, hs);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static Hashtable Update(Model.GoodsPic model, Hashtable MyHs)
        {
            string        guid   = Guid.NewGuid().ToString();
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update GoodsPic set ");
            strSql.Append(" GId = @GId , ");
            strSql.Append(" Code = @Code , ");
            strSql.Append(" PicURL = @PicURL , ");
            strSql.Append(" PicSize = @PicSize , ");
            strSql.Append(" IsMain = @IsMain , ");
            strSql.Append(" Decription = @Decription , ");
            strSql.Append(" IsDeleted = @IsDeleted , ");
            strSql.Append(" Status = @Status  ");
            strSql.Append(" where Id=@Id  ");
            strSql.AppendFormat(" ;select '{0}'", guid);

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",         SqlDbType.Int,        4),
                new SqlParameter("@GId",        SqlDbType.VarChar,   50),
                new SqlParameter("@Code",       SqlDbType.VarChar,   50),
                new SqlParameter("@PicURL",     SqlDbType.VarChar,  500),
                new SqlParameter("@PicSize",    SqlDbType.Int,        4),
                new SqlParameter("@IsMain",     SqlDbType.Bit,        1),
                new SqlParameter("@Decription", SqlDbType.NVarChar, 500),
                new SqlParameter("@IsDeleted",  SqlDbType.Bit,        1),
                new SqlParameter("@Status",     SqlDbType.Int, 4)
            };

            parameters[0].Value = model.Id;
            parameters[1].Value = model.GId;
            parameters[2].Value = model.Code;
            parameters[3].Value = model.PicURL;
            parameters[4].Value = model.PicSize;
            parameters[5].Value = model.IsMain;
            parameters[6].Value = model.Decription;
            parameters[7].Value = model.IsDeleted;
            parameters[8].Value = model.Status;
            MyHs.Add(strSql.ToString(), parameters);
            return(MyHs);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///  实体转换
        /// <summary>
        private static Model.GoodsPic TranEntity(DataRow dr)
        {
            if (dr != null)
            {
                Model.GoodsPic model = new Model.GoodsPic();

                if (!string.IsNullOrEmpty(dr["Id"].ToString()))
                {
                    model.Id = int.Parse(dr["Id"].ToString());
                }

                model.GId = dr["GId"].ToString();

                model.Code   = dr["Code"].ToString();
                model.PicURL = dr["PicURL"].ToString();
                if (!string.IsNullOrEmpty(dr["PicSize"].ToString()))
                {
                    model.PicSize = int.Parse(dr["PicSize"].ToString());
                }
                if (!string.IsNullOrEmpty(dr["IsMain"].ToString()))
                {
                    model.IsMain = bool.Parse(dr["IsMain"].ToString());
                }
                model.Decription = dr["Decription"].ToString();
                if (!string.IsNullOrEmpty(dr["IsDeleted"].ToString()))
                {
                    model.IsDeleted = bool.Parse(dr["IsDeleted"].ToString());
                }
                if (!string.IsNullOrEmpty(dr["Status"].ToString()))
                {
                    model.Status = int.Parse(dr["Status"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static bool Insert(Model.GoodsPic model)
 {
     return(DAL.CommonBase.RunHashtable(Insert(model, new Hashtable())));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static bool Update(Model.GoodsPic model)
 {
     return(DAL.CommonBase.RunHashtable(Update(model, new Hashtable())));
 }
Ejemplo n.º 7
0
 public static bool Update(Model.GoodsPic model)
 {
     return(yny_005.DAL.GoodsPic.Update(model));
 }
Ejemplo n.º 8
0
 public static Hashtable Update(Model.GoodsPic model, Hashtable MyHs)
 {
     return(yny_005.DAL.GoodsPic.Update(model, MyHs));
 }
Ejemplo n.º 9
0
 public static bool Insert(Model.GoodsPic model)
 {
     return(yny_005.DAL.GoodsPic.Insert(model));
 }
Ejemplo n.º 10
0
 public static Hashtable Insert(Model.GoodsPic model, Hashtable MyHs)
 {
     return(yny_005.DAL.GoodsPic.Insert(model, MyHs));
 }