Exemple #1
0
        public Boolean insert()
        {
            var           CL  = new commonLogic();
            SqlConnection cnn = CL.connect();
            SqlCommand    command;
            String        sql            = "";
            string        uploadFileName = uploadFile();
            string        id             = HttpContext.Current.Session["id"].ToString();

            try
            {
                Durationofdrill = CL.setDurationOfDrill(DurationofdrillMinutes, DurationofdrillSeconds);
                string DrillType   = string.Join(",", TypeOfDrill);
                string drillStatus = CL.GetDrillStatus(reportForQuanterEnding, DrillDate, DrillType, Durationofdrill);
                string drillShift  = "1";//As it is non-residential, it always be shift 1.
                sql     = "INSERT INTO emergency_drill_log (user_id,evacuation,duration_of_drill,drill_status,report_for_quarter_ending,drill_shift,site_address,name_of_program,program_location,drill_date,time_started,time_completed,table_top_drill,person_conducted,type_of_drill,program_participants_involved,ec_evcuate,sc_accounted,people_left,emergency_disaster,pp_enhance_safety,report_completed_name,completed_date,improvement_date,upload_survey,added_date) OUTPUT INSERTED.ID VALUES";
                sql     = sql + "(@user_id,@evacuation,@Durationofdrill,@drillStatus,@reportForQuanterEnding,@drillShift,@site_address,@NameofProgram,@Location,@drill_date,@time_started,@time_completed,@table_top_drill,@person_conducted,@type_of_drill,@program_participants_involved,@ec_evcuate,@sc_accounted,@people_left,@emergency_disaster,@pp_enhance_safety,@report_completed_name,@completed_date,@improvement_date,@upload_survey,GETDATE())";
                command = new SqlCommand(sql, cnn);
                command.Parameters.AddWithValue("@user_id", id);
                command.Parameters.AddWithValue("@evacuation", Evacuation);
                if (Durationofdrill == null)
                {
                    command.Parameters.AddWithValue("@Durationofdrill", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@Durationofdrill", Durationofdrill);
                }

                command.Parameters.AddWithValue("@drillStatus", drillStatus);
                command.Parameters.AddWithValue("@reportForQuanterEnding", DBNull.Value);
                command.Parameters.AddWithValue("@drillShift", drillShift);
                command.Parameters.AddWithValue("@site_address", ProgramAddress);
                command.Parameters.AddWithValue("@NameofProgram", NameofProgram);
                command.Parameters.AddWithValue("@Location", Location);
                command.Parameters.AddWithValue("@drill_date", DrillDate);
                command.Parameters.AddWithValue("@time_started", DBNull.Value);
                command.Parameters.AddWithValue("@time_completed", DBNull.Value);
                command.Parameters.AddWithValue("@table_top_drill", DBNull.Value);
                command.Parameters.AddWithValue("@person_conducted", PersonConducted);
                command.Parameters.AddWithValue("@type_of_drill", DrillType);
                command.Parameters.AddWithValue("@program_participants_involved", ProgramParticipantsInvolved);
                command.Parameters.AddWithValue("@ec_evcuate", ECEvcuate);
                command.Parameters.AddWithValue("@sc_accounted", SCAccounted);
                command.Parameters.AddWithValue("@people_left", PeopleLeft);
                command.Parameters.AddWithValue("@emergency_disaster", EmergencyDisaster);
                command.Parameters.AddWithValue("@pp_enhance_safety", PPEnhanceSafety);
                command.Parameters.AddWithValue("@report_completed_name", ReportCompletedName);
                command.Parameters.AddWithValue("@completed_date", CompletedDate);
                command.Parameters.AddWithValue("@improvement_date", ImprovementDate);
                command.Parameters.AddWithValue("@upload_survey", uploadFileName);
                command.CommandType = CommandType.Text;
                int newId = Convert.ToInt32(command.ExecuteScalar());
                if (newId < 1)
                {
                    CL.getLog("Fail to insert");
                    return(false);
                }
                cnn.Close();
                bool EDparticipant = emergencyDrillParticipants(newId);
                bool EDClients     = true;
                if (ProgramParticipantsInvolved == "YES")
                {
                    EDClients = emergencyDrillClients(newId);
                }
                bool uniqueIdUpdate = updateUniqueId(newId);
                if (EDClients == false || EDparticipant == false || uniqueIdUpdate == false)
                {
                    CL.getLog("Fail to insert to other tables.");
                    return(false);
                }
            }
            catch (Exception e)
            {
                CL.getLog("Fail to insert to emergency_drill_log " + Location + "<++>" + NameofProgram + "<++>" + ProgramAddress + "<++>" + Durationofdrill + "<++>" + reportForQuanterEnding + "<++>" + e);
                return(false);
            }
            return(true);
        }
Exemple #2
0
        internal bool insert()
        {
            string        sql = "";
            SqlCommand    command;
            var           CL  = new commonLogic();
            SqlConnection cnn = CL.connect();
            string        id  = HttpContext.Current.Session["id"].ToString();

            try
            {
                string uploadFileName = uploadFile();
                string DrillType      = string.Join(",", TypeOfDrill);
                Durationofdrill = CL.setDurationOfDrill(DurationofdrillMinutes, DurationofdrillSeconds);
                string drillStatus = CL.GetDrillStatus(reportForQuanterEnding, DateTimeofDrill, DrillType, Durationofdrill);
                string drillShift  = CL.GetDrillShift(DateTimeofDrill);
                sql     = "INSERT INTO resdential_drill_log(user_id,program_address,program_location,drill_shift,report_for_quarter_ending,drill_status,type_of_drill,evacuation,name_of_program,date_time_of_drill,staff_ratio,duration_of_drill,drill_scenario,building_exit,egress_was_blocked,secondary_location,staff_signature,staff_signature_date,supervisor_signature,supervisor_signature_date,added_date,drill_was_during,name_of_staff,upload_survey) ";
                sql    += " OUTPUT INSERTED.ID VALUES(@user_id,@ProgramAddress,@ProgramLocation,@drillShift,@reportForQuanterEnding,@DrillStatus,@TypeOfDrill,@Evacuation,@NameofProgram,@DateTimeofDrill, @StaffRatio, @Durationofdrill,@DrillScenario, @BuildingExit,@EgressWasBlocked, @SecondaryLocation,@StaffSignature, @StaffSignatureDate,@SupervisorSignature,@SupervisorSignatureDate,GETDATE(),@DrillWasDuring,@NameofStaff,@upload_survey) ";
                command = new SqlCommand(sql, cnn);
                command.Parameters.AddWithValue("@user_id", id);
                command.Parameters.AddWithValue("@ProgramAddress", ProgramAddress);
                command.Parameters.AddWithValue("@ProgramLocation", Location);
                command.Parameters.AddWithValue("@drillShift", drillShift);
                command.Parameters.AddWithValue("@reportForQuanterEnding", DBNull.Value);
                command.Parameters.AddWithValue("@DrillStatus", drillStatus);
                command.Parameters.AddWithValue("@TypeOfDrill", DrillType);
                command.Parameters.AddWithValue("@Evacuation", Evacuation);
                command.Parameters.AddWithValue("@NameofProgram", NameofProgram);
                command.Parameters.AddWithValue("@DateTimeofDrill", DateTimeofDrill);
                command.Parameters.AddWithValue("@StaffRatio", StaffRatio);
                if (Durationofdrill == null)
                {
                    command.Parameters.AddWithValue("@Durationofdrill", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@Durationofdrill", Durationofdrill);
                }

                command.Parameters.AddWithValue("@DrillScenario", DrillScenario);
                command.Parameters.AddWithValue("@BuildingExit", BuildingExit);
                command.Parameters.AddWithValue("@EgressWasBlocked", EgressWasBlocked);
                command.Parameters.AddWithValue("@SecondaryLocation", SecondaryLocation);
                command.Parameters.AddWithValue("@StaffSignature", StaffSignature);
                command.Parameters.AddWithValue("@StaffSignatureDate", StaffSignatureDate);
                command.Parameters.AddWithValue("@SupervisorSignature", SupervisorSignature);
                command.Parameters.AddWithValue("@SupervisorSignatureDate", SupervisorSignatureDate);
                command.Parameters.AddWithValue("@DrillWasDuring", DrillWasDuring);
                command.Parameters.AddWithValue("@NameofStaff", NameofStaff);
                command.Parameters.AddWithValue("@upload_survey", uploadFileName);
                command.CommandType = CommandType.Text;
                int newId = Convert.ToInt32(command.ExecuteScalar());
                if (newId < 1)
                {
                    CL.getLog("Fail to insert");
                    return(false);
                }
                bool RDclient   = true;//ResidentialDrillClients(newId);
                bool RDUniqueID = updateUniqueId(newId);
                if (RDclient == false || RDUniqueID == false)
                {
                    CL.getLog("Fail to insert and update other tables");
                    return(false);
                }
                cnn.Close();
                return(true);
            }
            catch (Exception e)
            {
                CL.getLog("error while inserting records in resdential_drill_log " + e);
                cnn.Close();
                return(false);
            }
        }