Ejemplo n.º 1
0
 public List<Zone> GetAllZoneName()
 {
     string select = "SELECT * FROM tbl_zone";
     connectionObj.Open();
     commandObj.CommandText = select;
     SqlDataReader reader = commandObj.ExecuteReader();
     List<Zone> zoneList = new List<Zone>();
     while (reader.Read())
     {
         Zone aZone = new Zone();
         aZone.Id = (int)reader["id"];
         aZone.Name = reader["zoneName"].ToString();
         zoneList.Add(aZone);
     }
     reader.Close();
     connectionObj.Close();
     return zoneList;
 }
Ejemplo n.º 2
0
        public string SaveZone(Zone aZone)
        {
            if (zoneGateway.HasThisZoneExists(aZone))
            {
                return "Zone already Exists!";
            }
            else
            {

                if (zoneGateway.SaveZone(aZone))
                {
                    return "Successfull";
                }
                else
                {
                    return "Faild";
                }
            }
        }
Ejemplo n.º 3
0
        public bool HasThisZoneExists(Zone aZone)
        {
            string insert = "SELECT * FROM tbl_zone WHERE zoneName='" + aZone.Name + "'";
            connectionObj.Open();
            commandObj.CommandText = insert;
            SqlDataReader reader = commandObj.ExecuteReader();

            bool zoneStatus = reader.HasRows;
            reader.Close();
            connectionObj.Close();

            return zoneStatus;
        }
Ejemplo n.º 4
0
 public bool SaveZone(Zone aZone)
 {
     string insert = "INSERT INTO tbl_zone VALUES('" + aZone.Name + "')";
     connectionObj.Open();
     commandObj.CommandText = insert;
     int rowAffected = commandObj.ExecuteNonQuery();
     connectionObj.Close();
     if (rowAffected>0)
     {
         return true;
     }
     return false;
 }