Exemplo n.º 1
0
        public IList <InformationAdInfo> GetList()
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select Id,Title,Descr,ContentText,Url,ViewType,StartDate,EndDate,UserId,LastUpdatedDate 
			            from Information_Ad
					    order by LastUpdatedDate desc "                    );

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString()))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        InformationAdInfo model = new InformationAdInfo();
                        model.Id              = reader.GetGuid(0);
                        model.Title           = reader.GetString(1);
                        model.Descr           = reader.GetString(2);
                        model.ContentText     = reader.GetString(3);
                        model.Url             = reader.GetString(4);
                        model.ViewType        = reader.GetInt32(5);
                        model.StartDate       = reader.GetDateTime(6);
                        model.EndDate         = reader.GetDateTime(7);
                        model.UserId          = reader.GetGuid(8);
                        model.LastUpdatedDate = reader.GetDateTime(9);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Exemplo n.º 2
0
        public int Update(InformationAdInfo model)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"update Information_Ad set Title = @Title,Descr = @Descr,ContentText = @ContentText,Url = @Url,ViewType = @ViewType,StartDate = @StartDate,EndDate = @EndDate,UserId = @UserId,LastUpdatedDate = @LastUpdatedDate 
			            where Id = @Id
					    "                    );

            SqlParameter[] parms =
            {
                new SqlParameter("@Id",              SqlDbType.UniqueIdentifier),
                new SqlParameter("@Title",           SqlDbType.NVarChar,           100),
                new SqlParameter("@Descr",           SqlDbType.NVarChar,           200),
                new SqlParameter("@ContentText",     SqlDbType.NVarChar,          4000),
                new SqlParameter("@Url",             SqlDbType.VarChar,            200),
                new SqlParameter("@ViewType",        SqlDbType.Int),
                new SqlParameter("@StartDate",       SqlDbType.DateTime),
                new SqlParameter("@EndDate",         SqlDbType.DateTime),
                new SqlParameter("@UserId",          SqlDbType.UniqueIdentifier),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime)
            };
            parms[0].Value = model.Id;
            parms[1].Value = model.Title;
            parms[2].Value = model.Descr;
            parms[3].Value = model.ContentText;
            parms[4].Value = model.Url;
            parms[5].Value = model.ViewType;
            parms[6].Value = model.StartDate;
            parms[7].Value = model.EndDate;
            parms[8].Value = model.UserId;
            parms[9].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms));
        }
Exemplo n.º 3
0
        public IList <InformationAdInfo> GetList(int pageIndex, int pageSize, out int totalRecords, string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select count(*) from Information_Ad ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            totalRecords = (int)SqlHelper.ExecuteScalar(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms);

            if (totalRecords == 0)
            {
                return(new List <InformationAdInfo>());
            }

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

            sb.Append(@"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber,
			          Id,Title,Descr,ContentText,Url,ViewType,StartDate,EndDate,UserId,LastUpdatedDate
					  from Information_Ad "                    );
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex);

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        InformationAdInfo model = new InformationAdInfo();
                        model.Id              = reader.GetGuid(1);
                        model.Title           = reader.GetString(2);
                        model.Descr           = reader.GetString(3);
                        model.ContentText     = reader.GetString(4);
                        model.Url             = reader.GetString(5);
                        model.ViewType        = reader.GetInt32(6);
                        model.StartDate       = reader.GetDateTime(7);
                        model.EndDate         = reader.GetDateTime(8);
                        model.UserId          = reader.GetGuid(9);
                        model.LastUpdatedDate = reader.GetDateTime(10);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Exemplo n.º 4
0
        public Guid InsertByOutput(InformationAdInfo model)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"insert into Information_Ad (Title,Descr,ContentText,Url,ViewType,StartDate,EndDate,UserId,LastUpdatedDate)
			            output inserted.Id values
						(@Title,@Descr,@ContentText,@Url,@ViewType,@StartDate,@EndDate,@UserId,@LastUpdatedDate)
			            "            );

            SqlParameter[] parms =
            {
                new SqlParameter("@Title",           SqlDbType.NVarChar,           100),
                new SqlParameter("@Descr",           SqlDbType.NVarChar,           200),
                new SqlParameter("@ContentText",     SqlDbType.NVarChar,          4000),
                new SqlParameter("@Url",             SqlDbType.VarChar,            200),
                new SqlParameter("@ViewType",        SqlDbType.Int),
                new SqlParameter("@StartDate",       SqlDbType.DateTime),
                new SqlParameter("@EndDate",         SqlDbType.DateTime),
                new SqlParameter("@UserId",          SqlDbType.UniqueIdentifier),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime)
            };
            parms[0].Value = model.Title;
            parms[1].Value = model.Descr;
            parms[2].Value = model.ContentText;
            parms[3].Value = model.Url;
            parms[4].Value = model.ViewType;
            parms[5].Value = model.StartDate;
            parms[6].Value = model.EndDate;
            parms[7].Value = model.UserId;
            parms[8].Value = model.LastUpdatedDate;

            object obj = SqlHelper.ExecuteScalar(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms);

            if (obj != null)
            {
                return(Guid.Parse(obj.ToString()));
            }

            return(Guid.Empty);
        }
Exemplo n.º 5
0
        public IList <InformationAdInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select Id,Title,Descr,ContentText,Url,ViewType,StartDate,EndDate,UserId,LastUpdatedDate
                        from Information_Ad ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        InformationAdInfo model = new InformationAdInfo();
                        model.Id              = reader.GetGuid(0);
                        model.Title           = reader.GetString(1);
                        model.Descr           = reader.GetString(2);
                        model.ContentText     = reader.GetString(3);
                        model.Url             = reader.GetString(4);
                        model.ViewType        = reader.GetInt32(5);
                        model.StartDate       = reader.GetDateTime(6);
                        model.EndDate         = reader.GetDateTime(7);
                        model.UserId          = reader.GetGuid(8);
                        model.LastUpdatedDate = reader.GetDateTime(9);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Exemplo n.º 6
0
        public InformationAdInfo GetModel(object Id)
        {
            InformationAdInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 Id,Title,Descr,ContentText,Url,ViewType,StartDate,EndDate,UserId,LastUpdatedDate 
			            from Information_Ad
						where Id = @Id "                        );
            SqlParameter parm = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parm))
            {
                if (reader != null)
                {
                    if (reader.Read())
                    {
                        model                 = new InformationAdInfo();
                        model.Id              = reader.GetGuid(0);
                        model.Title           = reader.GetString(1);
                        model.Descr           = reader.GetString(2);
                        model.ContentText     = reader.GetString(3);
                        model.Url             = reader.GetString(4);
                        model.ViewType        = reader.GetInt32(5);
                        model.StartDate       = reader.GetDateTime(6);
                        model.EndDate         = reader.GetDateTime(7);
                        model.UserId          = reader.GetGuid(8);
                        model.LastUpdatedDate = reader.GetDateTime(9);
                    }
                }
            }

            return(model);
        }
Exemplo n.º 7
0
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(InformationAdInfo model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 8
0
 /// <summary>
 /// 添加数据到数据库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(InformationAdInfo model)
 {
     return(dal.Insert(model));
 }
Exemplo n.º 9
0
 /// <summary>
 /// 添加数据到数据库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public Guid InsertByOutput(InformationAdInfo model)
 {
     return(dal.InsertByOutput(model));
 }
Exemplo n.º 10
0
        public void SaveInformationAd(HttpContext context)
        {
            try
            {
                string id        = context.Request.Form["ctl00$cphMain$hId"].Trim();
                string sTitle    = context.Request.Form["ctl00$cphMain$txtTitle"].Trim();
                string sDescr    = context.Request.Form["ctl00$cphMain$txtDescr"].Trim();
                string sContent  = context.Request.Form["content"].Trim();
                string sViewType = context.Request.Form["rdViewType"].Trim();
                string startDate = context.Request.Form["ctl00$cphMain$startDate"].Trim();
                string endDate   = context.Request.Form["ctl00$cphMain$endDate"].Trim();
                string sUrl      = context.Request.Form["ctl00$cphMain$txtUrl"].Trim();

                string sPictureIdList = context.Request.Form["pictureId"].TrimEnd(',');

                sContent = HttpUtility.HtmlDecode(sContent);

                Guid gId = Guid.Empty;
                if (id != "")
                {
                    Guid.TryParse(id, out gId);
                }

                InformationAdInfo    model = new InformationAdInfo();
                InformationAdPicture bllPP = new InformationAdPicture();
                model.LastUpdatedDate = DateTime.Now;

                model.Id          = gId;
                model.Title       = sTitle;
                model.Descr       = sDescr;
                model.ContentText = sContent;
                model.ViewType    = byte.Parse(sViewType);
                model.Url         = sUrl;
                model.StartDate   = DateTime.Parse(startDate);
                model.EndDate     = DateTime.Parse(endDate);

                if (1 == model.ViewType && string.IsNullOrWhiteSpace(model.ContentText))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}");
                    return;
                }

                InformationAd bll    = new InformationAd();
                int           effect = -1;

                if (!gId.Equals(Guid.Empty))
                {
                    effect = bll.Update(model);
                    if (effect > 0)
                    {
                        bllPP.Delete(model.Id);
                        if (!string.IsNullOrWhiteSpace(sPictureIdList))
                        {
                            foreach (string sPictureId in sPictureIdList.Split(','))
                            {
                                InformationAdPictureInfo infoPP = new InformationAdPictureInfo();
                                Guid pictureId = Guid.Empty;
                                Guid.TryParse(sPictureId, out pictureId);
                                infoPP.InformationAdId = model.Id;
                                infoPP.PictureId       = pictureId;
                                bllPP.InsertModel(infoPP);
                            }
                        }
                    }
                }
                else
                {
                    model.LastUpdatedDate = DateTime.Now;
                    Guid anformationAdId = bll.InsertByOutput(model);
                    if (!anformationAdId.Equals(Guid.Empty))
                    {
                        effect = 1;
                        if (!string.IsNullOrWhiteSpace(sPictureIdList))
                        {
                            foreach (string sPictureId in sPictureIdList.Split(','))
                            {
                                InformationAdPictureInfo infoPP = new InformationAdPictureInfo();
                                Guid pictureId = Guid.Empty;
                                Guid.TryParse(sPictureId, out pictureId);
                                infoPP.InformationAdId = anformationAdId;
                                infoPP.PictureId       = pictureId;
                                bllPP.InsertModel(infoPP);
                            }
                        }
                    }
                }

                if (effect == 110)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Exist + "\"}");
                    return;
                }

                if (effect < 1)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Error + "\"}");
                    return;
                }

                context.Response.Write("{\"success\": true,\"message\": \"" + MessageContent.Submit_Success + "\"}");
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.AlertTitle_Ex_Error + ":" + ex.Message + "\"}");
            }
        }