internal void InsertWard(Ward ward)
 {
     using (SqlConnection connection = new SqlConnection(connectionString))
     {
         using (SqlCommand cmd = new SqlCommand("INSERT INTO Wards (WardName, CreatedBy, CreatedDate, UpdatedBy, UpdatedDate) VALUES " +
                                                "                                 ('St. George Ward', 'George', '2019-02-24','George', '2019-02-24');",
                                                connection))
         {
             cmd.ExecuteNonQuery();
         }
     }
 }
        public List <Ward> GetWards()
        {
            List <Ward> wardsList = new List <Ward>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand cmd = new SqlCommand("SELECT * FROM WARDS", connection))
                {
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Ward ward = new Ward();
                        ward.WardId = Convert.ToInt32(reader["Id"]);
                        wardsList.Add(ward);
                    }
                }
            }

            return(wardsList);
        }
示例#3
0
        public void InsertWard(Ward ward)
        {
            DataAccess ds = new DataAccess();

            ds.InsertWard(ward);
        }