示例#1
0
        /// <summary>
        /// 数据转专题实体
        /// </summary>
        public static ZhuanTiInfo DataToModel(SqlDataReader rdr)
        {
            ZhuanTiInfo zhuanTi = new ZhuanTiInfo();
            if (!rdr.IsDBNull(0)) zhuanTi.ZhuanTiID = rdr.GetInt32(0);
            if (!rdr.IsDBNull(1)) zhuanTi.ZhuanTiName = rdr.GetString(1);
            if (!rdr.IsDBNull(2)) zhuanTi.ZhuanTiImage = rdr.GetString(2);
            if (!rdr.IsDBNull(3)) zhuanTi.UserID = rdr.GetInt32(3);
            if (!rdr.IsDBNull(4)) zhuanTi.ZhuanTiLive = rdr.GetByte(4);
            if (!rdr.IsDBNull(5)) zhuanTi.Synchronize = rdr.GetByte(5);
            if (!rdr.IsDBNull(6)) zhuanTi.ModifyDate = rdr.GetDateTime(6);
            if (!rdr.IsDBNull(7)) zhuanTi.ZTID = rdr.GetInt32(7);

            return zhuanTi;
        }
示例#2
0
        /// <summary>
        /// 专题实体转参数
        /// </summary>
        public static SqlParameter[] ModelToParms(ZhuanTiInfo zhuanTi)
        {
            SqlParameter[] parms = {
                    new SqlParameter("@ZhuanTiID", SqlDbType.Int),
                    new SqlParameter("@ZhuanTiName", SqlDbType.NVarChar, 20),
                    new SqlParameter("@ZhuanTiImage", SqlDbType.NVarChar, 200),
                    new SqlParameter("@UserID", SqlDbType.Int),
                    new SqlParameter("@ZhuanTiLive", SqlDbType.TinyInt),
                    new SqlParameter("@Synchronize", SqlDbType.TinyInt),
                    new SqlParameter("@ModifyDate", SqlDbType.DateTime),
                    new SqlParameter("@ZTID", SqlDbType.Int)
            };
            parms[0].Value = zhuanTi.ZhuanTiID;
            parms[1].Value = zhuanTi.ZhuanTiName;
            parms[2].Value = zhuanTi.ZhuanTiImage;
            parms[3].Value = zhuanTi.UserID;
            parms[4].Value = zhuanTi.ZhuanTiLive;
            parms[5].Value = zhuanTi.Synchronize;
            parms[6].Value = zhuanTi.ModifyDate;
            parms[7].Value = zhuanTi.ZTID;

            return parms;
        }
示例#3
0
    //取专题ID
    private int? GetZhuanTiId(string zhuanTiName)
    {
        if (zhuanTiName == "")
        {
            return 0;
        }

        zhuanTiList = zt_bll.GetZhuanTiList(userId);
        foreach (DataRow dr in zhuanTiList.Rows)
        {
            if (zhuanTiName == dr["ZhuanTiName"].ToString())
            {
                return Convert.ToInt32(dr["ZTID"]);
            }
        }

        ZhuanTiInfo zhuanTi = new ZhuanTiInfo();
        zhuanTi.ZhuanTiName = zhuanTiName;
        zhuanTi.ZhuanTiLive = 1;
        zhuanTi.Synchronize = 1;
        zhuanTi.UserID = userId;
        zhuanTi.ModifyDate = DateTime.Now;
        zhuanTi.ZTID = zt_bll.GetMaxZhuanTiId(userId);

        bool success = zt_bll.InsertZhuanTi(zhuanTi);
        if (success)
        {
            return zhuanTi.ZTID;
        }
        else
        {
            throw new Exception();
        }
    }
示例#4
0
    //更新操作
    protected void List_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int ztId = Convert.ToInt32(List.DataKeys[e.RowIndex].Value);
        string zhuanTiImage = ((HiddenField)List.Rows[e.RowIndex].FindControl("ZhuanTiImageHid")).Value;
        string zhuanTiName = ((TextBox)List.Rows[e.RowIndex].FindControl("ZhuanTiNameBox")).Text.Trim();
        string zhuanTiNameHid = ((HiddenField)List.Rows[e.RowIndex].FindControl("ZhuanTiNameHid")).Value;

        FileUpload zhuanTiImageUpload = (FileUpload)List.Rows[e.RowIndex].FindControl("ZhuanTiImageUpload");
        if (zhuanTiImageUpload.HasFile)
        {
            zhuanTiImage = SaveZhuanTiImage(zhuanTiImageUpload, zhuanTiImage, ztId);
            if (zhuanTiImage == "")
            {
                return;
            }
        }

        if (zhuanTiName == "")
        {
            Utility.Alert(this, "专题名称未填写!");
            return;
        }

        ZhuanTiInfo zhuanTi = new ZhuanTiInfo();

        if (zhuanTiName != zhuanTiNameHid)
        {
            zhuanTi = bll.GetZhuanTiByZhuanTiName(userId, zhuanTiName);
            if (zhuanTi.ZhuanTiID > 0)
            {
                Utility.Alert(this, "专题已存在,不能重复添加!");
                return;
            }
        }

        zhuanTi.ZhuanTiImage = zhuanTiImage;
        zhuanTi.ZhuanTiName = zhuanTiName;
        zhuanTi.UserID = userId;
        zhuanTi.ModifyDate = DateTime.Now;
        zhuanTi.Synchronize = 1;
        zhuanTi.ZTID = ztId;

        bool success = bll.UpdateZhuanTi(zhuanTi);
        if (success)
        {
            Utility.Alert(this, "更新成功。");

            List.EditIndex = -1;
            BindGrid();
        }
        else
        {
            Utility.Alert(this, "更新失败!");
        }
    }
示例#5
0
        /// <summary>
        /// 根据专题ID取专题,返回实体
        /// </summary>
        public ZhuanTiInfo GetZhuanTiByZhuanTiId(int userId, int ztId)
        {
            ZhuanTiInfo zhuanTi = new ZhuanTiInfo();

            SqlParameter[] parms = {
                   new SqlParameter(PARM_USER_ID, SqlDbType.Int),
                   new SqlParameter(PARM_ZT_ID, SqlDbType.Int)
            };
            parms[0].Value = userId;
            parms[1].Value = ztId;

            using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, CommandType.Text, SQL_SELECT_ZHUANTI_BY_ZHUANTI_ID, parms))
            {
                while (rdr.Read())
                {
                    zhuanTi = DataToModel(rdr);
                }
            }

            return zhuanTi;
        }
示例#6
0
        /// <summary>
        /// 修改专题
        /// </summary>
        public bool UpdateZhuanTi(ZhuanTiInfo zhuanTi)
        {
            SqlParameter[] parms = ModelToParms(zhuanTi);

            int result = SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.StoredProcedure, SQL_UPDATE_ZHUANTI, parms);

            return result > 0;
        }
示例#7
0
 /// <summary>
 /// 修改专题
 /// </summary>
 public bool UpdateZhuanTi(ZhuanTiInfo zhuanTi)
 {
     return dal.UpdateZhuanTi(zhuanTi);
 }
示例#8
0
 /// <summary>
 /// 插入专题
 /// </summary>
 public bool InsertZhuanTi(ZhuanTiInfo zhuanTi)
 {
     return dal.InsertZhuanTi(zhuanTi);
 }