Esempio n. 1
0
        public void ActualizarOrdenCompra_Producto(OrdenCompra_Productos OrdenCompra_Producto)
        {
            AccesoDatos.ObtenerConexion().Open();
            using (ComandoSQL = new SqlCommand())
            {
                ComandoSQL.Connection  = AccesoDatos.ObtenerConexion();
                ComandoSQL.CommandType = CommandType.StoredProcedure;
                ComandoSQL.CommandText = "proc_OrdCompra_ProdActualizar";
                try
                {
                    ComandoSQL.Parameters.AddWithValue("@IdOrdenCompra", OrdenCompra_Producto.IdOrdenCompra);
                    ComandoSQL.Parameters.AddWithValue("@Cant", OrdenCompra_Producto.Cant);
                    ComandoSQL.Parameters.AddWithValue("@Producto", OrdenCompra_Producto.Producto);
                    ComandoSQL.Parameters.AddWithValue("@Precio", OrdenCompra_Producto.Precio);
                    ComandoSQL.Parameters.AddWithValue("@Costo", OrdenCompra_Producto.Costo);
                    ComandoSQL.Parameters.AddWithValue("@DescProd", OrdenCompra_Producto.DescProd);

                    //Ejecutar Comando
                    ComandoSQL.ExecuteNonQuery();
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    AccesoDatos.ObtenerConexion().Close();
                }
            }
        }
Esempio n. 2
0
        private void eliminarProductosOrdCompra()
        {
            OrdenCompra_ProductoBL ordpr   = new OrdenCompra_ProductoBL();
            OrdenCompra_Productos  entidad = new OrdenCompra_Productos();

            entidad.IdOrdenCompra = ID;
            ordpr.EliminarOrdenCompra_Producto(entidad);
        }
Esempio n. 3
0
        public void PaginarOrdenesDeCompra()
        {
            int fila = dgvOrd.CurrentRow.Index;

            try
            {
                string date = dgvOrd.Rows[fila].Cells["Fecha Solicitud"].Value.ToString().Substring(0, 10);

                ID         = dgvOrd.Rows[fila].Cells["Id"].Value.ToString();
                txtId.Text = dgvOrd.Rows[fila].Cells["Id"].Value.ToString();
                dtpFechaSolicitud.Value      = Convert.ToDateTime(date);
                cbxSolicitante.SelectedValue = dgvOrd.Rows[fila].Cells["Solicitante"].Value.ToString();
                cbxProveedor.SelectedValue   = dgvOrd.Rows[fila].Cells["Proveedor"].Value.ToString();
                txtFormaEntrega.Text         = dgvOrd.Rows[fila].Cells["Forma de Entrega"].Value.ToString();
                txtCondicionPago.Text        = dgvOrd.Rows[fila].Cells["Condicion de Pago"].Value.ToString();
                txtCostoEnvio.Text           = float.Parse(dgvOrd.Rows[fila].Cells["Costo Envio"].Value.ToString()).ToString("N2");
                lblCostoNeto.Text            = float.Parse(dgvOrd.Rows[fila].Cells["Costo Neto"].Value.ToString()).ToString("N2");
                lblCostoTotal.Text           = float.Parse(dgvOrd.Rows[fila].Cells["Costo Total"].Value.ToString()).ToString("N2");
                chkActivo.Checked            = Convert.ToBoolean(dgvOrd.Rows[fila].Cells["Activo"].Value.ToString());

                // Implementacion llenado DataGrid Productos
                if (Int32.Parse(dgvProd.Rows.Count.ToString()) > 0)
                {
                    limpiarDataGridProductos();
                }

                string[] row = new string[] { "", "", "", "", "" };

                OrdenCompra_ProductoBL ordpr   = new OrdenCompra_ProductoBL();
                OrdenCompra_Productos  entidad = new OrdenCompra_Productos();

                DataTable productos = new DataTable();
                productos = ordpr.LlenarOrdenCompra_Productos(ID);

                foreach (DataRow dgvRow in productos.Rows)
                {
                    try
                    {
                        dgvProd.Rows.Add(row);
                        cbxProducto.SelectedValue = dgvRow[2].ToString();
                        dgvProd.Rows[filaActual].Cells["Producto"].Value   = cbxProducto.GetItemText(this.cbxProducto.SelectedItem);
                        dgvProd.Rows[filaActual].Cells["Cantidad"].Value   = dgvRow[1].ToString();
                        dgvProd.Rows[filaActual].Cells["IdProducto"].Value = dgvRow[2].ToString();
                        dgvProd.Rows[filaActual].Cells["Precio"].Value     = dgvRow[3].ToString();
                        dgvProd.Rows[filaActual].Cells["DescProd"].Value   = dgvRow[4].ToString();
                        dgvProd.Rows[filaActual].Cells["Costo"].Value      = dgvRow[5].ToString();

                        filaActual += 1;
                    }
                    catch (Exception e) { throw e; }
                }
            }
            catch (Exception) { throw; }
        }
Esempio n. 4
0
        private void registrarProductosOrdCompra()
        {
            OrdenCompra_ProductoBL ordpr   = new OrdenCompra_ProductoBL();
            OrdenCompra_Productos  entidad = new OrdenCompra_Productos();

            foreach (DataGridViewRow fila in dgvProd.Rows)
            {
                try
                {
                    if (fila.Cells["IdProducto"].Value.ToString() == string.Empty)
                    {
                        fila.Cells["IdProducto"].Value = "0";
                    }
                    if (fila.Cells["Cantidad"].Value.ToString() == string.Empty)
                    {
                        fila.Cells["Cantidad"].Value = "0";
                    }
                    if (fila.Cells["Precio"].Value.ToString() == string.Empty)
                    {
                        fila.Cells["Precio"].Value = "0.00";
                    }
                    if (fila.Cells["Costo"].Value.ToString() == string.Empty)
                    {
                        fila.Cells["Costo"].Value = "0.00";
                    }
                    if (fila.Cells["DescProd"].Value == null)
                    {
                        fila.Cells["DescProd"].Value = string.Empty;
                    }

                    entidad.IdOrdenCompra = ID;
                    entidad.Producto      = Int32.Parse(fila.Cells["IdProducto"].Value.ToString());
                    entidad.Cant          = Int32.Parse(fila.Cells["Cantidad"].Value.ToString());
                    entidad.Precio        = float.Parse(fila.Cells["Precio"].Value.ToString());
                    entidad.Costo         = float.Parse(fila.Cells["Costo"].Value.ToString());
                    entidad.DescProd      = fila.Cells["DescProd"].Value.ToString();

                    ordpr.RegOrdenCompra_Producto(entidad);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Esempio n. 5
0
        public string InsertarOrdenCompra_Producto(OrdenCompra_Productos OrdenCompra_Producto)
        {
            string respuesta = "";

            AccesoDatos.ObtenerConexion().Open();
            using (ComandoSQL = new SqlCommand())
            {
                ComandoSQL.Connection  = AccesoDatos.ObtenerConexion();
                ComandoSQL.CommandType = CommandType.StoredProcedure;
                ComandoSQL.CommandText = "proc_OrdCompra_ProdInsertar";
                try
                {
                    ComandoSQL.Parameters.AddWithValue("@IdOrdenCompra", OrdenCompra_Producto.IdOrdenCompra);
                    ComandoSQL.Parameters.AddWithValue("@Cant", OrdenCompra_Producto.Cant);
                    ComandoSQL.Parameters.AddWithValue("@Producto", OrdenCompra_Producto.Producto);
                    ComandoSQL.Parameters.AddWithValue("@Precio", OrdenCompra_Producto.Precio);
                    ComandoSQL.Parameters.AddWithValue("@Costo", OrdenCompra_Producto.Costo);
                    ComandoSQL.Parameters.AddWithValue("@DescProd", OrdenCompra_Producto.DescProd);

                    //Ejecutar Comando
                    ComandoSQL.ExecuteNonQuery();
                    respuesta = "exito";
                }
                catch (SqlException e) when(e.Number == 2627)
                {
                    respuesta = "existe";
                }
                catch (Exception e)
                {
                    respuesta = e.Message;
                    throw;
                }
                finally
                {
                    AccesoDatos.ObtenerConexion().Close();
                }
            }

            return(respuesta);
        }
Esempio n. 6
0
 public void EliminarOrdenCompra_Producto(OrdenCompra_Productos OrdenCompra_Producto)
 {
     AccesoDatos.ObtenerConexion().Open();
     using (ComandoSQL = new SqlCommand())
     {
         ComandoSQL.Connection  = AccesoDatos.ObtenerConexion();
         ComandoSQL.CommandType = CommandType.StoredProcedure;
         ComandoSQL.CommandText = "proc_OrdCompra_ProdEliminar";
         try
         {
             ComandoSQL.Parameters.AddWithValue("@IdOrdenCompra", OrdenCompra_Producto.IdOrdenCompra);
             ComandoSQL.ExecuteNonQuery();
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             AccesoDatos.ObtenerConexion().Close();
         }
     }
 }
Esempio n. 7
0
 public void ActualizarOrdenCompra_Producto(OrdenCompra_Productos entidad)
 {
     cli.ActualizarOrdenCompra_Producto(entidad);
 }
Esempio n. 8
0
 public void EliminarOrdenCompra_Producto(OrdenCompra_Productos entidad)
 {
     cli.EliminarOrdenCompra_Producto(entidad);
 }
Esempio n. 9
0
 public string RegOrdenCompra_Producto(OrdenCompra_Productos entidad)
 {
     return(cli.InsertarOrdenCompra_Producto(entidad));
 }