Merge branch 'main' of https://github.com/kougyokugentou/GreatHomeChildcare into main
This commit is contained in:
commit
c17a463a05
BIN
GreatHome.db
BIN
GreatHome.db
Binary file not shown.
@ -126,11 +126,18 @@
|
||||
<Compile Include="frmPinEntry.Designer.cs">
|
||||
<DependentUpon>frmPinEntry.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmReports.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmReports.Designer.cs">
|
||||
<DependentUpon>frmReports.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ImageWrangler.cs" />
|
||||
<Compile Include="Models\Attendance.cs" />
|
||||
<Compile Include="Models\Authorized_Guardian.cs" />
|
||||
<Compile Include="Models\Child.cs" />
|
||||
<Compile Include="Models\Guardian.cs" />
|
||||
<Compile Include="Models\Reports.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SnapShotWin.cs">
|
||||
@ -161,6 +168,9 @@
|
||||
<EmbeddedResource Include="frmPinEntry.resx">
|
||||
<DependentUpon>frmPinEntry.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="frmReports.resx">
|
||||
<DependentUpon>frmReports.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
@ -39,5 +39,31 @@ namespace GreatHomeChildcare
|
||||
return Image.FromStream(ms);
|
||||
}
|
||||
}
|
||||
|
||||
/* Nowhere else to put this.
|
||||
* Capitalize the first letter of a given string
|
||||
* then return the string.
|
||||
* Ref: https://www.educative.io/edpresso/how-to-capitalize-the-first-letter-of-a-string-in-c-sharp
|
||||
*/
|
||||
public static string CapitalizeFirstLetter(string str)
|
||||
{
|
||||
if (str.Length <= 0)
|
||||
return null;
|
||||
else if (str.Length == 1)
|
||||
return char.ToUpper(str[0]).ToString();
|
||||
else
|
||||
{
|
||||
string output = string.Empty;
|
||||
output = char.ToUpper(str[0]).ToString();
|
||||
|
||||
int i = 1;
|
||||
for(i=1; i < str.Length; i++)
|
||||
{
|
||||
output += char.ToLower(str[i]).ToString();
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GreatHomeChildcare.Models
|
||||
namespace GreatHomeChildcare.Models
|
||||
{
|
||||
class Attendance
|
||||
{
|
||||
@ -14,4 +8,15 @@ namespace GreatHomeChildcare.Models
|
||||
public string in_out { get; set; }
|
||||
public string timestamp { get; set; }
|
||||
}
|
||||
|
||||
//For the report screen.
|
||||
class AttendenceSingleInOutData
|
||||
{
|
||||
public string ChildFirstName { get; set; }
|
||||
public string ChildLastName { get; set; }
|
||||
public string in_out { get; set; }
|
||||
public string GuardianFirstname { get; set; }
|
||||
public string GuardianLastName { get; set; }
|
||||
public string timestamp { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GreatHomeChildcare.Models
|
||||
namespace GreatHomeChildcare.Models
|
||||
{
|
||||
/* The authorized_guardian class and table acts
|
||||
* as a bridge table in the database to provide
|
||||
|
@ -1,13 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GreatHomeChildcare.Models
|
||||
namespace GreatHomeChildcare.Models
|
||||
{
|
||||
public class Child
|
||||
{
|
||||
private string displayName;
|
||||
|
||||
public int id { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
@ -17,12 +13,28 @@ namespace GreatHomeChildcare.Models
|
||||
public string gender { get; set; }
|
||||
public byte[] photo { get; set; }
|
||||
|
||||
//readonly property to populate the found student searchbox.
|
||||
// this is a "Get" only property
|
||||
/* Ppopulate a single child's full name.
|
||||
* "get" will return Lastname, Fistname if the lastname is not null.
|
||||
* otherwise it will return the variable displayName.
|
||||
* This is so we can insert "Everyone" into the list
|
||||
* of children for the reports form.
|
||||
*/
|
||||
public string DisplayName
|
||||
{
|
||||
get =>
|
||||
$"{LastName}, {FirstName}";
|
||||
get
|
||||
{
|
||||
//This is so we can have "everyone" in the list of
|
||||
//children in the reports form.
|
||||
if (LastName != null)
|
||||
{ return $"{LastName}, {FirstName}"; }
|
||||
else
|
||||
return displayName;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
displayName = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GreatHomeChildcare.Models
|
||||
namespace GreatHomeChildcare.Models
|
||||
{
|
||||
class Guardian
|
||||
public class Guardian
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
@ -15,5 +9,13 @@ namespace GreatHomeChildcare.Models
|
||||
public string EmailAddress { get; set; }
|
||||
public int PinNumber { get; set; }
|
||||
public int isAdmin { get; set; }
|
||||
|
||||
//readonly property to populate a single guardian's full name.
|
||||
// this is a "Get" only property
|
||||
public string DisplayName
|
||||
{
|
||||
get =>
|
||||
$"{LastName}, {FirstName}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
Models/Reports.cs
Normal file
14
Models/Reports.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GreatHomeChildcare.Models
|
||||
{
|
||||
class Reports
|
||||
{
|
||||
public string ChildName { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GreatHomeChildcare
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
|
@ -1,12 +1,9 @@
|
||||
using Dapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.SQLite;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GreatHomeChildcare.Models;
|
||||
|
||||
/* REFERENCES:
|
||||
@ -28,7 +25,7 @@ namespace GreatHomeChildcare
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "INSERT INTO STUDENTS (FirstName, LastName, DOB, address, race, gender, photo)" +
|
||||
string strQuery = "INSERT INTO Children (FirstName, LastName, DOB, address, race, gender, photo)" +
|
||||
"VALUES (@FirstName, @LastName, @DOB, @address, @race, @gender, @photo);";
|
||||
cnn.Execute(strQuery, child);
|
||||
}
|
||||
@ -36,6 +33,21 @@ namespace GreatHomeChildcare
|
||||
|
||||
// ***************** Read *******************
|
||||
|
||||
/* Gets the next available child_id from the sqlite database.
|
||||
* INPUT: void
|
||||
* OUTPUT: integer
|
||||
*/
|
||||
internal int GetNextChildID()
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "SELECT seq FROM sqlite_sequence WHERE name = 'Children';";
|
||||
int output = cnn.Query<int>(strQuery).SingleOrDefault();
|
||||
output++;
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
/* Gets a single child from the sqlite database
|
||||
* provided an id number.
|
||||
* INPUT: integer id
|
||||
@ -79,7 +91,7 @@ namespace GreatHomeChildcare
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "UPDATE Children SET FirstName = @First_Name, LastName = @Last_Name, " +
|
||||
"DOB = @_dob, address = @_address, race = @_race, gender = @_gender, photo = @_photo" +
|
||||
"DOB = @_dob, address = @_address, race = @_race, gender = @_gender, photo = @_photo " +
|
||||
"WHERE id = @_id;";
|
||||
|
||||
cnn.Execute(strQuery, new
|
||||
@ -97,13 +109,83 @@ namespace GreatHomeChildcare
|
||||
}
|
||||
|
||||
// ***************** Delete *****************
|
||||
|
||||
/* Deletes a child from the database.
|
||||
* INPUT: child
|
||||
* OUTPUT: void
|
||||
*/
|
||||
internal void DeleteChild(Child child_in)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "DELETE FROM Children WHERE id = @id;";
|
||||
cnn.Execute(strQuery, child_in);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region guardian
|
||||
// ***************** Create *****************
|
||||
internal void InsertNewGuardian(Guardian guardian_in)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "INSERT INTO Guardians (FirstName, LastName, PhoneNumber, EmailAddress, PinNumber, IsAdmin)" +
|
||||
"VALUES (@FirstName, @LastName, @PhoneNumber, @EmailAddress, @PinNumber, @IsAdmin);";
|
||||
cnn.Execute(strQuery, guardian_in);
|
||||
}
|
||||
}
|
||||
|
||||
// ***************** Read *****************
|
||||
|
||||
/* Gets a list of orphaned guardians
|
||||
* after a child has been deleted.
|
||||
* INPUT: void
|
||||
* OUTPUT: list of guardian objects or null.
|
||||
*/
|
||||
internal List<Guardian> GetOrphanedGuardians()
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string sqlQuery = "SELECT * FROM Guardians " +
|
||||
"LEFT OUTER JOIN Authorized_Guardians " +
|
||||
"ON Guardians.id = Authorized_Guardians.guardian_id " +
|
||||
"WHERE Authorized_Guardians.child_id IS NULL;";
|
||||
|
||||
var output = cnn.Query<Guardian>(sqlQuery);
|
||||
return output.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/* Gets a single guardian from the DB given db id.
|
||||
* INPUT: integer
|
||||
* OUTPUT Guardian object or null
|
||||
*/
|
||||
internal Guardian GetGuardianById(int id_in)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string sqlQuery = "SELECT * FROM Guardians WHERE id=@id;";
|
||||
Guardian output = cnn.Query<Guardian>(sqlQuery, new { id = id_in }).SingleOrDefault();
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
/* Gets all guardians from the DB.
|
||||
* INPUT: void
|
||||
* OUTPUT: list of guardian objects.
|
||||
*/
|
||||
internal List<Guardian> GetAllGuardians()
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "SELECT * FROM Guardians ORDER BY LastName ASC;";
|
||||
var output = cnn.Query<Guardian>(strQuery);
|
||||
return output.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/* Gets all guardians for a single child.
|
||||
* INPUT: Child
|
||||
* OUTPUT: List of guardian object.
|
||||
@ -132,14 +214,64 @@ namespace GreatHomeChildcare
|
||||
}
|
||||
}
|
||||
// ***************** Update *****************
|
||||
internal void UpdateGuardian(Guardian guardian_in)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "UPDATE Guardians SET FirstName = @FirstName, LastName = @LastName, " +
|
||||
"PhoneNumber = @PhoneNumber, EmailAddress = @EmailAddress, PinNumber = @PinNumber, " +
|
||||
"isAdmin = @isAdmin WHERE id=@id";
|
||||
cnn.Execute(strQuery, guardian_in);
|
||||
}
|
||||
}
|
||||
|
||||
// ***************** Delete *****************
|
||||
internal void DeleteGuardian(Guardian guardian_in)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "DELETE FROM Guardians WHERE id = @id;";
|
||||
cnn.Execute(strQuery, guardian_in);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region authorized_guardians
|
||||
// ***************** Create *****************
|
||||
|
||||
/* Add a guardian as an authorized_guardian of a specific child.
|
||||
* INPUT: child, guardian
|
||||
* OUTPUT: void to program, new row in authorized_guardian table of sql db.
|
||||
*/
|
||||
internal void AddNewGuardianToChild(Child child_in, Guardian guardian_in)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "INSERT INTO Authorized_Guardians (child_id, guardian_id) VALUES (@_child_id, @_guardian_id);";
|
||||
cnn.Execute(strQuery, new
|
||||
{
|
||||
_child_id = child_in.id,
|
||||
_guardian_id = guardian_in.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ***************** Read *****************
|
||||
|
||||
/* Check for octomom.
|
||||
* INPUT: Guardian
|
||||
* OUTPUT: integer Count of children per guardian.
|
||||
*/
|
||||
internal int CheckForOctomom(Guardian guardian_in)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "SELECT COUNT(child_id) from Authorized_Guardians WHERE guardian_id = @id;";
|
||||
int output = cnn.Query<int>(strQuery, guardian_in).SingleOrDefault();
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
/* Gets a list of all children per a specific guardian.
|
||||
* INPUT: Guardian
|
||||
* OUTPUT: List of Child object.
|
||||
@ -173,6 +305,16 @@ WHERE Guardians.id = @id
|
||||
}
|
||||
// ***************** Update *****************
|
||||
// ***************** Delete *****************
|
||||
|
||||
internal void RemoveGuardianFromAllChildren(Guardian guardian_in)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "DELETE FROM Authorized_Guardians WHERE guardian_id = @id;";
|
||||
cnn.Execute(strQuery, guardian_in);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region attendance
|
||||
@ -205,6 +347,37 @@ WHERE Guardians.id = @id
|
||||
|
||||
// ***************** Read *****************
|
||||
|
||||
/* Gets the first "in" or last "out" attendence for a child given a date string.
|
||||
* INPUTS: child, "in"/"out", date short string as YYYY-MM-DD%
|
||||
* hardest ef'in query ever, took 2 hours to write/debug wtf was going wrong,
|
||||
* don't put your parameters 'in between', it doesn't work.
|
||||
*/
|
||||
internal AttendenceSingleInOutData GetAttendenceByStatusForChildByDay(Child child_in, string in_out, string shortDateString)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
//Must wildcard for the like operator
|
||||
shortDateString += "%";
|
||||
|
||||
string minMax = in_out == "out" ? "max" : "min";
|
||||
|
||||
string strQuery = "SELECT Children.FirstName as ChildFirstName, Children.LastName as ChildLastName, in_out, " +
|
||||
"Guardians.FirstName as GuardianFirstName, Guardians.LastName as GuardianLastName, timestamp " +
|
||||
"FROM Attendence " +
|
||||
"INNER JOIN Children on Attendence.child_id = Children.id " +
|
||||
"INNER JOIN Guardians on Attendence.guardian_id = Guardians.id " +
|
||||
"WHERE Attendence.id = (SELECT "+minMax+ "(Attendence.id) FROM Attendence WHERE child_id = @_child_id AND in_out = @_in_out AND timestamp LIKE @_timestamp);";
|
||||
|
||||
var output = cnn.Query<AttendenceSingleInOutData>(strQuery, new
|
||||
{
|
||||
_child_id = child_in.id,
|
||||
_in_out = in_out,
|
||||
_timestamp = shortDateString
|
||||
}).SingleOrDefault();
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
/* gets a single child in/out status.
|
||||
* INPUT Child
|
||||
* OUTPUT string "in" or "out", plus the timestamp.
|
||||
@ -223,6 +396,15 @@ WHERE Guardians.id = @id
|
||||
// ***************** Update *****************
|
||||
|
||||
// ***************** Delete *****************
|
||||
internal void DeleteAttendenceForGuardian(Guardian for_guardian)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "DELETE FROM Attendence WHERE guardian_id = @id;";
|
||||
cnn.Execute(strQuery, for_guardian);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region misc
|
||||
@ -230,25 +412,30 @@ WHERE Guardians.id = @id
|
||||
// ***************** Read *******************
|
||||
|
||||
/* Checks to see if this is the first time the application has run.
|
||||
* by counting the number of guardians in the guardian table.
|
||||
* by counting the number of admins in the guardian table.
|
||||
* INPUT: void from program, count of guardians from db.
|
||||
* OUTPUT: boolean true/false.
|
||||
* OUTPUT: integer
|
||||
*/
|
||||
internal bool isFirstTimeRun()
|
||||
internal int GetNumAdmins()
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "SELECT COUNT(*) FROM Guardians";
|
||||
int num_guardians = cnn.Query<int>(strQuery).SingleOrDefault();
|
||||
string strQuery = "SELECT COUNT(*) FROM Guardians WHERE isAdmin = 1";
|
||||
int num_admins = cnn.Query<int>(strQuery).SingleOrDefault();
|
||||
|
||||
if (num_guardians > 0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
return num_admins;
|
||||
}
|
||||
}
|
||||
// ***************** Update *****************
|
||||
// ***************** Delete *****************
|
||||
internal void DeleteAttendenceForChild(Child child_in)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "DELETE FROM Attendence WHERE child_id=@id;";
|
||||
cnn.Execute(strQuery, child_in);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region reports
|
||||
|
@ -36,3 +36,10 @@ CREATE TABLE "Authorized_Guardians" (
|
||||
FOREIGN KEY("child_id") REFERENCES "Children"("id"),
|
||||
FOREIGN KEY("guardian_id") REFERENCES "Guardians"("id")
|
||||
);
|
||||
|
||||
CREATE TRIGGER trgUpdateTimestampToLocal AFTER INSERT ON Attendence
|
||||
BEGIN
|
||||
UPDATE Attendence
|
||||
SET timestamp = datetime(timestamp, 'localtime')
|
||||
WHERE id = new.id;
|
||||
END;
|
||||
|
@ -1,6 +1,6 @@
|
||||
INSERT INTO Children(FirstName,LastName,DOB,address,race,gender) VALUES ('Joe','Smith','1/13/2021 4:56:33 PM','123 Fake Street','White','Male');
|
||||
INSERT INTO Children(FirstName,LastName,DOB,address,race,gender) VALUES ('Mary','Smith','1/13/2021 4:56:33 PM','123 Fake Street','White','Female');
|
||||
INSERT INTO Children(FirstName,LastName,DOB,address,race,gender) VALUES ('Katie','Admin','1/13/2021 4:56:33 PM','123 Fake Street','White','Male');
|
||||
INSERT INTO Children(FirstName,LastName,DOB,address,race,gender) VALUES ('Joe','Smith','1/13/2021','123 Fake Street','White','Male');
|
||||
INSERT INTO Children(FirstName,LastName,DOB,address,race,gender) VALUES ('Mary','Smith','1/13/2021','123 Fake Street','White','Female');
|
||||
INSERT INTO Children(FirstName,LastName,DOB,address,race,gender) VALUES ('Katie','Admin','1/13/2021','123 Fake Street','White','Female');
|
||||
|
||||
INSERT INTO Guardians(FirstName,LastName,PhoneNumber,EmailAddress,PinNumber,isAdmin) VALUES ('Main','Admin',1000000001,'main@admin.com','9999',1);
|
||||
INSERT INTO Guardians(FirstName,LastName,PhoneNumber,EmailAddress,PinNumber) VALUES ('Parent','Smith',1000000001,'parent@smith.com','1234');
|
||||
@ -12,5 +12,5 @@ INSERT INTO Authorized_Guardians(child_id, guardian_id) VALUES (2,2);
|
||||
INSERT INTO Authorized_Guardians(child_id, guardian_id) VALUES (3,1);
|
||||
|
||||
INSERT INTO Attendence(child_id, guardian_id,in_out) VALUES (1,2,"in");
|
||||
INSERT INTO Attendence(child_id, guardian_id,in_out) VALUES (2,2,"out");
|
||||
INSERT INTO Attendence(child_id, guardian_id,in_out) VALUES (3,1,"out");
|
||||
INSERT INTO Attendence(child_id, guardian_id,in_out) VALUES (2,2,"in");
|
||||
INSERT INTO Attendence(child_id, guardian_id,in_out) VALUES (3,1,"in");
|
||||
|
6
docs/GetInOutByDate.sql
Normal file
6
docs/GetInOutByDate.sql
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
-- WORKY
|
||||
SELECT Children.FirstName as ChildFirstName, Children.LastName as ChildLastName, in_out, Guardians.FirstName as GuardianFirstName, Guardians.LastName as GuardianLastName, timestamp FROM Attendence INNER JOIN Children on Attendence.child_id = Children.id INNER JOIN Guardians on Attendence.guardian_id = Guardians.id WHERE Attendence.id = (SELECT min(Attendence.id) FROM Attendence WHERE child_id = 3 AND in_out = 'in' AND timestamp LIKE '2021-02-03%');
|
||||
|
||||
-- NO WORKY, you need to remove '' around the parameters.
|
||||
SELECT Children.FirstName as ChildFirstName, Children.LastName as ChildLastName, in_out, Guardians.FirstName as GuardianFirstName, Guardians.LastName as GuardianLastName, timestamp FROM Attendence INNER JOIN Children on Attendence.child_id = Children.id INNER JOIN Guardians on Attendence.guardian_id = Guardians.id WHERE Attendence.id = (SELECT min(Attendence.id) FROM Attendence WHERE child_id = @_child_id AND in_out = '@_in_out' AND timestamp LIKE '@_timestamp');
|
@ -1,11 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using GreatHomeChildcare.Models;
|
||||
|
||||
@ -60,13 +55,23 @@ namespace GreatHomeChildcare
|
||||
Close();
|
||||
}
|
||||
|
||||
//TODO: new form to generate reports
|
||||
/* VS generated delegate to handle report button clicking
|
||||
* Pops up the report form and hides this one.
|
||||
*/
|
||||
private void btnReports_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Reports button clicked.");
|
||||
Form frmRep = new frmReports();
|
||||
|
||||
//We can use the same event handler here, don't mind the name.
|
||||
frmRep.FormClosed += new FormClosedEventHandler(CrudFormClosed);
|
||||
frmRep.Show();
|
||||
Hide();
|
||||
}
|
||||
|
||||
//TODO: new form to add a new child and their guardian(s)
|
||||
/* Pop-open a new form for crud operations for children
|
||||
* and their guardians. Be sure you set the child_id
|
||||
* to -1 here just to be on the super-safe side.
|
||||
*/
|
||||
private void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
child_id = -1; //ENSURE!!!!
|
||||
@ -74,8 +79,10 @@ namespace GreatHomeChildcare
|
||||
ShowChildCrudForm();
|
||||
}
|
||||
|
||||
//TODO: new form(or same form as adding) for updating children
|
||||
//PB&J: get currently selected row from dgv, then pass to GetChildByID() to get Child object.
|
||||
/* Call the same crud form for adding a new child
|
||||
* but store the child_id so the crud form
|
||||
* can pick it up on form load.
|
||||
*/
|
||||
private void btnUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
/* Get the child's database ID which is secretly hidden
|
||||
@ -86,7 +93,13 @@ namespace GreatHomeChildcare
|
||||
|
||||
ShowChildCrudForm();
|
||||
}
|
||||
|
||||
|
||||
/* Seperate function to show the crud form
|
||||
* because both the add and the update buttons
|
||||
* will show the same crud form.
|
||||
* INPUT: void
|
||||
* OUTPUT: void
|
||||
*/
|
||||
private void ShowChildCrudForm()
|
||||
{
|
||||
Form frmCrud = new frmChildCrud();
|
||||
@ -102,9 +115,14 @@ namespace GreatHomeChildcare
|
||||
Show();
|
||||
}
|
||||
|
||||
/* Allow the admin to quit the program as a normal login
|
||||
* will not be able to exit the attendence program
|
||||
* from the main pin screen on the shared tablet.
|
||||
*/
|
||||
private void btnQuit_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Thank you for using the program! Your data has been saved. Good bye!", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
//TODO: I got the program to crash here by exiting from reports form then clicking quit??
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
|
140
frmChildCrud.Designer.cs
generated
140
frmChildCrud.Designer.cs
generated
@ -46,11 +46,12 @@
|
||||
this.lblGuardians = new System.Windows.Forms.Label();
|
||||
this.dgvGuardians = new System.Windows.Forms.DataGridView();
|
||||
this.id = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.isAdmin = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.LastName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.FirstName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.PhoneNumber = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.EmailAddress = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.btnAddGuardian = new System.Windows.Forms.Button();
|
||||
this.btnAddExistingGuardian = new System.Windows.Forms.Button();
|
||||
this.btnEditGuardian = new System.Windows.Forms.Button();
|
||||
this.btnDeleteGuardian = new System.Windows.Forms.Button();
|
||||
this.btnPhotoFromCam = new System.Windows.Forms.Button();
|
||||
@ -60,9 +61,13 @@
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.idNumericUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.dOBMonthCalendar = new System.Windows.Forms.MonthCalendar();
|
||||
this.childBindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||
this.pic_openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components);
|
||||
this.lblExistingGuardians = new System.Windows.Forms.Label();
|
||||
this.cbExistingGuardians = new System.Windows.Forms.ComboBox();
|
||||
this.btnNewGuardian = new System.Windows.Forms.Button();
|
||||
this.btnDelete = new System.Windows.Forms.Button();
|
||||
this.childBindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||
firstNameLabel = new System.Windows.Forms.Label();
|
||||
lastNameLabel = new System.Windows.Forms.Label();
|
||||
raceLabel = new System.Windows.Forms.Label();
|
||||
@ -73,8 +78,8 @@
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvGuardians)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.photoPictureBox)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.idNumericUpDown)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.childBindingSource)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.childBindingSource)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// firstNameLabel
|
||||
@ -146,6 +151,7 @@
|
||||
this.imageList1.Images.SetKeyName(5, "Edit_16x.png");
|
||||
this.imageList1.Images.SetKeyName(6, "SaveClose_16x.png");
|
||||
this.imageList1.Images.SetKeyName(7, "OpenfileDialog_16x.png");
|
||||
this.imageList1.Images.SetKeyName(8, "Add_16x.png");
|
||||
//
|
||||
// dOBLabel
|
||||
//
|
||||
@ -163,6 +169,7 @@
|
||||
this.firstNameTextBox.Name = "firstNameTextBox";
|
||||
this.firstNameTextBox.Size = new System.Drawing.Size(100, 22);
|
||||
this.firstNameTextBox.TabIndex = 2;
|
||||
this.firstNameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating);
|
||||
//
|
||||
// lastNameTextBox
|
||||
//
|
||||
@ -171,6 +178,7 @@
|
||||
this.lastNameTextBox.Name = "lastNameTextBox";
|
||||
this.lastNameTextBox.Size = new System.Drawing.Size(100, 22);
|
||||
this.lastNameTextBox.TabIndex = 4;
|
||||
this.lastNameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating);
|
||||
//
|
||||
// raceTextBox
|
||||
//
|
||||
@ -179,15 +187,18 @@
|
||||
this.raceTextBox.Name = "raceTextBox";
|
||||
this.raceTextBox.Size = new System.Drawing.Size(100, 22);
|
||||
this.raceTextBox.TabIndex = 6;
|
||||
this.raceTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating);
|
||||
//
|
||||
// genderComboBox
|
||||
//
|
||||
this.genderComboBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.childBindingSource, "gender", true));
|
||||
this.genderComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.genderComboBox.FormattingEnabled = true;
|
||||
this.genderComboBox.Location = new System.Drawing.Point(174, 107);
|
||||
this.genderComboBox.Name = "genderComboBox";
|
||||
this.genderComboBox.Size = new System.Drawing.Size(121, 24);
|
||||
this.genderComboBox.TabIndex = 8;
|
||||
this.genderComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.genderComboBox_Validating);
|
||||
//
|
||||
// addressTextBox
|
||||
//
|
||||
@ -197,6 +208,7 @@
|
||||
this.addressTextBox.Name = "addressTextBox";
|
||||
this.addressTextBox.Size = new System.Drawing.Size(283, 79);
|
||||
this.addressTextBox.TabIndex = 10;
|
||||
this.addressTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating);
|
||||
//
|
||||
// lblGuardians
|
||||
//
|
||||
@ -214,6 +226,7 @@
|
||||
this.dgvGuardians.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dgvGuardians.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.id,
|
||||
this.isAdmin,
|
||||
this.LastName,
|
||||
this.FirstName,
|
||||
this.PhoneNumber,
|
||||
@ -235,6 +248,15 @@
|
||||
this.id.Visible = false;
|
||||
this.id.Width = 125;
|
||||
//
|
||||
// isAdmin
|
||||
//
|
||||
this.isAdmin.HeaderText = "isAdmin";
|
||||
this.isAdmin.MinimumWidth = 6;
|
||||
this.isAdmin.Name = "isAdmin";
|
||||
this.isAdmin.ReadOnly = true;
|
||||
this.isAdmin.Visible = false;
|
||||
this.isAdmin.Width = 125;
|
||||
//
|
||||
// LastName
|
||||
//
|
||||
this.LastName.HeaderText = "LastName";
|
||||
@ -267,29 +289,29 @@
|
||||
this.EmailAddress.ReadOnly = true;
|
||||
this.EmailAddress.Width = 125;
|
||||
//
|
||||
// btnAddGuardian
|
||||
// btnAddExistingGuardian
|
||||
//
|
||||
this.btnAddGuardian.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.btnAddGuardian.ImageKey = "AddButton_16x.png";
|
||||
this.btnAddGuardian.ImageList = this.imageList1;
|
||||
this.btnAddGuardian.Location = new System.Drawing.Point(18, 439);
|
||||
this.btnAddGuardian.Name = "btnAddGuardian";
|
||||
this.btnAddGuardian.Size = new System.Drawing.Size(168, 26);
|
||||
this.btnAddGuardian.TabIndex = 13;
|
||||
this.btnAddGuardian.Text = "Add Guardian";
|
||||
this.btnAddGuardian.UseVisualStyleBackColor = true;
|
||||
this.btnAddGuardian.Click += new System.EventHandler(this.btnAddGuardian_Click);
|
||||
this.btnAddExistingGuardian.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.btnAddExistingGuardian.ImageKey = "AddButton_16x.png";
|
||||
this.btnAddExistingGuardian.ImageList = this.imageList1;
|
||||
this.btnAddExistingGuardian.Location = new System.Drawing.Point(206, 441);
|
||||
this.btnAddExistingGuardian.Name = "btnAddExistingGuardian";
|
||||
this.btnAddExistingGuardian.Size = new System.Drawing.Size(241, 75);
|
||||
this.btnAddExistingGuardian.TabIndex = 13;
|
||||
this.btnAddExistingGuardian.Text = "Add Chosen Existing\r\nGuardian (from Dropdown)\r\nto Child";
|
||||
this.btnAddExistingGuardian.UseVisualStyleBackColor = true;
|
||||
this.btnAddExistingGuardian.Click += new System.EventHandler(this.btnAddExistingGuardian_Click);
|
||||
//
|
||||
// btnEditGuardian
|
||||
//
|
||||
this.btnEditGuardian.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.btnEditGuardian.ImageIndex = 5;
|
||||
this.btnEditGuardian.ImageList = this.imageList1;
|
||||
this.btnEditGuardian.Location = new System.Drawing.Point(305, 439);
|
||||
this.btnEditGuardian.Location = new System.Drawing.Point(756, 438);
|
||||
this.btnEditGuardian.Name = "btnEditGuardian";
|
||||
this.btnEditGuardian.Size = new System.Drawing.Size(185, 26);
|
||||
this.btnEditGuardian.Size = new System.Drawing.Size(225, 34);
|
||||
this.btnEditGuardian.TabIndex = 14;
|
||||
this.btnEditGuardian.Text = "Edit Guardian";
|
||||
this.btnEditGuardian.Text = "Edit Selected Guardian";
|
||||
this.btnEditGuardian.UseVisualStyleBackColor = true;
|
||||
this.btnEditGuardian.Click += new System.EventHandler(this.btnEditGuardian_Click);
|
||||
//
|
||||
@ -298,11 +320,11 @@
|
||||
this.btnDeleteGuardian.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.btnDeleteGuardian.ImageIndex = 4;
|
||||
this.btnDeleteGuardian.ImageList = this.imageList1;
|
||||
this.btnDeleteGuardian.Location = new System.Drawing.Point(634, 439);
|
||||
this.btnDeleteGuardian.Location = new System.Drawing.Point(756, 478);
|
||||
this.btnDeleteGuardian.Name = "btnDeleteGuardian";
|
||||
this.btnDeleteGuardian.Size = new System.Drawing.Size(175, 26);
|
||||
this.btnDeleteGuardian.Size = new System.Drawing.Size(225, 38);
|
||||
this.btnDeleteGuardian.TabIndex = 15;
|
||||
this.btnDeleteGuardian.Text = "Delete Guardian";
|
||||
this.btnDeleteGuardian.Text = "Delete Selected Guardian";
|
||||
this.btnDeleteGuardian.UseVisualStyleBackColor = true;
|
||||
this.btnDeleteGuardian.Click += new System.EventHandler(this.btnDeleteGuardian_Click);
|
||||
//
|
||||
@ -371,7 +393,7 @@
|
||||
// idNumericUpDown
|
||||
//
|
||||
this.idNumericUpDown.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.childBindingSource, "id", true));
|
||||
this.idNumericUpDown.Location = new System.Drawing.Point(905, 125);
|
||||
this.idNumericUpDown.Location = new System.Drawing.Point(905, 202);
|
||||
this.idNumericUpDown.Name = "idNumericUpDown";
|
||||
this.idNumericUpDown.ReadOnly = true;
|
||||
this.idNumericUpDown.Size = new System.Drawing.Size(76, 22);
|
||||
@ -386,10 +408,7 @@
|
||||
this.dOBMonthCalendar.MaxSelectionCount = 1;
|
||||
this.dOBMonthCalendar.Name = "dOBMonthCalendar";
|
||||
this.dOBMonthCalendar.TabIndex = 25;
|
||||
//
|
||||
// childBindingSource
|
||||
//
|
||||
this.childBindingSource.DataSource = typeof(GreatHomeChildcare.Models.Child);
|
||||
this.dOBMonthCalendar.Validating += new System.ComponentModel.CancelEventHandler(this.dOBMonthCalendar_Validating);
|
||||
//
|
||||
// pic_openFileDialog
|
||||
//
|
||||
@ -403,11 +422,63 @@
|
||||
//
|
||||
this.errorProvider1.ContainerControl = this;
|
||||
//
|
||||
// lblExistingGuardians
|
||||
//
|
||||
this.lblExistingGuardians.AutoSize = true;
|
||||
this.lblExistingGuardians.Location = new System.Drawing.Point(12, 441);
|
||||
this.lblExistingGuardians.Name = "lblExistingGuardians";
|
||||
this.lblExistingGuardians.Size = new System.Drawing.Size(130, 17);
|
||||
this.lblExistingGuardians.TabIndex = 27;
|
||||
this.lblExistingGuardians.Text = "Existing Guardians:";
|
||||
//
|
||||
// cbExistingGuardians
|
||||
//
|
||||
this.cbExistingGuardians.FormattingEnabled = true;
|
||||
this.cbExistingGuardians.Location = new System.Drawing.Point(12, 464);
|
||||
this.cbExistingGuardians.Name = "cbExistingGuardians";
|
||||
this.cbExistingGuardians.Size = new System.Drawing.Size(171, 24);
|
||||
this.cbExistingGuardians.TabIndex = 26;
|
||||
this.cbExistingGuardians.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.cbExistingGuardians_KeyPress);
|
||||
//
|
||||
// btnNewGuardian
|
||||
//
|
||||
this.btnNewGuardian.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.btnNewGuardian.ImageIndex = 8;
|
||||
this.btnNewGuardian.ImageList = this.imageList1;
|
||||
this.btnNewGuardian.Location = new System.Drawing.Point(540, 442);
|
||||
this.btnNewGuardian.Name = "btnNewGuardian";
|
||||
this.btnNewGuardian.Size = new System.Drawing.Size(195, 66);
|
||||
this.btnNewGuardian.TabIndex = 28;
|
||||
this.btnNewGuardian.Text = "Create New Guardian\r\n&& Add to Child";
|
||||
this.btnNewGuardian.UseVisualStyleBackColor = true;
|
||||
this.btnNewGuardian.Click += new System.EventHandler(this.btnNewGuardian_Click);
|
||||
//
|
||||
// btnDelete
|
||||
//
|
||||
this.btnDelete.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.btnDelete.ImageIndex = 4;
|
||||
this.btnDelete.ImageList = this.imageList1;
|
||||
this.btnDelete.Location = new System.Drawing.Point(834, 143);
|
||||
this.btnDelete.Name = "btnDelete";
|
||||
this.btnDelete.Size = new System.Drawing.Size(159, 37);
|
||||
this.btnDelete.TabIndex = 29;
|
||||
this.btnDelete.Text = "DELETE CHILD";
|
||||
this.btnDelete.UseVisualStyleBackColor = true;
|
||||
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
|
||||
//
|
||||
// childBindingSource
|
||||
//
|
||||
this.childBindingSource.DataSource = typeof(GreatHomeChildcare.Models.Child);
|
||||
//
|
||||
// frmChildCrud
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1004, 608);
|
||||
this.ClientSize = new System.Drawing.Size(1004, 657);
|
||||
this.Controls.Add(this.btnDelete);
|
||||
this.Controls.Add(this.btnNewGuardian);
|
||||
this.Controls.Add(this.lblExistingGuardians);
|
||||
this.Controls.Add(this.cbExistingGuardians);
|
||||
this.Controls.Add(dOBLabel);
|
||||
this.Controls.Add(this.dOBMonthCalendar);
|
||||
this.Controls.Add(this.idNumericUpDown);
|
||||
@ -419,7 +490,7 @@
|
||||
this.Controls.Add(this.btnPhotoFromCam);
|
||||
this.Controls.Add(this.btnDeleteGuardian);
|
||||
this.Controls.Add(this.btnEditGuardian);
|
||||
this.Controls.Add(this.btnAddGuardian);
|
||||
this.Controls.Add(this.btnAddExistingGuardian);
|
||||
this.Controls.Add(this.dgvGuardians);
|
||||
this.Controls.Add(this.lblGuardians);
|
||||
this.Controls.Add(addressLabel);
|
||||
@ -439,8 +510,8 @@
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvGuardians)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.photoPictureBox)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.idNumericUpDown)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.childBindingSource)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.childBindingSource)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -456,7 +527,7 @@
|
||||
private System.Windows.Forms.TextBox addressTextBox;
|
||||
private System.Windows.Forms.Label lblGuardians;
|
||||
private System.Windows.Forms.DataGridView dgvGuardians;
|
||||
private System.Windows.Forms.Button btnAddGuardian;
|
||||
private System.Windows.Forms.Button btnAddExistingGuardian;
|
||||
private System.Windows.Forms.Button btnEditGuardian;
|
||||
private System.Windows.Forms.Button btnDeleteGuardian;
|
||||
private System.Windows.Forms.Button btnPhotoFromCam;
|
||||
@ -466,13 +537,18 @@
|
||||
private System.Windows.Forms.PictureBox photoPictureBox;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.NumericUpDown idNumericUpDown;
|
||||
private System.Windows.Forms.MonthCalendar dOBMonthCalendar;
|
||||
private System.Windows.Forms.OpenFileDialog pic_openFileDialog;
|
||||
private System.Windows.Forms.ErrorProvider errorProvider1;
|
||||
private System.Windows.Forms.Label lblExistingGuardians;
|
||||
private System.Windows.Forms.ComboBox cbExistingGuardians;
|
||||
private System.Windows.Forms.Button btnNewGuardian;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn id;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn isAdmin;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn LastName;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn FirstName;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn PhoneNumber;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn EmailAddress;
|
||||
private System.Windows.Forms.MonthCalendar dOBMonthCalendar;
|
||||
private System.Windows.Forms.OpenFileDialog pic_openFileDialog;
|
||||
private System.Windows.Forms.ErrorProvider errorProvider1;
|
||||
private System.Windows.Forms.Button btnDelete;
|
||||
}
|
||||
}
|
450
frmChildCrud.cs
450
frmChildCrud.cs
@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using GreatHomeChildcare.Models;
|
||||
|
||||
@ -20,7 +17,8 @@ namespace GreatHomeChildcare
|
||||
|
||||
//Global instance of the SqliteDataAccess object.
|
||||
SqliteDataAccess SqliteDataAccess = new SqliteDataAccess();
|
||||
Child child;
|
||||
Child child = new Child();
|
||||
public static int guardian_id;
|
||||
|
||||
enum Gender
|
||||
{
|
||||
@ -41,7 +39,10 @@ namespace GreatHomeChildcare
|
||||
*/
|
||||
private void frmChildCrud_Load(object sender, EventArgs e)
|
||||
{
|
||||
photoPictureBox.Tag = DEFAULT_PIC_TAG;
|
||||
|
||||
FillGenderComboBox();
|
||||
FillGuardiansComboBox();
|
||||
|
||||
int child_id = frmAdminForm.child_id;
|
||||
|
||||
@ -52,12 +53,36 @@ namespace GreatHomeChildcare
|
||||
}
|
||||
}
|
||||
|
||||
//Populate the gender combo box with our enum.
|
||||
private void FillGenderComboBox()
|
||||
{
|
||||
genderComboBox.Items.Add(Gender.Female);
|
||||
genderComboBox.Items.Add(Gender.Male);
|
||||
}
|
||||
|
||||
/* Populate the existing guardian combobox
|
||||
* with a listing of all guardians in the DB
|
||||
* sorted by last name. Bind the guardian object
|
||||
* to the drop-down so it can be easily referenced upon click
|
||||
* of "add existing guardian".
|
||||
* INPUTS: void from program
|
||||
* OUTPUT: list of guardians from SQL db
|
||||
*/
|
||||
private void FillGuardiansComboBox()
|
||||
{
|
||||
List<Guardian> guardians = new List<Guardian>();
|
||||
guardians = SqliteDataAccess.GetAllGuardians();
|
||||
|
||||
cbExistingGuardians.DataSource = null;
|
||||
|
||||
//TODO: check if needed.
|
||||
//cbExistingGuardians.Items.Clear();
|
||||
|
||||
cbExistingGuardians.DataSource = guardians;
|
||||
cbExistingGuardians.DisplayMember = "DisplayName";
|
||||
cbExistingGuardians.Text = "Choose a guardian to add to this child";
|
||||
}
|
||||
|
||||
/* Load an existing child onto the form for update/delete operations.
|
||||
* INPUT: integer child_id
|
||||
* OUTPUT: data to screen
|
||||
@ -76,7 +101,7 @@ namespace GreatHomeChildcare
|
||||
firstNameTextBox.Text = child.FirstName;
|
||||
lastNameTextBox.Text = child.LastName;
|
||||
raceTextBox.Text = child.race;
|
||||
|
||||
|
||||
//Load the gender combo box based from enum value.
|
||||
//ref: chuck costarella
|
||||
Enum.TryParse<Gender>(child.gender, out genderOut);
|
||||
@ -84,10 +109,27 @@ namespace GreatHomeChildcare
|
||||
|
||||
dOBMonthCalendar.SelectionStart = DateTime.Parse(child.DOB);
|
||||
addressTextBox.Text = child.address;
|
||||
photoPictureBox.Image = (child.photo != null) ? ImageWrangler.ByteArrayToImage(child.photo) : Properties.Resources.child;
|
||||
|
||||
//Load the child photo, if any.
|
||||
if (child.photo != null)
|
||||
{
|
||||
photoPictureBox.Image = ImageWrangler.ByteArrayToImage(child.photo);
|
||||
photoPictureBox.Tag = CUSTOM_PIC_TAG;
|
||||
}
|
||||
else
|
||||
{
|
||||
photoPictureBox.Image = Properties.Resources.child;
|
||||
photoPictureBox.Tag = DEFAULT_PIC_TAG;
|
||||
}
|
||||
|
||||
LoadGuardiansForChild(child);
|
||||
}
|
||||
|
||||
/* Loads all guardians for a single child
|
||||
* and populates them in the datagridview.
|
||||
* INPUT: child
|
||||
* OUTPUT: list of guardians to datagridview.
|
||||
*/
|
||||
private void LoadGuardiansForChild(Child child_in)
|
||||
{
|
||||
dgvGuardians.Rows.Clear();
|
||||
@ -96,12 +138,31 @@ namespace GreatHomeChildcare
|
||||
|
||||
foreach (Guardian g in guardians)
|
||||
{
|
||||
dgvGuardians.Rows.Add(g.id, g.LastName, g.FirstName, g.PhoneNumber, g.EmailAddress);
|
||||
dgvGuardians.Rows.Add(g.id, g.isAdmin, g.LastName, g.FirstName, g.PhoneNumber, g.EmailAddress);
|
||||
}
|
||||
}
|
||||
|
||||
// Close the form without saving changes to the child.
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Ensure an existing child has at least one guardian.
|
||||
if (idNumericUpDown.Value != 0 && dgvGuardians.Rows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("The child has no guardians assigned. Please fix that and try again.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If it's a new child and has one guardian already assigned, don't allow cancelling.
|
||||
* This is a sloppy-ass hack as popping the new guardian form on 'save and close' a new child
|
||||
* does not correctly work; and the program saves the child before attaching a new guardian
|
||||
* any god damn ways.... so fuck you. HOURS_WASTED_ON_TRYING_TO_FIX_IT = 10;
|
||||
*/
|
||||
if (idNumericUpDown.Value == 0 && dgvGuardians.Rows.Count >= 1)
|
||||
{
|
||||
MessageBox.Show("You have already assigned this new child a guardian. Please choose save and close instead.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
@ -110,6 +171,11 @@ namespace GreatHomeChildcare
|
||||
{
|
||||
|
||||
MessageBox.Show("From cam");
|
||||
return;
|
||||
|
||||
//TED: Be sure you set this somewhere along the way
|
||||
//after you wrangle the damn camera.
|
||||
photoPictureBox.Tag = CUSTOM_PIC_TAG;
|
||||
}
|
||||
|
||||
/* On click of the button, open a file picker dialog box
|
||||
@ -152,54 +218,278 @@ namespace GreatHomeChildcare
|
||||
}
|
||||
}
|
||||
|
||||
private void btnAddGuardian_Click(object sender, EventArgs e)
|
||||
/* Adds an existing guardian to the child, if that guardian is not already assigned
|
||||
* to the child. The existing guardians are in the drop down list immediately
|
||||
* to the right of the button. First choose one, then click this button.
|
||||
* INPUTS: Guardian from the dropdown list
|
||||
* OUTPUTS: Updated list of authorized guardians for the child.
|
||||
*/
|
||||
private void btnAddExistingGuardian_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Add guardian");
|
||||
//Perform sanity check, ensure all data is filled except picture
|
||||
this.Validate();
|
||||
this.ValidateChildren();
|
||||
|
||||
int iOctomomCheck;
|
||||
|
||||
//If the user did not select a guardian from the drop-down list.
|
||||
if(cbExistingGuardians.Text == "Choose a guardian to add to this child")
|
||||
{
|
||||
MessageBox.Show("Please select an existing guardian.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
|
||||
//The combobox is bound to a list of guardians, so we can just grab
|
||||
// the individual guardian object.
|
||||
Guardian newGuardian = (Guardian)cbExistingGuardians.SelectedItem;
|
||||
|
||||
//Check to see if newGuardian is already a guardian of this child.
|
||||
foreach(DataGridViewRow row in dgvGuardians.Rows)
|
||||
{
|
||||
if((int)row.Cells[0].Value == newGuardian.id)
|
||||
{
|
||||
MessageBox.Show("That guardian is already assigned to this child.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for octomom.
|
||||
iOctomomCheck = SqliteDataAccess.CheckForOctomom(newGuardian);
|
||||
if(iOctomomCheck > 9) // SERIOUSLY, KEEP IT IN YOUR PANTS
|
||||
{
|
||||
MessageBox.Show("Sorry, a single guardian can't have more than 9 children.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
|
||||
// We are clear to add this guardian.
|
||||
SqliteDataAccess.AddNewGuardianToChild(child, newGuardian);
|
||||
LoadGuardiansForChild(child);
|
||||
}
|
||||
|
||||
/* Open a new form to create new guardians.
|
||||
* INPUTS: none
|
||||
* OUTPUTS: none
|
||||
*/
|
||||
private void btnNewGuardian_Click(object sender, EventArgs e)
|
||||
{
|
||||
//Perform sanity check, ensure all data is filled except picture
|
||||
this.Validate();
|
||||
this.ValidateChildren();
|
||||
|
||||
guardian_id = -1; //ENSURE!!!!
|
||||
|
||||
ShowGuardianCrudForm();
|
||||
}
|
||||
|
||||
/* Open a new form to update new guardians.
|
||||
* INPUTS: none
|
||||
* OUTPUTS: none
|
||||
*/
|
||||
private void btnEditGuardian_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Edit Guardian");
|
||||
/* Get the guardian's database ID which is secretly hidden
|
||||
* in the datagrid view at column 0. Since value is an
|
||||
* Object, cast it to Int because that's what we know it is.
|
||||
*/
|
||||
guardian_id = (int)dgvGuardians.CurrentRow.Cells[0].Value;
|
||||
|
||||
ShowGuardianCrudForm();
|
||||
}
|
||||
|
||||
/* Single function to show guardian crud form
|
||||
* as both the 'new' and the 'update' buttons need it,
|
||||
* the only difference is passing guardian_id.
|
||||
*/
|
||||
private void ShowGuardianCrudForm()
|
||||
{
|
||||
Form frmGCrud = new frmGuardianCrud();
|
||||
frmGCrud.FormClosed += new FormClosedEventHandler(GCrudFormClosed);
|
||||
frmGCrud.Show();
|
||||
Hide();
|
||||
}
|
||||
|
||||
//Show this admin screen after the child crud form is closed.
|
||||
private void GCrudFormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
//This TOTALLY works!!!
|
||||
Guardian gFromGCrudForm = new Guardian();
|
||||
gFromGCrudForm = frmGuardianCrud.guardian;
|
||||
int next_child_id = 0;
|
||||
|
||||
//We added a new guardian.
|
||||
//TODO: TEST
|
||||
if(gFromGCrudForm.id == 0)
|
||||
{
|
||||
Guardian gToAddToChild = new Guardian();
|
||||
gToAddToChild = SqliteDataAccess.GetGuardianByPin(gFromGCrudForm.PinNumber);
|
||||
|
||||
//If this is a new child, get the next available child ID.
|
||||
if(idNumericUpDown.Value <= 0)
|
||||
{
|
||||
next_child_id = SqliteDataAccess.GetNextChildID();
|
||||
child.id = next_child_id;
|
||||
}
|
||||
SqliteDataAccess.AddNewGuardianToChild(child, gToAddToChild);
|
||||
}
|
||||
|
||||
FillGuardiansComboBox();
|
||||
LoadGuardiansForChild(child);
|
||||
Show();
|
||||
}
|
||||
|
||||
/* Code to see if we are removing the last
|
||||
* admin guardian from the program
|
||||
* INPUT: void
|
||||
* OUTPUT: bool t/f
|
||||
*/
|
||||
private bool CheckIfLastAdmin()
|
||||
{
|
||||
int count_admins = 0;
|
||||
|
||||
count_admins = SqliteDataAccess.GetNumAdmins();
|
||||
count_admins--;
|
||||
|
||||
if (count_admins <= 0)
|
||||
{ return true; }
|
||||
else
|
||||
{ return false; }
|
||||
}
|
||||
/* Irrevocably deletes a guardian and all attendence data
|
||||
* for that guardian out of the database.
|
||||
* INPUT: guardian
|
||||
* OUTPUT: void
|
||||
*/
|
||||
//TODO: Check to see if we orphan a child by removing the guardian from all children.
|
||||
//We may not need to do this provided the above save sanity check.
|
||||
private void btnDeleteGuardian_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Delete Guardian");
|
||||
/* Get the guardian's "isAdmin" value so we can check
|
||||
* to see if we are going to delete the last admin in the db.
|
||||
*/
|
||||
int isAdmin = (int)dgvGuardians.CurrentRow.Cells[1].Value;
|
||||
|
||||
if(isAdmin == 1 && CheckIfLastAdmin())
|
||||
{
|
||||
MessageBox.Show("You are removing the last known admin, that would break this program. Will not continue.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the guardian's database ID which is secretly hidden
|
||||
* in the datagrid view at column 0. Since value is an
|
||||
* Object, cast it to Int because that's what we know it is.
|
||||
*/
|
||||
guardian_id = (int)dgvGuardians.CurrentRow.Cells[0].Value;
|
||||
|
||||
|
||||
DialogResult dr = MessageBox.Show(">>WARNING!! Deleting the guardian will delete all attendence records associated with the guardian for all children.\n\rYOU CANNOT RECOVER OR UNDO THIS OPERATION.\n\rTHIS IS YOUR FINAL WARNING.\n\rDo you wish to continue?","Great Home Childcare",MessageBoxButtons.YesNoCancel,MessageBoxIcon.None);
|
||||
|
||||
if(dr == DialogResult.Yes)
|
||||
{
|
||||
Guardian guardian = new Guardian(); //does not need to be full object.
|
||||
guardian.id = guardian_id;
|
||||
|
||||
//Delete all the attendence data of that guardian.
|
||||
SqliteDataAccess.DeleteAttendenceForGuardian(guardian);
|
||||
|
||||
//Remove the guardian from the child.
|
||||
SqliteDataAccess.RemoveGuardianFromAllChildren(guardian);
|
||||
|
||||
//So long, sweet prince.
|
||||
SqliteDataAccess.DeleteGuardian(guardian);
|
||||
|
||||
MessageBox.Show("The guardian has been deleted.");
|
||||
LoadGuardiansForChild(child);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Delete canceled, no changes have been made.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
}
|
||||
}
|
||||
|
||||
/* Saves a new child to the DB
|
||||
* or updates an existing child.
|
||||
* INPUT: Data from form
|
||||
* OUTPUT: Data to SQL database.
|
||||
*/
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Save and close");
|
||||
return;
|
||||
//Perform sanity check, ensure all data is filled except picture
|
||||
this.Validate();
|
||||
this.ValidateChildren();
|
||||
|
||||
// Check to see if any control is in error.
|
||||
foreach (Control c in errorProvider1.ContainerControl.Controls)
|
||||
{
|
||||
if (errorProvider1.GetError(c) != "")
|
||||
{
|
||||
MessageBox.Show("Child not saved due to errors on the form!", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//collect form and save to child object.
|
||||
child.id = (int)idNumericUpDown.Value;
|
||||
child.address = addressTextBox.Text;
|
||||
child.DOB = dOBMonthCalendar.SelectionStart.ToShortDateString();
|
||||
child.FirstName = firstNameTextBox.Text;
|
||||
child.FirstName = ImageWrangler.CapitalizeFirstLetter(firstNameTextBox.Text);
|
||||
child.gender = genderComboBox.Text;
|
||||
child.LastName = lastNameTextBox.Text;
|
||||
child.race = raceTextBox.Text;
|
||||
child.LastName = ImageWrangler.CapitalizeFirstLetter(lastNameTextBox.Text);
|
||||
child.race = ImageWrangler.CapitalizeFirstLetter(raceTextBox.Text);
|
||||
|
||||
if (photoPictureBox.Tag.ToString() == DEFAULT_PIC_TAG)
|
||||
child.photo = null;
|
||||
else
|
||||
child.photo = ImageWrangler.ImageToByteArray(photoPictureBox.Image);
|
||||
|
||||
//TODO: test
|
||||
if(child.id > 0) //Should be all that's needed.....
|
||||
{
|
||||
// Ensure the child has at least one guardian.
|
||||
if (dgvGuardians.Rows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("The child has no guardians assigned. Please fix that and try again.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
|
||||
SqliteDataAccess.UpdateChild(child);
|
||||
MessageBox.Show("Child updated successfully! Data saved!");
|
||||
}
|
||||
else
|
||||
else //add child. >> bee-gee's "Stayin' alive" plays <<
|
||||
{
|
||||
//TODO: write code to add child. >> bee-gee's "Stayin' alive" plays <<
|
||||
/* PB&J
|
||||
* Pop new window to add at least one guardian to the child, either existing or new.
|
||||
* Validate guardian exist in db upon return to this form.
|
||||
* if valid, then populate guardian table and update authorized_guardians
|
||||
* LAST THING: InsertNewStudent(child);
|
||||
*/
|
||||
|
||||
//STEP 1: Attach a guardian to this child. This is done by "create new guardian and add to child" button.
|
||||
|
||||
/* If the user selected a guardian from the drop-down list.,
|
||||
* This is a sloppy-ass hack as popping the new guardian form on 'save and close' a new child
|
||||
* does not correctly work; and the program saves the child before attaching a new guardian
|
||||
* any god damn ways.... so fuck you. HOURS_WASTED_ON_TRYING_TO_FIX_IT = 10;
|
||||
*/
|
||||
if (cbExistingGuardians.Text != "Choose a guardian to add to this child")
|
||||
{
|
||||
btnAddExistingGuardian_Click(btnSave, EventArgs.Empty);
|
||||
}
|
||||
|
||||
//STEP 2:
|
||||
//Validate the child has at least one guardian.
|
||||
if(dgvGuardians.RowCount <= 0)
|
||||
{
|
||||
MessageBox.Show("The new child must have at least one guardian.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO: BUG: Inserting a new child happens before the above guardian stuff is done;
|
||||
/* STEP 3:
|
||||
* Add new child
|
||||
* The form has already been validated...
|
||||
* Do not need to add a guardian to the child here as that is taken care of in step 1.
|
||||
*/
|
||||
SqliteDataAccess.InsertNewChild(child);
|
||||
}
|
||||
Close();
|
||||
}
|
||||
@ -212,14 +502,126 @@ namespace GreatHomeChildcare
|
||||
{
|
||||
byte[] dickpic;
|
||||
|
||||
//Chunk file into bytes.
|
||||
//If file > MAX_PIC_SIZE bytes long, reject file.
|
||||
dickpic = File.ReadAllBytes(pic_openFileDialog.FileName);
|
||||
if (dickpic.Length >= MAX_PIC_SIZE) //THAT'S WHAT SHE SAID
|
||||
try
|
||||
{
|
||||
MessageBox.Show("The selected child's photo size is too large. Choose a smaller photo size or shrink the photo.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
//Chunk file into bytes.
|
||||
//If file > MAX_PIC_SIZE bytes long, reject file.
|
||||
dickpic = File.ReadAllBytes(pic_openFileDialog.FileName);
|
||||
if (dickpic.Length >= MAX_PIC_SIZE) //THAT'S WHAT SHE SAID
|
||||
{
|
||||
MessageBox.Show("The selected child's photo size is too large. Choose a smaller photo size or shrink the photo.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Unable to read selected file, try again.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Basic input validation on a string given a textbox control
|
||||
// ensures only values a-z, with length two or greater.
|
||||
private void String_TextBox_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
TextBox tb = (TextBox)sender;
|
||||
if (!Regex.IsMatch(tb.Text, "[A-Za-z]{2,}"))
|
||||
errorProvider1.SetError(tb, "Enter a value a-z only of length two or longer.");
|
||||
else
|
||||
errorProvider1.SetError(tb, "");
|
||||
}
|
||||
|
||||
//Ensures a gender was chosen.
|
||||
private void genderComboBox_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
ComboBox cb = (ComboBox)sender;
|
||||
|
||||
if (cb.SelectedIndex < 0)
|
||||
{ errorProvider1.SetError(cb, "Select an item."); }
|
||||
else
|
||||
{ errorProvider1.SetError(cb, ""); }
|
||||
}
|
||||
|
||||
/* Validation of DOB Date Time Picker does not really do any validation
|
||||
* other than check the basic, most probable case of the date is still today.
|
||||
* Yes, the Child can literally be born yesterday, and enrolled in daycare.
|
||||
*/
|
||||
private void dOBMonthCalendar_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
MonthCalendar mc = (MonthCalendar)sender;
|
||||
|
||||
if (mc.SelectionStart == DateTime.Today)
|
||||
{ errorProvider1.SetError(mc, "Please choose the DOB."); }
|
||||
else
|
||||
{ errorProvider1.SetError(mc, ""); }
|
||||
}
|
||||
|
||||
private void cbExistingGuardians_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
//Don't allow typing in the control.
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
/* Deletes a child.
|
||||
* The user has been aptly warned.
|
||||
*/
|
||||
private void btnDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
//if it's a new child, fuhgettaboutit.
|
||||
if (idNumericUpDown.Value == 0)
|
||||
{
|
||||
MessageBox.Show("Unable to delete this child as it is new. Either cancel or save.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
|
||||
string strWarning = ">>WARNING!!<< Deleting this child will:\n\r" +
|
||||
"1) Delete all attendence records of this child.\n\r" +
|
||||
"2) Detach this child from all guardians.\n\r" +
|
||||
"3) Look for any guardians with no other children,\n\r" +
|
||||
"3.1) For those guardians, delete all attendence records for those guardians.\n\r" +
|
||||
"3.2) Delete those guardians whom have no other children.\n\r" +
|
||||
"4) Delete the child from the database.\n\r\n\r" +
|
||||
"YOU CANNOT RECOVER OR UNDO THIS OPERATION.\n\rTHIS IS YOUR FINAL WARNING.\n\r\n\r" +
|
||||
"Do you wish to continue?";
|
||||
DialogResult dr = MessageBox.Show(strWarning, "Great Home Childcare", MessageBoxButtons.YesNoCancel, MessageBoxIcon.None);
|
||||
|
||||
if(dr == DialogResult.Yes)
|
||||
{
|
||||
MessageBox.Show("Code to-do: delete child");
|
||||
return;
|
||||
|
||||
//Step 1: Delete attendence data.
|
||||
SqliteDataAccess.DeleteAttendenceForChild(child);
|
||||
|
||||
//Step 2: Find other guardians of this child who don't have any more children assigned.
|
||||
List<Guardian> OrphanedGuardians = new List<Guardian>();
|
||||
OrphanedGuardians = SqliteDataAccess.GetOrphanedGuardians();
|
||||
|
||||
//Step 3: Find orphaned guardians.
|
||||
//Iterate through each guardian.
|
||||
foreach(Guardian g in OrphanedGuardians)
|
||||
{
|
||||
//if the guardian is admin
|
||||
//Check to see if this is the last admin. If so, don't delete it.
|
||||
if (g.isAdmin == 1 && CheckIfLastAdmin())
|
||||
{ continue; }
|
||||
|
||||
//Step 4: Delete the orphaned guardian.
|
||||
//Goodbye, guardian...
|
||||
SqliteDataAccess.DeleteGuardian(g);
|
||||
}
|
||||
|
||||
//Step 4: So long, sweet prince.
|
||||
SqliteDataAccess.DeleteChild(child);
|
||||
|
||||
//Show a message then close this crud form.
|
||||
MessageBox.Show("Child deleted.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Delete canceled, no changes have been made.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -136,14 +136,14 @@
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>205, 17</value>
|
||||
<value>256, 21</value>
|
||||
</metadata>
|
||||
<data name="imageList1.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACO
|
||||
DgAAAk1TRnQBSQFMAgEBCAEAAZgBAAGYAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABG
|
||||
DwAAAk1TRnQBSQFMAgEBCQEAAVgBAQFYAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||
AwABQAMAATADAAE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AAwAB8AIA
|
||||
Af8BwAMAAfABAQEAAX8BwAMAAfgBAQEAAT8BwAMAAfwBAQEAAR8BwAMAAfgBAQGAAQ8BwAMAAfgBAQHA
|
||||
AQcEAAGYAQEB4AEDBQABAQHwAQEFAAEDAfgFAAGAAQcB/AUAAYEB/wH+BgAC/wYAAv8BgAEAAX8CAAGZ
|
||||
Av8BwAEAAX8D/wHhBP8B7wH3Af8BgQL/AgABxwHjAf8BgQL/AgABgwHBAYABAQQAAQEBgAYAAYABAQYA
|
||||
AcABAwYAAeABBwYAAfABDwYAAfABDwYAAeABBwYAAcABAwYAAYABAQYAAQEBgAQAAfABDwGDAcEBgAEB
|
||||
BP8BxwHjAcMF/wHvAfcL
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="dOBLabel.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
<metadata name="childBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
<value>21, 21</value>
|
||||
</metadata>
|
||||
<metadata name="id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="isAdmin.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="LastName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
@ -229,29 +235,11 @@
|
||||
<metadata name="EmailAddress.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="LastName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="FirstName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="PhoneNumber.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="EmailAddress.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="childBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="pic_openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>362, 17</value>
|
||||
<value>453, 21</value>
|
||||
</metadata>
|
||||
<metadata name="errorProvider1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>553, 16</value>
|
||||
<value>691, 20</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
|
428
frmGuardianCrud.Designer.cs
generated
428
frmGuardianCrud.Designer.cs
generated
@ -37,73 +37,63 @@ namespace GreatHomeChildcare
|
||||
System.Windows.Forms.Label isAdminLabel;
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmGuardianCrud));
|
||||
this.idNumericUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.guardianBindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||
this.lastNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.firstNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.phoneNumberNumericUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.emailAddressTextBox = new System.Windows.Forms.TextBox();
|
||||
this.comboBox1 = new System.Windows.Forms.ComboBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.isAdminComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.btnCancelClose = new System.Windows.Forms.Button();
|
||||
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
|
||||
this.btnSaveClose = new System.Windows.Forms.Button();
|
||||
this.panelPinEntry = new System.Windows.Forms.Panel();
|
||||
this.lblPinEntry = new System.Windows.Forms.Label();
|
||||
this.tbPinNumber = new System.Windows.Forms.TextBox();
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.btnBack = new System.Windows.Forms.Button();
|
||||
this.btn0 = new System.Windows.Forms.Button();
|
||||
this.btn3 = new System.Windows.Forms.Button();
|
||||
this.btn1 = new System.Windows.Forms.Button();
|
||||
this.btn6 = new System.Windows.Forms.Button();
|
||||
this.btn5 = new System.Windows.Forms.Button();
|
||||
this.btn4 = new System.Windows.Forms.Button();
|
||||
this.btn8 = new System.Windows.Forms.Button();
|
||||
this.btn7 = new System.Windows.Forms.Button();
|
||||
this.btn2 = new System.Windows.Forms.Button();
|
||||
this.btnCE = new System.Windows.Forms.Button();
|
||||
this.btn9 = new System.Windows.Forms.Button();
|
||||
this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components);
|
||||
this.guardianBindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||
lastNameLabel = new System.Windows.Forms.Label();
|
||||
firstNameLabel = new System.Windows.Forms.Label();
|
||||
phoneNumberLabel = new System.Windows.Forms.Label();
|
||||
emailAddressLabel = new System.Windows.Forms.Label();
|
||||
isAdminLabel = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.idNumericUpDown)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.guardianBindingSource)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.phoneNumberNumericUpDown)).BeginInit();
|
||||
this.panelPinEntry.SuspendLayout();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.guardianBindingSource)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// idNumericUpDown
|
||||
//
|
||||
this.idNumericUpDown.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.guardianBindingSource, "id", true));
|
||||
this.idNumericUpDown.Location = new System.Drawing.Point(15, 121);
|
||||
this.idNumericUpDown.Name = "idNumericUpDown";
|
||||
this.idNumericUpDown.ReadOnly = true;
|
||||
this.idNumericUpDown.Size = new System.Drawing.Size(84, 22);
|
||||
this.idNumericUpDown.TabIndex = 2;
|
||||
this.idNumericUpDown.TabStop = false;
|
||||
this.idNumericUpDown.Visible = false;
|
||||
//
|
||||
// guardianBindingSource
|
||||
//
|
||||
this.guardianBindingSource.DataSource = typeof(GreatHomeChildcare.Models.Guardian);
|
||||
//
|
||||
// lastNameLabel
|
||||
//
|
||||
lastNameLabel.AutoSize = true;
|
||||
lastNameLabel.Location = new System.Drawing.Point(12, 9);
|
||||
lastNameLabel.Location = new System.Drawing.Point(150, 15);
|
||||
lastNameLabel.Name = "lastNameLabel";
|
||||
lastNameLabel.Size = new System.Drawing.Size(80, 17);
|
||||
lastNameLabel.TabIndex = 2;
|
||||
lastNameLabel.Text = "Last Name:";
|
||||
//
|
||||
// lastNameTextBox
|
||||
//
|
||||
this.lastNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.guardianBindingSource, "LastName", true));
|
||||
this.lastNameTextBox.Location = new System.Drawing.Point(15, 29);
|
||||
this.lastNameTextBox.Name = "lastNameTextBox";
|
||||
this.lastNameTextBox.Size = new System.Drawing.Size(100, 22);
|
||||
this.lastNameTextBox.TabIndex = 3;
|
||||
//
|
||||
// firstNameLabel
|
||||
//
|
||||
firstNameLabel.AutoSize = true;
|
||||
firstNameLabel.Location = new System.Drawing.Point(150, 9);
|
||||
firstNameLabel.Location = new System.Drawing.Point(12, 15);
|
||||
firstNameLabel.Name = "firstNameLabel";
|
||||
firstNameLabel.Size = new System.Drawing.Size(80, 17);
|
||||
firstNameLabel.TabIndex = 3;
|
||||
firstNameLabel.Text = "First Name:";
|
||||
//
|
||||
// firstNameTextBox
|
||||
//
|
||||
this.firstNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.guardianBindingSource, "FirstName", true));
|
||||
this.firstNameTextBox.Location = new System.Drawing.Point(153, 29);
|
||||
this.firstNameTextBox.Name = "firstNameTextBox";
|
||||
this.firstNameTextBox.Size = new System.Drawing.Size(100, 22);
|
||||
this.firstNameTextBox.TabIndex = 4;
|
||||
//
|
||||
// phoneNumberLabel
|
||||
//
|
||||
phoneNumberLabel.AutoSize = true;
|
||||
@ -113,6 +103,53 @@ namespace GreatHomeChildcare
|
||||
phoneNumberLabel.TabIndex = 5;
|
||||
phoneNumberLabel.Text = "Phone Number:";
|
||||
//
|
||||
// emailAddressLabel
|
||||
//
|
||||
emailAddressLabel.AutoSize = true;
|
||||
emailAddressLabel.Location = new System.Drawing.Point(151, 69);
|
||||
emailAddressLabel.Name = "emailAddressLabel";
|
||||
emailAddressLabel.Size = new System.Drawing.Size(102, 17);
|
||||
emailAddressLabel.TabIndex = 7;
|
||||
emailAddressLabel.Text = "Email Address:";
|
||||
//
|
||||
// isAdminLabel
|
||||
//
|
||||
isAdminLabel.AutoSize = true;
|
||||
isAdminLabel.Location = new System.Drawing.Point(96, 130);
|
||||
isAdminLabel.Name = "isAdminLabel";
|
||||
isAdminLabel.Size = new System.Drawing.Size(65, 17);
|
||||
isAdminLabel.TabIndex = 12;
|
||||
isAdminLabel.Text = "is Admin:";
|
||||
//
|
||||
// idNumericUpDown
|
||||
//
|
||||
this.idNumericUpDown.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.guardianBindingSource, "id", true));
|
||||
this.idNumericUpDown.Location = new System.Drawing.Point(8, 150);
|
||||
this.idNumericUpDown.Name = "idNumericUpDown";
|
||||
this.idNumericUpDown.ReadOnly = true;
|
||||
this.idNumericUpDown.Size = new System.Drawing.Size(65, 22);
|
||||
this.idNumericUpDown.TabIndex = 2;
|
||||
this.idNumericUpDown.TabStop = false;
|
||||
this.idNumericUpDown.Visible = false;
|
||||
//
|
||||
// lastNameTextBox
|
||||
//
|
||||
this.lastNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.guardianBindingSource, "LastName", true));
|
||||
this.lastNameTextBox.Location = new System.Drawing.Point(153, 35);
|
||||
this.lastNameTextBox.Name = "lastNameTextBox";
|
||||
this.lastNameTextBox.Size = new System.Drawing.Size(100, 22);
|
||||
this.lastNameTextBox.TabIndex = 2;
|
||||
this.lastNameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating);
|
||||
//
|
||||
// firstNameTextBox
|
||||
//
|
||||
this.firstNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.guardianBindingSource, "FirstName", true));
|
||||
this.firstNameTextBox.Location = new System.Drawing.Point(15, 35);
|
||||
this.firstNameTextBox.Name = "firstNameTextBox";
|
||||
this.firstNameTextBox.Size = new System.Drawing.Size(100, 22);
|
||||
this.firstNameTextBox.TabIndex = 1;
|
||||
this.firstNameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating);
|
||||
//
|
||||
// phoneNumberNumericUpDown
|
||||
//
|
||||
this.phoneNumberNumericUpDown.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.guardianBindingSource, "PhoneNumber", true));
|
||||
@ -135,68 +172,274 @@ namespace GreatHomeChildcare
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// emailAddressLabel
|
||||
//
|
||||
emailAddressLabel.AutoSize = true;
|
||||
emailAddressLabel.Location = new System.Drawing.Point(151, 69);
|
||||
emailAddressLabel.Name = "emailAddressLabel";
|
||||
emailAddressLabel.Size = new System.Drawing.Size(102, 17);
|
||||
emailAddressLabel.TabIndex = 7;
|
||||
emailAddressLabel.Text = "Email Address:";
|
||||
this.phoneNumberNumericUpDown.Validating += new System.ComponentModel.CancelEventHandler(this.phoneNumberNumericUpDown_Validating);
|
||||
//
|
||||
// emailAddressTextBox
|
||||
//
|
||||
this.emailAddressTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.guardianBindingSource, "EmailAddress", true));
|
||||
this.emailAddressTextBox.Location = new System.Drawing.Point(153, 89);
|
||||
this.emailAddressTextBox.Name = "emailAddressTextBox";
|
||||
this.emailAddressTextBox.Size = new System.Drawing.Size(100, 22);
|
||||
this.emailAddressTextBox.Size = new System.Drawing.Size(190, 22);
|
||||
this.emailAddressTextBox.TabIndex = 8;
|
||||
//
|
||||
// comboBox1
|
||||
//
|
||||
this.comboBox1.FormattingEnabled = true;
|
||||
this.comboBox1.Location = new System.Drawing.Point(353, 29);
|
||||
this.comboBox1.Name = "comboBox1";
|
||||
this.comboBox1.Size = new System.Drawing.Size(121, 24);
|
||||
this.comboBox1.TabIndex = 11;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(353, 6);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(130, 17);
|
||||
this.label1.TabIndex = 12;
|
||||
this.label1.Text = "Existing Guardians:";
|
||||
//
|
||||
// isAdminLabel
|
||||
//
|
||||
isAdminLabel.AutoSize = true;
|
||||
isAdminLabel.Location = new System.Drawing.Point(104, 155);
|
||||
isAdminLabel.Name = "isAdminLabel";
|
||||
isAdminLabel.Size = new System.Drawing.Size(65, 17);
|
||||
isAdminLabel.TabIndex = 12;
|
||||
isAdminLabel.Text = "is Admin:";
|
||||
this.emailAddressTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.emailAddressTextBox_Validating);
|
||||
//
|
||||
// isAdminComboBox
|
||||
//
|
||||
this.isAdminComboBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.guardianBindingSource, "isAdmin", true));
|
||||
this.isAdminComboBox.FormattingEnabled = true;
|
||||
this.isAdminComboBox.Location = new System.Drawing.Point(87, 175);
|
||||
this.isAdminComboBox.Location = new System.Drawing.Point(79, 150);
|
||||
this.isAdminComboBox.Name = "isAdminComboBox";
|
||||
this.isAdminComboBox.Size = new System.Drawing.Size(121, 24);
|
||||
this.isAdminComboBox.TabIndex = 13;
|
||||
this.isAdminComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.isAdminComboBox_Validating);
|
||||
//
|
||||
// btnCancelClose
|
||||
//
|
||||
this.btnCancelClose.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.btnCancelClose.ImageIndex = 0;
|
||||
this.btnCancelClose.ImageList = this.imageList1;
|
||||
this.btnCancelClose.Location = new System.Drawing.Point(21, 209);
|
||||
this.btnCancelClose.Name = "btnCancelClose";
|
||||
this.btnCancelClose.Size = new System.Drawing.Size(140, 50);
|
||||
this.btnCancelClose.TabIndex = 14;
|
||||
this.btnCancelClose.Text = "Cancel && Close";
|
||||
this.btnCancelClose.UseVisualStyleBackColor = true;
|
||||
this.btnCancelClose.Click += new System.EventHandler(this.btnCancelClose_Click);
|
||||
//
|
||||
// imageList1
|
||||
//
|
||||
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
|
||||
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
|
||||
this.imageList1.Images.SetKeyName(0, "Cancel_16x.png");
|
||||
this.imageList1.Images.SetKeyName(1, "SaveClose_16x.png");
|
||||
//
|
||||
// btnSaveClose
|
||||
//
|
||||
this.btnSaveClose.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.btnSaveClose.ImageIndex = 1;
|
||||
this.btnSaveClose.ImageList = this.imageList1;
|
||||
this.btnSaveClose.Location = new System.Drawing.Point(204, 208);
|
||||
this.btnSaveClose.Name = "btnSaveClose";
|
||||
this.btnSaveClose.Size = new System.Drawing.Size(139, 50);
|
||||
this.btnSaveClose.TabIndex = 15;
|
||||
this.btnSaveClose.Text = "Save && Close";
|
||||
this.btnSaveClose.UseVisualStyleBackColor = true;
|
||||
this.btnSaveClose.Click += new System.EventHandler(this.btnSaveClose_Click);
|
||||
//
|
||||
// panelPinEntry
|
||||
//
|
||||
this.panelPinEntry.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.panelPinEntry.Controls.Add(this.lblPinEntry);
|
||||
this.panelPinEntry.Controls.Add(this.tbPinNumber);
|
||||
this.panelPinEntry.Controls.Add(this.tableLayoutPanel1);
|
||||
this.panelPinEntry.Location = new System.Drawing.Point(360, 12);
|
||||
this.panelPinEntry.Name = "panelPinEntry";
|
||||
this.panelPinEntry.Size = new System.Drawing.Size(252, 297);
|
||||
this.panelPinEntry.TabIndex = 16;
|
||||
//
|
||||
// lblPinEntry
|
||||
//
|
||||
this.lblPinEntry.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblPinEntry.AutoSize = true;
|
||||
this.lblPinEntry.Location = new System.Drawing.Point(108, 9);
|
||||
this.lblPinEntry.Name = "lblPinEntry";
|
||||
this.lblPinEntry.Size = new System.Drawing.Size(34, 17);
|
||||
this.lblPinEntry.TabIndex = 4;
|
||||
this.lblPinEntry.Text = "PIN:";
|
||||
//
|
||||
// tbPinNumber
|
||||
//
|
||||
this.tbPinNumber.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.tbPinNumber.Location = new System.Drawing.Point(0, 33);
|
||||
this.tbPinNumber.MaxLength = 4;
|
||||
this.tbPinNumber.Name = "tbPinNumber";
|
||||
this.tbPinNumber.PasswordChar = '*';
|
||||
this.tbPinNumber.Size = new System.Drawing.Size(250, 22);
|
||||
this.tbPinNumber.TabIndex = 3;
|
||||
this.tbPinNumber.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.tbPinNumber.UseSystemPasswordChar = true;
|
||||
this.tbPinNumber.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbPinNumber_KeyPress);
|
||||
this.tbPinNumber.Validating += new System.ComponentModel.CancelEventHandler(this.tbPinNumber_Validating);
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.ColumnCount = 3;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.btnBack, 2, 3);
|
||||
this.tableLayoutPanel1.Controls.Add(this.btn0, 1, 3);
|
||||
this.tableLayoutPanel1.Controls.Add(this.btn3, 2, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.btn1, 0, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.btn6, 2, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.btn5, 1, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.btn4, 0, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.btn8, 1, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.btn7, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.btn2, 1, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.btnCE, 0, 3);
|
||||
this.tableLayoutPanel1.Controls.Add(this.btn9, 2, 0);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 55);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 4;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(250, 240);
|
||||
this.tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// btnBack
|
||||
//
|
||||
this.btnBack.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.btnBack.Location = new System.Drawing.Point(169, 183);
|
||||
this.btnBack.Name = "btnBack";
|
||||
this.btnBack.Size = new System.Drawing.Size(78, 54);
|
||||
this.btnBack.TabIndex = 11;
|
||||
this.btnBack.Text = "<<";
|
||||
this.btnBack.UseVisualStyleBackColor = true;
|
||||
this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
|
||||
//
|
||||
// btn0
|
||||
//
|
||||
this.btn0.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.btn0.Location = new System.Drawing.Point(86, 183);
|
||||
this.btn0.Name = "btn0";
|
||||
this.btn0.Size = new System.Drawing.Size(77, 54);
|
||||
this.btn0.TabIndex = 10;
|
||||
this.btn0.Text = "0";
|
||||
this.btn0.UseVisualStyleBackColor = true;
|
||||
this.btn0.Click += new System.EventHandler(this.btnNumButton_Click);
|
||||
//
|
||||
// btn3
|
||||
//
|
||||
this.btn3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.btn3.Location = new System.Drawing.Point(169, 123);
|
||||
this.btn3.Name = "btn3";
|
||||
this.btn3.Size = new System.Drawing.Size(78, 54);
|
||||
this.btn3.TabIndex = 8;
|
||||
this.btn3.Text = "3";
|
||||
this.btn3.UseVisualStyleBackColor = true;
|
||||
this.btn3.Click += new System.EventHandler(this.btnNumButton_Click);
|
||||
//
|
||||
// btn1
|
||||
//
|
||||
this.btn1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.btn1.Location = new System.Drawing.Point(3, 123);
|
||||
this.btn1.Name = "btn1";
|
||||
this.btn1.Size = new System.Drawing.Size(77, 54);
|
||||
this.btn1.TabIndex = 6;
|
||||
this.btn1.Text = "1";
|
||||
this.btn1.UseVisualStyleBackColor = true;
|
||||
this.btn1.Click += new System.EventHandler(this.btnNumButton_Click);
|
||||
//
|
||||
// btn6
|
||||
//
|
||||
this.btn6.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.btn6.Location = new System.Drawing.Point(169, 63);
|
||||
this.btn6.Name = "btn6";
|
||||
this.btn6.Size = new System.Drawing.Size(78, 54);
|
||||
this.btn6.TabIndex = 5;
|
||||
this.btn6.Text = "6";
|
||||
this.btn6.UseVisualStyleBackColor = true;
|
||||
this.btn6.Click += new System.EventHandler(this.btnNumButton_Click);
|
||||
//
|
||||
// btn5
|
||||
//
|
||||
this.btn5.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.btn5.Location = new System.Drawing.Point(86, 63);
|
||||
this.btn5.Name = "btn5";
|
||||
this.btn5.Size = new System.Drawing.Size(77, 54);
|
||||
this.btn5.TabIndex = 4;
|
||||
this.btn5.Text = "5";
|
||||
this.btn5.UseVisualStyleBackColor = true;
|
||||
this.btn5.Click += new System.EventHandler(this.btnNumButton_Click);
|
||||
//
|
||||
// btn4
|
||||
//
|
||||
this.btn4.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.btn4.Location = new System.Drawing.Point(3, 63);
|
||||
this.btn4.Name = "btn4";
|
||||
this.btn4.Size = new System.Drawing.Size(77, 54);
|
||||
this.btn4.TabIndex = 3;
|
||||
this.btn4.Text = "4";
|
||||
this.btn4.UseVisualStyleBackColor = true;
|
||||
this.btn4.Click += new System.EventHandler(this.btnNumButton_Click);
|
||||
//
|
||||
// btn8
|
||||
//
|
||||
this.btn8.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.btn8.Location = new System.Drawing.Point(86, 3);
|
||||
this.btn8.Name = "btn8";
|
||||
this.btn8.Size = new System.Drawing.Size(77, 54);
|
||||
this.btn8.TabIndex = 1;
|
||||
this.btn8.Text = "8";
|
||||
this.btn8.UseVisualStyleBackColor = true;
|
||||
this.btn8.Click += new System.EventHandler(this.btnNumButton_Click);
|
||||
//
|
||||
// btn7
|
||||
//
|
||||
this.btn7.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.btn7.Location = new System.Drawing.Point(3, 3);
|
||||
this.btn7.Name = "btn7";
|
||||
this.btn7.Size = new System.Drawing.Size(77, 54);
|
||||
this.btn7.TabIndex = 0;
|
||||
this.btn7.Text = "7";
|
||||
this.btn7.UseVisualStyleBackColor = true;
|
||||
this.btn7.Click += new System.EventHandler(this.btnNumButton_Click);
|
||||
//
|
||||
// btn2
|
||||
//
|
||||
this.btn2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.btn2.Location = new System.Drawing.Point(86, 123);
|
||||
this.btn2.Name = "btn2";
|
||||
this.btn2.Size = new System.Drawing.Size(77, 54);
|
||||
this.btn2.TabIndex = 7;
|
||||
this.btn2.Text = "2";
|
||||
this.btn2.UseVisualStyleBackColor = true;
|
||||
this.btn2.Click += new System.EventHandler(this.btnNumButton_Click);
|
||||
//
|
||||
// btnCE
|
||||
//
|
||||
this.btnCE.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.btnCE.Location = new System.Drawing.Point(3, 183);
|
||||
this.btnCE.Name = "btnCE";
|
||||
this.btnCE.Size = new System.Drawing.Size(77, 54);
|
||||
this.btnCE.TabIndex = 9;
|
||||
this.btnCE.Text = "CE";
|
||||
this.btnCE.UseVisualStyleBackColor = true;
|
||||
this.btnCE.Click += new System.EventHandler(this.btnCE_Click);
|
||||
//
|
||||
// btn9
|
||||
//
|
||||
this.btn9.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.btn9.Location = new System.Drawing.Point(169, 3);
|
||||
this.btn9.Name = "btn9";
|
||||
this.btn9.Size = new System.Drawing.Size(78, 54);
|
||||
this.btn9.TabIndex = 2;
|
||||
this.btn9.Text = "9";
|
||||
this.btn9.UseVisualStyleBackColor = true;
|
||||
this.btn9.Click += new System.EventHandler(this.btnNumButton_Click);
|
||||
//
|
||||
// errorProvider1
|
||||
//
|
||||
this.errorProvider1.ContainerControl = this;
|
||||
//
|
||||
// guardianBindingSource
|
||||
//
|
||||
this.guardianBindingSource.DataSource = typeof(GreatHomeChildcare.Models.Guardian);
|
||||
//
|
||||
// frmGuardianCrud
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(873, 450);
|
||||
this.ClientSize = new System.Drawing.Size(636, 368);
|
||||
this.Controls.Add(this.panelPinEntry);
|
||||
this.Controls.Add(this.btnSaveClose);
|
||||
this.Controls.Add(this.btnCancelClose);
|
||||
this.Controls.Add(isAdminLabel);
|
||||
this.Controls.Add(this.isAdminComboBox);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.comboBox1);
|
||||
this.Controls.Add(emailAddressLabel);
|
||||
this.Controls.Add(this.emailAddressTextBox);
|
||||
this.Controls.Add(phoneNumberLabel);
|
||||
@ -208,10 +451,15 @@ namespace GreatHomeChildcare
|
||||
this.Controls.Add(this.idNumericUpDown);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "frmGuardianCrud";
|
||||
this.Text = "frmGuardianCrud";
|
||||
this.Text = "Guardian Management: Great Home Childcare";
|
||||
this.Load += new System.EventHandler(this.frmGuardianCrud_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.idNumericUpDown)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.guardianBindingSource)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.phoneNumberNumericUpDown)).EndInit();
|
||||
this.panelPinEntry.ResumeLayout(false);
|
||||
this.panelPinEntry.PerformLayout();
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.guardianBindingSource)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -225,8 +473,26 @@ namespace GreatHomeChildcare
|
||||
private System.Windows.Forms.TextBox firstNameTextBox;
|
||||
private System.Windows.Forms.NumericUpDown phoneNumberNumericUpDown;
|
||||
private System.Windows.Forms.TextBox emailAddressTextBox;
|
||||
private System.Windows.Forms.ComboBox comboBox1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.ComboBox isAdminComboBox;
|
||||
private System.Windows.Forms.Button btnCancelClose;
|
||||
private System.Windows.Forms.ImageList imageList1;
|
||||
private System.Windows.Forms.Button btnSaveClose;
|
||||
private System.Windows.Forms.Panel panelPinEntry;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private System.Windows.Forms.Label lblPinEntry;
|
||||
private System.Windows.Forms.TextBox tbPinNumber;
|
||||
private System.Windows.Forms.ErrorProvider errorProvider1;
|
||||
private System.Windows.Forms.Button btnBack;
|
||||
private System.Windows.Forms.Button btn0;
|
||||
private System.Windows.Forms.Button btnCE;
|
||||
private System.Windows.Forms.Button btn3;
|
||||
private System.Windows.Forms.Button btn2;
|
||||
private System.Windows.Forms.Button btn1;
|
||||
private System.Windows.Forms.Button btn6;
|
||||
private System.Windows.Forms.Button btn5;
|
||||
private System.Windows.Forms.Button btn4;
|
||||
private System.Windows.Forms.Button btn9;
|
||||
private System.Windows.Forms.Button btn8;
|
||||
private System.Windows.Forms.Button btn7;
|
||||
}
|
||||
}
|
@ -1,20 +1,257 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using GreatHomeChildcare.Models;
|
||||
|
||||
namespace GreatHomeChildcare
|
||||
{
|
||||
public partial class frmGuardianCrud : Form
|
||||
{
|
||||
//global variables
|
||||
SqliteDataAccess SqliteDataAccess = new SqliteDataAccess();
|
||||
public static Guardian guardian = new Guardian();
|
||||
public static string strPin = String.Empty;
|
||||
|
||||
enum IsAdmin
|
||||
{
|
||||
No = 0,
|
||||
Yes = 1
|
||||
}
|
||||
|
||||
public frmGuardianCrud()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/* Load up the form with an existing guardian
|
||||
* if the "edit guardian" button was pressed
|
||||
* on the child crud form.
|
||||
*/
|
||||
private void frmGuardianCrud_Load(object sender, EventArgs e)
|
||||
{
|
||||
int guardian_id = 0;
|
||||
IsAdmin adminOut;
|
||||
|
||||
FillIsAdminComboBox();
|
||||
|
||||
/* If it's the first time run of this program
|
||||
* then setup the initial admin user.
|
||||
*/
|
||||
if(SqliteDataAccess.GetNumAdmins() <= 0)
|
||||
{
|
||||
isAdminComboBox.SelectedItem = IsAdmin.Yes;
|
||||
isAdminComboBox.Enabled = false;
|
||||
btnCancelClose.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
guardian_id = frmChildCrud.guardian_id;
|
||||
}
|
||||
|
||||
if (guardian_id > 0)
|
||||
{
|
||||
guardian = SqliteDataAccess.GetGuardianById(guardian_id);
|
||||
idNumericUpDown.Value = guardian.id;
|
||||
lastNameTextBox.Text = guardian.LastName;
|
||||
firstNameTextBox.Text = guardian.FirstName;
|
||||
phoneNumberNumericUpDown.Value = guardian.PhoneNumber;
|
||||
emailAddressTextBox.Text = guardian.EmailAddress;
|
||||
strPin = guardian.PinNumber.ToString();
|
||||
tbPinNumber.Text = "****";
|
||||
|
||||
//Load the isAdmin combo box based from enum value.
|
||||
//ref: chuck costarella
|
||||
Enum.TryParse<IsAdmin>(guardian.isAdmin.ToString(), out adminOut);
|
||||
isAdminComboBox.SelectedItem = adminOut;
|
||||
}
|
||||
}
|
||||
|
||||
// Fill the IsAdmin combo box with our enum.
|
||||
private void FillIsAdminComboBox()
|
||||
{
|
||||
isAdminComboBox.Items.Add(IsAdmin.No);
|
||||
isAdminComboBox.Items.Add(IsAdmin.Yes);
|
||||
isAdminComboBox.SelectedItem = IsAdmin.No;
|
||||
}
|
||||
|
||||
//Close the form without saving changes.
|
||||
private void btnCancelClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
/* Save a new guardian or update
|
||||
* an existing guardian.
|
||||
* INPUT: Data from form.
|
||||
* OUTPUT: data to sql database.
|
||||
*/
|
||||
private void btnSaveClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
Guardian checkExistingGuardian = new Guardian();
|
||||
int num_admins;
|
||||
|
||||
this.Validate();
|
||||
this.ValidateChildren();
|
||||
|
||||
// Check to see if any control is in error.
|
||||
foreach (Control c in errorProvider1.ContainerControl.Controls)
|
||||
{
|
||||
if (errorProvider1.GetError(c) != "")
|
||||
{
|
||||
MessageBox.Show("Guardian not saved due to errors on the form!", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// validate pin
|
||||
if(strPin.Length < 4)
|
||||
{
|
||||
MessageBox.Show("Please enter a 4-digit pin number.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
|
||||
checkExistingGuardian = SqliteDataAccess.GetGuardianByPin(Int32.Parse(strPin));
|
||||
|
||||
//If this is a new guardian, check to see if that pin is in use.
|
||||
if(idNumericUpDown.Value == 0 && checkExistingGuardian != null)
|
||||
{
|
||||
MessageBox.Show("Please choose a different PIN number.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
return;
|
||||
}
|
||||
|
||||
guardian.id = Int32.Parse(idNumericUpDown.Value.ToString());
|
||||
guardian.LastName = ImageWrangler.CapitalizeFirstLetter(lastNameTextBox.Text);
|
||||
guardian.FirstName = ImageWrangler.CapitalizeFirstLetter(firstNameTextBox.Text);
|
||||
guardian.PhoneNumber = long.Parse(phoneNumberNumericUpDown.Value.ToString());
|
||||
guardian.EmailAddress = emailAddressTextBox.Text;
|
||||
guardian.PinNumber = Int32.Parse(strPin);
|
||||
guardian.isAdmin = (int)isAdminComboBox.SelectedItem;
|
||||
|
||||
if(guardian.id == 0) // new guardian
|
||||
{
|
||||
SqliteDataAccess.InsertNewGuardian(guardian);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Check to see if no admins will be left over.
|
||||
num_admins = SqliteDataAccess.GetNumAdmins();
|
||||
num_admins--;
|
||||
|
||||
if ((IsAdmin)isAdminComboBox.SelectedItem == IsAdmin.No
|
||||
&& num_admins <= 0)
|
||||
{
|
||||
MessageBox.Show("You are removing the last known admin, that would break this program.\n\rThe IsAdmin selection has changed to YES, please re-check the form entry then resubmit.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
isAdminComboBox.SelectedItem = IsAdmin.Yes;
|
||||
return;
|
||||
}
|
||||
|
||||
SqliteDataAccess.UpdateGuardian(guardian);
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
// Basic input validation on a string given a textbox control
|
||||
// ensures only values a-z, with length two or greater.
|
||||
private void String_TextBox_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
TextBox tb = (TextBox)sender;
|
||||
if (!Regex.IsMatch(tb.Text, "[A-Za-z]{2,}"))
|
||||
errorProvider1.SetError(tb, "Enter a value a-z only of length two or longer.");
|
||||
else
|
||||
errorProvider1.SetError(tb, "");
|
||||
}
|
||||
|
||||
/* Does not really check to see if it is a valid phone number
|
||||
* since the phone companies introduce new area codes all the damn time.
|
||||
* Only checks to see the most likely case that the user of the program
|
||||
* has left the phone number value as the default minimum value.
|
||||
*/
|
||||
private void phoneNumberNumericUpDown_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (phoneNumberNumericUpDown.Value == phoneNumberNumericUpDown.Minimum
|
||||
|| phoneNumberNumericUpDown.Value == phoneNumberNumericUpDown.Maximum)
|
||||
{ errorProvider1.SetError(phoneNumberNumericUpDown, "Type in a valid phone number"); }
|
||||
else
|
||||
{ errorProvider1.SetError(phoneNumberNumericUpDown, ""); }
|
||||
}
|
||||
|
||||
//Validates any given combobox to ensure an item is selected.
|
||||
private void isAdminComboBox_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
ComboBox cb = (ComboBox)sender;
|
||||
|
||||
if (cb.SelectedIndex < 0)
|
||||
{ errorProvider1.SetError(cb, "Select an item."); }
|
||||
else
|
||||
{ errorProvider1.SetError(cb, ""); }
|
||||
}
|
||||
|
||||
//validate a 4-digit pin number was entered.
|
||||
private void tbPinNumber_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
if(tbPinNumber.TextLength != 4)
|
||||
{ errorProvider1.SetError(tbPinNumber, "Please enter a 4-digit PIN."); }
|
||||
else
|
||||
{ errorProvider1.SetError(tbPinNumber, ""); }
|
||||
}
|
||||
|
||||
/* Checks to see if provided email address is valid
|
||||
* by matching against an email address regex i stole from the interweb.
|
||||
*/
|
||||
private void emailAddressTextBox_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
//email address regex
|
||||
//^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,5}$
|
||||
if (!Regex.IsMatch(emailAddressTextBox.Text, @"^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,5}$"))
|
||||
errorProvider1.SetError(emailAddressTextBox, "Enter a valid email address: user@domain.com");
|
||||
else
|
||||
errorProvider1.SetError(emailAddressTextBox, "");
|
||||
}
|
||||
|
||||
private void btnNumButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
//Don't allow a PIN length longer than 4 digits.
|
||||
if (strPin.Length >= 4)
|
||||
return;
|
||||
|
||||
//to the passed in sender source and cast it to a Button
|
||||
Button button = (Button)sender;
|
||||
strPin += button.Text;
|
||||
tbPinNumber.Text += button.Text;
|
||||
}
|
||||
|
||||
//Prevents typing in the pin number box.
|
||||
private void tbPinNumber_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
//Don't allow typing in the control.
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
/*Clears the pin entry completely,
|
||||
* resetting the hidden variable strPin,
|
||||
* and clearing the text box
|
||||
*/
|
||||
private void btnCE_Click(object sender, EventArgs e)
|
||||
{
|
||||
strPin = String.Empty;
|
||||
tbPinNumber.Text = String.Empty;
|
||||
}
|
||||
|
||||
// Deletes the last number entered into the pinpad.
|
||||
private void btnBack_Click(object sender, EventArgs e)
|
||||
{
|
||||
//If there is nothing in the display, do not attempt
|
||||
//to remove any digits, or the program will crash.
|
||||
if (strPin.Length == 0)
|
||||
return;
|
||||
|
||||
//Assign the text in the display using a substring
|
||||
//of whatever the text is, subtracting the length by 1.
|
||||
//This effectively 'strips' the last digit from the display string.
|
||||
tbPinNumber.Text = tbPinNumber.Text.Substring(0, tbPinNumber.Text.Length - 1);
|
||||
strPin = strPin.Substring(0, strPin.Length - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,9 +117,6 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="guardianBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="lastNameLabel.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
@ -135,6 +132,63 @@
|
||||
<metadata name="isAdminLabel.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
<metadata name="guardianBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>233, 17</value>
|
||||
</metadata>
|
||||
<data name="imageList1.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||
ZW0uV2luZG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H/AfMBFAHtAfQBBwH0Ae0BFAH0BooB9CEAAfQBGwFMAfIB9AQA
|
||||
AfQB8gFMARoB9AEAAfMB6gH0Ae0BFAHtAfMBEgj0IgAD9AYAA/QCAAHzARQB6gMUARIBFAH0KgAB/wgA
|
||||
Af8DAAn0JwABQgFNAT4HAAE+AwABKAMAAUADAAEQAwABAQEAAQEFAAGAFwAD/wEAAe8B9wHgBQABxwHj
|
||||
AcAFAAGDAcEBwAUAAQEBgAHABQABgAEBAcAFAAHAAQMBwAUAAeABBwHABQAB8AEPBgAB8AEPBgAB4AEH
|
||||
BgABwAEDBgABgAEBBgABAQGABgABgwHBBgABxwHjAQABfwQAAe8B9wEAAX8EAAs=
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="errorProvider1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>363, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
17
frmMainForm.Designer.cs
generated
17
frmMainForm.Designer.cs
generated
@ -42,7 +42,6 @@ namespace GreatHomeChildcare
|
||||
this.btnChild3 = new System.Windows.Forms.Button();
|
||||
this.picturebox_child3 = new System.Windows.Forms.PictureBox();
|
||||
this.panelChild4 = new System.Windows.Forms.Panel();
|
||||
this.lblNoChildren = new System.Windows.Forms.Label();
|
||||
this.btnChild4 = new System.Windows.Forms.Button();
|
||||
this.picturebox_child4 = new System.Windows.Forms.PictureBox();
|
||||
this.panelChild5 = new System.Windows.Forms.Panel();
|
||||
@ -222,7 +221,6 @@ namespace GreatHomeChildcare
|
||||
// panelChild4
|
||||
//
|
||||
this.panelChild4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.panelChild4.Controls.Add(this.lblNoChildren);
|
||||
this.panelChild4.Controls.Add(this.btnChild4);
|
||||
this.panelChild4.Controls.Add(this.picturebox_child4);
|
||||
this.panelChild4.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
@ -232,17 +230,6 @@ namespace GreatHomeChildcare
|
||||
this.panelChild4.TabIndex = 6;
|
||||
this.panelChild4.Visible = false;
|
||||
//
|
||||
// lblNoChildren
|
||||
//
|
||||
this.lblNoChildren.AutoSize = true;
|
||||
this.lblNoChildren.Location = new System.Drawing.Point(80, 40);
|
||||
this.lblNoChildren.Name = "lblNoChildren";
|
||||
this.lblNoChildren.Size = new System.Drawing.Size(563, 17);
|
||||
this.lblNoChildren.TabIndex = 2;
|
||||
this.lblNoChildren.Text = "You don\'t have any children. Please have an admin assign your children in the pro" +
|
||||
"gram.";
|
||||
this.lblNoChildren.Visible = false;
|
||||
//
|
||||
// btnChild4
|
||||
//
|
||||
this.btnChild4.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
@ -431,7 +418,7 @@ namespace GreatHomeChildcare
|
||||
// lblInstructions
|
||||
//
|
||||
this.lblInstructions.AutoSize = true;
|
||||
this.lblInstructions.Location = new System.Drawing.Point(61, 24);
|
||||
this.lblInstructions.Location = new System.Drawing.Point(84, 24);
|
||||
this.lblInstructions.Name = "lblInstructions";
|
||||
this.lblInstructions.Size = new System.Drawing.Size(573, 17);
|
||||
this.lblInstructions.TabIndex = 2;
|
||||
@ -469,7 +456,6 @@ namespace GreatHomeChildcare
|
||||
this.panelChild3.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.picturebox_child3)).EndInit();
|
||||
this.panelChild4.ResumeLayout(false);
|
||||
this.panelChild4.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picturebox_child4)).EndInit();
|
||||
this.panelChild5.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.picturebox_child5)).EndInit();
|
||||
@ -517,7 +503,6 @@ namespace GreatHomeChildcare
|
||||
private System.Windows.Forms.Button btnChild9;
|
||||
private System.Windows.Forms.PictureBox picturebox_child9;
|
||||
private System.Windows.Forms.Button btnChild1;
|
||||
private System.Windows.Forms.Label lblNoChildren;
|
||||
private System.Windows.Forms.Label lblInstructions;
|
||||
private System.Windows.Forms.Button btnDone;
|
||||
}
|
||||
|
@ -1,11 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using GreatHomeChildcare.Models;
|
||||
|
||||
@ -45,9 +40,9 @@ namespace GreatHomeChildcare
|
||||
}
|
||||
|
||||
//If the guardian has no children, show a message.
|
||||
if (children == null)
|
||||
if (children.Count == 0)
|
||||
{
|
||||
lblNoChildren.Visible = true;
|
||||
lblInstructions.Text = "You don\'t have any children. Please have an admin assign your children in the program.";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -77,6 +72,9 @@ namespace GreatHomeChildcare
|
||||
*/
|
||||
private void PopulateButton(Child child_in, Control controls_in)
|
||||
{
|
||||
Attendance studentStatus = new Attendance();
|
||||
string btnText = String.Empty;
|
||||
|
||||
Control.ControlCollection nested_controls = controls_in.Controls;
|
||||
foreach(Control c in nested_controls)
|
||||
{
|
||||
@ -89,10 +87,29 @@ namespace GreatHomeChildcare
|
||||
if (c is Button)
|
||||
{
|
||||
Button btn = (Button)c;
|
||||
Attendance studentStatus = SqliteDataAccess.GetChildSignInOut(child_in);
|
||||
string btnText = child_in.DisplayName + "\n\r"
|
||||
+ "Status: Signed " + studentStatus.in_out.ToUpper() + "\n\r"
|
||||
+ studentStatus.timestamp;
|
||||
studentStatus = SqliteDataAccess.GetChildSignInOut(child_in);
|
||||
|
||||
if(studentStatus != null)
|
||||
{
|
||||
btnText = child_in.DisplayName + "\n\r"
|
||||
+ "Status: Signed " + studentStatus.in_out.ToUpper() + "\n\r"
|
||||
+ studentStatus.timestamp;
|
||||
}
|
||||
else //it's a new student.
|
||||
{
|
||||
/* The studentStatus object must be reinitialized here as
|
||||
* GetChildSignInOut can return null. If so; then
|
||||
* studentStatus is also null and is no longer an Attendence object.
|
||||
*/
|
||||
studentStatus = new Attendance();
|
||||
|
||||
//Set the status to out for the button display and the update panel color.
|
||||
studentStatus.in_out = "out";
|
||||
|
||||
btnText = child_in.DisplayName + "\n\r"
|
||||
+ "Status: Signed " + studentStatus.in_out.ToUpper() + "\n\r"
|
||||
+ "No attendence record.";
|
||||
}
|
||||
|
||||
//shove the child into the Tag property which is a type of 'object' for later retrieval.
|
||||
//see also: cheap hax
|
||||
|
2
frmPinEntry.Designer.cs
generated
2
frmPinEntry.Designer.cs
generated
@ -245,7 +245,7 @@ namespace GreatHomeChildcare
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "frmPinEntry";
|
||||
this.Text = "Great Home Childcare";
|
||||
this.Load += new System.EventHandler(this.frmPinEntry_Load);
|
||||
this.Shown += new System.EventHandler(this.frmPinEntry_Shown);
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
@ -1,14 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using GreatHomeChildcare.Models;
|
||||
|
||||
//Refs
|
||||
// https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.form.shown?redirectedfrom=MSDN&view=net-5.0
|
||||
namespace GreatHomeChildcare
|
||||
{
|
||||
public partial class frmPinEntry : Form
|
||||
@ -128,28 +123,41 @@ namespace GreatHomeChildcare
|
||||
/* Checks to see if this is the first-ever time the application has
|
||||
* run by querying number of rows in Guardian table.
|
||||
* If number of rows <= 0, we must setup an admin user in the guardian table.
|
||||
* The Shown event is only raised the first time a form is displayed; subsequently
|
||||
* minimizing, maximizing, restoring, hiding, showing, or invalidating and repainting
|
||||
* will not raise this event. Ref: Microsoft
|
||||
*/
|
||||
private void frmPinEntry_Load(object sender, EventArgs e)
|
||||
private void frmPinEntry_Shown(object sender, EventArgs e)
|
||||
{
|
||||
bool bIsFirstTime = false;
|
||||
Hide();
|
||||
|
||||
int num_admins = 0;
|
||||
DialogResult dr;
|
||||
|
||||
bIsFirstTime = SqliteDataAccess.isFirstTimeRun();
|
||||
num_admins = SqliteDataAccess.GetNumAdmins();
|
||||
|
||||
if(bIsFirstTime)
|
||||
if (num_admins <= 0)
|
||||
{
|
||||
dr = MessageBox.Show("Program not setup yet. Setup now?", "Great Home Childcare", MessageBoxButtons.YesNo, MessageBoxIcon.None);
|
||||
|
||||
//TODO: Open the form to add a new guardian.
|
||||
// Open the form to add a new guardian.
|
||||
if (dr == DialogResult.Yes)
|
||||
return;
|
||||
|
||||
{
|
||||
Form frm2 = new frmGuardianCrud();
|
||||
frm2.FormClosed += new FormClosedEventHandler(MainFormClosed);
|
||||
frm2.Show();
|
||||
Hide();
|
||||
}
|
||||
else //Show a message and close the application.
|
||||
{
|
||||
MessageBox.Show("Come back when you are ready to setup the program!", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
161
frmReports.Designer.cs
generated
Normal file
161
frmReports.Designer.cs
generated
Normal file
@ -0,0 +1,161 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace GreatHomeChildcare
|
||||
{
|
||||
partial class frmReports
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.cbChildPicker = new System.Windows.Forms.ComboBox();
|
||||
this.lblFilter = new System.Windows.Forms.Label();
|
||||
this.dtpFrom = new System.Windows.Forms.DateTimePicker();
|
||||
this.dtpTo = new System.Windows.Forms.DateTimePicker();
|
||||
this.lblFrom = new System.Windows.Forms.Label();
|
||||
this.lblTo = new System.Windows.Forms.Label();
|
||||
this.dgvReports = new System.Windows.Forms.DataGridView();
|
||||
this.ChildDisplayName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvReports)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// cbChildPicker
|
||||
//
|
||||
this.cbChildPicker.DisplayMember = "DisplayName";
|
||||
this.cbChildPicker.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cbChildPicker.FormattingEnabled = true;
|
||||
this.cbChildPicker.Location = new System.Drawing.Point(13, 57);
|
||||
this.cbChildPicker.Name = "cbChildPicker";
|
||||
this.cbChildPicker.Size = new System.Drawing.Size(121, 24);
|
||||
this.cbChildPicker.TabIndex = 0;
|
||||
this.cbChildPicker.SelectionChangeCommitted += new System.EventHandler(this.cbChildPicker_SelectionChangeCommitted);
|
||||
//
|
||||
// lblFilter
|
||||
//
|
||||
this.lblFilter.AutoSize = true;
|
||||
this.lblFilter.Location = new System.Drawing.Point(13, 22);
|
||||
this.lblFilter.Name = "lblFilter";
|
||||
this.lblFilter.Size = new System.Drawing.Size(39, 17);
|
||||
this.lblFilter.TabIndex = 1;
|
||||
this.lblFilter.Text = "Filter";
|
||||
//
|
||||
// dtpFrom
|
||||
//
|
||||
this.dtpFrom.Format = System.Windows.Forms.DateTimePickerFormat.Short;
|
||||
this.dtpFrom.Location = new System.Drawing.Point(13, 177);
|
||||
this.dtpFrom.MaxDate = new System.DateTime(2021, 2, 3, 12, 52, 11, 370);
|
||||
this.dtpFrom.Name = "dtpFrom";
|
||||
this.dtpFrom.Size = new System.Drawing.Size(121, 22);
|
||||
this.dtpFrom.TabIndex = 2;
|
||||
this.dtpFrom.Value = new System.DateTime(2021, 2, 3, 12, 52, 11, 370);
|
||||
this.dtpFrom.CloseUp += new System.EventHandler(this.dtpFrom_CloseUp);
|
||||
this.dtpFrom.DropDown += new System.EventHandler(this.dtpFrom_DropDown);
|
||||
//
|
||||
// dtpTo
|
||||
//
|
||||
this.dtpTo.Format = System.Windows.Forms.DateTimePickerFormat.Short;
|
||||
this.dtpTo.Location = new System.Drawing.Point(12, 257);
|
||||
this.dtpTo.MaxDate = new System.DateTime(2021, 2, 3, 12, 52, 11, 383);
|
||||
this.dtpTo.MinDate = this.dtpFrom.Value;
|
||||
this.dtpTo.Name = "dtpTo";
|
||||
this.dtpTo.Size = new System.Drawing.Size(121, 22);
|
||||
this.dtpTo.TabIndex = 3;
|
||||
this.dtpTo.Value = new System.DateTime(2021, 2, 3, 12, 52, 11, 383);
|
||||
//
|
||||
// lblFrom
|
||||
//
|
||||
this.lblFrom.AutoSize = true;
|
||||
this.lblFrom.Location = new System.Drawing.Point(12, 154);
|
||||
this.lblFrom.Name = "lblFrom";
|
||||
this.lblFrom.Size = new System.Drawing.Size(40, 17);
|
||||
this.lblFrom.TabIndex = 4;
|
||||
this.lblFrom.Text = "From";
|
||||
//
|
||||
// lblTo
|
||||
//
|
||||
this.lblTo.AutoSize = true;
|
||||
this.lblTo.Location = new System.Drawing.Point(12, 234);
|
||||
this.lblTo.Name = "lblTo";
|
||||
this.lblTo.Size = new System.Drawing.Size(25, 17);
|
||||
this.lblTo.TabIndex = 5;
|
||||
this.lblTo.Text = "To";
|
||||
//
|
||||
// dgvReports
|
||||
//
|
||||
this.dgvReports.AllowUserToAddRows = false;
|
||||
this.dgvReports.AllowUserToDeleteRows = false;
|
||||
this.dgvReports.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dgvReports.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ChildDisplayName});
|
||||
this.dgvReports.Location = new System.Drawing.Point(204, 39);
|
||||
this.dgvReports.Name = "dgvReports";
|
||||
this.dgvReports.ReadOnly = true;
|
||||
this.dgvReports.RowHeadersWidth = 51;
|
||||
this.dgvReports.RowTemplate.Height = 24;
|
||||
this.dgvReports.Size = new System.Drawing.Size(565, 367);
|
||||
this.dgvReports.TabIndex = 6;
|
||||
//
|
||||
// ChildDisplayName
|
||||
//
|
||||
this.ChildDisplayName.HeaderText = "Child";
|
||||
this.ChildDisplayName.MinimumWidth = 6;
|
||||
this.ChildDisplayName.Name = "ChildDisplayName";
|
||||
this.ChildDisplayName.ReadOnly = true;
|
||||
this.ChildDisplayName.Width = 125;
|
||||
//
|
||||
// frmReports
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.dgvReports);
|
||||
this.Controls.Add(this.lblTo);
|
||||
this.Controls.Add(this.lblFrom);
|
||||
this.Controls.Add(this.dtpTo);
|
||||
this.Controls.Add(this.dtpFrom);
|
||||
this.Controls.Add(this.lblFilter);
|
||||
this.Controls.Add(this.cbChildPicker);
|
||||
this.Name = "frmReports";
|
||||
this.Text = "Reports : Great Home Childcare";
|
||||
this.Load += new System.EventHandler(this.frmReports_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvReports)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ComboBox cbChildPicker;
|
||||
private System.Windows.Forms.Label lblFilter;
|
||||
private System.Windows.Forms.DateTimePicker dtpFrom;
|
||||
private System.Windows.Forms.DateTimePicker dtpTo;
|
||||
private System.Windows.Forms.Label lblFrom;
|
||||
private System.Windows.Forms.Label lblTo;
|
||||
private System.Windows.Forms.DataGridView dgvReports;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn ChildDisplayName;
|
||||
}
|
||||
}
|
110
frmReports.cs
Normal file
110
frmReports.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using GreatHomeChildcare.Models;
|
||||
|
||||
//REF:
|
||||
//https://stackoverflow.com/questions/9780800/what-event-is-raised-when-a-user-interacts-with-the-datetimepicker-control
|
||||
|
||||
namespace GreatHomeChildcare
|
||||
{
|
||||
public partial class frmReports : Form
|
||||
{
|
||||
//globals for cheap access.
|
||||
SqliteDataAccess SqliteDataAccess = new SqliteDataAccess();
|
||||
List<Child> AllChildren = new List<Child>();
|
||||
|
||||
public frmReports()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void frmReports_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadFilterComboBox();
|
||||
RefreshReportDgv();
|
||||
}
|
||||
|
||||
private void LoadFilterComboBox()
|
||||
{
|
||||
Child everyoneSelection = new Child();
|
||||
|
||||
/* cheap hack since you can't add an item to
|
||||
* a combobox that has existing databinding.
|
||||
*/
|
||||
everyoneSelection.id = 0;
|
||||
everyoneSelection.DisplayName = "Everyone";
|
||||
|
||||
AllChildren = SqliteDataAccess.GetAllChildren();
|
||||
AllChildren.Insert(0, everyoneSelection);
|
||||
|
||||
cbChildPicker.DataSource = AllChildren;
|
||||
}
|
||||
|
||||
/* Updates the on-screen display datagridview
|
||||
* upon selecting a new child from the drop-down box.
|
||||
*/
|
||||
private void cbChildPicker_SelectionChangeCommitted(object sender, EventArgs e)
|
||||
{
|
||||
RefreshReportDgv();
|
||||
}
|
||||
|
||||
//DTP shenanigans ref stackexchange
|
||||
private void dtpFrom_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
//Update the to date, but not before the From date.
|
||||
dtpTo.MinDate = dtpFrom.Value;
|
||||
}
|
||||
|
||||
private void dtpFrom_DropDown(object sender, EventArgs e)
|
||||
{
|
||||
dtpFrom.ValueChanged -= dtpFrom_ValueChanged;
|
||||
}
|
||||
|
||||
private void dtpFrom_CloseUp(object sender, EventArgs e)
|
||||
{
|
||||
dtpFrom.ValueChanged += dtpFrom_ValueChanged;
|
||||
dtpFrom_ValueChanged(sender, e);
|
||||
}
|
||||
|
||||
//Refresh the datagrid view.
|
||||
private void RefreshReportDgv()
|
||||
{
|
||||
dgvReports.Rows.Clear();
|
||||
|
||||
//First do the everyone case.
|
||||
if(cbChildPicker.Text == "Everyone")
|
||||
{
|
||||
foreach(DateTime day in EachDay(dtpFrom.Value,dtpTo.Value))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else //load an individual child
|
||||
{
|
||||
Child child = (Child)cbChildPicker.SelectedItem;
|
||||
AttendenceSingleInOutData in_data = new AttendenceSingleInOutData();
|
||||
AttendenceSingleInOutData out_data = new AttendenceSingleInOutData();
|
||||
|
||||
foreach (DateTime day in EachDay(dtpFrom.Value, dtpTo.Value))
|
||||
{
|
||||
in_data = SqliteDataAccess.GetAttendenceByStatusForChildByDay(child, "in", day.ToString("yyyy-MM-dd"));
|
||||
out_data = SqliteDataAccess.GetAttendenceByStatusForChildByDay(child, "out",day.ToString("yyyy-MM-dd"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//https://stackoverflow.com/questions/1847580/how-do-i-loop-through-a-date-range
|
||||
public IEnumerable<DateTime> EachDay(DateTime from, DateTime thru)
|
||||
{
|
||||
for (var day = from.Date; day.Date <= thru.Date; day = day.AddDays(1))
|
||||
yield return day;
|
||||
}
|
||||
}
|
||||
}
|
126
frmReports.resx
Normal file
126
frmReports.resx
Normal file
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ChildDisplayName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ChildDisplayName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user