コード例 #1
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);
        }
コード例 #2
0
    public string GetDrillStatus(string reportForQuanterEnding, string DateTimeofDrill, string TypeOfDrill, string Durationofdrill)
    {
        var    CL     = new commonLogic();
        string status = "Fail";

        try
        {
            if (Durationofdrill != null)
            {
                double seconds = TimeSpan.Parse(Durationofdrill).TotalMinutes;  //convert to seconds

                if (TypeOfDrill == "Fire" && seconds < 150)
                {
                    status = "Pass";
                }
                if (TypeOfDrill != "Fire")
                {
                    status = "Pass";
                }
            }
            else
            {
                status = "Pass";
            }
        }
        catch (Exception e)
        {
            CL.getLog("error getting status resdential_drill_log " + e);
        }
        return(status);
    }
コード例 #3
0
ファイル: EmergencyModels.cs プロジェクト: vadlamudigopi/chd
        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);
        }
コード例 #4
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);
            }
        }
コード例 #5
0
        public FileContentResult pdf()
        {
            string html           = string.Empty;
            string uniqueId       = (string)Request.QueryString["a"];
            string page           = (string)Request.QueryString["page"];
            var    OS             = new OfficeSurveyModel();
            var    CL             = new commonLogic();
            var    htmlToPdf      = new HtmlToPdfConverter();
            var    pdfContentType = "application/pdf";

            try
            {
                OS.where     = " WHERE unique_id = '" + uniqueId + "'";
                CL.dataTable = OS.select();
                CL.pageType  = page;
                html         = CL.ViewHtml();
                string htmlContent = "<!DOCTYPE html><html lang='en'><head><style><style>body{font-family: 'Poppins', sans-serif;}.h5, h5 {font-size: 1rem; }hr{width: 100%;}hr {margin-top: 1rem;margin-bottom: 1rem;border: 0; border-top: 1px solid rgba(0, 0, 0, 0.1);}.col-md-12{width:100%;}.col-sm-8{width:60%; float:left;}.col-sm-4{width:40%;float:right;}</style></style></head><body>" + html + "</body></html>";

                //var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
                htmlToPdf.PageFooterHtml = $@"page <span class=""page""></span> of <span class=""topage""></span>";
                var    pdfBytes = htmlToPdf.GeneratePdf(htmlContent);
                string fileName = CL.getFileName();
                return(File(pdfBytes, "application/pdf", fileName + ".pdf"));
            }
            catch (Exception e)
            {
                CL.getLog("Fail to generate PDF." + e);
                return(File(htmlToPdf.GeneratePdf("<b>Something Went wrong!!!</b>", null), pdfContentType));
            }
        }
コード例 #6
0
ファイル: EmergencyModels.cs プロジェクト: vadlamudigopi/chd
        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);
            }
        }
コード例 #7
0
ファイル: EmergencyModels.cs プロジェクト: vadlamudigopi/chd
        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);
            }
        }
コード例 #8
0
ファイル: EmergencyModels.cs プロジェクト: vadlamudigopi/chd
        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);
        }
コード例 #9
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);
            }
        }
コード例 #10
0
        public string fileUpload()
        {
            string fileDataString = "{";
            var    CL             = new commonLogic();

            try
            {
                var i = 0;
                foreach (HttpPostedFileBase file in files)
                {
                    //Checking file is available to save.
                    if (file != null)
                    {
                        i++;
                        if (CheckFileType(file.FileName.ToString(), CL))
                        {
                            string newFileName = Path.GetFileNameWithoutExtension(file.FileName) + "_" + DateTime.Now.ToString("yyyyMMddhhmmss") + Path.GetExtension(file.FileName);
                            var    path        = Path.Combine(HttpContext.Current.Server.MapPath("~/upload"), newFileName);
                            file.SaveAs(path);

                            fileDataString += "File" + i + ":'" + newFileName + "',";
                        }
                    }
                }
            }
            catch (Exception e)
            {
                CL.getLog("error uploading file ");
                fileDataString += "}";
                return(fileDataString);
            }
            fileDataString += "}";
            return(fileDataString);
        }
コード例 #11
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);
            }
        }
コード例 #12
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);
        }
コード例 #13
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);
            }
        }
コード例 #14
0
        public ActionResult Index()
        {
            var RDObj = new ResidentialDrillModel();
            var CL    = new commonLogic();

            CL.dataTable     = RDObj.select();
            CL.tableId       = "residentialsDrill";
            ViewBag.htmldata = CL.buildGridView();
            return(View());
        }
コード例 #15
0
        public ActionResult SurveyList()
        {
            var emergencyObj = new EmergencyModels();
            var CL           = new commonLogic();

            CL.dataTable     = emergencyObj.select();
            CL.tableId       = "emergencyDrill";
            ViewBag.htmldata = CL.buildGridView();
            return(View());
        }
コード例 #16
0
 public ActionResult list()
 {
     try
     {
         var OS = new OfficeSurveyModel();
         var CL = new commonLogic();
         CL.dataTable     = OS.select();
         CL.tableId       = "officeSurveyList";
         ViewBag.htmldata = CL.residenceSurveyGridView();
     }
     catch (Exception e)
     {
         return(View());
     }
     return(View());
 }
コード例 #17
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);
        }
コード例 #18
0
        public string view(string uniqueID)
        {
            string html = string.Empty;

            try
            {
                var OS = new OfficeSurveyModel();
                var CL = new commonLogic();
                OS.where     = " WHERE unique_id = '" + uniqueID + "'";
                CL.dataTable = OS.select();
                CL.pageType  = "summary";
                html         = CL.ViewHtml();
            }
            catch (Exception e)
            {
                return(html);
            }
            return(html);
        }
コード例 #19
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);
            }
        }
コード例 #20
0
        public String getViewData(FormCollection form)
        {
            string uniqueID = form["uniqueID"];
            string html     = "";
            var    CL       = new commonLogic();

            try
            {
                var       RM = new ResidentialDrillModel();
                DataTable residentialData = RM.GetResidentialData(uniqueID);
                //DataTable residentialClientData = RM.GetResidentialClientData(residentialData.Rows[0]["id"].ToString());
                html += CL.buildResidentialHTML(residentialData);
            }
            catch (Exception e)
            {
                CL.getLog("error while getting data for popip in resdential_drill_log " + e);
                return(html);
            }
            return(html);
        }
コード例 #21
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);
            }
        }
コード例 #22
0
        public String getViewData(FormCollection form)
        {
            string uniqueID = form["uniqueID"];
            string html     = "";
            var    CL       = new commonLogic();

            try
            {
                var EM = new EmergencyModels();

                DataTable emergencyLogData          = EM.viewData(uniqueID);
                DataTable emergencyClientData       = EM.GetEmergencyClientData(emergencyLogData.Rows[0]["id"].ToString());
                DataTable emergencyParticipantsData = EM.GetEmergencyParticipantsData(emergencyLogData.Rows[0]["id"].ToString());
                html += CL.buildEmergencyHTML(emergencyLogData, emergencyClientData, emergencyParticipantsData);
            }
            catch (Exception e)
            {
                CL.getLog("error while getting data for popip in resdential_drill_log " + e);
                return(html);
            }
            return(html);
        }
コード例 #23
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);
        }
コード例 #24
0
ファイル: EmergencyModels.cs プロジェクト: vadlamudigopi/chd
        public string uploadFile()
        {
            string newFileName = "";
            var    CL          = new commonLogic();

            try
            {
                if (uploadSurvey != null && uploadSurvey.ContentLength > 0)
                {
                    // extract only the filename
                    newFileName = Path.GetFileNameWithoutExtension(uploadSurvey.FileName) + "_" + DateTime.Now.ToString("yyyyMMddhhmmss") + Path.GetExtension(uploadSurvey.FileName);
                    var path = Path.Combine(HttpContext.Current.Server.MapPath("~/upload"), newFileName);
                    uploadSurvey.SaveAs(path);
                }
            }
            catch (Exception e)
            {
                CL.getLog("error uploading file ");
                return(newFileName);
            }
            return(newFileName);
        }
コード例 #25
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);
            }
        }
コード例 #26
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);
        }
コード例 #27
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);
            }
        }
コード例 #28
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);
        }
コード例 #29
0
ファイル: EmergencyModels.cs プロジェクト: vadlamudigopi/chd
        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);
        }