Esempio n. 1
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="mod">AdPositionInfo</param>
 /// <returns>受影响行数</returns>
 public int Update(AdPositionInfo mod)
 {
     using (DbConnection conn = db.CreateConnection())
     {
         conn.Open();
         using (DbTransaction tran = conn.BeginTransaction())
         {
             try
             {
                 using (DbCommand cmd = db.GetStoredProcCommand("SP_AdPosition_Update"))
                 {
                     db.AddInParameter(cmd, "@AdpID", DbType.Int32, mod.AdpID);
                     db.AddInParameter(cmd, "@Name", DbType.String, mod.Name);
                     db.AddInParameter(cmd, "@Width", DbType.Int32, mod.Width);
                     db.AddInParameter(cmd, "@Height", DbType.Int32, mod.Height);
                     db.AddInParameter(cmd, "@State", DbType.Int32, mod.State);
                     db.AddInParameter(cmd, "@IsDeleted", DbType.Int32, mod.IsDeleted);
                     db.AddInParameter(cmd, "@Sort", DbType.Int32, mod.Sort);
                     tran.Commit();
                     return(db.ExecuteNonQuery(cmd));
                 }
             }
             catch (Exception e)
             {
                 tran.Rollback();
                 throw e;
             }
             finally
             {
                 conn.Close();
             }
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 广告位列表
        /// </summary>
        /// <param name="setting"></param>
        /// <returns></returns>
        public static IPageOfList <AdPositionInfo> List(AdSearchSetting setting)
        {
            FastPaging fp = new FastPaging();

            fp.OverOrderBy = " CreateDateTime DESC";
            fp.PageIndex   = setting.PageIndex;
            fp.PageSize    = setting.PageSize;
            fp.QueryFields = "*";
            fp.TableName   = "AdPosition";
            fp.PrimaryKey  = "Id";
            fp.WithOptions = " WITH(NOLOCK)";


            IList <AdPositionInfo> list  = new List <AdPositionInfo>();
            AdPositionInfo         model = null;
            DataTable dt = SQLPlus.ExecuteDataTable(CommandType.Text, fp.Build2005());

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    model = GetByRow(dr);
                    if (model != null)
                    {
                        list.Add(model);
                    }
                }
            }
            int count = Convert.ToInt32(SQLPlus.ExecuteScalar(CommandType.Text, fp.BuildCountSQL()));

            return(new PageOfList <AdPositionInfo>(list, setting.PageIndex, setting.PageSize, count));
        }
Esempio n. 3
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="mod">AdPositionInfo</param>
        /// <returns>受影响行数</returns>
        public int Update(AdPositionInfo mod)
        {
           using (DbConnection conn = db.CreateConnection())
			{
				conn.Open();
				using (DbTransaction tran = conn.BeginTransaction())
				{ 
					try
					{ 
						using (DbCommand cmd = db.GetStoredProcCommand("SP_AdPosition_Update"))
						{
							db.AddInParameter(cmd, "@AdpID", DbType.Int32, mod.AdpID); 
							db.AddInParameter(cmd, "@Name", DbType.String, mod.Name); 
							db.AddInParameter(cmd, "@Width", DbType.Int32, mod.Width); 
							db.AddInParameter(cmd, "@Height", DbType.Int32, mod.Height); 
							db.AddInParameter(cmd, "@State", DbType.Int32, mod.State); 
							db.AddInParameter(cmd, "@IsDeleted", DbType.Int32, mod.IsDeleted); 
							db.AddInParameter(cmd, "@Sort", DbType.Int32, mod.Sort); 
							tran.Commit();
							return db.ExecuteNonQuery(cmd);
						} 
					}
					catch (Exception e)
					{
						tran.Rollback();
						throw e;
					}
					finally
					{
						conn.Close();
					}
				}
			}
        }  
Esempio n. 4
0
        /// <summary>
        /// 根据分页获得数据列表
        /// </summary>
        /// <param name="TbFields">返回字段</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="OrderField">排序字段</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页尺寸</param>
        /// <param name="TotalCount">返回总记录数</param>
        /// <returns>IList<AdPositionInfo></returns>
        public IList <AdPositionInfo> Find(string tbFields, string strWhere, string orderField, int pageIndex, int pageSize, out int totalCount)
        {
            IList <AdPositionInfo> list = new List <AdPositionInfo>();

            using (DbCommand cmd = db.GetStoredProcCommand("SP_SqlPagenation"))
            {
                db.AddInParameter(cmd, "@TbName", DbType.String, "AdPosition");
                db.AddInParameter(cmd, "@TbFields", DbType.String, tbFields);
                db.AddInParameter(cmd, "@StrWhere", DbType.String, strWhere);
                db.AddInParameter(cmd, "@OrderField", DbType.String, orderField);
                db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageIndex);
                db.AddInParameter(cmd, "@PageSize", DbType.Int32, pageSize);
                db.AddOutParameter(cmd, "@Total", DbType.Int32, int.MaxValue);
                using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
                {
                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            AdPositionInfo model = new AdPositionInfo();
                            model.LoadFromDataRow(dr);
                            list.Add(model);
                        }
                    }
                }

                totalCount = (int)db.GetParameterValue(cmd, "@Total");
                return(list);
            }
        }
 private void SerializeInternal(AdPositionInfo model, IDictionary<string, object> result)
 { 
     result.Add("adpid", model.AdpID);
     result.Add("name", model.Name);
     result.Add("width", model.Width);
     result.Add("height", model.Height);
     result.Add("state", model.State);
     result.Add("isdeleted", model.IsDeleted);
     result.Add("sort", model.Sort);
 }
Esempio n. 6
0
 /// <summary>
 /// 添加或编辑广告位信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static AdPositionInfo Create(AdPositionInfo model)
 {
     if (model.Id == 0)
     {
         int id = AdPositionManage.Insert(model);
     }
     else
     {
         AdPositionManage.Update(model);
     }
     return(model);
 }
Esempio n. 7
0
 private void bind()
 {
     if (id > 0)
     {
         hfid.Value = id.ToString();
         AdPositionInfo info = BLL.AdPositionBLL.GetModel(id);
         txbname.Text       = info.name;
         txbcall_index.Text = info.call_index;
         txbwidth.Text      = info.width.ToString();
         txbheight.Text     = info.height.ToString();
     }
 }
Esempio n. 8
0
 protected void bindAdPosition()
 {
     if (call_index.Trim().Length > 0)
     {
         List <AdPositionInfo> list = BLL.AdPositionBLL.GetList(1, "call_index='" + call_index + "'", "");
         if (list != null && list.Count > 0)
         {
             AdPositionInfo info = list[0];
             title = info.name;
         }
     }
     else
     {
         title = "广告";
     }
 }
Esempio n. 9
0
        public ActionResult Modify(AdPositionInfo model)
        {
            bool errors = false;

            if (string.IsNullOrEmpty(model.Name))
            {
                ModelState.AddModelError("NAME", "广告名称不能为空");
                errors = true;
            }
            if (ModelState.IsValid && !errors)
            {
                AdPositionService.Create(model);
                ViewBag.Msg = "修改成功!<a href=\"/adm/slot/list\">返回</a>";
            }
            return(View(model));
        }
Esempio n. 10
0
        /// <summary>
        /// 添加新的广告位
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int Insert(AdPositionInfo model)
        {
            string strSQL = "INSERT INTO dbo.AdPosition(Name,Width,Height,Remark) VALUES(@Name,@Width,@Height,@Remark);SELECT @@IDENTITY;";

            SqlParameter[] parms =
            {
                new SqlParameter("Name",   SqlDbType.NVarChar),
                new SqlParameter("Width",  SqlDbType.Int),
                new SqlParameter("Height", SqlDbType.Int),
                new SqlParameter("Remark", SqlDbType.NVarChar)
            };
            parms[0].Value = model.Name;
            parms[1].Value = model.Width;
            parms[2].Value = model.Height;
            parms[3].Value = model.Remark;
            return(Convert.ToInt32(SQLPlus.ExecuteScalar(CommandType.Text, strSQL, parms)));
        }
Esempio n. 11
0
        protected void ddlAdPositionbind()
        {
            ddlAdPosition.Items.Clear();
            ddlAdPosition.Items.Add(new ListItem("选择广告位", "0"));
            List <AdPositionInfo> list = BLL.AdPositionBLL.GetList(-1, "", "");

            if (list == null || list.Count == 0)
            {
                return;
            }
            //ddlAdPosition.DataTextField = "name";
            //ddlAdPosition.DataValueField = "id";
            //ddlAdPosition.DataSource = list;
            //ddlAdPosition.DataBind();


            foreach (AdPositionInfo info in list)
            {
                ddlAdPosition.Items.Add(new ListItem(info.name + " (" + info.width + "px * " + info.height + "px)", info.id.ToString()));
            }

            if (call_index.Trim().Length > 0)
            {
                List <AdPositionInfo> adpositioninfolist = BLL.AdPositionBLL.GetList(1, "call_index='" + call_index.Trim() + "'", "");
                if (adpositioninfolist != null && adpositioninfolist.Count > 0)
                {
                    AdPositionInfo adpositioninfo = list[0];
                    if (adpositioninfo != null && adpositioninfo.id > 0)
                    {
                        ddlAdPosition.SelectedValue = adpositioninfo.id.ToString();
                        title = adpositioninfo.name;
                    }
                }
            }
            if (adpositionid > 0)
            {
                AdPositionInfo adpositioninfo = BLL.AdPositionBLL.GetModel(adpositionid);
                if (adpositioninfo != null && adpositioninfo.id > 0)
                {
                    ddlAdPosition.SelectedValue = adpositioninfo.id.ToString();
                    title = adpositioninfo.name;
                }
            }
        }
Esempio n. 12
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <param name="keyValue">编号</param>
        /// <returns>AdPositionInfo</returns>
        public AdPositionInfo Get(int keyValue)
        {
            AdPositionInfo model = null;

            using (DbCommand cmd = db.GetStoredProcCommand("SP_GetRecord"))
            {
                db.AddInParameter(cmd, "@TableName", DbType.String, "AdPosition");
                db.AddInParameter(cmd, "@KeyName", DbType.String, "AdpID");
                db.AddInParameter(cmd, "@KeyValue", DbType.Int32, keyValue);
                using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
                {
                    if (dt.Rows.Count > 0)
                    {
                        model = new AdPositionInfo();
                        model.LoadFromDataRow(dt.Rows[0]);
                    }
                }
                return(model);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 更新广告位
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int Update(AdPositionInfo model)
        {
            string strSQL = "UPDATE AdPosition SET Name = @Name,Width = @Width,Height = @Height,Remark = @Remark,DeliveryUrl = @DeliveryUrl WHERE Id = @Id";

            SqlParameter[] parms =
            {
                new SqlParameter("Name",        SqlDbType.NVarChar),
                new SqlParameter("Width",       SqlDbType.Int),
                new SqlParameter("Height",      SqlDbType.Int),
                new SqlParameter("Remark",      SqlDbType.NVarChar),
                new SqlParameter("Id",          SqlDbType.Int),
                new SqlParameter("DeliveryUrl", SqlDbType.NVarChar),
            };
            parms[0].Value = model.Name;
            parms[1].Value = model.Width;
            parms[2].Value = model.Height;
            parms[3].Value = model.Remark;
            parms[4].Value = model.Id;
            parms[5].Value = "sss";
            return(SQLPlus.ExecuteNonQuery(CommandType.Text, strSQL, parms));
        }
Esempio n. 14
0
        public static void init()
        {
            //初始化广告位
            AdPositionInfo adinfo = new AdPositionInfo()
            {
                name = "首页幻灯片", width = 480, height = 160, filetype = "", call_index = "index_hdp"
            };

            AdPositionBLL.Add(adinfo);
            adinfo = new AdPositionInfo()
            {
                name = "首页内容栏1张", width = 180, height = 180, filetype = "", call_index = "index_ad1"
            };
            AdPositionBLL.Add(adinfo);
            adinfo = new AdPositionInfo()
            {
                name = "首页内容栏2张", width = 180, height = 90, filetype = "", call_index = "index_ad2"
            };
            AdPositionBLL.Add(adinfo);
            //==========================商城
            //adinfo = new AdPositionInfo() { name = "商城首页幻灯片", width = 480, height = 160, filetype = "", call_index = "mall_hdp" };
            //AdPositionBLL.Add(adinfo);
            //==========================
        }
Esempio n. 15
0
        /// <summary>
        /// 根据分页获得数据列表
        /// </summary>
        /// <param name="TbFields">返回字段</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="OrderField">排序字段</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页尺寸</param> 
        /// <param name="TotalCount">返回总记录数</param>
        /// <returns>IList<AdPositionInfo></returns>
        public IList<AdPositionInfo> Find(string tbFields, string strWhere, string orderField, int pageIndex, int pageSize, out int totalCount)
        {
			IList<AdPositionInfo> list = new List<AdPositionInfo>();
			using (DbCommand cmd = db.GetStoredProcCommand("SP_SqlPagenation"))
			{
				db.AddInParameter(cmd, "@TbName", DbType.String, "AdPosition");
				db.AddInParameter(cmd, "@TbFields", DbType.String, tbFields);
				db.AddInParameter(cmd, "@StrWhere", DbType.String, strWhere);
				db.AddInParameter(cmd, "@OrderField", DbType.String, orderField);
				db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageIndex);
				db.AddInParameter(cmd, "@PageSize", DbType.Int32, pageSize);
				db.AddOutParameter(cmd, "@Total", DbType.Int32, int.MaxValue);
				using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
				{
					if (dt.Rows.Count > 0)
					{
						foreach (DataRow dr in dt.Rows)
						{
							AdPositionInfo model = new AdPositionInfo();
							model.LoadFromDataRow(dr);
							list.Add(model);
						}
					}
				}

				totalCount = (int)db.GetParameterValue(cmd, "@Total");
				return list;
			}
		} 
Esempio n. 16
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <param name="keyValue">编号</param>
        /// <returns>AdPositionInfo</returns>
        public AdPositionInfo Get(int keyValue)
        {
            AdPositionInfo model = null;
			using (DbCommand cmd = db.GetStoredProcCommand("SP_GetRecord"))
			{
				db.AddInParameter(cmd, "@TableName", DbType.String, "AdPosition");
				db.AddInParameter(cmd, "@KeyName", DbType.String, "AdpID");
				db.AddInParameter(cmd, "@KeyValue", DbType.Int32, keyValue);
				using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
				{
					if (dt.Rows.Count > 0)
					{
						model = new AdPositionInfo();
						model.LoadFromDataRow(dt.Rows[0]);
					}
				}
				return model;
			}
        }