Example #1
0
        private void Atualizar(object sender, RoutedEventArgs e)
        {
            Compras c = new Compras();

            try
            {
                c.IdCliente = int.Parse(txtI.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Não é um numero");
            }
            c.NomeLivro = txtN.Text;
            try
            {
                c.Quantidade = int.Parse(txtQ.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Não é um numero");
            }
            try
            {
                c.ValorTotal = double.Parse(txtT.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Não é um numero");
            }
            NCompras n = new NCompras();

            n.Update(c);
            grid.ItemsSource = null;
            grid.ItemsSource = n.Select();
        }
Example #2
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                ErrorIcono.Clear();

                string msgRespuesta = "";
                if (txtIDSuplidor.Text == "" || txtSuplidorNombre.Text == "" || txtNCFSuplidor.Text == "" || txtDetalles.Text == "")
                {
                    MsgError("Debe ingresar los datos correctamente para continuar: ");
                }
                if (txtIDSuplidor.Text == string.Empty)
                {
                    ErrorIcono.SetError(txtSuplidorNombre, "Debe ingresar un Suplidor");
                }
                if (txtNCFSuplidor.Text == string.Empty)
                {
                    ErrorIcono.SetError(txtNCFSuplidor, "Debe Ingresar un NCF");
                }

                else
                {
                    if (N == true)
                    {
                        msgRespuesta = NCompras.IngresarCompra(Convert.ToInt32(txtIDSuplidor.Text), txtNCFSuplidor.Text, dtpfecha.Value, txtDetalles.Text);
                    }
                    else
                    {
                        //   msgRespuesta = NPresentacion.ModificarPresentacion(Convert.ToInt32(txtCodigo.Text), txtNombre.Text.Trim(), txtDescripcion.Text.Trim());
                    }
                    if (msgRespuesta.Equals("Ok"))
                    {
                        if (N)
                        {
                            MsgConfirmacion("Se han guardado los datos correctamente");
                        }
                        else
                        {
                            MsgConfirmacion("Se han editado los datos correctamente");
                        }
                        N = false;
                        E = false;
                        HoB_btn();
                        limpiar();
                        MostrarDatos();
                        ErrorIcono.Clear();
                    }
                    else
                    {
                        MsgError(msgRespuesta);
                    }
                }
            }

            catch (Exception ex)
            {
                MsgError(ex.Message + ex.StackTrace);
            }
        }
Example #3
0
        private void Excluir(object sender, RoutedEventArgs e)
        {
            Compras l = new Compras();

            l.IdCliente = int.Parse(txtI.Text);
            NCompras n = new NCompras();

            n.Delete(l);
            grid.ItemsSource = null;
            grid.ItemsSource = n.Select();
        }
Example #4
0
        private void Inserir(object sender, RoutedEventArgs e)
        {
            Produtos w = new Produtos();

            if (w.ShowDialog().Value)
            {
                NCompras n = new NCompras();
                n.Insert(w.GetP());
                grid.ItemsSource = null;
                grid.ItemsSource = n.Select();
            }
        }
Example #5
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                ErrorIcono.Clear();

                string msgRespuesta = "";
                if (txtIDArticulo.Text == "" || txtNombre.Text == "" || txtCantidad.Text == "" || txtCosto.Text == "" || txtDescuento.Text == "")
                {
                    MsgError("Debe ingresar los datos correctamente para continuar: ");
                }
                if (txtNombre.Text == string.Empty)
                {
                    ErrorIcono.SetError(txtNombre, "Debe seleccionar un articulo");
                }
                if (txtCantidad.Text == string.Empty)
                {
                    ErrorIcono.SetError(txtCantidad, "Debe Ingresar una Cantidad");
                }
                if (txtCosto.Text == string.Empty)
                {
                    ErrorIcono.SetError(txtCosto, "Debe Ingresar el costo del producto");
                }
                if (txtDescuento.Text == string.Empty)
                {
                    ErrorIcono.SetError(txtDescuento, "Debe el porcentade de descuento");
                }


                else
                {
                    decimal comprabruto;
                    int     CANTIDAD = Convert.ToInt32(txtCantidad.Text);

                    comprabruto = CANTIDAD * costo;
                    decimal descuentogenerado = comprabruto * (descuento / 100);

                    decimal compramenosdescuento = comprabruto - descuentogenerado;
                    decimal subtotal             = 0;
                    decimal itbis      = 18;
                    decimal totalitbis = 0;
                    if (cbITBIS.Checked == true)
                    {
                        totalitbis = compramenosdescuento * (itbis / 100);
                        subtotal   = totalitbis;
                    }
                    else
                    {
                        subtotal = compramenosdescuento;
                    }

                    frmCompra FRM = new frmCompra();
                    msgRespuesta = NCompras.IngresarDetalleCompra(Convert.ToInt32(FRM.txtCodigoC.Text), Convert.ToInt32(txtIDArticulo.Text), Convert.ToInt32(txtCantidad.Text)
                                                                  , Convert.ToDecimal(txtCosto.Text), comprabruto, descuentogenerado, totalitbis, subtotal);

                    /*
                     *
                     * if (msgRespuesta.Equals("Ok"))
                     * {
                     *   if (N)
                     *   {
                     *       MsgConfirmacion("Se han guardado los datos correctamente");
                     *   }
                     *   else
                     *   {
                     *       MsgConfirmacion("Se han editado los datos correctamente");
                     *   }
                     *   N = false;
                     *   E = false;
                     *   HoB_btn();
                     *   limpiar();
                     *   MostrarDatos();
                     *   ErrorIcono.Clear();
                     * }
                     * else { MsgError(msgRespuesta); }
                     */
                }
            }

            catch (Exception ex)
            {
                MsgError(ex.Message + ex.StackTrace);
            }
        }