Example #1
0
 //*** btn DELETAR
 private void btnDeletar_Click(object sender, EventArgs e)
 {
     objState = EntityState.Deleted;
     if (MetroFramework.MetroMessageBox.Show(this, "Tem certeza que deseja Excluir esta registro", "Excluir ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         try
         {
             Contato obj = contatoBindingSource.Current as Contato;
             if (obj != null)
             {
                 ContatoServiceSoapClient client = new ContatoServiceSoapClient();
                 bool result = client.Delete(obj.ContatoID);
                 if (result)
                 {
                     contatoBindingSource.RemoveCurrent();
                     pContainer.Enabled = false;
                     picFoto.Image      = null;
                     objState           = EntityState.Unchanged;
                 }
             }
         }
         catch (Exception ex)
         {
             MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Example #2
0
        //*** btn SALVAR
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            //Validações...
            validarEmail(txtEmail, errorProvider1);
            validarCPF(txtCPF, errorProvider1);

            try
            {
                Contato obj = contatoBindingSource.Current as Contato;
                if (obj != null)
                {
                    ContatoServiceSoapClient client = new ContatoServiceSoapClient();
                    if (objState == EntityState.Added)
                    {
                        obj.ContatoID = client.Inserir(obj);
                    }
                    else if (objState == EntityState.Changed)
                    {
                        client.Update(obj);
                    }
                    gdContatos.Refresh();
                    pContainer.Enabled = false;
                    objState           = EntityState.Unchanged;
                }
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #3
0
 private void Form1_Load(object sender, EventArgs e)
 {
     try
     {
         CRUDService.ContatoServiceSoapClient client = new ContatoServiceSoapClient();
         contatoBindingSource.DataSource = client.GetAll();
         pContainer.Enabled = false;
         Contato obj = contatoBindingSource.Current as Contato;
         if (obj != null)
         {
             if (!string.IsNullOrEmpty(obj.ImagemUrl))
             {
                 picFoto.Image = Image.FromFile(obj.ImagemUrl);
             }
         }
     }
     catch (Exception ex)
     {
         MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }