Beispiel #1
0
        public Masa getir(int masaID)
        {
            try
            {
                sqlConnection.Open();
                cmd = new SqlCommand("SELECT * FROM Masa where masaID=" + masaID, sqlConnection);
                dr  = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        Masa masa = new Masa();
                        masa.masaID     = masaID;
                        masa.masaAdi    = dr["masaAdi"].ToString();
                        masa.masaDurumu = dr["masaDurumu"].ToString();
                        dr.Close();
                        sqlConnection.Close();
                        return(masa);
                    }
                }
            }
            catch (Exception)
            {
                dr.Close();
                if (sqlConnection.State == System.Data.ConnectionState.Open)
                {
                    sqlConnection.Close();
                }
            }

            return(null);
        }
Beispiel #2
0
        public Masa[] liste()
        {
            List <Masa> masaListesi = new List <Masa>();

            try
            {
                sqlConnection.Open();
                cmd = new SqlCommand("SELECT * FROM Masa", sqlConnection);
                dr  = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        Masa masa = new Masa();
                        masa.masaID     = Convert.ToInt32(dr["masaID"]);
                        masa.masaAdi    = dr["masaAdi"].ToString();
                        masa.masaDurumu = dr["masaDurumu"].ToString();
                        masaListesi.Add(masa);
                    }
                }
            }
            catch (Exception)
            {
                dr.Close();
                if (sqlConnection.State == System.Data.ConnectionState.Open)
                {
                    sqlConnection.Close();
                }
            }
            dr.Close();
            sqlConnection.Close();
            return(masaListesi.ToArray());
        }
Beispiel #3
0
 public string ekle(Masa masa)
 {
     try
     {
         sqlConnection.Open();
         cmd = new SqlCommand("insert into Masa (masaAdi,masaDurumu) values(@masaAdi,@masaDurumu)", sqlConnection);
         cmd.Parameters.AddWithValue("@masaAdi", masa.masaAdi);
         cmd.Parameters.AddWithValue("@masaDurumu", masa.masaDurumu);
         sqlConnection.Close();
         return("Masa eklendi.");
     }
     catch (Exception e)
     {
         if (sqlConnection.State == System.Data.ConnectionState.Open)
         {
             sqlConnection.Close();
         }
         return("Bir hata oluştu.\nHata mesajı:" + e.Message);
     }
 }