Exemple #1
0
        public int FinalizarVenda(int idCliente, int idtTipoVenda)
        {
            try
            {
                VendaBLL vendaBLL = new VendaBLL();
                ItemVendaBLL itemVendaBLL = new ItemVendaBLL();
                VENDA venda = new VENDA();

                venda.IDT_CLIENTE = idCliente;
                venda.IDT_TIPO_VENDA = idtTipoVenda;
                venda.DATA_VENDA = DateTime.Now;
                venda.VALOR_TOTAL = this.ValorTotal();

                vendaBLL.Add(venda);
                vendaBLL.SaveChanges();

                foreach (ITEM_VENDA itemvenda in Itens)
                {
                    itemvenda.IDT_VENDA = venda.IDT_VENDA;
                    itemVendaBLL.Add(itemvenda);
                    itemVendaBLL.SaveChanges();
                }

                itemVendaBLL = null;
                vendaBLL = null;

                return venda.IDT_VENDA;
            }
            catch
            {
                return 0;
            }
        }
Exemple #2
0
        public int FinalizarVenda(int idCliente, int IdtTipoVenda)
        {
            try
            {
                VENDA        venda        = new VENDA();
                ItemVendaBLL itemVendaBLL = new ItemVendaBLL();
                VendaBLL     vendaBLL     = new VendaBLL();

                venda.IDT_CLIENTE    = idCliente;
                venda.IDT_TIPO_VENDA = IdtTipoVenda;
                venda.DATA_VENDA     = DateTime.Now;
                venda.VALOR_TOTAL    = this.ValorTotal();

                vendaBLL.Add(venda);
                vendaBLL.SaveChanges();

                foreach (ITEM_VENDA itemvenda in Itens)
                {
                    itemvenda.IDT_VENDA = venda.IDT_VENDA;
                    itemVendaBLL.Add(itemvenda);
                    itemVendaBLL.SaveChanges();
                }

                venda        = null;
                itemVendaBLL = null;
                vendaBLL     = null;

                return(venda.IDT_VENDA);
            }
            catch
            {
                return(0);
            }
        }
Exemple #3
0
        public static void DefineType(Object obj, string command)
        {
            try
            {
                if (obj != null)
                {
                    string nome = obj.GetType().FullName.ToLower();

                    if (nome.Trim().ToLower().Contains("cliente"))
                    {
                        Cliente cliente = new Cliente();
                        cliente = (Cliente)obj;

                        ClienteBLL clienteBLL = new ClienteBLL();

                        switch (command.ToUpper()[0])
                        {
                        case 'A':
                            clienteBLL.Update(cliente);
                            System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!");
                            break;

                        case 'D':
                            clienteBLL.Delete(cliente);
                            System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!");
                            break;

                        case 'I':
                            clienteBLL.Insert(cliente);
                            System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!");
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    if (nome.Trim().ToLower().Contains("fornecedor"))
                    {
                        Fornecedor fornecedor = new Fornecedor();
                        fornecedor = (Fornecedor)obj;

                        FornecedorBLL fornecedorBLL = new FornecedorBLL();

                        switch (command.ToUpper()[0])
                        {
                        case 'A':
                            fornecedorBLL.Update(fornecedor);
                            System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!");
                            break;

                        case 'D':
                            fornecedorBLL.Delete(fornecedor);
                            System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!");
                            break;

                        case 'I':
                            fornecedorBLL.Insert(fornecedor);
                            System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!");
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    if (nome.Trim().ToLower().Contains("funcionario"))
                    {
                        Funcionario funcionario = new Funcionario();
                        funcionario = (Funcionario)obj;

                        FuncionarioBLL funcionarioBLL = new FuncionarioBLL();

                        switch (command.ToUpper()[0])
                        {
                        case 'A':
                            funcionarioBLL.Update(funcionario);
                            System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!");
                            break;

                        case 'D':
                            funcionarioBLL.Delete(funcionario);
                            System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!");
                            break;

                        case 'I':
                            funcionarioBLL.Insert(funcionario);
                            System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!");
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    if (nome.Trim().ToLower().Contains("produto"))
                    {
                        Produto produto = new Produto();
                        produto = (Produto)obj;

                        ProdutoBLL produtoBLL = new ProdutoBLL();

                        switch (command.ToUpper()[0])
                        {
                        case 'A':
                            produtoBLL.Update(produto);
                            System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!");
                            break;

                        case 'D':
                            produtoBLL.Delete(produto);
                            System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!");
                            break;

                        case 'I':
                            produtoBLL.Insert(produto);
                            System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!");
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    if (nome.Trim().ToLower().Contains("itemVenda"))
                    {
                        ItemVenda itemVenda = new ItemVenda();
                        itemVenda = (ItemVenda)obj;

                        ItemVendaBLL itemVendaBLL = new ItemVendaBLL();

                        switch (command.ToUpper()[0])
                        {
                        case 'A':
                            itemVendaBLL.Update(itemVenda);
                            System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!");
                            break;

                        case 'D':
                            itemVendaBLL.Delete(itemVenda);
                            System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!");
                            break;

                        case 'I':
                            itemVendaBLL.Insert(itemVenda);
                            System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!");
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    if (nome.Trim().ToLower().Contains("itemEntrada"))
                    {
                        ItemEntrada itemEntrada = new ItemEntrada();
                        itemEntrada = (ItemEntrada)obj;

                        ItemEntradaBLL itemEntradaBLL = new ItemEntradaBLL();

                        switch (command.ToUpper()[0])
                        {
                        case 'A':
                            itemEntradaBLL.Update(itemEntrada);
                            System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!");
                            break;

                        case 'D':
                            itemEntradaBLL.Delete(itemEntrada);
                            System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!");
                            break;

                        case 'I':
                            itemEntradaBLL.Insert(itemEntrada);
                            System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!");
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    if (nome.Trim().ToLower().Contains("entrada"))
                    {
                        Entrada entrada = new Entrada();
                        entrada = (Entrada)obj;

                        EntradaBLL entradaBLL = new EntradaBLL();

                        switch (command.ToUpper()[0])
                        {
                        case 'A':
                            entradaBLL.Update(entrada);
                            System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!");
                            break;

                        case 'D':
                            entradaBLL.Delete(entrada);
                            System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!");
                            break;

                        case 'I':
                            entradaBLL.Insert(entrada);
                            System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!");
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    if (nome.Trim().ToLower().Contains("venda"))
                    {
                        Venda venda = new Venda();
                        venda = (Venda)obj;

                        VendaBLL vendaBLL = new VendaBLL();

                        switch (command.ToUpper()[0])
                        {
                        case 'A':
                            vendaBLL.Update(venda);
                            System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!");
                            break;

                        case 'D':
                            vendaBLL.Delete(venda);
                            System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!");
                            break;

                        case 'I':
                            vendaBLL.Insert(venda);
                            System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!");
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);;
            }
        }