Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
G10TSI1
Practico1
Commits
61966d53
Commit
61966d53
authored
Apr 02, 2016
by
Fedepa
Browse files
boton que conecta, lanzamiento de excepciones en logica
parent
30ae042a
Pipeline
#183
skipped
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
BusinessLogicLayer/BLEmployees.cs
View file @
61966d53
...
...
@@ -19,7 +19,14 @@ namespace BusinessLogicLayer
public
void
AddEmployee
(
Employee
emp
)
{
_dal
.
AddEmployee
(
emp
);
try
{
_dal
.
AddEmployee
(
emp
);
}
catch
(
Exception
ex
)
{
throw
ex
;
}
}
public
void
DeleteEmployee
(
int
id
)
...
...
DataAccessLayer/DALEmployeesEF.cs
View file @
61966d53
...
...
@@ -9,8 +9,22 @@ namespace DataAccessLayer
{
public
class
DALEmployeesEF
:
IDALEmployees
{
protected
void
controlEmployeeArguments
(
Employee
emp
)
{
var
error
=
""
;
if
(
emp
.
Name
==
null
||
emp
.
Name
.
Trim
()
==
String
.
Empty
)
{
error
+=
"- El nombre no puede ser vacío\n"
;
}
if
(
emp
.
StartDate
==
null
)
error
+=
"- La fecha no puede ser vacía\n"
;
if
(
error
!=
""
)
throw
new
ArgumentNullException
(
error
);
}
public
void
AddEmployee
(
Employee
emp
)
{
controlEmployeeArguments
(
emp
);
using
(
var
context
=
new
Model
.
tsi_pr1Entities
())
{
Model
.
Employee
e
=
this
.
toModel
(
emp
);
...
...
PresentationLayerWinform/EmployeeAddEdit.cs
View file @
61966d53
...
...
@@ -31,25 +31,30 @@ namespace PresentationLayerWinform
private
void
button1_Click
(
object
sender
,
EventArgs
e
)
{
Employee
newemp
=
null
;
if
(
medioT
.
Checked
)
{
newemp
=
new
PartTimeEmployee
();
((
PartTimeEmployee
)
newemp
).
HourlyRate
=
(
double
)
empSal
.
Value
;
}
else
if
(
compT
.
Checked
)
{
newemp
=
new
FullTimeEmployee
();
((
FullTimeEmployee
)
newemp
).
Salary
=
(
int
)
empSal
.
Value
;
try
{
if
(
medioT
.
Checked
)
{
newemp
=
new
PartTimeEmployee
();
((
PartTimeEmployee
)
newemp
).
HourlyRate
=
(
double
)
empSal
.
Value
;
}
else
if
(
compT
.
Checked
)
{
newemp
=
new
FullTimeEmployee
();
((
FullTimeEmployee
)
newemp
).
Salary
=
(
int
)
empSal
.
Value
;
}
if
(
newemp
!=
null
)
{
newemp
.
Name
=
empNom
.
Text
;
newemp
.
StartDate
=
empDate
.
Value
;
IBLEmployees
i
=
new
BLEmployees
(
new
DALEmployeesEF
());
i
.
AddEmployee
(
newemp
);
this
.
Close
();
_e
.
ListEmployees
();
}
}
if
(
newemp
!=
null
)
catch
(
Exception
ex
)
{
newemp
.
Name
=
empNom
.
Text
;
newemp
.
StartDate
=
empDate
.
Value
;
IBLEmployees
i
=
new
BLEmployees
(
new
DALEmployeesEF
());
i
.
AddEmployee
(
newemp
);
this
.
Close
();
_e
.
ListEmployees
();
}
}
private
void
Bback_Click
(
object
sender
,
EventArgs
e
)
...
...
PresentationLayerWinform/EmployeeList.Designer.cs
View file @
61966d53
...
...
@@ -31,6 +31,7 @@
this
.
components
=
new
System
.
ComponentModel
.
Container
();
this
.
dataGridView1
=
new
System
.
Windows
.
Forms
.
DataGridView
();
this
.
employeeBindingSource
=
new
System
.
Windows
.
Forms
.
BindingSource
(
this
.
components
);
this
.
AddEmpBtn
=
new
System
.
Windows
.
Forms
.
Button
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
dataGridView1
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
employeeBindingSource
)).
BeginInit
();
this
.
SuspendLayout
();
...
...
@@ -40,11 +41,12 @@
this
.
dataGridView1
.
AllowUserToAddRows
=
false
;
this
.
dataGridView1
.
AllowUserToDeleteRows
=
false
;
this
.
dataGridView1
.
ColumnHeadersHeightSizeMode
=
System
.
Windows
.
Forms
.
DataGridViewColumnHeadersHeightSizeMode
.
AutoSize
;
this
.
dataGridView1
.
Location
=
new
System
.
Drawing
.
Point
(
26
,
82
);
this
.
dataGridView1
.
Location
=
new
System
.
Drawing
.
Point
(
11
,
30
);
this
.
dataGridView1
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
2
,
2
,
2
,
2
);
this
.
dataGridView1
.
Name
=
"dataGridView1"
;
this
.
dataGridView1
.
ReadOnly
=
true
;
this
.
dataGridView1
.
RowTemplate
.
Height
=
24
;
this
.
dataGridView1
.
Size
=
new
System
.
Drawing
.
Size
(
952
,
2
92
);
this
.
dataGridView1
.
Size
=
new
System
.
Drawing
.
Size
(
714
,
2
37
);
this
.
dataGridView1
.
TabIndex
=
0
;
this
.
dataGridView1
.
CellContentClick
+=
new
System
.
Windows
.
Forms
.
DataGridViewCellEventHandler
(
this
.
dataGridView1_CellContentClick
);
//
...
...
@@ -52,13 +54,23 @@
//
this
.
employeeBindingSource
.
DataSource
=
typeof
(
Shared
.
Entities
.
Employee
);
//
// AddEmpBtn
//
this
.
AddEmpBtn
.
Location
=
new
System
.
Drawing
.
Point
(
428
,
292
);
this
.
AddEmpBtn
.
Name
=
"AddEmpBtn"
;
this
.
AddEmpBtn
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
23
);
this
.
AddEmpBtn
.
TabIndex
=
1
;
this
.
AddEmpBtn
.
Text
=
"Agregar empleado"
;
this
.
AddEmpBtn
.
UseVisualStyleBackColor
=
true
;
this
.
AddEmpBtn
.
Click
+=
new
System
.
EventHandler
(
this
.
AddEmpBtn_Click
);
//
// EmployeeList
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
8
F
,
1
6
F
);
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6
F
,
1
3
F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1021
,
401
);
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
766
,
345
);
this
.
Controls
.
Add
(
this
.
AddEmpBtn
);
this
.
Controls
.
Add
(
this
.
dataGridView1
);
this
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
4
,
4
,
4
,
4
);
this
.
Name
=
"EmployeeList"
;
this
.
Text
=
"EmployeeList"
;
this
.
Load
+=
new
System
.
EventHandler
(
this
.
EmployeeList_Load
);
...
...
@@ -72,6 +84,7 @@
private
System
.
Windows
.
Forms
.
DataGridView
dataGridView1
;
private
System
.
Windows
.
Forms
.
BindingSource
employeeBindingSource
;
private
System
.
Windows
.
Forms
.
Button
AddEmpBtn
;
}
}
PresentationLayerWinform/EmployeeList.cs
View file @
61966d53
...
...
@@ -55,5 +55,15 @@ namespace PresentationLayerWinform
{
}
private
void
AddEmpBtn_Click
(
object
sender
,
EventArgs
e
)
{
var
frm
=
new
EmployeeAddEdit
(
this
);
frm
.
Show
();
frm
.
Location
=
this
.
Location
;
frm
.
StartPosition
=
FormStartPosition
.
Manual
;
frm
.
FormClosing
+=
delegate
{
this
.
Show
();
};
this
.
Hide
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment