/// <summary> /// Adds an unassignment request for the specified guards. /// </summary> /// <param name="cid">Client ID</param> /// <param name="gid">An array of Guard ID's to be dismissed</param> /// <param name="ReportType">Enumeration.ReportType (Incident)</param> /// <param name="pcompleting">Idk unsa ni na field.</param> /// <param name="EventDate">Date of event.</param> /// <param name="location">Brief location description</param> /// <param name="description">Brief description of incident.</param> public static void AddUnassignmentRequest(int cid, int[] gid, int ReportType, String pcompleting, DateTime EventDate, String location, String description, DateTime DateEffective) { // 1.) Add Incident Report String q = String.Format(@"INSERT INTO `msadb`.`incidentreport` (`ReportType`, `DateEntry`, `PCompleting`, `EventDate`, `EventLocation`, `Description`) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}');", ReportType, SQLTools.getDateTime(), pcompleting, EventDate.ToString("yyyy-MM-dd"), location, description ); SQLTools.ExecuteNonQuery(q); // 2.) Insert a dismissal request.\ // 2a: Get last inserted Incident Report (link this) int IncidentId = int.Parse(SQLTools.getLastInsertedId("IncidentReport", "iid")); // 2b: Insert request q = "INSERT INTO `msadb`.`request` (`RequestType`, `CID`, `DateEntry`,`rstatus`) VALUES ('{0}', '{1}', '{2}','{3}')"; q = string.Format(q, Enumeration.RequestType.Dismissal, cid, SQLTools.getDateTime(), Enumeration.RequestStatus.Pending); SQLTools.ExecuteNonQuery(q); String lid = SQLTools.getLastInsertedId("request", "rid"); for (int c = 0; c < gid.Length; c++) { q = $@"INSERT INTO `msadb`.`request_unassign` (`RID`, `gid`, `iid`, `DateEffective`) VALUES ('{lid.ToString()}', '{ gid[c]}', '{IncidentId}', '{DateEffective:yyyy-MM-dd}');"; SQLTools.ExecuteNonQuery(q); } }
public static void AddUnassignmentRequestNoIncident(int cid, int[] gid, DateTime DateEffective) { // 2b: Insert request var q = "INSERT INTO `msadb`.`request` (`RequestType`, `CID`, `DateEntry`,`rstatus`) VALUES ('{0}', '{1}', '{2}','{3}')"; q = string.Format(q, Enumeration.RequestType.Dismissal, cid, SQLTools.getDateTime(), Enumeration.RequestStatus.Pending); SQLTools.ExecuteNonQuery(q); String lid = SQLTools.getLastInsertedId("request", "rid"); for (int c = 0; c < gid.Length; c++) { q = $@"INSERT INTO `msadb`.`request_unassign` (`RID`, `gid`, `DateEffective`) VALUES ('{lid.ToString()}', '{ gid[c]}', '{DateEffective:yyyy-MM-dd}');"; SQLTools.ExecuteNonQuery(q); } }