예제 #1
0
        public List <ProductPictureInfo> GetList()
        {
            string cmdText = @"select Id,OriginalPicture,BPicture,MPicture,SPicture,OtherPicture,LastUpdatedDate 
			                from ProductPicture
							order by LastUpdatedDate desc "                            ;

            List <ProductPictureInfo> list = new List <ProductPictureInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, cmdText))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ProductPictureInfo model = new ProductPictureInfo();
                        model.Id = reader.GetGuid(0);
                        model.OriginalPicture = reader.GetString(1);
                        model.BPicture        = reader.GetString(2);
                        model.MPicture        = reader.GetString(3);
                        model.SPicture        = reader.GetString(4);
                        model.OtherPicture    = reader.GetString(5);
                        model.LastUpdatedDate = reader.GetDateTime(6);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
예제 #2
0
        public int Update(ProductPictureInfo model)
        {
            string cmdText = @"update ProductPicture set OriginalPicture = @OriginalPicture,BPicture = @BPicture,MPicture = @MPicture,SPicture = @SPicture,OtherPicture = @OtherPicture,LastUpdatedDate = @LastUpdatedDate 
			                 where Id = @Id"            ;

            SqlParameter[] parms =
            {
                new SqlParameter("@Id",              SqlDbType.UniqueIdentifier),
                new SqlParameter("@OriginalPicture", SqlDbType.VarChar,           100),
                new SqlParameter("@BPicture",        SqlDbType.VarChar,           100),
                new SqlParameter("@MPicture",        SqlDbType.VarChar,           100),
                new SqlParameter("@SPicture",        SqlDbType.VarChar,           100),
                new SqlParameter("@OtherPicture",    SqlDbType.VarChar,           100),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime)
            };
            parms[0].Value = model.Id;
            parms[1].Value = model.OriginalPicture;
            parms[2].Value = model.BPicture;
            parms[3].Value = model.MPicture;
            parms[4].Value = model.SPicture;
            parms[5].Value = model.OtherPicture;
            parms[6].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcShopDbConnString, CommandType.Text, cmdText, parms));
        }
예제 #3
0
        public int Insert(ProductPictureInfo model)
        {
            string cmdText = @"insert into ProductPicture (OriginalPicture,BPicture,MPicture,SPicture,OtherPicture,LastUpdatedDate)
			                 values
							 (@OriginalPicture,@BPicture,@MPicture,@SPicture,@OtherPicture,@LastUpdatedDate)
			                 "            ;

            SqlParameter[] parms =
            {
                new SqlParameter("@OriginalPicture", SqlDbType.VarChar, 100),
                new SqlParameter("@BPicture",        SqlDbType.VarChar, 100),
                new SqlParameter("@MPicture",        SqlDbType.VarChar, 100),
                new SqlParameter("@SPicture",        SqlDbType.VarChar, 100),
                new SqlParameter("@OtherPicture",    SqlDbType.VarChar, 100),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime)
            };
            parms[0].Value = model.OriginalPicture;
            parms[1].Value = model.BPicture;
            parms[2].Value = model.MPicture;
            parms[3].Value = model.SPicture;
            parms[4].Value = model.OtherPicture;
            parms[5].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcShopDbConnString, CommandType.Text, cmdText, parms));
        }
예제 #4
0
        public List <ProductPictureInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            string cmdText = @"select Id,OriginalPicture,BPicture,MPicture,SPicture,OtherPicture,LastUpdatedDate
                              from ProductPicture";

            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += " where 1=1 " + sqlWhere;
            }

            List <ProductPictureInfo> list = new List <ProductPictureInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, cmdText, cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ProductPictureInfo model = new ProductPictureInfo();
                        model.Id = reader.GetGuid(0);
                        model.OriginalPicture = reader.GetString(1);
                        model.BPicture        = reader.GetString(2);
                        model.MPicture        = reader.GetString(3);
                        model.SPicture        = reader.GetString(4);
                        model.OtherPicture    = reader.GetString(5);
                        model.LastUpdatedDate = reader.GetDateTime(6);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
예제 #5
0
        public ProductPictureInfo GetModel(object Id)
        {
            ProductPictureInfo model = null;

            string       cmdText = @"select top 1 Id,OriginalPicture,BPicture,MPicture,SPicture,OtherPicture,LastUpdatedDate 
			                   from ProductPicture
							   where Id = @Id "                            ;
            SqlParameter parm    = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);

            parm.Value = Guid.Parse(Id.ToString());

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, cmdText, parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model    = new ProductPictureInfo();
                        model.Id = reader.GetGuid(0);
                        model.OriginalPicture = reader.GetString(1);
                        model.BPicture        = reader.GetString(2);
                        model.MPicture        = reader.GetString(3);
                        model.SPicture        = reader.GetString(4);
                        model.OtherPicture    = reader.GetString(5);
                        model.LastUpdatedDate = reader.GetDateTime(6);
                    }
                }
            }

            return(model);
        }
예제 #6
0
        public List <ProductPictureInfo> GetList(int pageIndex, int pageSize, out int totalRecords, string sqlWhere, params SqlParameter[] cmdParms)
        {
            string cmdText = @"select count(*) from ProductPicture ";

            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += " where 1=1 " + sqlWhere;
            }
            totalRecords = (int)SqlHelper.ExecuteScalar(SqlHelper.HnztcShopDbConnString, CommandType.Text, cmdText, cmdParms);

            int startIndex = (pageIndex - 1) * pageSize + 1;
            int endIndex   = pageIndex * pageSize;

            cmdText = @"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber,
			          Id,OriginalPicture,BPicture,MPicture,SPicture,OtherPicture,LastUpdatedDate
					  from ProductPicture "                    ;
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += "where 1=1 " + sqlWhere;
            }
            cmdText += ")as objTable where RowNumber between " + startIndex + " and " + endIndex + " ";

            List <ProductPictureInfo> list = new List <ProductPictureInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, cmdText, cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ProductPictureInfo model = new ProductPictureInfo();
                        model.Id = reader.GetGuid(1);
                        model.OriginalPicture = reader.GetString(2);
                        model.BPicture        = reader.GetString(3);
                        model.MPicture        = reader.GetString(4);
                        model.SPicture        = reader.GetString(5);
                        model.OtherPicture    = reader.GetString(6);
                        model.LastUpdatedDate = reader.GetDateTime(7);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
예제 #7
0
        private void OnUpload(HttpContext context)
        {
            string errorMsg = "";

            try
            {
                int  effect              = 0;
                bool isCreateThumbnail   = ConfigHelper.GetValueByKey("IsCteateProductPictureThumbnail") == "1";
                UploadFilesHelper  ufh   = new UploadFilesHelper();
                HttpFileCollection files = context.Request.Files;
                foreach (string item in files.AllKeys)
                {
                    if (files[item] == null || files[item].ContentLength == 0)
                    {
                        continue;
                    }
                    string[]           paths   = ufh.Upload(files[item], "ProductPictures", isCreateThumbnail);
                    ProductPicture     ppBll   = new ProductPicture();
                    ProductPictureInfo ppModel = new ProductPictureInfo();

                    string originalPicturePath = "";
                    string bPicturePath        = "";
                    string mPicturePath        = "";
                    string sPicturePath        = "";
                    string otherPicturePath    = "";
                    for (int i = 0; i < paths.Length; i++)
                    {
                        switch (i)
                        {
                        case 0:
                            originalPicturePath = paths[i].Replace("~", "");
                            break;

                        case 1:
                            bPicturePath = paths[i].Replace("~", "");
                            break;

                        case 2:
                            mPicturePath = paths[i].Replace("~", "");
                            break;

                        case 3:
                            sPicturePath = paths[i].Replace("~", "");
                            break;

                        case 4:
                            otherPicturePath = paths[i].Replace("~", "");
                            break;

                        default:
                            break;
                        }
                    }
                    ppModel.OriginalPicture = originalPicturePath;
                    ppModel.BPicture        = bPicturePath;
                    ppModel.MPicture        = mPicturePath;
                    ppModel.SPicture        = sPicturePath;
                    ppModel.OtherPicture    = otherPicturePath;
                    ppModel.LastUpdatedDate = DateTime.Now;
                    ppBll.Insert(ppModel);
                    effect++;
                }

                if (effect == 0)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}");
                    return;
                }

                context.Response.Write("{\"success\": true,\"message\": \"已成功上传文件数:" + effect + "个\"}");
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }

            if (errorMsg != "")
            {
                context.Response.Write("{\"success\": false,\"message\": \"" + errorMsg + "\"}");
            }
        }
예제 #8
0
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(ProductPictureInfo model)
 {
     return(dal.Update(model));
 }
예제 #9
0
 /// <summary>
 /// 添加数据到数据库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(ProductPictureInfo model)
 {
     return(dal.Insert(model));
 }