Пример #1
0
        public int Update(ContentPictureInfo model)
        {
            string cmdText = @"update ContentPicture 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.SqlProviderConnString, CommandType.Text, cmdText, parms));
        }
Пример #2
0
        public IList <ContentPictureInfo> GetList()
        {
            string cmdText = @"select Id,OriginalPicture,BPicture,MPicture,SPicture,OtherPicture,LastUpdatedDate 
			                from ContentPicture
							order by LastUpdatedDate desc "                            ;

            IList <ContentPictureInfo> list = new List <ContentPictureInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentPictureInfo model = new ContentPictureInfo();
                        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);
        }
Пример #3
0
        public IList <ContentPictureInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            string cmdText = @"select Id,OriginalPicture,BPicture,MPicture,SPicture,OtherPicture,LastUpdatedDate
                              from ContentPicture";

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

            IList <ContentPictureInfo> list = new List <ContentPictureInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentPictureInfo model = new ContentPictureInfo();
                        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);
        }
Пример #4
0
        public int Insert(ContentPictureInfo model)
        {
            string cmdText = @"insert into ContentPicture (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.SqlProviderConnString, CommandType.Text, cmdText, parms));
        }
Пример #5
0
        public ContentPictureInfo GetModel(object Id)
        {
            ContentPictureInfo model = null;

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

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model    = new ContentPictureInfo();
                        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 IList <ContentPictureInfo> GetList(int pageIndex, int pageSize, out int totalRecords, string sqlWhere, params SqlParameter[] cmdParms)
        {
            string cmdText = @"select count(*) from ContentPicture ";

            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += " where 1=1 " + sqlWhere;
            }
            totalRecords = (int)SqlHelper.ExecuteScalar(SqlHelper.SqlProviderConnString, 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 ContentPicture "                    ;
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += "where 1=1 " + sqlWhere;
            }
            cmdText += ")as objTable where RowNumber between " + startIndex + " and " + endIndex + " ";

            IList <ContentPictureInfo> list = new List <ContentPictureInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentPictureInfo model = new ContentPictureInfo();
                        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
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(ContentPictureInfo model)
 {
     return(dal.Update(model));
 }
Пример #8
0
 /// <summary>
 /// 添加数据到数据库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(ContentPictureInfo model)
 {
     return(dal.Insert(model));
 }
Пример #9
0
        private void OnUpload(HttpContext context)
        {
            string errorMsg = "";

            try
            {
                int  effect              = 0;
                bool isCreateThumbnail   = ConfigHelper.GetValueByKey("IsCteateContentPictureThumbnail") == "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], "ContentPictures", isCreateThumbnail);
                    ContentPicture     ppBll   = new ContentPicture();
                    ContentPictureInfo ppModel = new ContentPictureInfo();

                    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 + "\"}");
            }
        }