Ejemplo n.º 1
0
        public static void prepJobList()
        {
            if (jobList == null)
            {
                jobList = new List <JobModels>();
            }
            else
            {
                return;
            }
            SqlConnection connect = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|/Database1.mdf;Integrated Security=True");

            connect.Open();
            SqlCommand comm = new SqlCommand("SELECT COUNT(*) from Job;");

            SqlDataReader reader = comm.ExecuteReader();

            while (reader.Read())
            {
                JobModels newMod = new JobModels();
                jobList.Add(newMod);
            }

            connect.Close();

            foreach (JobModels am in jobList)
            {
                am.LoadFromTable();
            }
        }
Ejemplo n.º 2
0
        public static void addNewJob(string title, string desc, string skillReq,
                                     string city, string salaryRange)
        {
            JobModels jm = new JobModels();

            jobList.Add(jm);
            jm.description = desc;
            jm.Location    = city;
            jm.salary      = salaryRange;
            jm.skills      = skillReq;
            jm.Title       = title;

            SqlConnection connect = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|/Database1.mdf;Integrated Security=True");

            connect.Open();
            string commandStr = "INSERT INTO Job (JobTitle,Jobdescription,JobReqSkill,JobCity,JobSalaryRange)\n";

            commandStr += " VALUES ('" + jm.Title + "','" + jm.description + "','" + jm.skills + "','" + jm.Location + "','" + jm.salary + "')";

            SqlCommand comm = new SqlCommand(commandStr, connect);

            comm.ExecuteNonQuery();
            connect.Close();
        }