C#技术百科
问问你的心你有没有信心 做事情要专一坚定,执着

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace zj123.UI.images.Expro
{
    public partial class SortEdit: zj123.BLL.AdminPage
    {
           protected void Page_Load(object sender, EventArgs e)
           {
            this.BtDel.Attributes["onclick"] = "window.close()";
            if (!Page.IsPostBack)
            {  
                BindUpdate();  
            }
        }
      
        public void BindUpdate()
        {
            string action = this.GetRequest("action");
            if (action == "upd")
            {
                string sql = string.Format("select * from [Expro_NewsType] where column_id='{0}'", this.GetRequest("id"));
                DataTable dt = this.Db.GetTable(sql);
                if (dt != null)
                {
                    this.TbName.Text = Convert.ToString(dt.Rows[0]["column_name"]);
                    this.TbIntro.Text = Convert.ToString(dt.Rows[0]["column_intro"]);
                }
            }
        }
        protected void BtVerfly_Click(object sender, EventArgs e)
        {
            string action = this.GetRequest("action");
            string name = this.TbName.Text.Trim();
            string intro = this.TbIntro.Text.Trim();
            string parentid = this.GetRequest("parentid");
            parentid = parentid.Length<1?("0"):(parentid);
            string depth = this.GetRequest("depth");
            
         
            string message = "";
            string sql = "";
            switch (action)
            {
                case "add":
                    message = "添加";
                    int depthint = Convert.ToInt32(depth) + 1;
                 
                    sql = string.Format("insert into Expro_NewsType([column_id],[column_name],[parent_id],[column_depth],[column_intro]) values( '{0}','{1}','{2}',{3},'{4}')", System.Guid.NewGuid().ToString().Replace("-", "").ToUpper().Substring(1, 6), name, parentid, depthint, intro);
                    break;
                case "upd":
                    message = "修改";
                    sql = string.Format("update [Expro_NewsType] set Column_Name='{0}',Column_Intro='{1}' where [column_ID]='{2}'", name, intro, this.GetRequest("id"));
                    break;
                default:
                    break;
            }
            if (this.Db.GetState(sql))
            {
                this.ShowMessage("成功" + message, "window.opener.location.reload()");
            }
            else
            {
                this.ShowMessage("操作失败请联系管理员!!!","");
            }

        }

        protected void BtDel_Click(object sender, EventArgs e)
        {
           // Response.Write(this.Script());
        }
    }
}

posted on 2009-03-13 18:14  王德田  阅读(214)  评论(0编辑  收藏  举报