Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>

        public int Add(AdvTopicMod model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AdvTopic(");
            strSql.Append("Title,Group,DR,TS)");
            strSql.Append(" values (");
            strSql.Append("@Title,@Group,@DR,@TS)");
            strSql.Append(";select @@IDENTITY");
            SqlCommand cmd = new SqlCommand(strSql.ToString());

            SqlParameter[] parameters =
            {
                new SqlParameter("@Title", SqlDbType.NVarChar,  400),
                new SqlParameter("@Group", SqlDbType.Int,         4),
                new SqlParameter("@DR",    SqlDbType.Int,         4),
                new SqlParameter("@TS",    SqlDbType.DateTime),
            };
            if (model.Title != AppConst.StringNull)
            {
                parameters[0].Value = model.Title;
            }
            else
            {
                parameters[0].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[0]);
            if (model.Group != AppConst.IntNull)
            {
                parameters[1].Value = model.Group;
            }
            else
            {
                parameters[1].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[1]);
            if (model.DR != AppConst.IntNull)
            {
                parameters[2].Value = model.DR;
            }
            else
            {
                parameters[2].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[2]);
            if (model.TS != AppConst.DateTimeNull)
            {
                parameters[3].Value = model.TS;
            }
            else
            {
                parameters[3].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[3]);

            return(SqlHelper.ExecuteNonQuery(cmd, parameters));
        }
        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            AdvTopicMod m_topic = new AdvTopicMod();

            if (type == "EDIT")
            {
                if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
                {
                    SysNo = int.Parse(Request.QueryString["id"]);
                }
                m_topic = AdvTopicBll.GetInstance().GetModel(SysNo);

                try
                {
                    m_topic.Title = txtName.Text.Trim();
                    m_topic.Group = int.Parse(drpGroup.SelectedValue);
                    m_topic.DR    = int.Parse(drpStatus.SelectedValue);
                    AdvTopicBll.GetInstance().Update(m_topic);
                    LogManagement.getInstance().WriteTrace(m_topic.SysNo, "APP.AdvTopic.Update", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username);

                    ltrNotice.Text = "该记录已保存成功!";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true);
                }
                catch
                {
                    ltrError.Text = "输入资料格式有误,请检查!";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                    return;
                }
            }
            else if (type == "ADD")
            {
                try
                {
                    m_topic.Title = txtName.Text.Trim();
                    m_topic.Group = int.Parse(drpGroup.SelectedValue);
                    m_topic.DR    = int.Parse(drpStatus.SelectedValue);
                    m_topic.TS    = DateTime.Now;
                    AdvTopicBll.GetInstance().Add(m_topic);
                    LogManagement.getInstance().WriteTrace(m_topic.SysNo, "APP.AdvTopic.Add", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username);

                    ltrNotice.Text = "该记录已保存成功!";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true);
                }
                catch
                {
                    ltrError.Text = "输入资料格式有误,请检查!";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                    return;
                }
            }
        }
        protected void PrepareForm()
        {
            DataTable m_child = AdvTopicBll.GetInstance().GetTopicList();

            rptFamous.DataSource = m_child;
            rptFamous.DataBind();

            if (type == "ADD")
            {
                fieldset1.Style["display"] = "";
                fieldset2.Style["display"] = "";
            }
            else if (type == "EDIT")
            {
                if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
                {
                    try
                    {
                        SysNo = int.Parse(Request.QueryString["id"]);
                        AdvTopicMod m_topic = AdvTopicBll.GetInstance().GetModel(SysNo);
                        txtName.Text            = m_topic.Title;
                        drpGroup.SelectedIndex  = drpGroup.Items.IndexOf(drpGroup.Items.FindByValue(m_topic.Group.ToString()));
                        drpStatus.SelectedIndex = drpStatus.Items.IndexOf(drpStatus.Items.FindByValue(m_topic.DR.ToString()));

                        fieldset1.Style["display"] = "";
                        fieldset2.Style["display"] = "";
                    }
                    catch
                    {
                        Response.Redirect("../Error.aspx?msg=");
                        return;
                    }
                }
            }
            else if (type == "TOP")
            {
                fieldset1.Style["display"] = "none";
                fieldset2.Style["display"] = "none";
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>

        public AdvTopicMod GetModel(int SysNo)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select SysNo, Title, Group, DR, TS from  AdvTopic");
            strSql.Append(" where SysNo=@SysNo ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SysNo", SqlDbType.Int, 4)
            };
            parameters[0].Value = SysNo;
            AdvTopicMod model = new AdvTopicMod();
            DataSet     ds    = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["SysNo"].ToString() != "")
                {
                    model.SysNo = int.Parse(ds.Tables[0].Rows[0]["SysNo"].ToString());
                }
                model.Title = ds.Tables[0].Rows[0]["Title"].ToString();
                if (ds.Tables[0].Rows[0]["Group"].ToString() != "")
                {
                    model.Group = int.Parse(ds.Tables[0].Rows[0]["Group"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DR"].ToString() != "")
                {
                    model.DR = int.Parse(ds.Tables[0].Rows[0]["DR"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TS"].ToString() != "")
                {
                    model.TS = DateTime.Parse(ds.Tables[0].Rows[0]["TS"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(AdvTopicMod model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into AdvTopic(");
            strSql.Append("Title,Group,DR,TS)");
            strSql.Append(" values (");
            strSql.Append("@Title,@Group,@DR,@TS)");
            strSql.Append(";select @@IDENTITY");
            SqlCommand cmd = new SqlCommand(strSql.ToString());
            SqlParameter[] parameters = {
                 new SqlParameter("@Title",SqlDbType.NVarChar,400),
                 new SqlParameter("@Group",SqlDbType.Int,4),
                 new SqlParameter("@DR",SqlDbType.Int,4),
                 new SqlParameter("@TS",SqlDbType.DateTime),
             };
            if (model.Title != AppConst.StringNull)
                parameters[0].Value = model.Title;
            else
                parameters[0].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[0]);
            if (model.Group != AppConst.IntNull)
                parameters[1].Value = model.Group;
            else
                parameters[1].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[1]);
            if (model.DR != AppConst.IntNull)
                parameters[2].Value = model.DR;
            else
                parameters[2].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[2]);
            if (model.TS != AppConst.DateTimeNull)
                parameters[3].Value = model.TS;
            else
                parameters[3].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[3]);

            return SqlHelper.ExecuteNonQuery(cmd,parameters);
        }
Beispiel #6
0
        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            AdvTopicMod m_topic = new AdvTopicMod();
            if (type == "EDIT")
            {
                if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
                {
                    SysNo = int.Parse(Request.QueryString["id"]);
                }
                m_topic = AdvTopicBll.GetInstance().GetModel(SysNo);

                try
                {
                    m_topic.Title = txtName.Text.Trim();
                    m_topic.Group = int.Parse(drpGroup.SelectedValue);
                    m_topic.DR = int.Parse(drpStatus.SelectedValue);
                    AdvTopicBll.GetInstance().Update(m_topic);
                    LogManagement.getInstance().WriteTrace(m_topic.SysNo, "APP.AdvTopic.Update", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username);

                    ltrNotice.Text = "该记录已保存成功!";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true);
                }
                catch
                {
                    ltrError.Text = "输入资料格式有误,请检查!";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                    return;
                }
            }
            else if (type == "ADD")
            {
                try
                {
                    m_topic.Title = txtName.Text.Trim();
                    m_topic.Group = int.Parse(drpGroup.SelectedValue);
                    m_topic.DR = int.Parse(drpStatus.SelectedValue);
                    m_topic.TS = DateTime.Now;
                    AdvTopicBll.GetInstance().Add(m_topic);
                    LogManagement.getInstance().WriteTrace(m_topic.SysNo, "APP.AdvTopic.Add", "IP:" + Request.UserHostAddress + "|AdminID:" + GetSession().AdminEntity.Username);

                    ltrNotice.Text = "该记录已保存成功!";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true);
                }
                catch
                {
                    ltrError.Text = "输入资料格式有误,请检查!";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                    return;
                }
            }
        }
Beispiel #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(AdvTopicMod model)
 {
     dal.Update(model);
 }
Beispiel #8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(AdvTopicMod model)
 {
     return dal.Add(model);
 }
Beispiel #9
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(AdvTopicMod model)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("update AdvTopic set ");
     strSql.Append("Title=@Title,");
     strSql.Append("Group=@Group,");
     strSql.Append("DR=@DR,");
     strSql.Append("TS=@TS");
     strSql.Append(" where SysNo=@SysNo ");
     SqlCommand cmd = new SqlCommand(strSql.ToString());
     SqlParameter[] parameters = {
          new SqlParameter("@SysNo",SqlDbType.Int,4),
          new SqlParameter("@Title",SqlDbType.NVarChar,400),
          new SqlParameter("@Group",SqlDbType.Int,4),
          new SqlParameter("@DR",SqlDbType.Int,4),
          new SqlParameter("@TS",SqlDbType.DateTime)
      };
     if (model.SysNo != AppConst.IntNull)
         parameters[0].Value = model.SysNo;
     else
         parameters[0].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[0]);
     if (model.Title != AppConst.StringNull)
         parameters[1].Value = model.Title;
     else
         parameters[1].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[1]);
     if (model.Group != AppConst.IntNull)
         parameters[2].Value = model.Group;
     else
         parameters[2].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[2]);
     if (model.DR != AppConst.IntNull)
         parameters[3].Value = model.DR;
     else
         parameters[3].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[3]);
     if (model.TS != AppConst.DateTimeNull)
         parameters[4].Value = model.TS;
     else
         parameters[4].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[4]);
     return SqlHelper.ExecuteNonQuery(cmd,parameters);;
 }
Beispiel #10
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public AdvTopicMod GetModel(int SysNo)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select SysNo, Title, Group, DR, TS from  AdvTopic");
     strSql.Append(" where SysNo=@SysNo ");
     SqlParameter[] parameters = {
     new SqlParameter("@SysNo", SqlDbType.Int,4 )
      		};
     parameters[0].Value = SysNo;
     AdvTopicMod model = new AdvTopicMod();
     DataSet ds = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters);
     if (ds.Tables[0].Rows.Count > 0)
     {
         if (ds.Tables[0].Rows[0]["SysNo"].ToString() != "")
         {
             model.SysNo = int.Parse(ds.Tables[0].Rows[0]["SysNo"].ToString());
         }
         model.Title = ds.Tables[0].Rows[0]["Title"].ToString();
         if (ds.Tables[0].Rows[0]["Group"].ToString() != "")
         {
             model.Group = int.Parse(ds.Tables[0].Rows[0]["Group"].ToString());
         }
         if (ds.Tables[0].Rows[0]["DR"].ToString() != "")
         {
             model.DR = int.Parse(ds.Tables[0].Rows[0]["DR"].ToString());
         }
         if (ds.Tables[0].Rows[0]["TS"].ToString() != "")
         {
             model.TS = DateTime.Parse(ds.Tables[0].Rows[0]["TS"].ToString());
         }
         return model;
     }
     else
     {
         return null;
     }
 }
Beispiel #11
0
        /// <summary>
        /// 更新一条数据
        /// </summary>

        public int Update(AdvTopicMod model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AdvTopic set ");
            strSql.Append("Title=@Title,");
            strSql.Append("Group=@Group,");
            strSql.Append("DR=@DR,");
            strSql.Append("TS=@TS");
            strSql.Append(" where SysNo=@SysNo ");
            SqlCommand cmd = new SqlCommand(strSql.ToString());

            SqlParameter[] parameters =
            {
                new SqlParameter("@SysNo", SqlDbType.Int,        4),
                new SqlParameter("@Title", SqlDbType.NVarChar, 400),
                new SqlParameter("@Group", SqlDbType.Int,        4),
                new SqlParameter("@DR",    SqlDbType.Int,        4),
                new SqlParameter("@TS",    SqlDbType.DateTime)
            };
            if (model.SysNo != AppConst.IntNull)
            {
                parameters[0].Value = model.SysNo;
            }
            else
            {
                parameters[0].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[0]);
            if (model.Title != AppConst.StringNull)
            {
                parameters[1].Value = model.Title;
            }
            else
            {
                parameters[1].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[1]);
            if (model.Group != AppConst.IntNull)
            {
                parameters[2].Value = model.Group;
            }
            else
            {
                parameters[2].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[2]);
            if (model.DR != AppConst.IntNull)
            {
                parameters[3].Value = model.DR;
            }
            else
            {
                parameters[3].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[3]);
            if (model.TS != AppConst.DateTimeNull)
            {
                parameters[4].Value = model.TS;
            }
            else
            {
                parameters[4].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[4]);
            return(SqlHelper.ExecuteNonQuery(cmd, parameters));;
        }
Beispiel #12
0
        /// <summary>
        /// 更新一条数据
        /// </summary>

        public void Update(AdvTopicMod model)
        {
            dal.Update(model);
        }
Beispiel #13
0
        /// <summary>
        /// 增加一条数据
        /// </summary>

        public int Add(AdvTopicMod model)
        {
            return(dal.Add(model));
        }