Ejemplo n.º 1
0
        public bool updatePassword(String Email)
        {
            var           CL  = new commonLogic();
            SqlConnection con = CL.connect();

            try
            {
                Password = hassPassword(CnfPassword);
                SqlCommand cmd;
                string     query = "UPDATE users SET password = @password WHERE email = @email";
                cmd = new SqlCommand(query, con);
                cmd.Parameters.AddWithValue("@email", Email);
                cmd.Parameters.AddWithValue("@password", Password);
                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();
                con.Close();
                SqlConnection cnn = CL.connect();
                try
                {
                    SqlCommand command;
                    string     sql;
                    sql     = "SELECT * FROM users WHERE email = @email";
                    command = new SqlCommand(sql, cnn);
                    command.Parameters.AddWithValue("@email", Email);
                    SqlDataReader dataReader = command.ExecuteReader();

                    if (dataReader.HasRows)
                    {
                        while (dataReader.Read())
                        {
                            HttpContext.Current.Session["id"]         = dataReader["id"].ToString();
                            HttpContext.Current.Session["email"]      = dataReader["email"].ToString();
                            HttpContext.Current.Session["first_name"] = dataReader["first_name"].ToString();
                            HttpContext.Current.Session["last_name"]  = dataReader["last_name"].ToString();
                            break;
                        }
                        cnn.Close();
                        return(true);
                    }
                    else
                    {
                        cnn.Close();
                        return(false);
                    }
                }
                catch (Exception e)
                {
                    CL.getLog("error while updating unique id to table" + e);
                    cnn.Close();
                    return(false);
                }
            }
            catch (Exception e)
            {
                CL.getLog("error while updating unique id to table" + e);
                con.Close();
                return(false);
            }
        }
Ejemplo n.º 2
0
        public DataTable select()
        {
            SqlDataReader dataReader = null;
            var           dataTable  = new DataTable();

            try
            {
                var           CL  = new commonLogic();
                SqlConnection cnn = CL.connect();
                SqlCommand    command;
                String        sql = "";
                //sql = "SELECT 'Adult Mental Health Services' as 'Name of Program',added_date as 'date of Review', 'Administrative Office' as 'Residence/Team','***ActionEmergencyModel***' as Action   FROM [chd].[dbo].[residency_survey]";
                sql = "SELECT unique_id, form_data as JSONArray,files FROM residency_survey ";
                if (where != "")
                {
                    sql = sql + where;
                }
                command    = new SqlCommand(sql, cnn);
                dataReader = command.ExecuteReader();
                //dataReader.Close();
                if (dataReader.HasRows)
                {
                    dataTable.Load(dataReader);
                    return(dataTable);
                }
                else
                {
                    return(dataTable);  //No data
                }
            }
            catch (Exception e)
            {
                return(dataTable);
            }
        }
Ejemplo n.º 3
0
        public bool emergencyDrillClients(int newId)
        {
            var CL = new commonLogic();

            try
            {
                SqlConnection cnn = CL.connect();
                SqlCommand    command;
                string        sql;
                for (int loop = 0; loop < ClientName.Length; loop++)
                {
                    sql     = "INSERT INTO emergency_drill_clients (emergency_drill_log_id,client_name,evacuation_time,prompt_level,comments,updated_date,added_date) VALUES ";
                    sql     = sql + " (@emergency_drill_log_id,@ClientName,@EvacuationTime,@PromptLevel,@Comments,@updatedDate,GETDATE())";
                    command = new SqlCommand(sql, cnn);
                    command.Parameters.AddWithValue("@emergency_drill_log_id", newId);
                    command.Parameters.AddWithValue("@ClientName", ClientName[loop]);
                    command.Parameters.AddWithValue("@EvacuationTime", EvacuationTime[loop]);
                    command.Parameters.AddWithValue("@PromptLevel", PromptLevel[loop]);
                    command.Parameters.AddWithValue("@Comments", Comments[loop]);
                    command.Parameters.AddWithValue("@updatedDate", DBNull.Value);
                    command.CommandType = CommandType.Text;
                    command.ExecuteNonQuery();
                }
                cnn.Close();
            }
            catch (Exception e)
            {
                CL.getLog("error while adding data to emergency_drill_clients table" + e);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 4
0
        public bool emergencyDrillParticipants(int newId)
        {
            var CL = new commonLogic();

            try
            {
                SqlConnection cnn = CL.connect();
                SqlCommand    command;
                string        sql;
                for (int loop = 0; loop < ParticipantName.Length; loop++)
                {
                    sql     = "INSERT INTO emergency_drill_participants (emergency_drill_log_id,participant_name,participant_title,added_date) VALUES (@emergency_drill_log_id,@ParticipantName,@ParticipantTitle,GETDATE())";
                    command = new SqlCommand(sql, cnn);
                    command.Parameters.AddWithValue("@emergency_drill_log_id", newId);
                    command.Parameters.AddWithValue("@ParticipantName", ParticipantName[loop]);
                    command.Parameters.AddWithValue("@ParticipantTitle", ParticipantTitle[loop]);
                    command.CommandType = CommandType.Text;
                    command.ExecuteNonQuery();
                }
                cnn.Close();
            }
            catch (Exception e)
            {
                CL.getLog("error while adding data to emergencyDrillParticipants table" + e);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 5
0
        public DataTable select()
        {
            SqlDataReader dataReader = null;
            var           dataTable  = new DataTable();

            try
            {
                var           CL  = new commonLogic();
                SqlConnection cnn = CL.connect();
                SqlCommand    command;
                String        sql = "";
                sql        = "select distinct unique_id as 'Unique ID',name_of_program as 'Program Name',program_location as 'Team Or Residence',site_address as 'Location',licensing_body_funding as 'Licensing Body',carf as CARF,evacuation as 'Drill category',type_of_drill as 'Drill Type',drill_date as 'Drill Date',drill_status as 'Drill Status',drill_shift as 'Shift',first_name as 'First Name',last_name as 'Last Name','***ActionEmergencyModel***' as Action FROM emergency_drill_log LEFT JOIN programs ON programs.program_name = name_of_program AND programs.team_residence_location = program_location AND programs.address = site_address LEFT JOIN users ON users.id=user_id";
                command    = new SqlCommand(sql, cnn);
                dataReader = command.ExecuteReader();
                //dataReader.Close();
                if (dataReader.HasRows)
                {
                    dataTable.Load(dataReader);
                    return(dataTable);
                }
                else
                {
                    return(dataTable);  //No data
                }
            }
            catch (Exception e)
            {
                return(dataTable);
            }
        }
Ejemplo n.º 6
0
        public DataTable viewData(string uniqueId)
        {
            SqlDataReader dataReader = null;
            var           dataTable  = new DataTable();

            try
            {
                var           CL  = new commonLogic();
                SqlConnection cnn = CL.connect();
                SqlCommand    command;
                String        sql = "";
                sql     = "select * FROM emergency_drill_log WHERE unique_id = @uniqueID";
                command = new SqlCommand(sql, cnn);
                command.Parameters.AddWithValue("@uniqueID", uniqueId);
                dataReader = command.ExecuteReader();
                if (dataReader.HasRows)
                {
                    dataTable.Load(dataReader);
                    return(dataTable);
                }
                else
                {
                    return(dataTable);  //No data
                }
            }
            catch (Exception e)
            {
                return(dataTable);
            }
        }
Ejemplo n.º 7
0
        public DataTable select()
        {
            SqlDataReader dataReader = null;
            var           dataTable  = new DataTable();

            try
            {
                var           CL  = new commonLogic();
                SqlConnection cnn = CL.connect();
                SqlCommand    command;
                String        sql = "SELECT unique_id, form_data as JSONArray,files FROM office_survey ";
                if (where != "")
                {
                    sql = sql + where;
                }

                command    = new SqlCommand(sql, cnn);
                dataReader = command.ExecuteReader();
                //dataReader.Close();
                if (dataReader.HasRows)
                {
                    dataTable.Load(dataReader);
                    return(dataTable);
                }
                else
                {
                    return(dataTable);  //No data
                }
            }
            catch (Exception e)
            {
                return(dataTable);
            }
        }
Ejemplo n.º 8
0
        public DataTable GetResidentialClientData(string id)
        {
            SqlDataReader dataReader = null;
            var           dataTable  = new DataTable();

            try
            {
                var           CL  = new commonLogic();
                SqlConnection cnn = CL.connect();
                SqlCommand    command;
                String        sql = "";
                sql     = "select * FROM resdential_drill_clients where residential_drill_id = @residential_drill_id";
                command = new SqlCommand(sql, cnn);
                command.Parameters.AddWithValue("@residential_drill_id", id);
                dataReader = command.ExecuteReader();
                if (dataReader.HasRows)
                {
                    dataTable.Load(dataReader);
                    return(dataTable);
                }
                else
                {
                    return(dataTable);  //No data
                }
            }
            catch (Exception e)
            {
                return(dataTable);
            }
        }
Ejemplo n.º 9
0
        public bool ResidentialDrillClients(int newId)
        {
            var CL = new commonLogic();

            try
            {
                SqlConnection cnn = CL.connect();
                SqlCommand    command;
                string        sql;
                for (int loop = 0; loop < ClientName.Length; loop++)
                {
                    if (ClientName[loop] != "")
                    {
                        sql     = "INSERT INTO resdential_drill_clients (residential_drill_id,client_name,present_for_drill,time_to_exit,client_classification,prompt_level,added_date) VALUES (@residential_drill_id,@client_name,@present_for_drill,@time_to_exit,@client_classification,@prompt_level,GETDATE())";
                        command = new SqlCommand(sql, cnn);
                        command.Parameters.AddWithValue("@residential_drill_id", newId);
                        command.Parameters.AddWithValue("@client_name", ClientName[loop]);
                        command.Parameters.AddWithValue("@present_for_drill", PresentForDrill[loop]);
                        command.Parameters.AddWithValue("@time_to_exit", TimeToExit[loop]);
                        command.Parameters.AddWithValue("@client_classification", ClientClassification[loop]);
                        command.Parameters.AddWithValue("@prompt_level", PromptLevel[loop]);
                        command.CommandType = CommandType.Text;
                        command.ExecuteNonQuery();
                    }
                }
                cnn.Close();
            }
            catch (Exception e)
            {
                CL.getLog("error while adding data to resdential_drill_clients table" + e);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 10
0
        public bool updateUniqueId(int newId)
        {
            var CL = new commonLogic();

            try
            {
                SqlConnection cnn = CL.connect();
                SqlCommand    command;
                string        sql;
                string        uniqueID = "RES" + DateTime.Now.ToString("hhmmss") + newId;
                sql     = "UPDATE residency_survey SET unique_id = @unique_id WHERE id = @id";
                command = new SqlCommand(sql, cnn);
                command.Parameters.AddWithValue("@id", newId);
                command.Parameters.AddWithValue("@unique_id", uniqueID);
                command.CommandType = CommandType.Text;
                command.ExecuteNonQuery();
                cnn.Close();
            }
            catch (Exception e)
            {
                CL.getLog("error while updating unique id to table" + e);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 11
0
        public bool checkUser()
        {
            bool          status = false;
            var           CL     = new commonLogic();
            SqlConnection cnn    = CL.connect();

            try
            {
                SqlCommand command;
                string     sql;
                Password = hassPassword(Password);
                sql      = "SELECT * FROM users WHERE email = @email AND password = @password";
                command  = new SqlCommand(sql, cnn);
                command.Parameters.AddWithValue("@email", Email);
                command.Parameters.AddWithValue("@password", Password);
                SqlDataReader dataReader = command.ExecuteReader();

                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        HttpContext.Current.Session["id"]         = dataReader["id"].ToString();
                        HttpContext.Current.Session["email"]      = dataReader["email"].ToString();
                        HttpContext.Current.Session["first_name"] = dataReader["first_name"].ToString();
                        HttpContext.Current.Session["last_name"]  = dataReader["last_name"].ToString();
                        break;
                    }
                    status = true;
                }
                else
                {
                    status = false;
                }
                return(status);
            }
            catch (Exception e)
            {
                CL.getLog("error while updating unique id to table" + e);
                cnn.Close();
                return(false);
            }
            cnn.Close();
            return(status);
        }
Ejemplo n.º 12
0
        public List <string> GetLocationsList(String ProgramName, string drillType)
        {
            List <string> locationList = new List <string>();
            SqlDataReader dataReader   = null;
            string        condition    = "program_name=@program_name";

            try
            {
                var           CL  = new commonLogic();
                SqlConnection cnn = CL.connect();
                SqlCommand    command;
                String        sql = "";
                if (drillType != "" && drillType == "Residential")
                {
                    condition += " AND residential_program = 'Y'";
                }
                if (drillType != "" && drillType == "Non-Residential")
                {
                    condition += " AND residential_program = 'N'";
                }
                sql     = "select DISTINCT team_residence_location FROM programs where " + condition;
                command = new SqlCommand(sql, cnn);
                command.Parameters.AddWithValue("@program_name", ProgramName);
                dataReader = command.ExecuteReader();
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        locationList.Add(dataReader["team_residence_location"].ToString());
                    }
                    return(locationList);
                }
                else
                {
                    return(locationList);  //No data
                }
            }
            catch (Exception e)
            {
                return(locationList);
            }
        }
Ejemplo n.º 13
0
        public string GetProgramList(string residential)
        {
            SqlDataReader dataReader = null;
            DataTable     dataTable  = new DataTable();
            string        html       = "";
            string        condition  = "1";

            try
            {
                if (residential != "")
                {
                    condition = " residential_program = '" + residential + "'";
                }
                var           CL  = new commonLogic();
                SqlConnection cnn = CL.connect();
                SqlCommand    command;
                String        sql = "";
                sql        = "select DISTINCT program_name FROM programs WHERE " + condition;
                command    = new SqlCommand(sql, cnn);
                dataReader = command.ExecuteReader();
                if (dataReader.HasRows)
                {
                    dataTable.Load(dataReader);
                    CL.ddData      = dataTable;
                    CL.val         = "program_name";
                    CL.text        = "program_name";
                    CL.selectedVal = "";
                    html           = CL.createDropDown();
                    return(html);
                }
                else
                {
                    return(html);  //No data
                }
            }
            catch (Exception e)
            {
                return(html);
            }
        }
Ejemplo n.º 14
0
        public Boolean insert()
        {
            var           CL  = new commonLogic();
            SqlConnection cnn = CL.connect();
            SqlCommand    command;
            String        sql   = "";
            string        files = fileUpload();
            string        id    = HttpContext.Current.Session["id"].ToString();

            try
            {
                sql     = "INSERT INTO residency_survey (user_id,form_data,files,added_date) OUTPUT INSERTED.ID VALUES";
                sql     = sql + "(@user_id,@form_data,@files,GETDATE())";
                command = new SqlCommand(sql, cnn);
                command.Parameters.AddWithValue("@user_id", id);
                command.Parameters.AddWithValue("@form_data", completeFormData);
                command.Parameters.AddWithValue("@files", files);
                command.CommandType = CommandType.Text;
                int newId = Convert.ToInt32(command.ExecuteScalar());
                if (newId < 1)
                {
                    CL.getLog("Fail to insert");
                    return(false);
                }
                bool uniqueIdUpdate = updateUniqueId(newId);
                if (uniqueIdUpdate == false)
                {
                    CL.getLog("Fail to update with unique id to Residency Survey table.");
                    return(false);
                }
                cnn.Close();
            }
            catch (Exception e)
            {
                CL.getLog("Fail to insert to Residency Survey " + e);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 15
0
        public List <KeyValuePair <string, string> > GetFullDetails(String ProgramAddress, String ProgramName, String Address)
        {
            List <KeyValuePair <string, string> > addressList = new List <KeyValuePair <string, string> >();
            SqlDataReader dataReader = null;

            try
            {
                var           CL  = new commonLogic();
                SqlConnection cnn = CL.connect();
                SqlCommand    command;
                String        sql = "";
                sql     = "select DISTINCT ID,division, licensing_body_funding, address, carf,residential_program FROM programs where program_name=@program_name and team_residence_location=@team_residence_location and address=@address";
                command = new SqlCommand(sql, cnn);
                command.Parameters.AddWithValue("@program_name", ProgramName);
                command.Parameters.AddWithValue("@team_residence_location", Address);
                command.Parameters.AddWithValue("@address", ProgramAddress);
                dataReader = command.ExecuteReader();
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        addressList.Add(new KeyValuePair <string, string>("Licensing Body", dataReader["licensing_body_funding"].ToString()));
                        addressList.Add(new KeyValuePair <string, string>("Address", dataReader["address"].ToString()));
                        addressList.Add(new KeyValuePair <string, string>("Division", dataReader["division"].ToString()));
                        addressList.Add(new KeyValuePair <string, string>("CARF", dataReader["carf"].ToString()));
                        addressList.Add(new KeyValuePair <string, string>("ResidentialProgram", dataReader["residential_program"].ToString()));
                    }
                    return(addressList);
                }
                else
                {
                    return(addressList);  //No data
                }
            }
            catch (Exception e)
            {
                return(addressList);
            }
        }
Ejemplo n.º 16
0
        public bool checkVerificationCode(String verification_code)
        {
            bool          status = false;
            var           CL     = new commonLogic();
            SqlConnection cnn    = CL.connect();

            try
            {
                SqlCommand command;
                string     sql;
                sql     = "SELECT * FROM reset_password WHERE verification_code = @verification_code";
                command = new SqlCommand(sql, cnn);
                command.Parameters.AddWithValue("@verification_code", verification_code);
                SqlDataReader dataReader = command.ExecuteReader();

                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        HttpContext.Current.Session["email"] = dataReader["email"].ToString();
                        break;
                    }
                    status = true;
                }
                else
                {
                    status = false;
                }
                return(status);
            }
            catch (Exception e)
            {
                CL.getLog("error while updating unique id to table" + e);
                cnn.Close();
                return(false);
            }
            cnn.Close();
            return(status);
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
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);
            }
        }
Ejemplo n.º 19
0
        public bool checkEmail()
        {
            bool          status = false;
            var           CL     = new commonLogic();
            SqlConnection cnn    = CL.connect();

            try
            {
                SqlCommand command;
                string     sql;
                sql     = "SELECT * FROM users WHERE email = @email";
                command = new SqlCommand(sql, cnn);
                command.Parameters.AddWithValue("@email", Email);
                SqlDataReader dataReader = command.ExecuteReader();

                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        var    ID                = dataReader["id"].ToString();
                        var    Email             = dataReader["email"].ToString();
                        var    FristName         = dataReader["first_name"].ToString();
                        var    LastName          = dataReader["last_name"].ToString();
                        String verification_code = CL.GetUniqueKey(49);

                        cnn.Close();
                        SqlConnection con = CL.connect();
                        try
                        {
                            SqlCommand cmd;
                            string     query = @"IF EXISTS(SELECT * FROM reset_password WHERE email = @email)
                        UPDATE reset_password 
                        SET verification_code = @verification_code
                        WHERE email = @email
                    ELSE
                        INSERT INTO reset_password(email, verification_code) VALUES(@email, @verification_code);";

                            cmd = new SqlCommand(query, con);
                            cmd.Parameters.AddWithValue("@email", Email);
                            cmd.Parameters.AddWithValue("@verification_code", verification_code);
                            cmd.CommandType = CommandType.Text;
                            cmd.ExecuteNonQuery();
                            var Body = "Hi " + FristName + ",<br/><br/>Please <a href='http://*****:*****@chd.com", Email, "CHD password reset", Body);
                        }
                        catch (Exception e)
                        {
                            CL.getLog("error while updating unique id to table" + e);
                            con.Close();
                            return(false);
                        }
                        con.Close();
                        break;
                    }
                    status = true;
                }
                else
                {
                    status = false;
                }
                return(status);
            }
            catch (Exception e)
            {
                CL.getLog("error while updating unique id to table" + e);
                cnn.Close();
                return(false);
            }
            cnn.Close();
            return(status);
        }