Exemplo n.º 1
0
        public ActionResult AjaxIndexBannerDeleteFile(IndexBannerParameter param)
        {
            var result = new JsonNetResult();

            Io.DeleteFile(HttpContext.Server.MapPath($"~{param.Entity.ImgPath}"));
            result.Data = new { Ststus = "OK" };
            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 首頁 Banner 清單頁
 /// </summary>
 /// <param name="param"></param>
 /// <returns></returns>
 public ActionResult IndexBanners(IndexBannerParameter param)
 {
     param.KeyWord = HttpUtility.UrlDecode(param.KeyWord);
     return(View(
                new InternalDataTransferToView {
         List = IndexBannerTableProvider.List(param),
         Data = param
     }));
 }
Exemplo n.º 3
0
 public ActionResult IndexBannerEdit(IndexBannerParameter param)
 {
     if (0L < param.Entity.IndexBannerId)
     {
         param.Entity = IndexBannerTableProvider.Detail(param);
     }
     return(View(new InternalDataTransferToView {
         Data = param
     }));
 }
Exemplo n.º 4
0
 public static int Delete(IndexBannerParameter param)
 {
     using (var db = new MsSql(DbName.Official)) {
         return(db.Write(
                    CommandType.Text,
                    " DELETE FROM [dbo].[IndexBanner] WHERE [IndexBannerId] = @IndexBannerId;",
                    new DbParameter[] {
             new SqlParameter {
                 Value = param.Entity.IndexBannerId,
                 SqlDbType = SqlDbType.Int,
                 ParameterName = "@IndexBannerId",
                 Direction = ParameterDirection.Input
             }
         }));
     }
 }
Exemplo n.º 5
0
        public ActionResult AjaxIndexBannerEdit(IndexBannerParameter param)
        {
            var result = new JsonNetResult();
            var r      = new GeneralResponse();

            try {
                r.Code = (0L < param.Entity.IndexBannerId
                    ? IndexBannerTableProvider.Update(param)
                    : IndexBannerTableProvider.Create(param)).ToString(Section.Get.Common.Culture);
            }
            catch (Exception ex) {
                Log.Error(ex.Message, ex);
                r.Code = "-11" + ex.Message;
            }
            result.Data = r;
            return(result);
        }
Exemplo n.º 6
0
 public static IndexBanner Detail(IndexBannerParameter param)
 {
     using (var db = new MsSql(DbName.Official)) {
         var data = new IndexBanner();
         data.Fill(
             db.First(
                 CommandType.Text,
                 "SELECT [IndexBannerId],[ImgPath],[FirstString],[FirstStringColor],[SecondString],[SecondStringColor],[ThreeString],[ThreeStringColor],[Align],[Link],[CreateTime] FROM [dbo].[IndexBanner] WITH(READUNCOMMITTED) WHERE [IndexBannerId] = @IndexBannerId;",
                 new DbParameter[] {
             new SqlParameter {
                 Value         = param.Entity.IndexBannerId,
                 SqlDbType     = SqlDbType.Int,
                 ParameterName = "@IndexBannerId",
                 Direction     = ParameterDirection.Input
             }
         }));
         return(data);
     }
 }
Exemplo n.º 7
0
        public ActionResult AjaxIndexBannerDelete(IndexBannerParameter param)
        {
            var result = new JsonNetResult();
            var r      = new GeneralResponse();

            try {
                var detail = IndexBannerTableProvider.Detail(param);
                r.Code = IndexBannerTableProvider.Delete(param).ToString(Section.Get.Common.Culture);

                if (!string.IsNullOrEmpty(detail.ImgPath))
                {
                    Io.DeleteFile(System.Web.HttpContext.Current.Server.MapPath($"~{detail.ImgPath}"));
                }
            }
            catch (Exception ex) {
                Log.Error(ex.Message, ex);
                r.Code = "-11";
            }
            result.Data = r;
            return(result);
        }
Exemplo n.º 8
0
 public static DataSet List(IndexBannerParameter param)
 {
     using (var db = new MsSql(DbName.Official)) {
         return(db.DataSet(
                    CommandType.StoredProcedure,
                    "[dbo].[sp_FetchIndexBannerList_Sel]",
                    new DbParameter[] {
             new SqlParameter {
                 Value = param.KeyWord,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@argStrKeyWord",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = string.IsNullOrEmpty(param.StartUtcDateTime) ? null : param.StartUtcDateTime,
                 SqlDbType = SqlDbType.DateTime,
                 ParameterName = "@argDteStart",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = string.IsNullOrEmpty(param.EndUtcDateTime) ? null : param.EndUtcDateTime,
                 SqlDbType = SqlDbType.DateTime,
                 ParameterName = "@argDteEnd",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Page,
                 SqlDbType = SqlDbType.Int,
                 ParameterName = "@argIntPage",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.PageSize,
                 SqlDbType = SqlDbType.Int,
                 ParameterName = "@argIntPageSize",
                 Direction = ParameterDirection.Input
             }
         }));
     }
 }
Exemplo n.º 9
0
 public static int Update(IndexBannerParameter param)
 {
     using (var db = new MsSql(DbName.Official)) {
         return(db.Write(
                    CommandType.Text,
                    "UPDATE [dbo].[IndexBanner] SET [ImgPath] = @ImgPath,[Link] = @Link, [Align]=@Align,[FirstString] = @FirstString,[FirstStringColor] = @FirstStringColor,[SecondString] = @SecondString,[SecondStringColor] = @SecondStringColor,[ThreeString] = @ThreeString,[ThreeStringColor] = @ThreeStringColor WHERE [IndexBannerId] = @IndexBannerId;",
                    new DbParameter[] {
             new SqlParameter {
                 Value = param.Entity.IndexBannerId,
                 SqlDbType = SqlDbType.Int,
                 ParameterName = "@IndexBannerId",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.FirstString,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@FirstString",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.FirstStringColor,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@FirstStringColor",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.SecondString,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@SecondString",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.SecondStringColor,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@SecondStringColor",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.ThreeString,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@ThreeString",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.ThreeStringColor,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@ThreeStringColor",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.Align,
                 SqlDbType = SqlDbType.VarChar,
                 ParameterName = "@Align",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.Link,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@Link",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.ImgPath,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@ImgPath",
                 Direction = ParameterDirection.Input
             }
         }));
     }
 }
Exemplo n.º 10
0
 public static int Create(IndexBannerParameter param)
 {
     using (var db = new MsSql(DbName.Official)) {
         return(db.Write(
                    CommandType.Text,
                    "INSERT INTO [dbo].[IndexBanner]([ImgPath],[FirstString],[FirstStringColor],[SecondString],[SecondStringColor],[ThreeString],[ThreeStringColor],[Align],[Link],[CreateTime])VALUES(@ImgPath,@FirstString,@FirstStringColor,@SecondString,@SecondStringColor,@ThreeString,@ThreeStringColor,@Align,@Link,GETUTCDATE());",
                    new DbParameter[] {
             new SqlParameter {
                 Value = param.Entity.FirstString,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@FirstString",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.FirstStringColor,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@FirstStringColor",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.SecondString,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@SecondString",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.SecondStringColor,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@SecondStringColor",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.ThreeString,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@ThreeString",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.ThreeStringColor,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@ThreeStringColor",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.Align,
                 SqlDbType = SqlDbType.VarChar,
                 ParameterName = "@Align",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.Link,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@Link",
                 Direction = ParameterDirection.Input
             },
             new SqlParameter {
                 Value = param.Entity.ImgPath,
                 SqlDbType = SqlDbType.NVarChar,
                 ParameterName = "@ImgPath",
                 Direction = ParameterDirection.Input
             }
         }));
     }
 }