}//fin del metodo public Int32 DelHabitacion(Tbl_habitacion thb) { int eliminado; sb.Clear(); sb.Append("USE hotel;"); sb.Append("DELETE FROM tbl_habitacion WHERE id_tipoHabitacion=" + thb.Id_tipoHabitacion + ";"); try { con.AbrirConexion(); eliminado = con.Ejecutar(CommandType.Text, sb.ToString()); return(eliminado); } catch (Exception e) { ms = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, e.Message); ms.Run(); ms.Destroy(); throw; } finally { con.CerrarConexion(); } }//fin del metodo
}//fin del metodo public bool existeHabitacion(Tbl_habitacion thb) { bool existe = false; //bandera IDataReader idr = null; sb.Clear(); sb.Append("USE hotel;"); sb.Append("SELECT * FROM tbl_habitacion WHERE numero=" + "'" + thb.Numero + "';"); //sb.Append("AND id_tipoHabitacion=" + thb.Id_tipoHabitacion + ";"); try { con.AbrirConexion(); idr = con.Leer(CommandType.Text, sb.ToString()); if (idr.Read()) { existe = true; } return(existe); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); throw; } finally { idr.Close(); con.CerrarConexion(); } }//fin del metodo
}//fin del metodo public bool GuardarHabitacion(Tbl_habitacion thb) { bool guardado = false; //bandera int x = 0; //variable de control sb.Clear(); sb.Append("USE hotel;"); sb.Append("INSERT INTO tbl_habitacion"); sb.Append("(numero, id_tipoHabitacion, estado)"); sb.Append(" VALUES('" + thb.Numero + "','" + thb.Id_tipoHabitacion + "','" + 1 + "')"); try { con.AbrirConexion(); x = con.Ejecutar(CommandType.Text, sb.ToString()); if (x > 0) { guardado = true; /* ms = new MessageDialog(null,DialogFlags.Modal, * MessageType.Info,ButtonsType.Ok,"Se guardo el usuario con exito!!!"); * ms.Run(); * ms.Destroy();*/ } return(guardado); } catch (Exception e) { ms = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, e.Message); ms.Run(); ms.Destroy(); Console.WriteLine("ERROR: " + e.Message); Console.WriteLine("ERROR: " + e.StackTrace); throw; } finally { con.CerrarConexion(); } }//fin del metodo