-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormProject.cs
125 lines (104 loc) · 4.42 KB
/
FormProject.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace PBioManager
{
public partial class FormProject : Form
{
private Guid _IdProject;
public FormProject()
{
InitializeComponent();
_IdProject = Guid.Empty;
}
public FormProject(Guid IdProject)
{
InitializeComponent();
_IdProject = IdProject;
}
private void FormProject_Load(object sender, EventArgs e)
{
// TODO: esta línea de código carga datos en la tabla 'webappDBDataSet.Proyecto' Puede moverla o quitarla según sea necesario.
this.proyectoTableAdapter.Fill(this.webappDBDataSet.Proyecto);
// TODO: esta línea de código carga datos en la tabla 'webappDBDataSet.Carpeta' Puede moverla o quitarla según sea necesario.
this.carpetaTableAdapter.Fill(this.webappDBDataSet.Carpeta);
if (!_IdProject.Equals(Guid.Empty))
{
WebappDBDataSet.ProyectoRow project = this.webappDBDataSet.Proyecto.Where(proj => proj.IdProyecto.Equals(_IdProject)).Single();
txtName.Text = project.Nombre;
if (!project.IsDescripcionNull())
txtDescription.Text = project.Descripcion;
cbxFolder.SelectedValue = project.IdCarpeta;
lblCreationDate.Text = project.FechaCreacionProyecto.ToString();
if (!project.IsFechaLanzUltSimulacionNull())
lblLastExecution.Text = project.FechaLanzUltSimulacion.ToString();
btnDelete.Enabled = true;
btnDelete.Visible = true;
}
}
private void btnSave_Click(object sender, EventArgs e)
{
Save();
this.DialogResult = DialogResult.OK;
this.Close();
}
private void Save()
{
if (txtName.Text != "")
{
if (_IdProject.Equals(Guid.Empty))
{
WebappDBDataSetTableAdapters.ProyectoTableAdapter newProject = new WebappDBDataSetTableAdapters.ProyectoTableAdapter();
_IdProject = Guid.NewGuid();
newProject.Insert(
_IdProject,
txtName.Text,
txtDescription.Text,
null,
DateTime.Now,
(Guid)cbxFolder.SelectedValue
);
}
else
{
WebappDBDataSet.ProyectoRow project = this.webappDBDataSet.Proyecto.Where(proj => proj.IdProyecto.Equals(_IdProject)).Single();
project.Nombre = txtName.Text;
project.Descripcion = txtDescription.Text;
project.IdCarpeta = (Guid)cbxFolder.SelectedValue;
this.proyectoTableAdapter.Update(project);
}
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
DialogResult resp = MessageBox.Show(
"Do you want to delete this project? This operation deletes folders, files, simulations and logs associated to this project.",
"Close",
MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Question
);
if (resp.Equals(DialogResult.Yes))
{
WebappDBDataSet.ProyectoRow project = this.webappDBDataSet.Proyecto.Where(proj => proj.IdProyecto.Equals(_IdProject)).Single();
WebappDBDataSet.CarpetaRow folder = this.webappDBDataSet.Carpeta.Where(fold => fold.IdCarpeta.Equals(project.IdCarpeta)).Single();
// TODO Implementar delete en cascada: Implementado en base de datos directamente.
project.BeginEdit();
project.Delete();
project.EndEdit();
this.proyectoTableAdapter.Update(project);
// On cascade
folder.BeginEdit();
folder.Delete();
folder.EndEdit();
this.carpetaTableAdapter.Update(folder);
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}
}