Example #1
0
        public void CrearDataSetCompleto()
        {
            dsAlmacen = new DsAlmacen();

            daCliente = new DsAlmacenTableAdapters.ClienteTableAdapter();
            daCliente.Fill(dsAlmacen.Cliente);

            daPedido = new DsAlmacenTableAdapters.PedidoTableAdapter();
            daPedido.Fill(dsAlmacen.Pedido);

            daEmpleado = new DsAlmacenTableAdapters.EmpleadoTableAdapter();
            daEmpleado.Fill(dsAlmacen.Empleado);

            daProducto = new DsAlmacenTableAdapters.ProductoTableAdapter();
            daProducto.Fill(dsAlmacen.Producto);

            daDetalles = new DsAlmacenTableAdapters.DetallesPedidoTableAdapter();
            daDetalles.Fill(dsAlmacen.DetallesPedido);

            daCategoria = new DsAlmacenTableAdapters.CategoriaTableAdapter();
            daCategoria.Fill(dsAlmacen.Categoria);

            daProveedor = new DsAlmacenTableAdapters.ProveedorTableAdapter();
            daProveedor.Fill(dsAlmacen.Proveedor);
        }
Example #2
0
        private void btnLocalizaPedido_Click(object sender, EventArgs e)
        {
            PedidoTableAdapter taPedido = new PedidoTableAdapter();

            DataSet_Dados_do_Banco.PedidoDataTable dt = new DataSet_Dados_do_Banco.PedidoDataTable();
            dt = taPedido.PesquisaPedido(int.Parse(txtNumPedidoPesq.Text));
            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("Pedido inexistente");
                txtNumPedidoPesq.Focus();
                txtNumPedidoPesq.SelectAll();
            }
            else
            {
                lblNumeroPedido.Text     = dt.Rows[0]["ped_id"].ToString();
                cmbCliente.SelectedValue = dt.Rows[0]["cli_id"];
                dtpDataVenda.Value       = DateTime.Parse(dt.Rows[0]["ped_dtEncomenda"].ToString());
                lblTotalPedido.Text      = String.Format(dt.Rows[0]["ped_valor"].ToString(), "###,##0.00");
                txtObservacao.Text       = dt.Rows[0]["Ped_observacao"].ToString();
                //if (dt.Rows[0]["ped_id"].ToString() == "")
                //TODO lblStatus
                ItemTableAdapter taItem = new ItemTableAdapter();
                ItemDataTable    dtItem = new ItemDataTable();
                dtItem             = taItem.Pesquisa_Itens_Pedido(int.Parse(txtNumPedidoPesq.Text));
                dgvItem.DataSource = dtItem;
                dgvItem.Columns["Codigo"].DisplayIndex     = 0;
                dgvItem.Columns["Descricao"].DisplayIndex  = 1;
                dgvItem.Columns["Quantidade"].DisplayIndex = 2;
                dgvItem.Columns["Valor_Unit"].DisplayIndex = 3;
                dgvItem.Columns["TotalItem"].DisplayIndex  = 4;
            }
        }
Example #3
0
        public static Pedido GetPedidoById(int PedidoID)
        {
            PedidoTableAdapter localAdapter = new PedidoTableAdapter();

            if (PedidoID <= 0)
            {
                return(null);
            }

            Pedido theUser = null;

            try
            {
                PedidoDS.PedidoDataTable table = localAdapter.GetPedidoById(PedidoID);

                if (table != null && table.Rows.Count > 0)
                {
                    PedidoDS.PedidoRow row = table[0];
                    theUser = FillPedidoRecord(row);
                }
            }
            catch (Exception q)
            {
                log.Error("An error was ocurred while geting Pedido data", q);
                return(null);
            }

            return(theUser);
        }
Example #4
0
        //------------------------------------------------------------------------------------------------------------------



        public static List <Pedido> GetPedidoListForSearch(string whereSql)
        {
            if (string.IsNullOrEmpty(whereSql))
            {
                whereSql = "1 = 1";
            }

            List <Pedido>      theList    = new List <Pedido>();
            Pedido             theUser    = null;
            PedidoTableAdapter theAdapter = new PedidoTableAdapter();

            try
            {
                PedidoDS.PedidoDataTable table = theAdapter.GetPedidoForSearch(whereSql);

                if (table != null && table.Rows.Count > 0)
                {
                    foreach (PedidoDS.PedidoRow row in table.Rows)
                    {
                        theUser = FillPedidoRecord(row);
                        theList.Add(theUser);
                    }
                }
            }
            catch (Exception q)
            {
                log.Error("el error ocurrio mientras obtenia la lista de los pedido de la base de datos", q);
                return(null);
            }
            return(theList);
        }
Example #5
0
 private void btnFinalizar_Click(object sender, EventArgs e)
 {
     try
     {
         if (chkAberto.Checked || chkFechado.Checked && txtTotalFin.Text != "")
         {
             if (txtDebito.Text == "")
             {
                 PedidoTableAdapter taPedido = new PedidoTableAdapter();
                 taPedido.Update(Convert.ToInt32(txtCodClie.Text), dateTimePicker1.Value, Convert.ToDecimal(txtValorfin2.Text), txtPag.Text, 0, Convert.ToInt32(txtNumPedido.Text), Convert.ToInt32(txtNumPedido.Text));
                 MessageBox.Show("Venda Concluida com sucesso!");
                 PagamentoTableAdapter taPagamento = new PagamentoTableAdapter();
                 taPagamento.Insert(int.Parse(txtNumPedido.Text), txttipPag.Text);
                 this.Close();
             }
             else
             {
                 PedidoTableAdapter taPedido = new PedidoTableAdapter();
                 taPedido.Update(Convert.ToInt32(txtCodClie.Text), dateTimePicker1.Value, Convert.ToDecimal(txtValorfin2.Text), txtPag.Text, Convert.ToDecimal(txtdebito2.Text), Convert.ToInt32(txtNumPedido.Text), Convert.ToInt32(txtNumPedido.Text));
                 MessageBox.Show("Venda Concluida com sucesso!");
                 this.Close();
             }
         }
         else
         {
             MessageBox.Show("Não deixei campos em branco");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #6
0
        private void btnGravar_Click(object sender, EventArgs e)
        {
            if (cmbCliente.SelectedIndex == -1)
            {
                ErrErro.SetError(cmbCliente, "Selecione um Cliente");
                return;
            }
            else
            {
                ErrErro.SetError(cmbCliente, "");
            }
            // Grava Pedido
            PedidoTableAdapter taPedido = new PedidoTableAdapter();

            taPedido.Insert(int.Parse(cmbCliente.SelectedValue.ToString()),
                            dtpDataVenda.Value, decimal.Parse(vTotalDoPedido.ToString()), "V",
                            txtObservacao.Text);
            vld_VendaAtual = Convert.ToInt32(taPedido.UltimoPedido().Rows[0]["UltimoID"]);
            // —————————————————————————————————————————————————————————————————————

            // Gravando os itens
            ItemTableAdapter    taItem = new ItemTableAdapter();
            ProdutoTableAdapter taProduto = new ProdutoTableAdapter();
            int     vCodigoProduto, vQtdVendida;
            decimal vValorUnit;

            for (int i = 0; i <= dgvItem.RowCount - 1; i++)
            {
                vCodigoProduto = (int)dgvItem.Rows[i].Cells["Codigo"].Value;
                vQtdVendida    = (int)dgvItem.Rows[i].Cells["Quantidade"].Value;
                vValorUnit     = (decimal)dgvItem.Rows[i].Cells["Valor_Unit"].Value;

                taItem.Insert(vld_VendaAtual, vCodigoProduto, vQtdVendida, vValorUnit);

                taProduto.Acerta_Saldo_Saida(vCodigoProduto, vQtdVendida);
            }

            MessageBox.Show("Venda gravada com sucesso");
            Limpa_Campos_Pedido();
            // Limpa os itens da tabela temporária
            Item_TempTableAdapter taItem_Temp = new Item_TempTableAdapter();

            taItem_Temp.Limpa_Itens(vld_VendaAtual, vUsuario);
            CarregaGridItens();
            // Desabilita controles
            grbPedido.Enabled     = false;
            grbItens.Enabled      = false;
            btnGravar.Enabled     = false;
            cmbCliente.Enabled    = false;
            txtObservacao.Enabled = false;
            btnNovo.Enabled       = true;
            btnCancelar.Enabled   = false;
        }
Example #7
0
        private void btnNovo_Click(object sender, EventArgs e)
        {
            btnCancelar_Click(null, null); // para limpar informações pré existentes no formulário
            CarregaGridItens();
            PedidoTableAdapter taPedido = new PedidoTableAdapter();

            vid_VendaAtual      = (int)taPedido.UltimoPedido() + 1;
            lblN.Text           = vld_VendaAtual.ToString();
            grbPedido.Enabled   = true;
            grbItens.Enabled    = true;
            btnGravar.Enabled   = true;
            btnNovo.Enabled     = false;
            btnCancelar.Visible = true;
            cmbCliente.Focus();
        }
Example #8
0
        public static void DeletePedido(int PedidoId)
        {
            if (PedidoId <= 0)
            {
                throw new ArgumentException("el pedidoId no puede ser menor o igual a cero.");
            }

            try
            {
                PedidoTableAdapter theAdapter = new PedidoTableAdapter();
                theAdapter.DeletePedido(PedidoId);
            }
            catch (Exception ex)
            {
                log.Error("Ocurrio un error al Eliminar el pedido.", ex);
                throw ex;
            }
        }
Example #9
0
        private void frmCaixa_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'lealDataSet.Cliente' table. You can move, or remove it, as needed.
            this.clienteTableAdapter.Fill(this.lealDataSet.Cliente);
            // TODO: This line of code loads data into the 'lealDataSet.Pedido' table. You can move, or remove it, as needed.
            this.pedidoTableAdapter.Fill(this.lealDataSet.Pedido);
            try
            {
                txtPag.Text          = "Cancelado";
                dateTimePicker1.Text = DateTime.Now.ToString();
                PedidoTableAdapter taPedido     = new PedidoTableAdapter();
                string             ultimopedido = taPedido.UltimoCOD().ToString();
                txtNumPedido.Text = ultimopedido;
                if (!this.codcli.Equals(""))
                {
                    txtCodCli.Text = this.codcli;
                }
                ClienteTableAdapter taCliente = new ClienteTableAdapter();
                DataTable           dtCliente;
                dtCliente = taCliente.Pesquisa_Cliente(int.Parse(txtCodCli.Text));
                if (dtCliente.Rows.Count == 0)
                {
                    MessageBox.Show("Pessosa Não Cadastrada");
                    this.Close();
                }
                else
                {
                    txtNome.Text      = dtCliente.Rows[0]["Nome_Cliente"].ToString();
                    txtSobrenome.Text = dtCliente.Rows[0]["Sobrenome_Cliente"].ToString();
                    txtNomeCli.Text   = txtNome.Text + " " + txtSobrenome.Text;
                }

                //ClienteTableAdapter taCliente = new ClienteTableAdapter();
                //DataTable dtCliente;
                //dtCliente = taCliente.QueyBox2();
                //cbxClientes.Text = dtCliente.Rows[1]["NomeComp"].ToString(); ;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #10
0
        public static void UpdatePedVentFacturaEntregado(int pedidoId)
        {
            if (pedidoId <= 0)
            {
                throw new ArgumentException("El PedidoId no puede ser nulo no puede ser menor o igual a cero.");
            }

            try
            {
                PedidoTableAdapter localAdapter = new PedidoTableAdapter();
                object             resutl       = localAdapter.UpdateEstadosVentaPedFact(pedidoId);

                log.Debug("Se actualizo El Pedido al estado de entregado: " + pedidoId);
            }
            catch (Exception q)
            {
                log.Error("Ocurrió un error al actualizar el estado del pedido", q);
                throw q;
            }
        }
Example #11
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtValorfin2.Text == "")
                {
                    this.Dispose();
                }
                else if (txtValorall.Text == "R$ 0,00" || txtValorall.Text == "R$0,00")
                {
                    if (txtdebito2.Text == "")
                    {
                        PedidoTableAdapter taPed = new PedidoTableAdapter();
                        taPed.Update(Convert.ToInt32(txtCodCli.Text), dateTimePicker1.Value, Convert.ToDecimal(txtValorfin2.Text), txtPag.Text, 0, Convert.ToInt32(txtNumPedido.Text), Convert.ToInt32(txtNumPedido.Text));

                        //taPed.Delete(int.Parse(txtNumPedido.Text), int.Parse(txtCodCli.Text), dateTimePicker1.Value, decimal.Parse(txtValorfin2.Text), txttipPag.Text, 0);
                        //taPed.DeleteQuery(int.Parse(txtNumPedido.Text));
                        //this.Close();
                        this.Dispose();
                    }
                    else
                    {
                        PedidoTableAdapter taPed = new PedidoTableAdapter();
                        taPed.Update(Convert.ToInt32(txtCodCli.Text), dateTimePicker1.Value, Convert.ToDecimal(txtValorfin2.Text), txtPag.Text, Convert.ToDecimal(txtdebito2.Text), Convert.ToInt32(txtNumPedido.Text), Convert.ToInt32(txtNumPedido.Text));

                        //taPed.Delete(int.Parse(txtNumPedido.Text), int.Parse(txtCodCli.Text), dateTimePicker1.Value, decimal.Parse(txtValorfin2.Text), txttipPag.Text, decimal.Parse(txtdebito2.Text));
                        //taPed.DeleteQuery(int.Parse(txtNumPedido.Text));
                        //this.Close();
                        this.Dispose();
                    }
                }
                else if (txtValorall.Text != "R$ 0,00" || txtValorall.Text != "R$0,00")
                {
                    MessageBox.Show("Cancele todos os itens!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #12
0
        //------------------------------------------paginacion-----------------------------------------------------
        public static int SearchProductoPaginacion(ref List <Pedido> articulos, string where, int pageSize, int firstRow, string ordenar)
        {
            try
            {
                int?totalRows = 0;
                PedidoTableAdapter       localAdapter = new PedidoTableAdapter();
                PedidoDS.PedidoDataTable theTable     = localAdapter.searchPedidoBusqueda(where, pageSize, firstRow, ref totalRows, ordenar);

                if (theTable != null && theTable.Rows.Count > 0)
                {
                    foreach (PedidoDS.PedidoRow row in theTable.Rows)
                    {
                        articulos.Add(FillPedidoRecord(row));
                    }
                }
                return((int)totalRows);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #13
0
        public static int InsertPedido(Pedido objPedido)
        {
            try
            {
                if (objPedido == null)
                {
                    throw new ArgumentException("El pedidoid no puede ser nulo o vacío.");
                }

                int?PedidoId = 0;
                PedidoTableAdapter localAdapter = new PedidoTableAdapter();
                object             resutl       = localAdapter.InsertPedido(
                    ref PedidoId,
                    objPedido.UsuarioId,
                    objPedido.DepartamentoId,
                    objPedido.Direccion,
                    objPedido.NombreCliente,
                    objPedido.ApellidoCliente,
                    objPedido.Nit,
                    objPedido.FechaPedido,
                    //objPedido.FechaEntrega,
                    //objPedido.Observacion,
                    objPedido.CarritoId,
                    objPedido.TipoPago,
                    objPedido.VentaId,
                    objPedido.MontoTotal,
                    objPedido.Latitud,
                    objPedido.Longitud);

                log.Debug("Se insertó el pedido al nombre de: " + objPedido.NombreCliente);
                return((int)PedidoId);
            }
            catch (Exception q)
            {
                log.Error("Ocurrió un error al insertar el pedido", q);
                throw q;
            }
        }
Example #14
0
        public static void UpdatePedido(Pedido objPedido)
        {
            if (objPedido.PedidoId <= 0)
            {
                throw new ArgumentException("El PedidoId no puede ser menor o igual a cero.");
            }

            try
            {
                PedidoTableAdapter localAdapter = new PedidoTableAdapter();
                object             resutl       = localAdapter.UpdatePedido(
                    objPedido.UsuarioId,
                    objPedido.DepartamentoId,
                    objPedido.Direccion,
                    objPedido.NombreCliente,
                    objPedido.ApellidoCliente,
                    objPedido.Nit,
                    objPedido.FechaPedido,
                    objPedido.FechaEntrega,
                    objPedido.Observacion,
                    objPedido.CarritoId,
                    objPedido.TipoPago,
                    objPedido.VentaId,
                    objPedido.MontoTotal,
                    objPedido.Latitud,
                    objPedido.Longitud,
                    objPedido.PedidoId);

                log.Debug("Se actualizo El Pedido al nombre de : " + objPedido.NombreCliente);
            }
            catch (Exception q)
            {
                log.Error("Ocurrió un error al actualizar el pedido", q);
                throw q;
            }
        }
Example #15
0
        private void btnInserir_Click(object sender, EventArgs e)
        {
            try {
                int estoque = int.Parse(txtQuantidadeEstoq.Text);
                if (txtQuantComp.Value <= estoque)
                {
                    string marca = txtMarca.Text;
                    //decimal precounit = Convert.ToDecimal(txtPrecounid.Text);
                    ////preco = preco.Replace("R$", "#######,##");
                    CultureInfo ci = new CultureInfo("pt-BR");
                    //txtPreco.Text= precounit.ToString("C2", ci);
                    //decimal total = Convert.ToDecimal(txtVtotal.Text);
                    //txtVtotal.Text = total.ToString("C2", ci);
                    //total = total.Replace("R$ ", "#######,##");
                    if (txtMarca.Text != "")
                    {
                        txtDesc.Text = txtDesc.Text + ", " + txtMarca.Text;
                    }
                    else if (txtMarca.Text == "")
                    {
                        txtDesc.Text = txtMarca.Text;
                    }

                    if (txtQuantComp.Value != 0)
                    {
                        decimal            totalvenda = 0;
                        string             pag        = "";
                        PedidoTableAdapter taPedido   = new PedidoTableAdapter();
                        taPedido.Insert(Convert.ToInt32(txtCodCli.Text), dateTimePicker1.Value, totalvenda, pag, 0);
                        ItemPedidoTableAdapter taItemPedido = new ItemPedidoTableAdapter();

                        string quantidadeprod = txtQuantComp.Value.ToString();
                        taItemPedido.Insert(Convert.ToInt32(txtNumPedido.Text), int.Parse(quantidadeprod), int.Parse(txtCodPro.Text));
                        dgvPedido.Rows.Add(txtCodigoB.Text, txtDesc.Text, txtPrecounid.Text, txtQuantComp.Value.ToString(), txtTotal.Text);
                        {
                            //decimal total2 = 0;
                            //int i = 0;
                            //for (i = 0; i < dgvPedido.Rows.Count; i++)
                            //{
                            //    total2 = total2 + Convert.ToDecimal(dgvPedido.Rows[i].Cells["Total"].Value);
                            //}

                            //txtVtotal.Text = total2.ToString("C2", ci);

                            string novoEstoque            = (Convert.ToDecimal(txtQuantidadeEstoq.Text) - Convert.ToDecimal(txtQuantComp.Text)).ToString();
                            ProdutoTableAdapter taProduto = new ProdutoTableAdapter();
                            taProduto.UpdateEstoque(int.Parse(novoEstoque), Convert.ToInt64(txtCodigoB.Text));
                        }
                        decimal valorTotal = 0;
                        foreach (DataGridViewRow col in dgvPedido.Rows)
                        {
                            valorTotal = valorTotal + Convert.ToDecimal(col.Cells[4].Value);
                        }

                        //decimal valorall = Convert.ToDecimal(txtValorall.Text);
                        txtValorfin2.Text = valorTotal.ToString();
                        txtValorall.Text  = valorTotal.ToString("C2", ci);
                        txtTotalFin.Text  = valorTotal.ToString("C2", ci);
                        //txtTotalFin.Text = valorTotal.ToString("C2", ci);

                        txtCodigoB.Focus();
                        txtQuantComp.Text       = "";
                        txtPreco.Text           = "";
                        txtDesc.Text            = "";
                        txtCodigoB.Text         = "";
                        txtQuantidadeEstoq.Text = "";
                        txtVtotal.Text          = "";
                    }
                    else
                    {
                        MessageBox.Show("Adicione um quantidade!");
                    }
                }
                else
                {
                    MessageBox.Show("A quantidade ultrapassa o estoque.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //MessageBox.Show("Favor completar os espaços em branco.");
            }
        }
Example #16
0
        private void frmCaixaCli_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'lealDataSet.ItemPedido' table. You can move, or remove it, as needed.
            this.itemPedidoTableAdapter.Fill(this.lealDataSet.ItemPedido);
            // TODO: This line of code loads data into the 'lealDataSet.ItemPedido' table. You can move, or remove it, as needed.
            this.itemPedidoTableAdapter.Fill(this.lealDataSet.ItemPedido);
            if (!this.Propriedade.Equals(""))
            {
                txtNumPedido.Text = this.Propriedade;
            }
            if (!this.codcli.Equals(""))
            {
                txtCodClie.Text = this.codcli;
            }

            try
            {
                ItemPedidoTableAdapter taItemPedido = new ItemPedidoTableAdapter();
                DataTable dtlista;
                dtlista = taItemPedido.ConsultaPedido(Convert.ToInt32(txtNumPedido.Text));
                dataGridView1.DataSource = dtlista;
                ClienteTableAdapter taCli = new ClienteTableAdapter();

                dtlista = taCli.Pesquisa_Cliente(int.Parse(txtCodClie.Text));
                if (dtlista.Rows.Count == 0)
                {
                    MessageBox.Show("Pedido Não Encontrado!");
                    this.Close();
                }
                else
                {
                    txtNome.Text      = dtlista.Rows[0]["Nome_Cliente"].ToString();
                    txtSobrenome.Text = dtlista.Rows[0]["Sobrenome_Cliente"].ToString();
                    txtNomeCli.Text   = txtNome.Text + " " + txtSobrenome.Text;
                }
                PedidoTableAdapter taPedido = new PedidoTableAdapter();
                dtlista = taPedido.Pesquisa_Pedido(int.Parse(txtNumPedido.Text));
                if (dtlista.Rows.Count == 0)
                {
                    MessageBox.Show("Pedido Não Encontrado");
                    this.Close();
                }
                else
                {
                    txtValorfin2.Text = dtlista.Rows[0]["SubTotal_Pedido"].ToString();
                    txtdebi.Text      = dtlista.Rows[0]["Debito_Pedido"].ToString();
                }
                if (txtdebi.Text == "0")
                {
                    decimal     valor = Convert.ToDecimal(txtValorfin2.Text);
                    CultureInfo ci    = new CultureInfo("pt-BR");
                    txtValorall.Text = valor.ToString("C2", ci);
                    txtTotalFin.Text = valor.ToString("C2", ci);
                }
                else if (txtdebi.Text != "0")
                {
                    decimal     valor = Convert.ToDecimal(txtValorfin2.Text);
                    decimal     debi  = Convert.ToDecimal(txtdebi.Text);
                    CultureInfo ci    = new CultureInfo("pt-BR");
                    txtValorall.Text = valor.ToString("C2", ci);
                    txtTotalFin.Text = debi.ToString("C2", ci);
                }
            }
            catch
            {
            }
        }