Beispiel #1
0
        public void Excluir(CadastroHotel oCadastroHotel)
        {
            odb.CadastroHotel.Remove(oCadastroHotel);
            //odb.Entry(oCadastroUsuario).State = System.Data.Entity.EntityState.Deleted;

            odb.SaveChanges();
        }
Beispiel #2
0
 public void Alterar(CadastroHotel oCadastroHotel, bool attach = false)
 {
     if (attach)
     {
         odb.Entry(oCadastroHotel).State = System.Data.Entity.EntityState.Modified;
     }
     odb.SaveChanges();
 }
        private void BtnSalvarH_Click(object sender, EventArgs e)
        {
            if (ValidaControles())
            {
                if (Incluir)
                {
                    CadastroHotel oHotel = new CadastroHotel();
                    oHotel.Bairroh        = TxtBairroH.Text;
                    oHotel.Categoria      = CbCategoriaH.Text;
                    oHotel.Cidadeh        = TxtCidadeH.Text;
                    oHotel.DescricaoHotel = TxtDescricaoH.Text;
                    oHotel.NomeCliente    = TxtClienteH.Text;
                    oHotel.ReferenciaH    = TxtReferenciaH.Text;
                    oHotel.Ruah           = TxtRuaH.Text;
                    oHotel.Ufh            = TxtUfH.Text;
                    oHotel.Valorh         = ValorH.Text;
                    oHotel.Telefone       = TxtTelefoneH.Text;

                    Bitmap bmp = new Bitmap(PbImagem.Image);

                    MemoryStream memory = new MemoryStream();
                    bmp.Save(memory, ImageFormat.Bmp);

                    byte[] Imagem = memory.ToArray();

                    oHotel.FotoHotel = Imagem;


                    _Control.Incluir(oHotel);
                }

                TxtBairroH.Text     = "";
                CbCategoriaH.Text   = "";
                TxtCidadeH.Text     = "";
                TxtDescricaoH.Text  = "";
                TxtClienteH.Text    = "";
                TxtReferenciaH.Text = "";
                TxtRuaH.Text        = "";
                TxtUfH.Text         = "";
                ValorH.Text         = "";
                TxtTelefoneH.Text   = "";

                PbImagem.Image = null;
                TxtAbrir.Text  = String.Empty;

                CarregaGrid();
            }
        }
        private void GridHotel_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (GridHotel.Rows[e.RowIndex].DataBoundItem != null)
            {
                CadastroHotel oHotel = ((CadastroHotel)GridHotel.Rows[e.RowIndex].DataBoundItem);
                if (GridHotel.Columns[e.ColumnIndex].Name == "BtnAlterar")
                {
                    Incluir             = false;
                    TxtBairroH.Text     = oHotel.Bairroh;
                    CbCategoriaH.Text   = oHotel.Categoria;
                    TxtCidadeH.Text     = oHotel.Cidadeh;
                    TxtDescricaoH.Text  = oHotel.DescricaoHotel;
                    TxtClienteH.Text    = oHotel.NomeCliente;
                    TxtReferenciaH.Text = oHotel.ReferenciaH;
                    TxtRuaH.Text        = oHotel.Ruah;
                    TxtUfH.Text         = oHotel.Ufh;
                    ValorH.Text         = oHotel.Valorh;
                    TxtTelefoneH.Text   = oHotel.Telefone;

                    PbImagem.Image = null;
                    TxtAbrir.Text  = String.Empty;
                }
                else if (GridHotel.Columns[e.ColumnIndex].Name == "BtnExcluir")
                {
                    _Control.Excluir(oHotel);
                    TxtBairroH.Text     = "";
                    CbCategoriaH.Text   = "";
                    TxtCidadeH.Text     = "";
                    TxtDescricaoH.Text  = "";
                    TxtClienteH.Text    = "";
                    TxtReferenciaH.Text = "";
                    TxtRuaH.Text        = "";
                    TxtUfH.Text         = "";
                    ValorH.Text         = "";
                    TxtTelefoneH.Text   = "";

                    PbImagem.Image = null;
                    TxtAbrir.Text  = String.Empty;

                    CarregaGrid();
                }
            }
        }
 public void Excluir(CadastroHotel oHotel)
 {
     _Repository.Excluir(oHotel);
 }
 public void Alterar(CadastroHotel oHotel, bool attach = false)
 {
     _Repository.Alterar(oHotel, attach);
 }
 public void Incluir(CadastroHotel oHotel)
 {
     _Repository.Incluir(oHotel);
 }
Beispiel #8
0
 public void Incluir(CadastroHotel oHotel)
 {
     //odb.Entry(oCadastroUsuario).State = System.Data.Entity.EntityState.Added;
     odb.CadastroHotel.Add(oHotel);
     odb.SaveChanges();
 }