public void AgregarItemTablaProductos(int _idProd, string _nombre, int _cantidad, decimal _preUni, decimal _preTot)
 {
     try
     {
         DataTable tabla = ((DataView)dgProductos.ItemsSource).ToTable();
         DataRow   fila  = tabla.NewRow();
         fila["ID PRODUCTO"]     = _idProd;
         fila["PRODUCTO"]        = _nombre;
         fila["CANTIDAD"]        = _cantidad;
         fila["PRECIO UNITARIO"] = _preUni;
         fila["PRECIO TOTAL"]    = _preTot;
         tabla.Rows.Add(fila);
         dgProductos.ItemsSource = tabla.DefaultView;
         CalcularTotalCLP();
         if (cbxMoneda.SelectedValue != null)
         {
             int            moneda         = int.Parse(cbxMoneda.SelectedValue.ToString());
             MultiMonedaNEG multiMonedaNEG = new MultiMonedaNEG();
             var            datos          = multiMonedaNEG.CargarMultiMoneda(moneda);
             decimal        valorMoneda    = Convert.ToDecimal(datos.MONTO);
             decimal        costoCLP       = Convert.ToDecimal(txtCostoTotal.Text);
             txtCostoMoneda.Text = string.Format("{0:n2}", (Math.Truncate((costoCLP / valorMoneda))));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error:\n" + ex.TargetSite + "\n" + ex.Message.ToString());
     }
 }
 internal void AgregarItemDetalle(string cantidad, string tipoItem, string idItem, string nombreItem, string precioUni, string total)
 {
     try
     {
         DataTable tabla = ((DataView)dgDetalleDocumento.ItemsSource).ToTable();
         DataRow   fila  = tabla.NewRow();
         fila["CANTIDAD"]    = cantidad;
         fila["TIPO ITEM"]   = tipoItem;
         fila["ID ITEM"]     = idItem;
         fila["NOMBRE ITEM"] = nombreItem;
         fila["P UNITARIO"]  = precioUni;
         fila["TOTAL"]       = total;
         tabla.Rows.Add(fila);
         dgDetalleDocumento.ItemsSource = tabla.DefaultView;
         CalcularTotalCLP();
         if (cbxMoneda.SelectedValue != null)
         {
             int            moneda         = int.Parse(cbxMoneda.SelectedValue.ToString());
             MultiMonedaNEG multiMonedaNEG = new MultiMonedaNEG();
             var            datos          = multiMonedaNEG.CargarMultiMoneda(moneda);
             decimal        valorMoneda    = Convert.ToDecimal(datos.MONTO);
             decimal        costoCLP       = Convert.ToDecimal(txtNeto.Text);
             txtTotalMoneda.Text = string.Format("{0:n2}", (Math.Truncate((costoCLP / valorMoneda))));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error:\n" + ex.TargetSite + "\n" + ex.Message.ToString());
     }
 }
Exemplo n.º 3
0
        private void dgDatos_MouseDoubleClick(object sender, EventArgs e)
        {
            DataRowView    dr             = dgDatos.SelectedItem as DataRowView;
            DataRow        dr1            = dr.Row;
            int            id             = Convert.ToInt32(dr1.ItemArray[0]);
            MultiMonedaNEG multiMonedaNEG = new MultiMonedaNEG();
            var            datos          = multiMonedaNEG.CargarMultiMoneda(id);

            txtNombre.Text = datos.TIPO_MODONEDA;
            txtValor.Text  = datos.MONTO.ToString();
            lblId.Content  = datos.ID;
        }
Exemplo n.º 4
0
        private void CargarFormulario(OrdenPedidoVIEW data)
        {
            lblIdOrdenPedido.Content      = data.ID.ToString();
            txtFolio.Text                 = dataRow["FOLIO"].ToString();
            txtproveedor.Text             = data.PROVEEDOR;
            txtRutProveedor.Text          = dataRow["RUT PROVEEDOR"].ToString();
            dpkFechaCreacion.SelectedDate = data.FECHA_CREACION;
            txtSucursal.Text              = data.SUCURSAL;
            SucursalNEG sucursalNEG = new SucursalNEG();
            var         datos       = sucursalNEG.CargarSucursal(data.SUCURSAL_ID);

            txtDireccion.Text         = datos.DIRECCION;
            txtTelFijo.Text           = datos.NUMERO_TELEFONO.ToString();
            txtEmailSucursal.Text     = data.EMAIL_SUCURSAL.ToString();
            cbxMoneda.SelectedValue   = data.MULTI_MONEDA_ID;
            cbxEmpleado.SelectedValue = data.EMPLEADO_ID;
            txtEmailProveedor.Text    = data.EMAIL_PROVEEDOR;

            int          empleado     = int.Parse(cbxEmpleado.SelectedValue.ToString());
            EmpleadosNEG empleadosNEG = new EmpleadosNEG();
            var          datos1       = empleadosNEG.CargarEmpleado(empleado);

            txtNombreEmpleado.Text = datos1.NOMBRE + " " + datos1.APELLIDO;

            DetalleOrdenPedidoNEG       detalleOrdenPedidoNEG = new DetalleOrdenPedidoNEG();
            List <DETALLE_ORDEN_PEDIDO> listaDetalle          = detalleOrdenPedidoNEG.CargarlistaDetalleOrden(data.ID);

            foreach (var fila in listaDetalle)
            {
                AgregarItemTablaProductos(fila.PRODUCTO_ID, fila.NOMBRE_PRODUCTO, int.Parse(fila.CANTIDAD.ToString()), Convert.ToDecimal(fila.PRECIO_COMPRA), Convert.ToDecimal(fila.MONTO_TOTAL));
            }

            int            moneda         = int.Parse(cbxMoneda.SelectedValue.ToString());
            MultiMonedaNEG multiMonedaNEG = new MultiMonedaNEG();
            var            datos2         = multiMonedaNEG.CargarMultiMoneda(moneda);
            decimal        valorMoneda    = Convert.ToDecimal(datos2.MONTO);
            decimal        costoCLP       = Convert.ToDecimal(txtCostoTotal.Text);

            txtCostoMoneda.Text = string.Format("{0:n2}", (Math.Truncate((costoCLP / valorMoneda))));
        }
 private void cbxMoneda_Seleccion(object sender, SelectionChangedEventArgs e)
 {
     if (cbxMoneda.SelectedValue != null)
     {
         try
         {
             int            moneda         = int.Parse(cbxMoneda.SelectedValue.ToString());
             MultiMonedaNEG multiMonedaNEG = new MultiMonedaNEG();
             var            datos          = multiMonedaNEG.CargarMultiMoneda(moneda);
             decimal        valorMoneda    = Convert.ToDecimal(datos.MONTO);
             decimal        costoCLP       = Convert.ToDecimal(txtCostoTotal.Text);
             txtCostoMoneda.Text = string.Format("{0:n2}", (Math.Truncate((costoCLP / valorMoneda))));
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error:\n" + ex.TargetSite + "\n" + ex.Message.ToString());
         }
     }
     else
     {
         txtCostoMoneda.Text = "";
     }
 }
 private void btnQuitarProducto_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (dgProductos.SelectedItems.Count > 0)
         {
             DataTable tabla = ((DataView)dgProductos.ItemsSource).ToTable();
             for (int i = 0; i < dgProductos.SelectedItems.Count; i++)
             {
                 int     indice = dgProductos.Items.IndexOf(dgProductos.SelectedItems[i]);
                 DataRow fila   = tabla.Rows[indice];
                 tabla.Rows.Remove(fila);
             }
             dgProductos.ItemsSource = null;
             dgProductos.ItemsSource = tabla.DefaultView;
             CalcularTotalCLP();
             if (cbxMoneda.SelectedValue != null)
             {
                 int            moneda         = int.Parse(cbxMoneda.SelectedValue.ToString());
                 MultiMonedaNEG multiMonedaNEG = new MultiMonedaNEG();
                 var            datos          = multiMonedaNEG.CargarMultiMoneda(moneda);
                 decimal        valorMoneda    = Convert.ToDecimal(datos.MONTO);
                 decimal        costoCLP       = Convert.ToDecimal(txtCostoTotal.Text);
                 txtCostoMoneda.Text = string.Format("{0:n2}", (Math.Truncate((costoCLP / valorMoneda))));
             }
         }
         else
         {
             MessageBox.Show("Debe seleccionar por lo menos una fila");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error:\n" + ex.TargetSite + "\n" + ex.Message.ToString());
     }
 }