protected void btnEditDatabaseSave_Click(object sender, EventArgs e) { Projet myProjet = GetProjet(); if (myProjet != null) { bool isModif = false; BaseDonnee myDatabase = new BaseDonnee(); if (!string.IsNullOrEmpty(hfDatabseId.Value)) { myDatabase = BaseDonneeManager.Load(iZyInt.ConvertStringToInt(hfDatabseId.Value)); if (myDatabase != null) { isModif = true; } else { myDatabase = new BaseDonnee(); } } myDatabase.host = tbEditDatabaseHost.Text; myDatabase.databaseName = tbEditDatabaseName.Text; myDatabase.user = tbEditDatabaseUser.Text; myDatabase.password = tbEditDatabasePassword.Text; myDatabase.cheminSauvegarde = tbEditDatabaseChemin.Text; myDatabase.idProjet = myProjet.id; myDatabase.libelle = tbEditDatabaseLibelle.Text; if (isModif) { BaseDonneeManager.Update(myDatabase); } else { BaseDonneeManager.Insert(myDatabase); } ListeBaseDonnees_Init(); ResetDatabaseForm(); btnAddDatabase.Enabled = true; pnlEditDatabase.Visible = false; // Sauvegarde upDatabase.Update(); } }
protected void btnSaveDatabase_Click(object sender, EventArgs e) { LinkButton btn = (LinkButton)sender; if (btn != null && !string.IsNullOrEmpty(btn.CommandArgument)) { int idDatabase = iZyInt.ConvertStringToInt(btn.CommandArgument); BaseDonnee myDatabase = BaseDonneeManager.Load(idDatabase); if (myDatabase != null) { // sauvegarde simple if (!string.IsNullOrEmpty(BaseDonneeManager.Sauvegarde(myDatabase))) { // afficher erreur car pas de sauvegarde } } } }
public void ListeBaseDonnees_Init(Projet myProjet = null) { Utilisateur myUser = GetUtilisateur(); if (myProjet == null) { myProjet = GetProjet(); } if (myProjet != null) { ListeBaseDonneeFavoris = BaseDonneeManager.FindFavoris(myUser.id); List <BaseDonnee> bdd = BaseDonneeManager.FindAll(myProjet.id); rptDatabase.DataSource = bdd; rptDatabase.DataBind(); upDatabase.Update(); } }
protected void btnDownload_Click(object sender, EventArgs e) { LinkButton btn = (LinkButton)sender; if (btn != null && !string.IsNullOrEmpty(btn.CommandArgument)) { int idDatabase = iZyInt.ConvertStringToInt(btn.CommandArgument); BaseDonnee myDatabase = BaseDonneeManager.Load(idDatabase); if (myDatabase != null) { // export + récupération du chemin du fichier string cheminZip = BaseDonneeManager.Sauvegarde(myDatabase, true); if (File.Exists(cheminZip)) { Response.AppendHeader("content-disposition", "attachment; filename=" + Path.GetFileName(cheminZip)); Response.ContentType = "application/zip"; Response.WriteFile(cheminZip); } } } }
protected void btnConfigDatabase_Click(object sender, EventArgs e) { LinkButton btn = (LinkButton)sender; if (btn != null) { BaseDonnee myDatabase = BaseDonneeManager.Load(iZyInt.ConvertStringToInt(btn.CommandArgument)); if (myDatabase != null) { hfDatabseId.Value = btn.CommandArgument; tbEditDatabaseHost.Text = myDatabase.host; tbEditDatabaseName.Text = myDatabase.databaseName; tbEditDatabaseUser.Text = myDatabase.user; tbEditDatabasePassword.Text = myDatabase.password; tbEditDatabaseChemin.Text = myDatabase.cheminSauvegarde; tbEditDatabaseLibelle.Text = myDatabase.libelle; pnlEditDatabase.Visible = true; btnAddDatabase.Enabled = false; } } upDatabase.Update(); }