//Insert new incidents
        public int insert_Incident(byte areaID, Int16 locationID, DateTime dateOccured, TimeSpan timeOccured, byte incidentTypeID, string otherTypeDescription, string description, string incidentNumber, byte userID, byte shiftID, string actionTaken)
        {
            int incidentID = 0;

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Insert transaction
                        EDM.tbl_Op_Incidents a = new EDM.tbl_Op_Incidents();
                        {
                            a.AreaID               = areaID;
                            a.LocationID           = locationID;
                            a.DateOccured          = dateOccured;
                            a.TimeOccured          = timeOccured;
                            a.IncidentTypeID       = incidentTypeID;
                            a.OtherTypeDescription = otherTypeDescription.Length > 0 ? firstCharToUpper(otherTypeDescription) : null;
                            a.Description          = description.Length > 0 ? firstCharToUpper(description) : null;
                            a.ActionTaken          = actionTaken.Length > 0 ? firstCharToUpper(actionTaken) : null;
                            a.IncidentNumber       = incidentNumber;
                            a.ShiftID              = shiftID == 0 ? null : (byte?)shiftID;
                            a.CreatedBy            = userID;
                            a.CreatedOn            = DateTime.Now;
                        };
                        model.tbl_Op_Incidents.Add(a);
                        model.SaveChanges();

                        //Get the incidentID
                        incidentID = (from b in model.tbl_Op_Incidents
                                      where b.IncidentNumber == incidentNumber
                                      select b.IncidentID
                                      ).FirstOrDefault();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = incidentID;
                            z.TableName    = "tbl_Op_Incidents";
                            z.AuditProcess = "Created Incident Report - " + incidentNumber;
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                incidentID       = 0;
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
            return(incidentID);
        }
Ejemplo n.º 2
0
        public void insert_Shift(byte positionID, TimeSpan fromTime, TimeSpan toTime, string shiftName, string hrsInShift, bool isActive, byte userID)
        {
            int shiftID = 0;

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Insert header
                        EDM.tbl_Ref_Shifts a = new EDM.tbl_Ref_Shifts();
                        {
                            a.PositionID   = positionID;
                            a.FromTime     = fromTime;
                            a.ToTime       = toTime;
                            a.HoursInShift = hrsInShift;
                            a.IsActive     = isActive;
                            a.CreatedBy    = userID;
                            a.CreatedOn    = DateTime.Now;
                        };
                        model.tbl_Ref_Shifts.Add(a);
                        model.SaveChanges();

                        //Get the id
                        shiftID = a.ShiftID;
                        if (shiftID != 0)
                        {
                            //Insert AuditTrail
                            EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                            {
                                z.SourceID     = shiftID;
                                z.TableName    = "tbl_Ref_Shifts";
                                z.AuditProcess = "Created Shift (" + shiftName + ")";
                                z.DateTime     = DateTime.Now;
                                z.UserID       = userID;
                            };
                            model.tbl_AuditLog.Add(z);
                            model.SaveChanges();
                        }
                        else
                        {
                            successfulCommit = false;
                            MISC.writetoAlertLog("No Shift ID returned after insert!!");
                        }
                    }
                    if (shiftID != 0)
                    {
                        //commit transaction
                        ts.Complete();
                        successfulCommit = true;
                    }
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
Ejemplo n.º 3
0
        public void insert_Location(byte areaID, string location, bool isActive, byte userID)
        {
            int locationID = 0;

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Insert header
                        EDM.tbl_Ref_Locations a = new EDM.tbl_Ref_Locations();
                        {
                            a.AreaID       = areaID;
                            a.LocationName = firstCharToUpper(location);
                            a.IsActive     = isActive;
                            a.CreatedBy    = userID;
                            a.CreatedOn    = DateTime.Now;
                        };
                        model.tbl_Ref_Locations.Add(a);
                        model.SaveChanges();

                        //Get the id
                        locationID = a.LocationID;
                        if (locationID != 0)
                        {
                            //Insert AuditTrail
                            EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                            {
                                z.SourceID     = locationID;
                                z.TableName    = "tbl_Ref_Locations";
                                z.AuditProcess = "Created Location (" + location + ")";
                                z.DateTime     = DateTime.Now;
                                z.UserID       = userID;
                            };
                            model.tbl_AuditLog.Add(z);
                            model.SaveChanges();
                        }
                        else
                        {
                            successfulCommit = false;
                            MISC.writetoAlertLog("No location ID returned after insert!!");
                        }
                    }
                    if (locationID != 0)
                    {
                        //commit transaction
                        ts.Complete();
                        successfulCommit = true;
                    }
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
Ejemplo n.º 4
0
        public void insert_Grant(DateTime dtDateFrom, DateTime dtDateTo, string comments, byte userID)
        {
            int grantID = 0;

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        EDM.tbl_Mgr_DateTimeGrant a = new EDM.tbl_Mgr_DateTimeGrant();
                        {
                            a.DateTimeFrom = dtDateFrom;
                            a.DateTimeTo   = dtDateTo;
                            a.Comments     = comments;
                            a.CreatedBy    = userID;
                            a.CreatedOn    = DateTime.Now;
                        };
                        model.tbl_Mgr_DateTimeGrant.Add(a);
                        model.SaveChanges();

                        //Get the id
                        grantID = a.GrantID;
                        if (grantID != 0)
                        {
                            //Insert AuditTrail
                            EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                            {
                                z.SourceID     = grantID;
                                z.TableName    = "tbl_Mgr_DateTimeGrant";
                                z.AuditProcess = "Created Date/Time Grant for period " + dtDateFrom + " to " + dtDateTo + ")";
                                z.DateTime     = DateTime.Now;
                                z.UserID       = userID;
                            };
                            model.tbl_AuditLog.Add(z);
                            model.SaveChanges();
                        }
                        else
                        {
                            successfulCommit = false;
                            MISC.writetoAlertLog("No grant ID returned after insert!!");
                        }
                    }
                    if (grantID != 0)
                    {
                        //commit transaction
                        ts.Complete();
                        successfulCommit = true;
                    }
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
Ejemplo n.º 5
0
        //Update complaint
        public void update_Absence(int callInOffID, bool isCallIn, Int16 employeeID, DateTime date, TimeSpan time, Int16 callTakenByID, Int16 callForwardedToID, string workSchedule, string phoneNumber, byte absentType, string otherTypeDescription, byte sickLeaveForID, string otherSickLeaveForDescription, string comments, byte userID, string reportNumber, DateTime startDate, DateTime endDate)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Get the record to update
                        var recordToUpdate = (from a in model.tbl_Op_CallIn_Absent
                                              where a.CallInOffID == callInOffID
                                              select a).First();
                        recordToUpdate.IsCallIn                         = isCallIn;
                        recordToUpdate.EmployeeID                       = employeeID;
                        recordToUpdate.Date                             = date;
                        recordToUpdate.Time                             = time;
                        recordToUpdate.CallTakenByID                    = callTakenByID == 0 ? null : (Int16?)callTakenByID;
                        recordToUpdate.ForwardedToID                    = callForwardedToID == 0 ? null : (Int16?)callForwardedToID;
                        recordToUpdate.WorkSchedule                     = workSchedule == "" ? null : firstCharToUpper(workSchedule);
                        recordToUpdate.PhoneNumber                      = phoneNumber == "" ? null : phoneNumber;
                        recordToUpdate.AbsentTypeID                     = absentType;
                        recordToUpdate.OtherTypeDescription             = otherTypeDescription == "" ? null : firstCharToUpper(otherTypeDescription);
                        recordToUpdate.SickLeaveForID                   = sickLeaveForID == 0 ? null : (byte?)sickLeaveForID;
                        recordToUpdate.OtherSickLeaveForTypeDescription = otherSickLeaveForDescription == "" ? null : firstCharToUpper(otherSickLeaveForDescription);
                        recordToUpdate.Comments                         = comments == "" ? null : firstCharToUpper(comments);
                        recordToUpdate.StartDate                        = startDate.Date;
                        recordToUpdate.EndDate                          = endDate.Date;
                        //recordToUpdate.ShiftID = shiftID;
                        recordToUpdate.LastModifiedBy = userID;
                        recordToUpdate.LastModifiedOn = DateTime.Now;
                        model.SaveChanges();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = callInOffID;
                            z.TableName    = "tbl_Op_CallIn_Absent";
                            z.AuditProcess = "Modified Call In/Absent Report - " + reportNumber;
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
        public void update_dailyPostAssignment(int postAssignmentID, DateTime date, byte shiftID, Int16 lateArrivals, Int16 callsForAssistance, Int16 officersPresent, Int16 officersAbsent, Int16 officersAssigned, Int16 officersCalledOut, Int16 officersCallInForDayOff, Int16 officersOnDayOff, Int16 notDressedProperly, string shiftSummary, string shiftBriefingNotes, string PassedOnFrom, string passedOnTo, string summaryOfIncidents, string reportNumber, byte userID, Int16 sleeping)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Update header table
                        var dl = (from a in model.tbl_Sup_DailyPostAssignment
                                  where a.PostAssignmentID == postAssignmentID
                                  select a).First();
                        dl.LateArrivals            = lateArrivals;
                        dl.CallsForAssistance      = callsForAssistance;
                        dl.OfficersPresent         = officersPresent;
                        dl.OfficersAbsent          = officersAbsent;
                        dl.OfficersAssigned        = officersAssigned;
                        dl.OfficersCalledOut       = officersCalledOut;
                        dl.OfficersCallInForDayOff = officersCallInForDayOff;
                        dl.OfficersOnDayOff        = officersOnDayOff;
                        dl.NotDressedProperly      = notDressedProperly;
                        dl.ShiftSummary            = shiftSummary;
                        dl.ShiftBriefingNotes      = shiftBriefingNotes;
                        dl.PassedOnFrom            = PassedOnFrom;
                        dl.PassedOnTo         = passedOnTo;
                        dl.SummaryOfIncidents = summaryOfIncidents;
                        dl.ReportNumber       = reportNumber;
                        dl.Sleeping           = sleeping;
                        dl.LastModifiedBy     = userID;
                        dl.LastModifiedOn     = DateTime.Now;
                        model.SaveChanges();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog x = new EDM.tbl_AuditLog();
                        {
                            x.SourceID     = postAssignmentID;
                            x.TableName    = "tbl_Sup_DailyPostAssignment";
                            x.AuditProcess = "Modified Daily Post Assignment " + reportNumber;
                            x.DateTime     = DateTime.Now;
                            x.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(x);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
Ejemplo n.º 7
0
        //Update complaint
        public void update_Complaint(int complaintID, byte complaintChannelID, string personMakingReport, string contactNumber, byte areaID, Int16 locationID, DateTime dateOfIncident, TimeSpan timeofIncident, Int16 receivedByID, DateTime dateReceived, byte acknowledgementID, string clientcomplaint, bool feedbackProvided, DateTime dateOfFeedback, string actionTaken, byte userID, string complaintNumber, byte shiftID)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Get the record to update
                        var recordToUpdate = (from a in model.tbl_Op_Complaints
                                              where a.ComplaintID == complaintID
                                              select a).First();
                        recordToUpdate.ComplaintChannelID = complaintChannelID;
                        recordToUpdate.DateOfIncident     = dateOfIncident;
                        recordToUpdate.TimeOfIncident     = timeofIncident;
                        recordToUpdate.AreaID             = areaID;
                        recordToUpdate.LocationID         = locationID;
                        recordToUpdate.PersonMakingReport = firstCharToUpper(personMakingReport);
                        recordToUpdate.ContactNumber      = contactNumber.Length > 0 ? contactNumber : null;
                        recordToUpdate.ReceivedByID       = receivedByID;
                        recordToUpdate.DateReceived       = dateReceived;
                        recordToUpdate.ShiftID            = shiftID;
                        recordToUpdate.AcknowledgementID  = acknowledgementID == 0 ? null : (byte?)acknowledgementID;
                        recordToUpdate.ClientComplaint    = clientcomplaint.Length > 0 ? firstCharToUpper(clientcomplaint) : null;
                        recordToUpdate.FeedbackProvided   = feedbackProvided;
                        recordToUpdate.DateOfFeedback     = dateOfFeedback.ToString() == "1/1/0001 12:00:00 AM" ? null : (DateTime?)dateOfFeedback;
                        recordToUpdate.ActionTaken        = actionTaken.Length > 0 ? firstCharToUpper(actionTaken) : null;
                        recordToUpdate.LastModifiedBy     = userID;
                        recordToUpdate.LastModifiedOn     = DateTime.Now;
                        model.SaveChanges();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = complaintID;
                            z.TableName    = "tbl_Op_Complaints";
                            z.AuditProcess = "Modified Complaint Report - " + complaintNumber;
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
        public void insert_IncidentPersonAffected(byte affectedTypeID, string firstName, string lastName, string description, string address, string otherTypeDescription, int incidentID, string phoneNumber, byte userID)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Insert transaction
                        EDM.tbl_Op_IncidentPersonsAffected a = new EDM.tbl_Op_IncidentPersonsAffected();
                        {
                            a.AffectedTypeID       = affectedTypeID;
                            a.FirstName            = firstName.Length > 0 ? firstCharToUpper(firstName) : null;
                            a.LastName             = firstCharToUpper(lastName);
                            a.Description          = firstCharToUpper(description);
                            a.Address              = address.Length > 0 ? firstCharToUpper(address) : null;
                            a.OtherTypeDescription = otherTypeDescription.Length > 0 ? firstCharToUpper(otherTypeDescription) : null;
                            a.IncidentID           = incidentID;
                            a.PhoneNumber          = phoneNumber.Length > 0 ? phoneNumber : null;
                            a.CreatedBy            = userID;
                            a.CreatedOn            = DateTime.Now;
                        };
                        model.tbl_Op_IncidentPersonsAffected.Add(a);
                        model.SaveChanges();

                        //Get the incidentID
                        string incidentNumber = (from b in model.tbl_Op_Incidents
                                                 where b.IncidentID == incidentID
                                                 select b.IncidentNumber
                                                 ).FirstOrDefault();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = incidentID;
                            z.TableName    = "tbl_Op_IncidentPersonsAffected";
                            z.AuditProcess = "Created Person Affected - " + incidentNumber;
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
Ejemplo n.º 9
0
        //insert doubles
        public void insert_double(int dailyLogID, Int16 employeeID, DateTime date, string areaName, string locationName, string shiftTime, byte userID, string logNumber)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Update header table
                        var dl = (from t in model.tbl_Op_DailyLogs
                                  where t.DailyLogID == dailyLogID
                                  select t).First();
                        dl.LastModifiedBy = userID;
                        dl.LastModifiedOn = DateTime.Now;
                        model.SaveChanges();

                        //Insert doubles
                        EDM.tbl_Op_DailyLogsPersonWorking a = new EDM.tbl_Op_DailyLogsPersonWorking();
                        {
                            a.DailyLogID  = dailyLogID;
                            a.EmployeeID  = employeeID;
                            a.IsPresent   = true;
                            a.TimeClocked = DateTime.Now;
                            a.IsDouble    = true;
                            a.IsSwitch    = false;
                            a.CreatedBy   = userID;
                            a.CreatedOn   = DateTime.Now;
                        };
                        model.tbl_Op_DailyLogsPersonWorking.Add(a);
                        model.SaveChanges();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = dailyLogID;
                            z.TableName    = "tbl_Op_DailyLogs";
                            z.AuditProcess = "Added Double to Daily Log (" + logNumber + ") " + date.Date.ToString("dd/MM/yyyy") + ", " + areaName + " - " + locationName + " -- " + shiftTime;
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
Ejemplo n.º 10
0
        //insert Call Log
        public void insert_CallLog(int dailyLogID, TimeSpan time, string reports, bool supCheckLocation, DateTime date, string areaName, string locationName, string shiftTime, byte userID, string logNumber)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Update header table
                        var dl = (from t in model.tbl_Op_DailyLogs
                                  where t.DailyLogID == dailyLogID
                                  select t).First();
                        dl.LastModifiedBy = userID;
                        dl.LastModifiedOn = DateTime.Now;
                        model.SaveChanges();

                        //Insert call log header
                        EDM.tbl_Op_DailyLogsCallLog a = new EDM.tbl_Op_DailyLogsCallLog();
                        {
                            a.DailyLogID       = dailyLogID;
                            a.Time             = time;
                            a.Reports          = reports;
                            a.SupCheckLocation = supCheckLocation;
                            a.CreatedBy        = userID;
                            a.CreatedOn        = DateTime.Now;
                        };
                        model.tbl_Op_DailyLogsCallLog.Add(a);
                        model.SaveChanges();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = dailyLogID;
                            z.TableName    = "tbl_Op_DailyLogs";
                            z.AuditProcess = "Created Call Log for Daily Log (" + logNumber + ") " + date.Date.ToString("dd/MM/yyyy") + ", " + areaName + " - " + locationName + " -- " + shiftTime;
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
        //Update employee
        public void update_Employee(Int16 employeeID, string firstName, string lastName, string otherName, DateTime dateHired, byte areaID, Int16 locationID, byte departmentID, byte positionID, byte shiftID, bool isStandbyEmployee, bool isActive, string employeeNumber, byte userID)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Get the record to update
                        var a = (from y in model.tbl_Sup_Employees
                                 where y.EmployeeID == employeeID
                                 select y).First();
                        a.FirstName      = firstName == "" ? null : firstCharToUpper(firstName);
                        a.LastName       = firstCharToUpper(lastName);
                        a.OtherName      = otherName == "" ? null : firstCharToUpper(otherName);
                        a.DateHired      = dateHired;
                        a.AreaID         = areaID == 0 ? null : (byte?)areaID;
                        a.LocationID     = locationID == 0 ? null : (Int16?)locationID;
                        a.DepartmentID   = departmentID == 0 ? null : (byte?)departmentID;
                        a.PositionID     = positionID == 0 ? null : (byte?)positionID;
                        a.ShiftID        = shiftID == 0 ? null : (byte?)shiftID;
                        a.IsStandbyStaff = isStandbyEmployee;
                        a.IsActive       = isActive;
                        a.EmployeeNumber = employeeNumber;
                        a.LastModifiedBy = userID;
                        a.LastModifiedOn = DateTime.Now;
                        model.SaveChanges();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = employeeID;
                            z.TableName    = "tbl_Sup_Employees";
                            z.AuditProcess = "Modified Employee Record - " + employeeNumber;
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
        //Update employee
        public void update_SO(int specialOperationsID, byte areaID, Int16 locationID, DateTime date, bool escortService, bool cashInGT, bool cashOutGT, bool extraOfficers, byte amountOfficers, string reportNumber, string comments, byte userID, byte shiftID)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Get the record to update
                        var a = (from y in model.tbl_Mgr_SpecialOperations
                                 where y.SpecialOperationsID == specialOperationsID
                                 select y).First();
                        a.AreaID         = areaID == 0 ? null : (byte?)areaID;
                        a.LocationID     = locationID == 0 ? null : (byte?)locationID;
                        a.Date           = date;
                        a.EscortService  = escortService;
                        a.CashInGT       = cashInGT;
                        a.CashOutGT      = cashOutGT;
                        a.ExtraOfficers  = extraOfficers;
                        a.AmountOfficers = amountOfficers == 0 ? null : (byte?)amountOfficers;
                        a.ReportNumber   = reportNumber;
                        a.Comments       = comments == "" ? null : comments;
                        a.ShiftID        = shiftID == 0 ? null : (byte?)shiftID;
                        a.LastModifiedBy = userID;
                        a.LastModifiedOn = DateTime.Now;
                        model.SaveChanges();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = specialOperationsID;
                            z.TableName    = "tbl_Mgr_SpecialOperations";
                            z.AuditProcess = "Modified Special Operations Log - " + reportNumber;
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
        public void update_Incident(int incidentID, byte areaID, Int16 locationID, DateTime dateOccured, TimeSpan timeOccured, byte incidentTypeID, string otherTypeDescription, string description, string incidentNumber, byte userID, byte shiftID, string actionTaken)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Get the record to update
                        var recordToUpdate = (from a in model.tbl_Op_Incidents
                                              where a.IncidentID == incidentID
                                              select a).First();
                        recordToUpdate.AreaID               = areaID;
                        recordToUpdate.LocationID           = locationID;
                        recordToUpdate.DateOccured          = dateOccured;
                        recordToUpdate.TimeOccured          = timeOccured;
                        recordToUpdate.IncidentTypeID       = incidentTypeID;
                        recordToUpdate.OtherTypeDescription = otherTypeDescription.Length > 0 ? firstCharToUpper(otherTypeDescription) : null;
                        recordToUpdate.Description          = firstCharToUpper(description);
                        recordToUpdate.ActionTaken          = firstCharToUpper(actionTaken);
                        recordToUpdate.IncidentNumber       = incidentNumber;
                        recordToUpdate.ShiftID              = shiftID == 0 ? null : (byte?)shiftID;
                        recordToUpdate.LastModifiedBy       = userID;
                        recordToUpdate.LastModifiedOn       = DateTime.Now;
                        model.SaveChanges();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = incidentID;
                            z.TableName    = "tbl_Op_Incidents";
                            z.AuditProcess = "Modified Incident Report - " + incidentNumber;
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
        //create employee link
        protected bool linkEmployee(short empID, bool resetneeded, bool status, byte UID, byte loggedIN)
        {
            bool success = false;

            var model = new EDM.DataSource();

            try
            {
                var query = (from a in model.tbl_Sup_Employees
                             where (a.EmployeeID == empID) &&
                             (a.UID == null)
                             select a).FirstOrDefault();
                query.UID            = UID;
                query.LastModifiedBy = loggedIN;
                query.LastModifiedOn = DateTime.Now;

                model.SaveChanges();
                success = true;
            }
            catch (Exception exec)
            {
                MISC.writetoAlertLog(exec.ToString());
                // ShowMessage("Something went wrong and the employee link could not be created. Kindly try again and if the error persists, refer to the error log for details.", MessageType.Error);
            }
            return(success);
        }
        //save user that is not an employee
        protected bool saveNonEmployee(string firstname, string lastname, bool resetneeded, bool status, byte UID)
        {
            bool success = false;

            using (EDM.DataSource model = new EDM.DataSource())
            {
                EDM.tbl_Sup_Employees a = new EDM.tbl_Sup_Employees()
                {
                    FirstName   = firstname,
                    LastName    = lastname,
                    IsActive    = status,
                    ResetNeeded = resetneeded,
                    UID         = UID,
                    IsEmployee  = false,
                    CreatedBy   = MISC.getUserID(),
                    CreatedOn   = DateTime.Now
                };
                model.tbl_Sup_Employees.Add(a);
                try
                {
                    model.SaveChanges();
                    success = true;
                }
                catch (Exception exec)
                {
                    MISC.writetoAlertLog(exec.ToString());
                    ShowMessage("Something went wrong and the user could not be created. Kindly try again and if the error persists, refer to the error log for details.", MessageType.Error);
                }
            }
            return(success);
        }
 //save audit log
 protected void AuditLog(int sourceID, string tableName, string AuditProcess, byte loggedInUser)
 {
     //Insert AuditTrail
     using (EDM.DataSource model = new EDM.DataSource())
     {
         EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
         {
             z.SourceID     = sourceID;
             z.TableName    = tableName;
             z.AuditProcess = AuditProcess;
             z.DateTime     = DateTime.Now;
             z.UserID       = loggedInUser;
         };
         model.tbl_AuditLog.Add(z);
         try
         {
             model.SaveChanges();
             //success = true;
         }
         catch (Exception exec)
         {
             MISC.writetoAlertLog(exec.ToString());
             ShowMessage("Something went wrong and the auditlog could not be created. Kindly try again and if the error persists, refer to the error log for details.", MessageType.Error);
         }
     }
 }
        protected bool updateEmployee(bool status, bool reset, string fname, string lname, short empId, byte loggedIN)
        {
            bool success = false;

            var model = new EDM.DataSource();

            try
            {
                var query = (from a in model.tbl_Sup_Employees
                             where (a.EmployeeID == empId)
                             select a).FirstOrDefault();
                if (query != null)
                {
                    query.FirstName      = fname;
                    query.LastName       = lname;
                    query.IsActive       = status;
                    query.ResetNeeded    = reset;
                    query.LastModifiedBy = loggedIN;
                    query.LastModifiedOn = DateTime.Now;

                    model.SaveChanges();
                    success = true;
                }
            }
            catch (Exception exec)
            {
                MISC.writetoAlertLog(exec.ToString());
            }
            return(success);
        }
        public void update_PersonAffected(int personAffectedID, byte affectedTypeID, string firstName, string lastName, string description, string address, string otherTypeDescription, string phoneNumber, byte userID, string incidentNumber, int incidentID)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Get the record to update
                        var recordToUpdate = (from a in model.tbl_Op_IncidentPersonsAffected
                                              where a.PersonAffectedID == personAffectedID
                                              select a).First();
                        recordToUpdate.AffectedTypeID       = affectedTypeID;
                        recordToUpdate.FirstName            = firstName.Length > 0 ? firstCharToUpper(firstName) : null;
                        recordToUpdate.LastName             = firstCharToUpper(lastName);
                        recordToUpdate.Description          = firstCharToUpper(description);
                        recordToUpdate.Address              = address.Length > 0 ? firstCharToUpper(address) : null;
                        recordToUpdate.PhoneNumber          = phoneNumber.Length > 0 ? phoneNumber : null;
                        recordToUpdate.OtherTypeDescription = otherTypeDescription.Length > 0 ? firstCharToUpper(otherTypeDescription) : null;
                        recordToUpdate.LastModifiedBy       = userID;
                        recordToUpdate.LastModifiedOn       = DateTime.Now;
                        model.SaveChanges();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = incidentID;
                            z.TableName    = "tbl_Op_Incidents";
                            z.AuditProcess = "Modified Person Affected - " + incidentNumber;
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
Ejemplo n.º 19
0
        public void update_Shift(byte shiftID, byte positionID, TimeSpan fromTime, TimeSpan toTime, string shiftName, string hrsInShift, bool isActive, byte userID)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        var record = (from a in model.tbl_Ref_Shifts
                                      where a.ShiftID == shiftID
                                      select a).First();
                        record.PositionID     = positionID;
                        record.FromTime       = fromTime;
                        record.ToTime         = toTime;
                        record.IsActive       = isActive;
                        record.HoursInShift   = hrsInShift;
                        record.LastModifiedBy = userID;
                        record.LastModifiedOn = DateTime.Now;
                        model.SaveChanges();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = shiftID;
                            z.TableName    = "tbl_Ref_Shifts";
                            z.AuditProcess = "Updated Shift (" + shiftName + ")";
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
Ejemplo n.º 20
0
        public void update_ShiftReport(int shiftReportID, byte areaID, byte shiftID, Int16 supervisorID, string reportNumber, byte userID)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Update header table
                        var dl = (from a in model.tbl_Sup_ShiftReport
                                  where a.ShiftReportID == shiftReportID
                                  select a).First();
                        dl.SupervisorID   = supervisorID;
                        dl.LastModifiedBy = userID;
                        dl.LastModifiedOn = DateTime.Now;
                        model.SaveChanges();


                        //Insert AuditTrail
                        EDM.tbl_AuditLog x = new EDM.tbl_AuditLog();
                        {
                            x.SourceID     = shiftReportID;
                            x.TableName    = "tbl_Sup_ShiftReport";
                            x.AuditProcess = "Modified Shift Report " + reportNumber;
                            x.DateTime     = DateTime.Now;
                            x.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(x);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
Ejemplo n.º 21
0
        public void update_Location(byte areaID, Int16 locationID, string Location, bool isActive, byte userID)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        var record = (from a in model.tbl_Ref_Locations
                                      where a.LocationID == locationID
                                      select a).First();
                        record.AreaID         = areaID;
                        record.LocationName   = firstCharToUpper(Location);
                        record.IsActive       = isActive;
                        record.LastModifiedBy = userID;
                        record.LastModifiedOn = DateTime.Now;
                        model.SaveChanges();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = locationID;
                            z.TableName    = "tbl_Ref_Locations";
                            z.AuditProcess = "Updated Location (" + Location + ")";
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
        public void employee_Delete(int employeeID)
        {
            var model = new EDM.DataSource();

            try
            {
                var emp = (from a in model.tbl_Sup_Employees
                           where a.EmployeeID == employeeID
                           select a).SingleOrDefault();

                if (emp != null)
                {
                    model.tbl_Sup_Employees.Remove(emp);
                    model.SaveChanges();
                    successfulCommit = true;
                }
            }
            catch (System.Exception excec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(excec.ToString());
            }
        }
        public void delete_Incident(int incidentID)
        {
            var model = new EDM.DataSource();

            try
            {
                var results = (from a in model.tbl_Op_Incidents
                               where a.IncidentID == incidentID
                               select a).SingleOrDefault();

                if (results != null)
                {
                    model.tbl_Op_Incidents.Remove(results);
                    model.SaveChanges();
                    successfulCommit = true;
                }
            }
            catch (System.Exception excec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(excec.ToString());
            }
        }
        public void update_WeeklySecurityReport(int securityReportID, string reportNumber, DateTime weekStart, DateTime weekEnd, byte areaID, string comments, GridView gvShiftReport, byte userID)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Update header table
                        var wsr = (from a in model.tbl_Mgr_WeeklySecurityReport
                                   where a.SecurityReportID == securityReportID
                                   select a).First();
                        wsr.WeekStart      = weekStart;
                        wsr.WeekEnd        = weekEnd;
                        wsr.Comments       = comments;
                        wsr.LastModifiedBy = userID;
                        wsr.LastModifiedOn = DateTime.Now;
                        model.SaveChanges();

                        ////Delete all shifts saved
                        //for (int j = 0; j < gvShiftReport.Rows.Count; j++)
                        //{
                        //    Label lblShiftID = (Label)gvShiftReport.Rows[j].FindControl("lblShiftID");
                        //    Label lblType = (Label)gvShiftReport.Rows[j].FindControl("lblType");
                        //    bool isScheduled = lblType.Text == "Scheduled" ? true : false;
                        //    byte shiftID = Convert.ToByte(lblShiftID.Text);
                        //    var wsrc = (from f in model.tbl_Mgr_WeeklySecurityReportComparison
                        //                where f.SecurityReportID == securityReportID &&  f.ShiftID == shiftID && f.IsScheduled == isScheduled
                        //                select f).SingleOrDefault();

                        //    if (wsrc != null)
                        //    {
                        //        model.tbl_Mgr_WeeklySecurityReportComparison.Remove(wsrc);
                        //        model.SaveChanges();
                        //        successfulCommit = true;
                        //    }
                        //}

                        for (int i = 0; i < gvShiftReport.Rows.Count; i++)
                        {
                            Label lblShiftID      = (Label)gvShiftReport.Rows[i].FindControl("lblShiftID");
                            Label lblType         = (Label)gvShiftReport.Rows[i].FindControl("lblType");
                            Label lblComparisonID = (Label)gvShiftReport.Rows[i].FindControl("lblComparisonID");

                            //Update shift if it has an ID
                            if (lblComparisonID.Text != "0")
                            {
                                Int32 comparisonID = Convert.ToInt32(lblComparisonID.Text);

                                //insert shift comparison data
                                if (lblType.Text == "Scheduled")
                                {
                                    Label lblCashInGT            = (Label)gvShiftReport.Rows[i].FindControl("lblCashInGT");
                                    Label lblCashOutGT           = (Label)gvShiftReport.Rows[i].FindControl("lblCashOutGT");
                                    Label lblOther               = (Label)gvShiftReport.Rows[i].FindControl("lblOther");
                                    Label lblMonday              = (Label)gvShiftReport.Rows[i].FindControl("lblMonday");
                                    Label lblTuesday             = (Label)gvShiftReport.Rows[i].FindControl("lblTuesday");
                                    Label lblWednesday           = (Label)gvShiftReport.Rows[i].FindControl("lblWednesday");
                                    Label lblThursday            = (Label)gvShiftReport.Rows[i].FindControl("lblThursday");
                                    Label lblFriday              = (Label)gvShiftReport.Rows[i].FindControl("lblFriday");
                                    Label lblSaturday            = (Label)gvShiftReport.Rows[i].FindControl("lblSaturday");
                                    Label lblSunday              = (Label)gvShiftReport.Rows[i].FindControl("lblSunday");
                                    Label lblPresent             = (Label)gvShiftReport.Rows[i].FindControl("lblPresent");
                                    Label lblAbsent              = (Label)gvShiftReport.Rows[i].FindControl("lblAbsent");
                                    Label lblIncidentsComplaints = (Label)gvShiftReport.Rows[i].FindControl("lblIncidentsComplaints");
                                    Label lblSwitches            = (Label)gvShiftReport.Rows[i].FindControl("lblSwitches");


                                    var shi = (from h in model.tbl_Mgr_WeeklySecurityReportComparison
                                               where h.ComparisonID == comparisonID
                                               select h).First();
                                    shi.CashInGT           = lblCashInGT.Text;
                                    shi.CashOutGT          = lblCashOutGT.Text;
                                    shi.Other              = lblOther.Text;
                                    shi.Monday             = lblMonday.Text;
                                    shi.Tuesday            = lblTuesday.Text;
                                    shi.Wednesday          = lblWednesday.Text;
                                    shi.Thursday           = lblThursday.Text;
                                    shi.Friday             = lblFriday.Text;
                                    shi.Saturday           = lblSaturday.Text;
                                    shi.Sunday             = lblSunday.Text;
                                    shi.Present            = lblPresent.Text;
                                    shi.Absent             = lblAbsent.Text;
                                    shi.IncidentComplaints = lblIncidentsComplaints.Text;
                                    shi.Switches           = lblSwitches.Text;
                                    shi.LastModifiedBy     = userID;
                                    shi.LastModifiedOn     = DateTime.Now;
                                    model.SaveChanges();
                                }
                                else if (lblType.Text == "Actual")
                                {
                                    Label   lblCashInGT           = (Label)gvShiftReport.Rows[i].FindControl("lblCashInGT");
                                    Label   lblCashOutGT          = (Label)gvShiftReport.Rows[i].FindControl("lblCashOutGT");
                                    Label   lblOther              = (Label)gvShiftReport.Rows[i].FindControl("lblOther");
                                    TextBox tbMonday              = (TextBox)gvShiftReport.Rows[i].FindControl("tbMonday");
                                    TextBox tbTuesday             = (TextBox)gvShiftReport.Rows[i].FindControl("tbTuesday");
                                    TextBox tbWednesday           = (TextBox)gvShiftReport.Rows[i].FindControl("tbWednesday");
                                    TextBox tbThursday            = (TextBox)gvShiftReport.Rows[i].FindControl("tbThursday");
                                    TextBox tbFriday              = (TextBox)gvShiftReport.Rows[i].FindControl("tbFriday");
                                    TextBox tbSaturday            = (TextBox)gvShiftReport.Rows[i].FindControl("tbSaturday");
                                    TextBox tbSunday              = (TextBox)gvShiftReport.Rows[i].FindControl("tbSunday");
                                    TextBox tbPresent             = (TextBox)gvShiftReport.Rows[i].FindControl("tbPresent");
                                    TextBox tbAbsent              = (TextBox)gvShiftReport.Rows[i].FindControl("tbAbsent");
                                    TextBox tbIncidentsComplaints = (TextBox)gvShiftReport.Rows[i].FindControl("tbIncidentsComplaints");
                                    TextBox tbSwitches            = (TextBox)gvShiftReport.Rows[i].FindControl("tbSwitches");

                                    var shi = (from h in model.tbl_Mgr_WeeklySecurityReportComparison
                                               where h.ComparisonID == comparisonID
                                               select h).First();
                                    shi.CashInGT           = lblCashInGT.Text;
                                    shi.CashOutGT          = lblCashOutGT.Text;
                                    shi.Other              = lblOther.Text;
                                    shi.Monday             = tbMonday.Text;
                                    shi.Tuesday            = tbTuesday.Text;
                                    shi.Wednesday          = tbWednesday.Text;
                                    shi.Thursday           = tbThursday.Text;
                                    shi.Friday             = tbFriday.Text;
                                    shi.Saturday           = tbSaturday.Text;
                                    shi.Sunday             = tbSunday.Text;
                                    shi.Present            = tbPresent.Text;
                                    shi.Absent             = tbAbsent.Text;
                                    shi.IncidentComplaints = tbIncidentsComplaints.Text;
                                    shi.Switches           = tbSwitches.Text;
                                    shi.LastModifiedBy     = userID;
                                    shi.LastModifiedOn     = DateTime.Now;
                                    model.SaveChanges();
                                }
                            }
                            //insert shift comparison data
                            else
                            {
                                if (lblType.Text == "Scheduled")
                                {
                                    Label lblCashInGT            = (Label)gvShiftReport.Rows[i].FindControl("lblCashInGT");
                                    Label lblCashOutGT           = (Label)gvShiftReport.Rows[i].FindControl("lblCashOutGT");
                                    Label lblOther               = (Label)gvShiftReport.Rows[i].FindControl("lblOther");
                                    Label lblMonday              = (Label)gvShiftReport.Rows[i].FindControl("lblMonday");
                                    Label lblTuesday             = (Label)gvShiftReport.Rows[i].FindControl("lblTuesday");
                                    Label lblWednesday           = (Label)gvShiftReport.Rows[i].FindControl("lblWednesday");
                                    Label lblThursday            = (Label)gvShiftReport.Rows[i].FindControl("lblThursday");
                                    Label lblFriday              = (Label)gvShiftReport.Rows[i].FindControl("lblFriday");
                                    Label lblSaturday            = (Label)gvShiftReport.Rows[i].FindControl("lblSaturday");
                                    Label lblSunday              = (Label)gvShiftReport.Rows[i].FindControl("lblSunday");
                                    Label lblPresent             = (Label)gvShiftReport.Rows[i].FindControl("lblPresent");
                                    Label lblAbsent              = (Label)gvShiftReport.Rows[i].FindControl("lblAbsent");
                                    Label lblIncidentsComplaints = (Label)gvShiftReport.Rows[i].FindControl("lblIncidentsComplaints");
                                    Label lblSwitches            = (Label)gvShiftReport.Rows[i].FindControl("lblSwitches");

                                    EDM.tbl_Mgr_WeeklySecurityReportComparison b = new EDM.tbl_Mgr_WeeklySecurityReportComparison();
                                    {
                                        b.ShiftID            = Convert.ToByte(lblShiftID.Text);
                                        b.SecurityReportID   = securityReportID;
                                        b.CashInGT           = lblCashInGT.Text;
                                        b.CashOutGT          = lblCashOutGT.Text;
                                        b.Other              = lblOther.Text;
                                        b.Monday             = lblMonday.Text;
                                        b.Tuesday            = lblTuesday.Text;
                                        b.Wednesday          = lblWednesday.Text;
                                        b.Thursday           = lblThursday.Text;
                                        b.Friday             = lblFriday.Text;
                                        b.Saturday           = lblSaturday.Text;
                                        b.Sunday             = lblSunday.Text;
                                        b.Present            = lblPresent.Text;
                                        b.Absent             = lblAbsent.Text;
                                        b.IncidentComplaints = lblIncidentsComplaints.Text;
                                        b.Switches           = lblSwitches.Text;
                                        b.IsScheduled        = true;
                                        b.CreatedBy          = userID;
                                        b.CreatedOn          = DateTime.Now;
                                    };
                                    model.tbl_Mgr_WeeklySecurityReportComparison.Add(b);
                                    model.SaveChanges();
                                }
                                else if (lblType.Text == "Actual")
                                {
                                    Label   lblCashInGT           = (Label)gvShiftReport.Rows[i].FindControl("lblCashInGT");
                                    Label   lblCashOutGT          = (Label)gvShiftReport.Rows[i].FindControl("lblCashOutGT");
                                    Label   lblOther              = (Label)gvShiftReport.Rows[i].FindControl("lblOther");
                                    TextBox tbMonday              = (TextBox)gvShiftReport.Rows[i].FindControl("tbMonday");
                                    TextBox tbTuesday             = (TextBox)gvShiftReport.Rows[i].FindControl("tbTuesday");
                                    TextBox tbWednesday           = (TextBox)gvShiftReport.Rows[i].FindControl("tbWednesday");
                                    TextBox tbThursday            = (TextBox)gvShiftReport.Rows[i].FindControl("tbThursday");
                                    TextBox tbFriday              = (TextBox)gvShiftReport.Rows[i].FindControl("tbFriday");
                                    TextBox tbSaturday            = (TextBox)gvShiftReport.Rows[i].FindControl("tbSaturday");
                                    TextBox tbSunday              = (TextBox)gvShiftReport.Rows[i].FindControl("tbSunday");
                                    TextBox tbPresent             = (TextBox)gvShiftReport.Rows[i].FindControl("tbPresent");
                                    TextBox tbAbsent              = (TextBox)gvShiftReport.Rows[i].FindControl("tbAbsent");
                                    TextBox tbIncidentsComplaints = (TextBox)gvShiftReport.Rows[i].FindControl("tbIncidentsComplaints");
                                    TextBox tbSwitches            = (TextBox)gvShiftReport.Rows[i].FindControl("tbSwitches");

                                    //insert shift comparison data
                                    EDM.tbl_Mgr_WeeklySecurityReportComparison b = new EDM.tbl_Mgr_WeeklySecurityReportComparison();
                                    {
                                        b.ShiftID            = Convert.ToByte(lblShiftID.Text);
                                        b.SecurityReportID   = securityReportID;
                                        b.CashInGT           = lblCashInGT.Text;
                                        b.CashOutGT          = lblCashOutGT.Text;
                                        b.Other              = lblOther.Text;
                                        b.Monday             = tbMonday.Text;
                                        b.Tuesday            = tbTuesday.Text;
                                        b.Wednesday          = tbWednesday.Text;
                                        b.Thursday           = tbThursday.Text;
                                        b.Friday             = tbFriday.Text;
                                        b.Saturday           = tbSaturday.Text;
                                        b.Sunday             = tbSunday.Text;
                                        b.Present            = tbPresent.Text;
                                        b.Absent             = tbAbsent.Text;
                                        b.IncidentComplaints = tbIncidentsComplaints.Text;
                                        b.Switches           = tbSwitches.Text;
                                        b.IsScheduled        = false;
                                        b.CreatedBy          = userID;
                                        b.CreatedOn          = DateTime.Now;
                                    };
                                    model.tbl_Mgr_WeeklySecurityReportComparison.Add(b);
                                    model.SaveChanges();
                                }
                            }
                        }

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = securityReportID;
                            z.TableName    = "tbl_Mgr_WeeklySecurityReport";
                            z.AuditProcess = "Updated Weekly Security Report for period " + weekStart + " to " + weekEnd + " (" + reportNumber + ")";
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
        protected void ChangePasswordPushButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if ((NewPassword.Text.Length >= 6) && (ConfirmNewPassword.Text.Length >= 6))
                {
                    //handle changing the password
                    string         newpassword  = NewPassword.Text;
                    byte           loggedInUser = MISC.getUserID();
                    MembershipUser user         = Membership.GetUser();
                    var            model        = new EDM.DataSource();
                    List <string>  roles        = new List <string>(Roles.GetRolesForUser());

                    try
                    {
                        bool changedPassword = user.ChangePassword(user.ResetPassword(), newpassword);
                        using (TransactionScope ts = new TransactionScope())
                        {
                            if (changedPassword)
                            {
                                var query = (from a in model.tbl_Sup_Employees
                                             where (a.UID == loggedInUser)
                                             select a).FirstOrDefault();

                                if (query != null)
                                {
                                    query.ResetNeeded    = false;
                                    query.LastModifiedBy = loggedInUser;
                                    query.LastModifiedOn = DateTime.Now;
                                    model.SaveChanges();
                                    ts.Complete();
                                    ShowMessage("Password Changed, Please wait to be redirected...", MessageType.Success);

                                    //redirect role based

                                    if (roles.Where(x => x.Contains("Manager")).FirstOrDefault() == "Manager")
                                    {
                                        Response.AddHeader("REFRESH", "5;URL=../../Pages/Managers/Alerts.aspx");
                                    }
                                    else if (roles.Where(x => x.Contains("Supervisor")).FirstOrDefault() == "Supervisor")
                                    {
                                        Response.AddHeader("REFRESH", "5;URL=../../Pages/Supervisors/ShiftReport.aspx");
                                    }
                                    else if (roles.Where(x => x.Contains("Operator")).FirstOrDefault() == "Operator")
                                    {
                                        Response.AddHeader("REFRESH", "5;URL=../../Pages/Operations/DailyLog.aspx");
                                    }
                                    else if (roles.Where(x => x.Contains("Contract Compliance Officer")).FirstOrDefault() == "Contract Compliance Officer")
                                    {
                                        Response.AddHeader("REFRESH", "5;URL=../../Pages/Operations/Incidents.aspx");
                                    }
                                    else if (roles.Where(x => x.Contains("Administrator")).FirstOrDefault() == "Administrator")
                                    {
                                        Response.AddHeader("REFRESH", "5;URL=../../Pages/Administrator/ManageUsers.aspx");
                                    }
                                }
                            }
                            else
                            {
                                ts.Dispose();
                            }
                        }
                    }
                    catch (Exception exec)
                    {
                        MISC.writetoAlertLog(exec.ToString());
                        ShowMessage("Something went wrong and the password could not be changed. Kindly try again and if the error persists, refer to the error log for details.", MessageType.Error);
                    }
                }
                else
                {
                    ShowMessage("Password length must be more than or equal to six characters.", MessageType.Warning);
                }
            }
        }
        public int insert_WeeklySecurityReport(string reportNumber, DateTime weekStart, DateTime weekEnd, byte areaID, string comments, GridView gvShiftReport, byte userID)
        {
            int securityReportID = 0;

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Insert header
                        EDM.tbl_Mgr_WeeklySecurityReport a = new EDM.tbl_Mgr_WeeklySecurityReport();
                        {
                            a.ReportNumber = reportNumber;
                            a.AreaID       = areaID;
                            a.WeekStart    = weekStart;
                            a.WeekEnd      = weekEnd;
                            a.Comments     = comments == "" ? null : comments;
                            a.CreatedBy    = userID;
                            a.CreatedOn    = DateTime.Now;
                        };
                        model.tbl_Mgr_WeeklySecurityReport.Add(a);
                        model.SaveChanges();

                        //Get the id
                        securityReportID = a.SecurityReportID;

                        if (securityReportID != 0)
                        {
                            for (int i = 0; i < gvShiftReport.Rows.Count; i++)
                            {
                                Label lblShiftID = (Label)gvShiftReport.Rows[i].FindControl("lblShiftID");
                                Label lblType    = (Label)gvShiftReport.Rows[i].FindControl("lblType");

                                if (lblType.Text == "Scheduled")
                                {
                                    Label lblCashInGT            = (Label)gvShiftReport.Rows[i].FindControl("lblCashInGT");
                                    Label lblCashOutGT           = (Label)gvShiftReport.Rows[i].FindControl("lblCashOutGT");
                                    Label lblOther               = (Label)gvShiftReport.Rows[i].FindControl("lblOther");
                                    Label lblMonday              = (Label)gvShiftReport.Rows[i].FindControl("lblMonday");
                                    Label lblTuesday             = (Label)gvShiftReport.Rows[i].FindControl("lblTuesday");
                                    Label lblWednesday           = (Label)gvShiftReport.Rows[i].FindControl("lblWednesday");
                                    Label lblThursday            = (Label)gvShiftReport.Rows[i].FindControl("lblThursday");
                                    Label lblFriday              = (Label)gvShiftReport.Rows[i].FindControl("lblFriday");
                                    Label lblSaturday            = (Label)gvShiftReport.Rows[i].FindControl("lblSaturday");
                                    Label lblSunday              = (Label)gvShiftReport.Rows[i].FindControl("lblSunday");
                                    Label lblPresent             = (Label)gvShiftReport.Rows[i].FindControl("lblPresent");
                                    Label lblAbsent              = (Label)gvShiftReport.Rows[i].FindControl("lblAbsent");
                                    Label lblIncidentsComplaints = (Label)gvShiftReport.Rows[i].FindControl("lblIncidentsComplaints");
                                    Label lblSwitches            = (Label)gvShiftReport.Rows[i].FindControl("lblSwitches");

                                    //insert shift comparison data
                                    EDM.tbl_Mgr_WeeklySecurityReportComparison b = new EDM.tbl_Mgr_WeeklySecurityReportComparison();
                                    {
                                        b.ShiftID            = Convert.ToByte(lblShiftID.Text);
                                        b.SecurityReportID   = securityReportID;
                                        b.CashInGT           = lblCashInGT.Text;
                                        b.CashOutGT          = lblCashOutGT.Text;
                                        b.Other              = lblOther.Text;
                                        b.Monday             = lblMonday.Text;
                                        b.Tuesday            = lblTuesday.Text;
                                        b.Wednesday          = lblWednesday.Text;
                                        b.Thursday           = lblThursday.Text;
                                        b.Friday             = lblFriday.Text;
                                        b.Saturday           = lblSaturday.Text;
                                        b.Sunday             = lblSunday.Text;
                                        b.Present            = lblPresent.Text;
                                        b.Absent             = lblAbsent.Text;
                                        b.IncidentComplaints = lblIncidentsComplaints.Text;
                                        b.Switches           = lblSwitches.Text;
                                        b.IsScheduled        = true;
                                        b.CreatedBy          = userID;
                                        b.CreatedOn          = DateTime.Now;
                                    };
                                    model.tbl_Mgr_WeeklySecurityReportComparison.Add(b);
                                    model.SaveChanges();
                                }
                                else if (lblType.Text == "Actual")
                                {
                                    Label   lblCashInGT           = (Label)gvShiftReport.Rows[i].FindControl("lblCashInGT");
                                    Label   lblCashOutGT          = (Label)gvShiftReport.Rows[i].FindControl("lblCashOutGT");
                                    Label   lblOther              = (Label)gvShiftReport.Rows[i].FindControl("lblOther");
                                    TextBox tbMonday              = (TextBox)gvShiftReport.Rows[i].FindControl("tbMonday");
                                    TextBox tbTuesday             = (TextBox)gvShiftReport.Rows[i].FindControl("tbTuesday");
                                    TextBox tbWednesday           = (TextBox)gvShiftReport.Rows[i].FindControl("tbWednesday");
                                    TextBox tbThursday            = (TextBox)gvShiftReport.Rows[i].FindControl("tbThursday");
                                    TextBox tbFriday              = (TextBox)gvShiftReport.Rows[i].FindControl("tbFriday");
                                    TextBox tbSaturday            = (TextBox)gvShiftReport.Rows[i].FindControl("tbSaturday");
                                    TextBox tbSunday              = (TextBox)gvShiftReport.Rows[i].FindControl("tbSunday");
                                    TextBox tbPresent             = (TextBox)gvShiftReport.Rows[i].FindControl("tbPresent");
                                    TextBox tbAbsent              = (TextBox)gvShiftReport.Rows[i].FindControl("tbAbsent");
                                    TextBox tbIncidentsComplaints = (TextBox)gvShiftReport.Rows[i].FindControl("tbIncidentsComplaints");
                                    TextBox tbSwitches            = (TextBox)gvShiftReport.Rows[i].FindControl("tbSwitches");

                                    //insert shift comparison data
                                    EDM.tbl_Mgr_WeeklySecurityReportComparison b = new EDM.tbl_Mgr_WeeklySecurityReportComparison();
                                    {
                                        b.ShiftID            = Convert.ToByte(lblShiftID.Text);
                                        b.SecurityReportID   = securityReportID;
                                        b.CashInGT           = lblCashInGT.Text;
                                        b.CashOutGT          = lblCashOutGT.Text;
                                        b.Other              = lblOther.Text;
                                        b.Monday             = tbMonday.Text;
                                        b.Tuesday            = tbTuesday.Text;
                                        b.Wednesday          = tbWednesday.Text;
                                        b.Thursday           = tbThursday.Text;
                                        b.Friday             = tbFriday.Text;
                                        b.Saturday           = tbSaturday.Text;
                                        b.Sunday             = tbSunday.Text;
                                        b.Present            = tbPresent.Text;
                                        b.Absent             = tbAbsent.Text;
                                        b.IncidentComplaints = tbIncidentsComplaints.Text;
                                        b.Switches           = tbSwitches.Text;
                                        b.IsScheduled        = false;
                                        b.CreatedBy          = userID;
                                        b.CreatedOn          = DateTime.Now;
                                    };
                                    model.tbl_Mgr_WeeklySecurityReportComparison.Add(b);
                                    model.SaveChanges();
                                }
                            }

                            //Insert AuditTrail
                            EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                            {
                                z.SourceID     = securityReportID;
                                z.TableName    = "tbl_Mgr_WeeklySecurityReport";
                                z.AuditProcess = "Created Weekly Security Report for period " + weekStart + " to " + weekEnd + " (" + reportNumber + ")";
                                z.DateTime     = DateTime.Now;
                                z.UserID       = userID;
                            };
                            model.tbl_AuditLog.Add(z);
                            model.SaveChanges();
                        }
                        else
                        {
                            securityReportID = 0;
                            successfulCommit = false;
                            MISC.writetoAlertLog("No security report ID returned after insert!!");
                        }
                    }
                    if (securityReportID != 0)
                    {
                        //commit transaction
                        ts.Complete();
                        successfulCommit = true;
                    }
                }
            }
            catch (Exception exec)
            {
                securityReportID = 0;
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
            return(securityReportID);
        }
Ejemplo n.º 27
0
        public void insert_Check(int shiftReportID, Int16 locationID, byte checkSequence, string generalObservations, string correctionsMade, string reportNumber, GridView Officers, byte userID)
        {
            try
            {
                Int64 checksID = new Int64();

                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //update header
                        var dl = (from a in model.tbl_Sup_ShiftReport
                                  where a.ShiftReportID == shiftReportID
                                  select a).First();
                        dl.LastModifiedBy = userID;
                        dl.LastModifiedOn = DateTime.Now;
                        model.SaveChanges();

                        //Insert Chesk
                        EDM.tbl_Sup_ShiftReportChecks b = new EDM.tbl_Sup_ShiftReportChecks();
                        {
                            b.ShiftReportID            = shiftReportID;
                            b.LocationID               = locationID;
                            b.CheckSequence            = checkSequence;
                            b.GeneralObservations      = generalObservations;
                            b.CorrectionsMadeSuggested = correctionsMade;
                            b.CreatedBy = userID;
                            b.CreatedOn = DateTime.Now;
                        };
                        model.tbl_Sup_ShiftReportChecks.Add(b);
                        model.SaveChanges();

                        //Get the id
                        checksID = b.ChecksID;

                        if (checksID != 0)
                        {
                            //insert officers
                            for (int i = 0; i < Officers.Rows.Count; i++)
                            {
                                DropDownList ddlOfficerName = (DropDownList)Officers.Rows[i].FindControl("ddlOfficerName");
                                TextBox      tbTime         = (TextBox)Officers.Rows[i].FindControl("tbTime");

                                if ((ddlOfficerName.SelectedIndex > 0) && (tbTime.Text != ""))
                                {
                                    Int16    empID = Convert.ToInt16(ddlOfficerName.SelectedValue);
                                    TimeSpan time  = new TimeSpan();
                                    TimeSpan.TryParse(tbTime.Text, out time);

                                    EDM.tbl_Sup_ShiftReportChecks_Officers c = new EDM.tbl_Sup_ShiftReportChecks_Officers();
                                    {
                                        c.ChecksID   = checksID;
                                        c.EmployeeID = empID;
                                        c.Time       = time;
                                        c.CreatedBy  = userID;
                                        c.CreatedOn  = DateTime.Now;
                                    };
                                    model.tbl_Sup_ShiftReportChecks_Officers.Add(c);
                                    model.SaveChanges();
                                }
                            }

                            //Insert AuditTrail
                            EDM.tbl_AuditLog x = new EDM.tbl_AuditLog();
                            {
                                x.SourceID     = shiftReportID;
                                x.TableName    = "tbl_Sup_ShiftReport";
                                x.AuditProcess = "Inserted Check for Shift Report " + reportNumber;
                                x.DateTime     = DateTime.Now;
                                x.UserID       = userID;
                            };
                            model.tbl_AuditLog.Add(x);
                            model.SaveChanges();
                        }
                        else
                        {
                            successfulCommit = false;
                            MISC.writetoAlertLog("No Checks ID returned after insert!!");
                        }
                    }
                    if (checksID != 0)
                    {
                        //commit transaction
                        ts.Complete();
                        successfulCommit = true;
                    }
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }
Ejemplo n.º 28
0
        public int insert_ShiftReport(DateTime date, byte areaID, byte shiftID, Int16 supervisorID, string reportNumber, byte userID)
        {
            int shiftReportID = 0;

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Insert header
                        EDM.tbl_Sup_ShiftReport a = new EDM.tbl_Sup_ShiftReport();
                        {
                            a.Date         = date;
                            a.AreaID       = areaID;
                            a.ShiftID      = shiftID;
                            a.ReportNumber = reportNumber;
                            a.SupervisorID = supervisorID;
                            a.CreatedBy    = userID;
                            a.CreatedOn    = DateTime.Now;
                        };
                        model.tbl_Sup_ShiftReport.Add(a);
                        model.SaveChanges();

                        //Get the id
                        shiftReportID = (from b in model.tbl_Sup_ShiftReport
                                         where b.ReportNumber == reportNumber
                                         select b.ShiftReportID
                                         ).FirstOrDefault();

                        if (shiftReportID != 0)
                        {
                            //Insert AuditTrail
                            EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                            {
                                z.SourceID     = shiftReportID;
                                z.TableName    = "tbl_Sup_ShiftReport";
                                z.AuditProcess = "Created Shift Report " + reportNumber;
                                z.DateTime     = DateTime.Now;
                                z.UserID       = userID;
                            };
                            model.tbl_AuditLog.Add(z);
                            model.SaveChanges();
                        }
                        else
                        {
                            shiftReportID    = 0;
                            successfulCommit = false;
                            MISC.writetoAlertLog("No shift report ID returned after insert!!");
                        }
                    }
                    if (shiftReportID != 0)
                    {
                        //commit transaction
                        ts.Complete();
                        successfulCommit = true;
                    }
                }
            }
            catch (Exception exec)
            {
                shiftReportID    = 0;
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
            return(shiftReportID);
        }
        //insert employee
        public int insert_SO(byte areaID, Int16 locationID, DateTime date, bool escortService, bool cashInGT, bool cashOutGT, bool extraOfficers, byte amountOfficers, string reportNumber, string comments, byte userID, byte shiftID)
        {
            int soID = 0;

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Insert transaction
                        EDM.tbl_Mgr_SpecialOperations a = new EDM.tbl_Mgr_SpecialOperations();
                        {
                            a.AreaID         = areaID == 0 ? null : (byte?)areaID;
                            a.LocationID     = locationID == 0 ? null : (byte?)locationID;
                            a.Date           = date;
                            a.EscortService  = escortService;
                            a.CashInGT       = cashInGT;
                            a.CashOutGT      = cashOutGT;
                            a.ExtraOfficers  = extraOfficers;
                            a.AmountOfficers = amountOfficers == 0 ? null : (byte?)amountOfficers;
                            a.ReportNumber   = reportNumber;
                            a.Comments       = comments == "" ? null : comments;
                            a.ShiftID        = shiftID == 0 ? null : (byte?)shiftID;
                            a.CreatedBy      = userID;
                            a.CreatedOn      = DateTime.Now;
                        };
                        model.tbl_Mgr_SpecialOperations.Add(a);
                        model.SaveChanges();

                        //Get the absenceid
                        soID = (from b in model.tbl_Mgr_SpecialOperations
                                where b.ReportNumber == reportNumber
                                select b.SpecialOperationsID
                                ).FirstOrDefault();

                        //Insert AuditTrail
                        EDM.tbl_AuditLog z = new EDM.tbl_AuditLog();
                        {
                            z.SourceID     = soID;
                            z.TableName    = "tbl_Mgr_SpecialOperations";
                            z.AuditProcess = "Created SO Report - " + reportNumber;
                            z.DateTime     = DateTime.Now;
                            z.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(z);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                soID             = 0;
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
            return(soID);
        }
Ejemplo n.º 30
0
        public void update_Check(int checksID, int shiftReportID, Int16 locationID, byte checkSequence, string generalObservations, string correctionsMade, string reportNumber, GridView Officers, byte userID)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (EDM.DataSource model = new EDM.DataSource())
                    {
                        //Update header table
                        var dl = (from a in model.tbl_Sup_ShiftReport
                                  where a.ShiftReportID == shiftReportID
                                  select a).First();
                        dl.LastModifiedBy = userID;
                        dl.LastModifiedOn = DateTime.Now;
                        model.SaveChanges();

                        //Update Checks table
                        var checks = (from b in model.tbl_Sup_ShiftReportChecks
                                      where b.ChecksID == checksID
                                      select b).First();
                        checks.LocationID               = locationID;
                        checks.CheckSequence            = checkSequence;
                        checks.GeneralObservations      = generalObservations;
                        checks.CorrectionsMadeSuggested = correctionsMade;
                        checks.LastModifiedBy           = userID;
                        checks.LastModifiedOn           = DateTime.Now;
                        model.SaveChanges();

                        //Select all officers
                        var officers = (from c in model.tbl_Sup_ShiftReportChecks_Officers
                                        where c.ChecksID == checksID
                                        select c).ToList();

                        if (officers != null)
                        {
                            //remove selected officers
                            foreach (var val in officers)
                            {
                                model.tbl_Sup_ShiftReportChecks_Officers.Remove(val);
                                model.SaveChanges();
                            }

                            //insert new officers
                            for (int i = 0; i < Officers.Rows.Count; i++)
                            {
                                DropDownList ddlOfficerName = (DropDownList)Officers.Rows[i].FindControl("ddlOfficerName");
                                TextBox      tbTime         = (TextBox)Officers.Rows[i].FindControl("tbTime");

                                if ((ddlOfficerName.SelectedIndex > 0) && (tbTime.Text != ""))
                                {
                                    Int16    empID = Convert.ToInt16(ddlOfficerName.SelectedValue);
                                    TimeSpan time  = new TimeSpan();
                                    TimeSpan.TryParse(tbTime.Text, out time);

                                    EDM.tbl_Sup_ShiftReportChecks_Officers c = new EDM.tbl_Sup_ShiftReportChecks_Officers();
                                    {
                                        c.ChecksID   = checksID;
                                        c.EmployeeID = empID;
                                        c.Time       = time;
                                        c.CreatedBy  = userID;
                                        c.CreatedOn  = DateTime.Now;
                                    };
                                    model.tbl_Sup_ShiftReportChecks_Officers.Add(c);
                                    model.SaveChanges();
                                }
                            }
                        }
                        //Insert AuditTrail
                        EDM.tbl_AuditLog x = new EDM.tbl_AuditLog();
                        {
                            x.SourceID     = shiftReportID;
                            x.TableName    = "tbl_Sup_ShiftReport";
                            x.AuditProcess = "Updated Check for Shift Report " + reportNumber;
                            x.DateTime     = DateTime.Now;
                            x.UserID       = userID;
                        };
                        model.tbl_AuditLog.Add(x);
                        model.SaveChanges();
                    }
                    //commit transaction
                    ts.Complete();
                    successfulCommit = true;
                }
            }
            catch (Exception exec)
            {
                successfulCommit = false;
                MISC.writetoAlertLog(exec.ToString());
            }
        }