Example #1
0
        public IList <InformationAdPictureInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select InformationAdId,PictureId
                        from InformationAdPicture ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        InformationAdPictureInfo model = new InformationAdPictureInfo();
                        model.InformationAdId = reader.GetGuid(0);
                        model.PictureId       = reader.GetGuid(1);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Example #2
0
        public IList <InformationAdPictureInfo> GetList()
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select InformationAdId,PictureId 
			            from InformationAdPicture
					    order by LastUpdatedDate desc "                    );

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString()))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        InformationAdPictureInfo model = new InformationAdPictureInfo();
                        model.InformationAdId = reader.GetGuid(0);
                        model.PictureId       = reader.GetGuid(1);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Example #3
0
        public IList <InformationAdPictureInfo> GetList(int pageIndex, int pageSize, string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb         = new StringBuilder(250);
            int           startIndex = (pageIndex - 1) * pageSize + 1;
            int           endIndex   = pageIndex * pageSize;

            sb.Append(@"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber,
			           InformationAdId,PictureId
					   from InformationAdPicture "                    );
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex);

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        InformationAdPictureInfo model = new InformationAdPictureInfo();
                        model.InformationAdId = reader.GetGuid(1);
                        model.PictureId       = reader.GetGuid(2);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Example #4
0
        public InformationAdPictureInfo GetModel(object InformationAdId)
        {
            InformationAdPictureInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 InformationAdId,PictureId 
			            from InformationAdPicture
						where InformationAdId = @InformationAdId "                        );
            SqlParameter parm = new SqlParameter("@InformationAdId", SqlDbType.UniqueIdentifier);

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parm))
            {
                if (reader != null)
                {
                    if (reader.Read())
                    {
                        model = new InformationAdPictureInfo();
                        model.InformationAdId = reader.GetGuid(0);
                        model.PictureId       = reader.GetGuid(1);
                    }
                }
            }

            return(model);
        }
Example #5
0
        public int Insert(InformationAdPictureInfo model)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"insert into InformationAdPicture (PictureId)
			            values
						(@PictureId)
			            "            );

            SqlParameter[] parms =
            {
                new SqlParameter("@PictureId", SqlDbType.UniqueIdentifier)
            };
            parms[0].Value = model.PictureId;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms));
        }
Example #6
0
        public int Update(InformationAdPictureInfo model)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"update InformationAdPicture set PictureId = @PictureId 
			            where InformationAdId = @InformationAdId
					    "                    );

            SqlParameter[] parms =
            {
                new SqlParameter("@InformationAdId", SqlDbType.UniqueIdentifier),
                new SqlParameter("@PictureId",       SqlDbType.UniqueIdentifier)
            };
            parms[0].Value = model.InformationAdId;
            parms[1].Value = model.PictureId;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms));
        }
Example #7
0
 public int InsertModel(InformationAdPictureInfo model)
 {
     return(dal.InsertModel(model));
 }
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(InformationAdPictureInfo model)
 {
     return(dal.Update(model));
 }
Example #9
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 + "\"}");
            }
        }