/// <summary> /// Saves an existing panel to the database, rewriting the original attributes and all the fields and controls (including those that haven`t changed), /// </summary> /// <param name="panel"></param> /// <param name="recursive"></param> public void UpdatePanel(Panel panel, bool recursive = true) { Dictionary <string, object> updateVals = new Dictionary <string, object>(); if (panel.parent != null) { updateVals["id_parent"] = panel.parent.panelId; } updateVals["content"] = panel.Serialize(); driver.query("UPDATE panels SET", dbe.UpdVals(updateVals), "WHERE ", dbe.Col("id_panel"), " = ", panel.panelId); driver.query("DELETE FROM", dbe.Table("fields"), "WHERE", dbe.Col("id_panel"), " = ", panel.panelId); foreach (IField field in panel.fields) { AddField(field); } driver.query("DELETE FROM ", dbe.Table("controls"), " WHERE ", dbe.Col("id_panel"), " = ", panel.panelId); foreach (Control control in panel.controls) { AddControl(control); } if (recursive) { foreach (Panel child in panel.children) { UpdatePanel(child, true); } } }
/// <summary> /// Saves the panel to the system database, but doesn`t save the filds / controls (so that they can be saved in "next wave", after the panel ID is known /// and the the control target panel can be bound to the new panel via this ID /// </summary> /// <param name="panel"></param> /// <param name="recursive"></param> private void AddPanelOnly(Panel panel, bool recursive = true) { Dictionary <string, object> insertVals = new Dictionary <string, object>(); insertVals["content"] = panel.Serialize(); insertVals["id_project"] = CE.project.Id; if (panel.parent != null) { insertVals["id_parent"] = panel.parent.panelId; } if (!driver.IsInTransaction) { driver.BeginTransaction(); driver.query("INSERT INTO", dbe.Table("panels"), dbe.InsVals(insertVals)); panel.SetCreationId(driver.LastId()); driver.CommitTransaction(); } else { driver.query("INSERT INTO", dbe.Table("panels"), dbe.InsVals(insertVals)); panel.SetCreationId(driver.LastId()); } if (recursive) { foreach (Panel child in panel.children) { AddPanelOnly(child); } } }
/// <summary> /// Saves the panel to the system database, but doesn`t save the filds / controls (so that they can be saved in "next wave", after the panel ID is known /// and the the control target panel can be bound to the new panel via this ID /// </summary> /// <param name="panel"></param> /// <param name="recursive"></param> private void AddPanelOnly(Panel panel, bool recursive = true) { Dictionary<string, object> insertVals = new Dictionary<string, object>(); insertVals["content"] = panel.Serialize(); insertVals["id_project"] = CE.project.Id; if (panel.parent != null) insertVals["id_parent"] = panel.parent.panelId; if (!driver.IsInTransaction) { driver.BeginTransaction(); driver.query("INSERT INTO", dbe.Table("panels"), dbe.InsVals(insertVals)); panel.SetCreationId(driver.LastId()); driver.CommitTransaction(); } else { driver.query("INSERT INTO", dbe.Table("panels"), dbe.InsVals(insertVals)); panel.SetCreationId(driver.LastId()); } if (recursive) foreach (Panel child in panel.children) AddPanelOnly(child); }
/// <summary> /// Saves an existing panel to the database, rewriting the original attributes and all the fields and controls (including those that haven`t changed), /// </summary> /// <param name="panel"></param> /// <param name="recursive"></param> public void UpdatePanel(Panel panel, bool recursive = true) { Dictionary<string, object> updateVals = new Dictionary<string, object>(); if (panel.parent != null) updateVals["id_parent"] = panel.parent.panelId; updateVals["content"] = panel.Serialize(); driver.query("UPDATE panels SET", dbe.UpdVals(updateVals), "WHERE ", dbe.Col("id_panel"), " = ", panel.panelId); driver.query("DELETE FROM", dbe.Table("fields"), "WHERE", dbe.Col("id_panel"), " = ", panel.panelId); foreach (IField field in panel.fields) { AddField(field); } driver.query("DELETE FROM ", dbe.Table("controls"), " WHERE ", dbe.Col("id_panel"), " = ", panel.panelId); foreach (Control control in panel.controls) { AddControl(control); } if (recursive) { foreach (Panel child in panel.children) UpdatePanel(child, true); } }