Exemple #1
0
        public void Alterar(CtrlNotasFiscais oCtrlNotasFiscais, bool attach = false)
        {
            var local = odb.Set <CtrlNotasFiscais>().Local.FirstOrDefault(p => p.Id == oCtrlNotasFiscais.Id);

            odb.Entry(local).State             = System.Data.Entity.EntityState.Detached;
            odb.Entry(oCtrlNotasFiscais).State = System.Data.Entity.EntityState.Modified;
            odb.SaveChanges();
        }
Exemple #2
0
        private void BtnSalvarControleNF_Click(object sender, EventArgs e)
        {
            if (ValidaControles())
            {
                CtrlNotasFiscais oNotasFiscais = new CtrlNotasFiscais();
                oNotasFiscais.Fornecedor = txtFornecedor.Text;
                oNotasFiscais.NumeroNF   = txtNF.Text;
                oNotasFiscais.Data       = TxtDataNF.Text;
                oNotasFiscais.Entrega    = txtEntrega.Text;
                oNotasFiscais.Hora       = txtHoraNF.Text;
                oNotasFiscais.Produto    = txtProduto.Text;
                oNotasFiscais.Recebido   = txtRecebimento.Text;

                if (Incluir)
                {
                    _Control.Incluir(oNotasFiscais);
                    Incluir = true;
                    MessageBox.Show("Cadastro de nota fiscal foi realizada com sucesso!");
                }
                else
                {
                    oNotasFiscais.Id = id;
                    _Control.Alterar(oNotasFiscais);
                    Incluir = true;
                    LimpaCampos();
                    MessageBox.Show("Os dados foram alterados com sucessso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                TxtDataNF.Text      = "";
                txtEntrega.Text     = "";
                txtFornecedor.Text  = "";
                txtHoraNF.Text      = "";
                txtNF.Text          = "";
                txtProduto.Text     = "";
                txtRecebimento.Text = "";

                CarregaGrid();
            }
        }
Exemple #3
0
        private void GrdNotas_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (GrdNotas.Rows[e.RowIndex].DataBoundItem != null)
            {
                CtrlNotasFiscais oNF = ((CtrlNotasFiscais)GrdNotas.Rows[e.RowIndex].DataBoundItem);
                if (GrdNotas.Columns[e.ColumnIndex].Name == "BtnAlterar")
                {
                    Incluir             = false;
                    TxtDataNF.Text      = oNF.Data;
                    txtEntrega.Text     = oNF.Entrega;
                    txtFornecedor.Text  = oNF.Fornecedor;
                    txtHoraNF.Text      = oNF.Hora;
                    txtNF.Text          = oNF.NumeroNF;
                    txtProduto.Text     = oNF.Produto;
                    txtRecebimento.Text = oNF.Recebido;
                    id = oNF.Id;
                    //Alterar = true;
                    //MessageBox.Show("Cliente alterado com sucesso!");
                }
                else if (GrdNotas.Columns[e.ColumnIndex].Name == "BtnExcluir")
                {
                    if (MessageBox.Show("Se confirmar será impossível recuperar os dados. Deseja continuar?", ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                    {
                        _Control.Excluir(oNF);

                        TxtDataNF.Text      = "";
                        txtEntrega.Text     = "";
                        txtFornecedor.Text  = "";
                        txtHoraNF.Text      = "";
                        txtNF.Text          = "";
                        txtProduto.Text     = "";
                        txtRecebimento.Text = "";

                        CarregaGrid();
                    }
                }
            }
        }
 public void Excluir(CtrlNotasFiscais oCtrlNotasFiscais)
 {
     _Repository.Excluir(oCtrlNotasFiscais);
 }
 public void Alterar(CtrlNotasFiscais oCtrlNotasFiscais, bool attach = false)
 {
     _Repository.Alterar(oCtrlNotasFiscais, attach);
 }
Exemple #6
0
 public void Excluir(CtrlNotasFiscais oCtrlNotasFiscais)
 {
     odb.CtrlNotasFiscais.Remove(oCtrlNotasFiscais);
     //odb.Entry(oCadastroUsuario).State = System.Data.Entity.EntityState.Deleted;
     odb.SaveChanges();
 }
Exemple #7
0
 public void Incluir(CtrlNotasFiscais oCtrlNotasFiscais)
 {
     odb.CtrlNotasFiscais.Add(oCtrlNotasFiscais);
     odb.SaveChanges();
 }