Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string editid = Request.QueryString["id"];

            MyCreek.Platform.DBConnection   bdbConn = new MyCreek.Platform.DBConnection();
            MyCreek.Data.Model.DBConnection dbconn  = null;
            if (editid.IsGuid())
            {
                dbconn = bdbConn.Get(editid.ToGuid());
            }
            bool   isAdd  = !editid.IsGuid();
            string oldXML = string.Empty;

            if (dbconn == null)
            {
                dbconn    = new MyCreek.Data.Model.DBConnection();
                dbconn.ID = Guid.NewGuid();
            }
            else
            {
                oldXML = dbconn.Serialize();
            }

            if (IsPostBack)
            {
                string Name     = Request.Form["Name"];
                string LinkType = Request.Form["LinkType"];
                string ConnStr  = Request.Form["ConnStr"];
                string Note     = Request.Form["Note"];
                dbconn.Name             = Name.Trim();
                dbconn.Type             = LinkType;
                dbconn.ConnectionString = ConnStr;
                dbconn.Note             = Note;

                if (isAdd)
                {
                    bdbConn.Add(dbconn);
                    MyCreek.Platform.Log.Add("添加了应用程序库", dbconn.Serialize(), MyCreek.Platform.Log.Types.角色应用);
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();", true);
                }
                else
                {
                    bdbConn.Update(dbconn);
                    MyCreek.Platform.Log.Add("修改了应用程序库", "", MyCreek.Platform.Log.Types.角色应用, oldXML, dbconn.Serialize());
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('修改成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();", true);
                }
                bdbConn.ClearCache();
            }
            if (dbconn != null)
            {
                this.Name.Value    = dbconn.Name;
                this.ConnStr.Value = dbconn.ConnectionString;
                this.Note.Value    = dbconn.Note;
            }
            this.TypeOptions.Text = bdbConn.GetAllTypeOptions(dbconn.Type);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(FormCollection collection)
        {
            string editid = Request.QueryString["id"];

            MyCreek.Platform.DBConnection   bdbConn = new MyCreek.Platform.DBConnection();
            MyCreek.Data.Model.DBConnection dbconn  = null;
            if (editid.IsGuid())
            {
                dbconn = bdbConn.Get(editid.ToGuid());
            }
            bool   isAdd  = !editid.IsGuid();
            string oldXML = string.Empty;

            if (dbconn == null)
            {
                dbconn    = new MyCreek.Data.Model.DBConnection();
                dbconn.ID = Guid.NewGuid();
            }
            else
            {
                oldXML = dbconn.Serialize();
            }

            if (collection != null)
            {
                string Name     = Request.Form["Name"];
                string LinkType = Request.Form["LinkType"];
                string ConnStr  = Request.Form["ConnStr"];
                string Note     = Request.Form["Note"];
                dbconn.Name             = Name.Trim();
                dbconn.Type             = LinkType;
                dbconn.ConnectionString = ConnStr;
                dbconn.Note             = Note;

                if (isAdd)
                {
                    bdbConn.Add(dbconn);
                    MyCreek.Platform.Log.Add("添加了应用程序库", dbconn.Serialize(), MyCreek.Platform.Log.Types.角色应用);
                    ViewBag.Script = "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
                }
                else
                {
                    bdbConn.Update(dbconn);
                    MyCreek.Platform.Log.Add("修改了应用程序库", "", MyCreek.Platform.Log.Types.角色应用, oldXML, dbconn.Serialize());
                    ViewBag.Script = "alert('修改成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
                }
                bdbConn.ClearCache();
            }

            ViewBag.TypeOptions = bdbConn.GetAllTypeOptions(dbconn.Type);

            return(View(dbconn));
        }