-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormAddLogManually.cs
More file actions
97 lines (84 loc) · 3.51 KB
/
FormAddLogManually.cs
File metadata and controls
97 lines (84 loc) · 3.51 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CSEmployeeAttendance25.Data;
namespace CSEmployeeAttendance25
{
public partial class FormAddLogManually : Form
{
BiometricLogDBHelper _biometricLogHelper;
private readonly EmployeeDTO employee;
private readonly BiometricLogDTO existingBiometricLog;
public FormAddLogManually(EmployeeDTO employee, BiometricLogDTO existingBiometricLog)
{
InitializeComponent();
_biometricLogHelper = new BiometricLogDBHelper();
this.employee = employee;
this.existingBiometricLog = existingBiometricLog;
// Read existing data
if (employee != null)
{
textBoxEmployeeName.Text = employee.EmployeeName;
textBoxBMEmployeeId.Text = employee.BMEmployeeId.ToString();
textBoxEmployeeCode.Text = employee.EmployeeCode;
}
if (existingBiometricLog != null)
{
textBoxPunchDate.Text = existingBiometricLog.PunchTime.ToString("dd/MM/yyyy hh:mm tt");
labelPunchDateToAdd.Text = existingBiometricLog.PunchTime.ToString("dd/MM/yyyy");
if (textBoxPunchDate.Text.Trim().EndsWith("AM", StringComparison.OrdinalIgnoreCase))
{
dtpPunchTimeToAdd.Value = DateTime.Today.AddHours(18).AddMinutes(0); // 6:00 PM
}
else if (textBoxPunchDate.Text.Trim().EndsWith("PM", StringComparison.OrdinalIgnoreCase))
{
dtpPunchTimeToAdd.Value = DateTime.Today.AddHours(8).AddMinutes(30); // 8:30 AM
}
}
}
private void buttonSave_Click(object sender, EventArgs e)
{
DateTime punchTimeToAdd = new DateTime(
existingBiometricLog.PunchTime.Year,
existingBiometricLog.PunchTime.Month,
existingBiometricLog.PunchTime.Day,
dtpPunchTimeToAdd.Value.Hour,
dtpPunchTimeToAdd.Value.Minute,
0);
// Add record to BiometricLogs | MANL
var manualEntry = new BiometricLogDTO
{
BMEmployeeId = existingBiometricLog.BMEmployeeId,
PunchTime = punchTimeToAdd,
DeviceId = existingBiometricLog.DeviceId,
PunchTypeFlag = existingBiometricLog.PunchTypeFlag, // Admin selects IN or OUT
VerificationMode = existingBiometricLog.VerificationMode, // Manual Entry Code
StatusCode = existingBiometricLog.StatusCode,
CreatedAt = DateTime.UtcNow,
RecordType = "MANL",
BatchCode = existingBiometricLog.BatchCode,
StartDate = existingBiometricLog.StartDate,
EndDate = existingBiometricLog.EndDate,
InOut = existingBiometricLog.InOut,
ManualEntryRemark = textBoxRemark.Text
};
_biometricLogHelper.AddBiometricLog(manualEntry);
this.Close();
}
private void buttonCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void buttonClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}