/// <summary> /// This handles logic of Report Number functioning /// Each new add gets the first available record number not in use. /// used='N' passes it back to the presentation layer and /// sets that report number used to 'Y' /// </summary> /// <returns></returns> public static string GetNextReportId() { //get the next available reportno. DataSet Reports = null; string reportNumber = ""; int Id = 0; Reports = ReportNumbers.GetNextReportId(); //want to only grab the first row ReportNumber and id. int count = Reports.Tables[0].Rows.Count; if (count > 0 && Id == 0) { reportNumber = Reports.Tables["ReportNo"].Rows[0]["ReportId"].ToString(); int.TryParse(Reports.Tables["ReportNo"].Rows[0]["Id"].ToString(), out Id); ReportNumbers.UpdateReportNumbers(Id, reportNumber, 'Y'); } return(reportNumber); }
internal static bool ReportNumberUsed(string ReportNumber) { //check if reportnumber used in detail reports if not then //update reportnumbers table with 'n' bool flag = true; int validReport = 0; validReport = ReportNumbers.ReportNumberUsed(ReportNumber); if (validReport == 0) {//if it exists, the user canceled out of anything but add mode. so we dont change it DataSet Reports = null; int Id = 0; Reports = ReportNumbers.getReportInfo(ReportNumber); int.TryParse(Reports.Tables["Report"].Rows[0]["Id"].ToString(), out Id); if (Id != 0) { ReportNumbers.UpdateReportNumbers(Id, ReportNumber, 'N'); } flag = false; } return(flag); }
internal static void DeleteDetailReport(int reportId, string reportNumber) { //delete the record if success bool success = false; try { success = Incidents.DeleteDetailReport(reportId); if (success == true) { DataSet Reports = null; int Id = 0; Reports = ReportNumbers.getReportInfo(reportNumber); int.TryParse(Reports.Tables["Report"].Rows[0]["Id"].ToString(), out Id); if (Id != 0) { ReportNumbers.UpdateReportNumbers(Id, reportNumber, 'N'); } } }catch { throw new Exception("The delete failed."); } }
//---------------------- Initialize ReportNumbering ------------------ /// <summary> /// /// </summary> /// <param name="sub"></param> /// <returns></returns> public static int AddReportNumbers(string sub) { return(ReportNumbers.AddReportNumbers(sub)); }