Beispiel #1
0
        public static void AddNewApplication(string name, string city, string state,
                                             string skills, string education, string reason, int jID)
        {
            ApplicationModels am = new ApplicationModels();

            ModelList.Add(am);
            am.City      = city;
            am.education = education;
            am.jobID     = jID;
            am.Name      = name;
            am.reason    = reason;
            am.skills    = skills;
            am.State     = state;

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

            connect.Open();
            string commandStr = "INSERT INTO App (AName, ACity, AState, ASkills, AEducation, Areason, JobID)\n";

            commandStr += " VALUES ('" + am.Name + "','" + am.City + "','" + am.State + "','" + am.skills + "','" + am.education + "','" + am.reason + "'," + am.jobID + ");\n";
            SqlCommand comm = new SqlCommand(commandStr, connect);

            comm.ExecuteNonQuery();

            connect.Close();
        }
Beispiel #2
0
        public static void prepFromDatabase()
        {
            if (ModelList == null)
            {
                ModelList = new List <ApplicationModels>();
            }
            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 App;");

            SqlDataReader reader = comm.ExecuteReader();

            while (reader.Read())
            {
                ApplicationModels newMod = new ApplicationModels();
                ModelList.Add(newMod);
            }

            connect.Close();

            foreach (ApplicationModels am in ModelList)
            {
                am.loadFromTable();
            }
        }