Exemple #1
0
        private void dgEmpleados_MouseDoubleClick(object sender, EventArgs e)
        {
            DataRowView  dr           = dgEmpleados.SelectedItem as DataRowView;
            DataRow      dr1          = dr.Row;
            int          idEmpleado   = Convert.ToInt32(dr1.ItemArray[0]);
            EmpleadosNEG empleadosNEG = new EmpleadosNEG();
            var          datos        = empleadosNEG.CargarEmpleado(idEmpleado);

            txtNombre.Text     = datos.NOMBRE;
            txtApellido.Text   = datos.APELLIDO;
            txtRut.Text        = datos.NUM_ID.ToString() + "-" + datos.DIV_ID;
            txtDireccion.Text  = datos.DIRECCION;
            txtTelFijo.Text    = datos.TELEFONO_FIJO.ToString();
            txtTelCelular.Text = datos.TELEFONO_CELULAR.ToString();
            cbxEstadoEmpleado.SelectedValue = datos.IdEstadoEmpleado;
            cbxTipoEmpleado.SelectedValue   = datos.IdTipoEmpleado;
            cbxEstadoPersona.SelectedValue  = datos.IdEstadoPersona;
            cbxTipoPersona.SelectedValue    = datos.IdTipoPersona;
            cbxSucursal.SelectedValue       = datos.IdSucursal;
            dpkFechaNac.SelectedDate        = datos.FECHA_NACIMIENTO;
            txtEmail.Text         = datos.CORREO;
            cbxPais.SelectedValue = datos.IdPais;
            RegionNEG     regionNEG   = new RegionNEG();
            List <REGION> listaRegion = regionNEG.ListarRegiones(datos.IdPais);

            if (listaRegion.Count > 0)
            {
                cbxRegion.ItemsSource       = listaRegion;
                cbxRegion.DisplayMemberPath = "NOMBRE";
                cbxRegion.SelectedValuePath = "ID";
            }
            cbxRegion.IsEnabled     = true;
            cbxRegion.SelectedValue = datos.IdRegion;
            ProvinciaNEG     provinciaNEG   = new ProvinciaNEG();
            List <PROVINCIA> listaProvincia = provinciaNEG.ListarProvincias(datos.IdRegion);

            if (listaProvincia.Count > 0)
            {
                cbxProvincia.ItemsSource       = listaProvincia;
                cbxProvincia.DisplayMemberPath = "NOMBRE";
                cbxProvincia.SelectedValuePath = "ID";
            }
            cbxProvincia.IsEnabled     = true;
            cbxProvincia.SelectedValue = datos.IdProvincia;
            ComunaNEG     comunaNEG   = new ComunaNEG();
            List <COMUNA> listaComuna = comunaNEG.ListarComunas(datos.IdProvincia);

            if (listaComuna.Count > 0)
            {
                cbxComuna.ItemsSource       = listaComuna;
                cbxComuna.DisplayMemberPath = "NOMBRE";
                cbxComuna.SelectedValuePath = "ID";
            }
            cbxComuna.SelectedValue = datos.IdComuna;
            cbxComuna.IsEnabled     = true;
        }
 private void cbxEmpleado_Seleccion(object sender, SelectionChangedEventArgs e)
 {
     if (cbxEmpleado.SelectedValue != null)
     {
         try
         {
             int          empleado     = int.Parse(cbxEmpleado.SelectedValue.ToString());
             EmpleadosNEG empleadosNEG = new EmpleadosNEG();
             var          datos        = empleadosNEG.CargarEmpleado(empleado);
             txtNombreEmpleado.Text = datos.NOMBRE + " " + datos.APELLIDO;
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error:\n" + ex.TargetSite + "\n" + ex.Message.ToString());
         }
     }
 }
Exemple #3
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 CargarBoleta(DataRow dataRow)
        {
            CargarTablaDetalle();
            int                idBoleta           = int.Parse(dataRow["ID"].ToString());
            VentasDAL          ventas             = new VentasDAL();
            AnulacionVentasDAL anulacionVentasDAL = new AnulacionVentasDAL();

            datosDocumentoPagoVIEW = ventas.CargarDatos(idBoleta);
            VENTAS       datoVenta    = ventas.ObtenerVentaId(idBoleta);
            SucursalNEG  sucursalNEG  = new SucursalNEG();
            EmpleadosNEG empleadosNEG = new EmpleadosNEG();

            txtCliente.Text  = datosDocumentoPagoVIEW.NOMBRE_CLIENTE + " " + datosDocumentoPagoVIEW.APELLIDO_CLIENTE;
            txtSucursal.Text = sucursalNEG.CargarSucursal(datoVenta.SUCURSAL_ID).NOMBRE;
            txtEmpleado.Text = empleadosNEG.CargarEmpleado(datoVenta.EMPLEADO_ID).NOMBRE + " " + empleadosNEG.CargarEmpleado(datoVenta.EMPLEADO_ID).APELLIDO;
            dpkFechaCreacion.SelectedDate = datoVenta.FECHA_VENTA;
            string folio = idBoleta.ToString();

            for (int i = 0; i < 9; i++)
            {
                if (folio.Length < 8)
                {
                    folio = "0" + folio;
                }
            }

            txtFolio.Text         = folio;
            txtTipoDocumento.Text = datosDocumentoPagoVIEW.TIPO_DOCUMENTO;
            txtestadoVenta.Text   = anulacionVentasDAL.ValidaEstadoVenta(idBoleta);
            txtMoneda.Text        = datosDocumentoPagoVIEW.TIPO_MONEDA;
            double neto = Convert.ToDouble(datosDocumentoPagoVIEW.TOTAL) / 1.19;

            txtNeto.Text = string.Format("{0:n2}", (neto));
            double iva = neto * 0.19;

            txtIva.Text         = string.Format("{0:n2}", iva);
            txtTotal.Text       = string.Format("{0:n2}", (Convert.ToDouble(datosDocumentoPagoVIEW.TOTAL)));
            txtTotalMoneda.Text = string.Format("{0:n2}", (datosDocumentoPagoVIEW.TOTAL * datosDocumentoPagoVIEW.COSTO_MONEDA));
            //ORDEN DE TRABAJO N°"
            List <DETALLE_VENTAS> listaDetalles = ventas.ListarDetalleVenta(idBoleta);

            foreach (var x in listaDetalles)
            {
                if (x.SERVICIO_ID == 1 && x.PRODUCTO_ID == 1)
                {//OT
                    string    idOrden = x.NOMBRE_PRODUCTO.Split('°')[1];
                    DataTable tabla   = ((DataView)dgDetalleDocumento.ItemsSource).ToTable();
                    DataRow   fila    = tabla.NewRow();
                    fila["CANTIDAD"]    = 1;
                    fila["TIPO ITEM"]   = "OT";
                    fila["ID ITEM"]     = idOrden;
                    fila["NOMBRE ITEM"] = x.NOMBRE_PRODUCTO;
                    fila["P UNITARIO"]  = x.PRECIO_VENTA;
                    fila["TOTAL"]       = x.PRECIO_VENTA;
                    tabla.Rows.Add(fila);
                    dgDetalleDocumento.ItemsSource = tabla.DefaultView;
                }
                else if (x.PRODUCTO_ID == 1 && x.SERVICIO_ID > 1)
                {//serv
                    DataTable tabla = ((DataView)dgDetalleDocumento.ItemsSource).ToTable();
                    DataRow   fila  = tabla.NewRow();
                    fila["CANTIDAD"]    = 1;
                    fila["TIPO ITEM"]   = "SER";
                    fila["ID ITEM"]     = x.SERVICIO_ID;
                    fila["NOMBRE ITEM"] = x.NOMBRE_PRODUCTO;
                    fila["P UNITARIO"]  = x.PRECIO_VENTA;
                    fila["TOTAL"]       = x.MONTO_TOTAL;
                    tabla.Rows.Add(fila);
                    dgDetalleDocumento.ItemsSource = tabla.DefaultView;
                }
                else if (x.PRODUCTO_ID > 1 && x.SERVICIO_ID == 1)
                {//prod
                    DataTable tabla = ((DataView)dgDetalleDocumento.ItemsSource).ToTable();
                    DataRow   fila  = tabla.NewRow();
                    fila["CANTIDAD"]    = x.CANTIDAD;
                    fila["TIPO ITEM"]   = "PRO";
                    fila["ID ITEM"]     = x.PRODUCTO_ID;
                    fila["NOMBRE ITEM"] = x.NOMBRE_PRODUCTO;
                    fila["P UNITARIO"]  = x.PRECIO_VENTA;
                    fila["TOTAL"]       = x.MONTO_TOTAL;
                    tabla.Rows.Add(fila);
                    dgDetalleDocumento.ItemsSource = tabla.DefaultView;
                }
            }
        }