Exemple #1
0
        private Stream Reporte(bool Correo)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            Stream archivo = null;

            try {
                frmViewer frm = new frmViewer();
                frm.iReport = new Reportes.rptCotizacion();

                frm.iReport.SetDataSource(oEnsamble.ENS_Cotizacion_Reporte(int.Parse(txtId.Text)));
                frm.iReport.Subreports["Detalle"].SetDataSource(oEnsamble.ENS_Cotizacion_ReporteDetalle(int.Parse(txtId.Text)));

                if (Correo)
                {
                    archivo = frm.iReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    //System.IO.DirectoryInfo dir = new DirectoryInfo(System.IO.Directory.GetCurrentDirectory());
                    //foreach (FileInfo file in dir.GetFiles()) {
                    //    if(file.Extension.Equals(".pdf"))
                    //        file.Delete();
                    //}
                    //frm.iReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"c:\Temp\Test.pdf");
                }
                else
                {
                    //MOSTRAR EN PANTALLA
                    frm.WindowState = FormWindowState.Maximized;
                    frm.ShowDialog();
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al mostrar el reporte\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            } finally {
                oEnsamble = null;
            }
            return(archivo);
        }
Exemple #2
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            oVentas = new WCF_Ensamble.Hersan_EnsambleClient();
            try {
                ClientesBE obj = new ClientesBE();
                obj.Id = int.Parse(txtClave.Text);
                obj.DatosUsuario.FechaCreacion = dtFecha.Checked ? dtFecha.Value : DateTime.Parse("01/01/1900");
                obj.RFC    = txtRFC.Text;
                obj.Nombre = txtNombre.Text;

                obj.Ciudad = cboTipo.SelectedItem.Tag.ToString();
                obj.Estado = cboEstatus.SelectedItem.Tag.ToString();

                //var Ent = new ClientesEntidadesBE();
                //Ent.Entidad.Id = int.Parse(cboTipo.SelectedItem.Tag.ToString()));
                //Ent.IdCliente = int.Parse(cboEstatus.SelectedItem.Tag.ToString());
                //obj.Entidades.Add(Ent);

                string Entidades = string.Empty;
                foreach (var item in lstEntidades.Items)
                {
                    if (item.CheckState == Telerik.WinControls.Enumerations.ToggleState.On)
                    {
                        Entidades += item.Value.ToString() + ",";
                    }
                }
                gvDatos.DataSource = oVentas.ABC_Clientes_Buscar(obj, Entidades);
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al cargar los datos\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            }
        }
Exemple #3
0
        private void CargarCotizacion(int IdCotiza)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            try {
                oCotiza = oEnsamble.ENS_Cotizacion_Obtener(IdCotiza);
                if (oCotiza.Count > 0)
                {
                    txtId.Text     = oCotiza[0].Id.ToString();
                    txtClave.Text  = oCotiza[0].Cliente.Id.ToString();
                    txtNombre.Text = oCotiza[0].Cliente.Nombre.ToString();
                    txtAgente.Text = oCotiza[0].Agente.Nombre.ToString();
                    txtFecha.Text  = oCotiza[0].DatosUsuario.FechaCreacion.ToShortDateString();

                    gvDatos.DataSource = oCotiza[0].Detalle;
                }
                else
                {
                    LimpiarCampos();
                    RadMessageBox.Show("No existe la cotización capturada o ya es un pedido.", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                }
            } catch (Exception ex) {
                throw ex;
            } finally {
                oEnsamble = null;
            }
        }
        private Stream Reporte(bool Correo)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            Stream archivo = null;

            try {
                frmViewer frm = new frmViewer();
                frm.iReport = new Reportes.rptCotizacion();

                frm.iReport.SetDataSource(oEnsamble.ENS_Cotizacion_Reporte(int.Parse(gvDatos.CurrentRow.Cells["Id"].Value.ToString())));
                frm.iReport.Subreports["Detalle"].SetDataSource(oEnsamble.ENS_Cotizacion_ReporteDetalle(int.Parse(gvDatos.CurrentRow.Cells["Id"].Value.ToString())));

                if (Correo)
                {
                    archivo = frm.iReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                }
                else
                {
                    //MOSTRAR EN PANTALLA
                    frm.WindowState = FormWindowState.Maximized;
                    frm.ShowDialog();
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al mostrar el reporte\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            } finally {
                oEnsamble = null;
            }
            return(archivo);
        }
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
     try {
         if (int.Parse(txtId.Text) > 0)
         {
             if (RadMessageBox.Show("Desea eliminar la ficha actual...?", this.Text, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
             {
                 if (oEnsamble.ENS_ProductosFicha_Actualizar(CrearTablasAuxiliares(), Imagen, Colores, Reflejantes, Accesorios, BaseWinBP.UsuarioLogueado.ID, false) > 0)
                 {
                     RadMessageBox.Show("Ficha técnica eliminada correctamente", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                     LimpiarCampos();
                 }
                 else
                 {
                     RadMessageBox.Show("Ocurrió un error al eliminar la ficha", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                 }
             }
         }
     } catch (Exception ex) {
         RadMessageBox.Show("Ocurrió un error al eliminar la ficha\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
     } finally {
         oEnsamble = null;
     }
 }
 private void CargarDatos()
 {
     oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
     try {
         gvDatos.DataSource = oEnsamble.ENS_Servicios_Obtener();
     } catch (Exception ex) {
         throw ex;
     } finally {
         oCatalogos = null;
     }
 }
Exemple #7
0
        private void CargarCotizacion(int IdCotiza)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            try {
                oCotiza = oEnsamble.ENS_Cotizacion_Obtener(IdCotiza);
                if (oCotiza.Count > 0)
                {
                    txtId.Text               = oCotiza[0].Id.ToString();
                    txtClave.Text            = oCotiza[0].Cliente.Id.ToString();
                    txtNombre.Text           = oCotiza[0].Cliente.Nombre;
                    txtVIP.Text              = oCotiza[0].Cliente.VIP.ToString();
                    txtFecha.Text            = oCotiza[0].DatosUsuario.FechaCreacion.ToShortDateString();
                    txtProyecto.Text         = oCotiza[0].Proyecto;
                    txtAgente.Text           = oCotiza[0].Agente.Nombre;
                    cboMonedas.SelectedValue = oCotiza[0].Moneda.Moneda;

                    if (oCotiza[0].Condiciones.Id > 0)
                    {
                        Nacional               = false;
                        lblCondicion.Visible   = !Nacional;
                        cboCondiciones.Visible = !Nacional;
                    }

                    if (oCotiza[0].Semaforo == 1)
                    {
                        rbVerde.IsChecked = true;
                    }
                    else
                    {
                        if (oCotiza[0].Semaforo == 2)
                        {
                            rbAmarillo.IsChecked = true;
                        }
                        else
                        {
                            rbRojo.IsChecked = true;
                        }
                    }
                    oList = oCotiza[0].Detalle;

                    gvDatos.DataSource = oList;
                }
                else
                {
                    RadMessageBox.Show("No existe la cotización capturada o se convirtió en pedido.", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                    txtId.Text = "0";
                }
            } catch (Exception ex) {
                throw ex;
            } finally {
                oEnsamble = null;
            }
        }
 private void gvDatos_CurrentRowChanged(object sender, Telerik.WinControls.UI.CurrentRowChangedEventArgs e)
 {
     oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
     try {
         if (gvDatos.RowCount > 0)
         {
             gvDetalle.DataSource = oEnsamble.ENS_Cotizacion_ReporteDetalle(int.Parse(gvDatos.CurrentRow.Cells["Id"].Value.ToString()));
         }
     } catch (Exception ex) {
         RadMessageBox.Show("Ocurrió un error al seleccionar el pedido\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
     }
 }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            int Result = 0;

            try {
                if (!ValidarCampos())
                {
                    RadMessageBox.Show("Debe capturar todos los datos para continuar", this.Text, MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                    return;
                }

                if (RadMessageBox.Show("Desea guardar la información capturada...?", this.Text, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.No)
                {
                    return;
                }

                /* ALTA DE FICHA TÉCNICA */
                if (int.Parse(txtId.Text) == 0)
                {
                    Result = oEnsamble.ENS_ProductosFicha_Guardar(CrearTablasAuxiliares(), Imagen, Colores, Reflejantes, Accesorios, BaseWinBP.UsuarioLogueado.ID);
                    if (Result != 0)
                    {
                        RadMessageBox.Show("Ficha técnica guardada correctamente", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                    }
                    else
                    {
                        RadMessageBox.Show("Ocurrió un error al guardar la ficha", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                    }
                }
                else
                {
                    Result = oEnsamble.ENS_ProductosFicha_Actualizar(CrearTablasAuxiliares(), Imagen, Colores, Reflejantes, Accesorios, BaseWinBP.UsuarioLogueado.ID, true);
                    if (Result != 0)
                    {
                        RadMessageBox.Show("Ficha técnica actualizada correctamente", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                    }
                    else
                    {
                        RadMessageBox.Show("Ocurrió un error al actualizar la ficha", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                    }
                }
                if (Result != 0)
                {
                    LimpiarCampos();
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al guardar la ficha\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            } finally {
                oEnsamble = null;
            }
        }
Exemple #10
0
 private void CargaFormasPago()
 {
     oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
     try {
         cboForma.DisplayMember = "Descripcion";
         cboForma.ValueMember   = "Id";
         cboForma.DataSource    = oEnsamble.ABC_FormaPago_Combo();
     } catch (Exception ex) {
         throw ex;
     } finally {
         oEnsamble = null;
     }
 }
Exemple #11
0
 private void CargaUsoCFDI()
 {
     oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
     try {
         cboUso.DisplayMember = "Descripcion";
         cboUso.ValueMember   = "Clave";
         cboUso.DataSource    = oEnsamble.ABC_UsoCFDI_Combo();
     } catch (Exception ex) {
         throw ex;
     } finally {
         oEnsamble = null;
     }
 }
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            try {
                int    IdCliente = txtClave.Text.Trim().Length == 0 ? 0 : int.Parse(txtClave.Text);
                string Inicial   = dtInicial.Checked ? dtInicial.Value.Year.ToString() + dtInicial.Value.Month.ToString().PadLeft(2, '0')
                                   + dtInicial.Value.Day.ToString().PadLeft(2, '0') : "19000101";
                string Final = dtInicial.Checked ? dtFinal.Value.Year.ToString() + dtFinal.Value.Month.ToString().PadLeft(2, '0')
                               + dtFinal.Value.Day.ToString().PadLeft(2, '0') : "21000101";

                gvDatos.DataSource = oEnsamble.ENS_Cotizacion_Buscar(IdCliente, txtNombre.Text.Trim(), Inicial, Final);
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al cargar los datos\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            }
        }
Exemple #13
0
 private void CargarDatos()
 {
     oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
     try {
         if (cboMonedas.Items.Count > 0)
         {
             gvDatos.DataSource = null;
             oList = oEnsamble.ENS_Precios_Obtener(cboMonedas.SelectedValue.ToString());
             gvDatos.DataSource = oList;
         }
     } catch (Exception ex) {
         throw ex;
     } finally {
         oEnsamble = null;
     }
 }
        private void cboTipo_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            try {
                if (cboTipo.Items.Count > 0 && cboTipo.SelectedValue != null)
                {
                    txtCodigo.Text = oFamilia.Find(item => item.Id == int.Parse(cboFamilia.SelectedValue.ToString())).Clave + " - " +
                                     oTipo.Find(Item => Item.Id == int.Parse(cboTipo.SelectedValue.ToString())).Clave;

                    CargarFicha();
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al seleccionar el Tipo de producto\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            } finally {
                oEnsamble = null;
            }
        }
Exemple #15
0
        private void CargaProductos(bool Nacional)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            try {
                oProductos = oEnsamble.ENS_ProductosCotizacion_Combo(Nacional, cboMonedas.SelectedValue.ToString());
                cboProductos.DisplayMember = "Producto.Nombre";
                cboProductos.ValueMember   = "Producto.Id";
                cboProductos.DataSource    = oProductos;

                if (oProductos.Count > 0)
                {
                    cboProductos.SelectedIndex = 0;
                }
            } catch (Exception ex) {
                throw ex;
            } finally {
                oEnsamble = null;
            }
        }
Exemple #16
0
        private void CargaServicios()
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            try {
                oServicios = oEnsamble.ENS_ServiciosCotizacion_Combo(cboMonedas.SelectedValue.ToString());
                cboServicios.DisplayMember = "Nombre";
                cboServicios.ValueMember   = "Id";
                cboServicios.DataSource    = oServicios;

                if (oServicios.Count > 0)
                {
                    cboServicios.SelectedIndex = 0;
                }
            } catch (Exception ex) {
                throw ex;
            } finally {
                oEnsamble = null;
            }
        }
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            try {
                string Inicial = !dtInicial.Checked ? "19000101" : dtInicial.Value.Year.ToString() + dtInicial.Value.Month.ToString().PadLeft(2, '0')
                                 + dtInicial.Value.Day.ToString().PadLeft(2, '0');
                string Final = !dtInicial.Checked ? "29000101" : dtFinal.Value.Year.ToString() + dtFinal.Value.Month.ToString().PadLeft(2, '0')
                               + dtFinal.Value.Day.ToString().PadLeft(2, '0');

                gvDatos.DataSource = oEnsamble.ENS_Pedido_Consulta(int.Parse(cboAgentes.SelectedValue.ToString()), int.Parse(txtId.Text), Inicial, Final);

                if (gvDatos.RowCount == 0)
                {
                    gvDetalle.DataSource = null;
                    RadMessageBox.Show("No se encontraron pedidos con los criterios seleccionados.", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al cargar los pedidos\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            }
        }
Exemple #18
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            try {
                if (RadMessageBox.Show("Desea dar de baja el cliente seleccionado...?", this.Text, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.No)
                {
                    return;
                }

                #region Entidades Seleccionadas
                string Entidades = string.Empty;
                foreach (var item in lstEntidades.Items)
                {
                    if (item.CheckState == Telerik.WinControls.Enumerations.ToggleState.On)
                    {
                        Entidades += item.Value.ToString() + ",";
                    }
                }
                #endregion

                int Result = oEnsamble.ABC_Clientes_Actualizar(CrearTablasAuxiliares(), Entidades, BaseWinBP.UsuarioLogueado.ID, false);
                if (Result != 0)
                {
                    RadMessageBox.Show("Cliente eliminado correctamente", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                }
                else
                {
                    RadMessageBox.Show("Ocurrió un error al actualizar la información", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                }

                if (Result != 0)
                {
                    LimpiarCampos();
                    this.docContactos.Select();
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al eliminar el cliente\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            } finally {
                oEnsamble = null;
            }
        }
Exemple #19
0
        private void CargaCliente(int IdCliente)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            try {
                oClientes = oEnsamble.ABC_Clientes_Obtener(IdCliente);
                if (oClientes.Count > 0)
                {
                    var item = oClientes[0];
                    if (item.DatosUsuario.Estatus == true)
                    {
                        txtClave.Text          = item.Id.ToString();
                        txtNombre.Text         = item.Nombre;
                        txtAgente.Text         = item.Agente.Nombre;
                        Nacional               = item.Nacional;
                        lblCondicion.Visible   = !Nacional;
                        cboCondiciones.Visible = !Nacional;
                        lblGastos.Visible      = !Nacional;
                        txtGastos.Visible      = !Nacional;
                        txtVIP.Text            = item.VIP.ToString();

                        CargaProductos(Nacional);
                        CargaServicios();
                    }
                    else
                    {
                        RadMessageBox.Show("El cliente seleccionado no existe o se ha dado de baja", this.Text, MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                        txtClave.Clear();
                    }
                }
                else
                {
                    RadMessageBox.Show("La clave del cliente no existe o no está asignada al agente", this.Text, MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                    txtClave.Clear();
                }
            } catch (Exception ex) {
                throw ex;
            } finally {
                oEnsamble = null;
            }
        }
Exemple #20
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            try {
                if (!ValidarCampos())
                {
                    RadMessageBox.Show("Los datos de la cotización están incompletos\nNo es posible continuar", this.Text, MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                    return;
                }

                if (RadMessageBox.Show("Esta acción cancelará la cotización\nDesea continuar...?", this.Text, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
                {
                    PedidosBE obj = new PedidosBE();
                    obj.Id             = int.Parse(txtId.Text);
                    obj.Cliente.Id     = int.Parse(txtClave.Text);
                    obj.Pedido         = false;
                    obj.Proyecto       = txtProyecto.Text;
                    obj.Semaforo       = rbVerde.IsChecked ? 1 : rbAmarillo.IsChecked ? 2 : 3;
                    obj.Condiciones.Id = oClientes[0].Nacional ? 0 : int.Parse(cboCondiciones.SelectedValue.ToString());
                    obj.DatosUsuario.IdUsuarioModif = BaseWinBP.UsuarioLogueado.ID;
                    obj.DatosUsuario.Estatus        = false;

                    int Result = oEnsamble.ENS_Cotizacion_Actualizar(obj, CrearTablasAuxiliares());
                    if (Result != 0)
                    {
                        RadMessageBox.Show("Cotización cancelada correctamente", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                        LimpiarCampos();
                    }
                    else
                    {
                        RadMessageBox.Show("Ocurrió un error al cancelar la cotización", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                    }
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al cancelar la cotización\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            } finally {
                oEnsamble = null;
            }
        }
Exemple #21
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            try {
                if (gvDatos.RowCount == 0)
                {
                    RadMessageBox.Show("Es necesario seleccionar una cotizacio.", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                    return;
                }

                if (RadMessageBox.Show("Desea generar el pedido de la cotización seleccionada...?", this.Text, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.No)
                {
                    return;
                }

                PedidosBE obj = new PedidosBE();
                obj.Id         = int.Parse(txtId.Text);
                obj.Cliente.Id = int.Parse(txtClave.Text);
                obj.Pedido     = true;
                obj.DatosUsuario.IdUsuarioModif = BaseWinBP.UsuarioLogueado.ID;
                obj.DatosUsuario.Estatus        = true;

                int Result = oEnsamble.ENS_Cotizacion_Actualizar(obj, CrearTablasAuxiliares());
                if (Result != 0)
                {
                    RadMessageBox.Show("Pedido generado correctamente, con folio: " + Result.ToString(), this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                    LimpiarCampos();
                }
                else
                {
                    RadMessageBox.Show("Ocurrió un error al generar el pedido", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al generar el pedido\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            } finally {
                oEnsamble = null;
            }
        }
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            ServiciosBE obj = new ServiciosBE();

            try {
                if (chkEstatus.Checked)
                {
                    if (RadMessageBox.Show("Esta acción dará de baja el servicio\nDesea continuar...?", this.Text, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
                    {
                        obj.Id                         = int.Parse(txtId.Text);
                        obj.Entidad.Id                 = int.Parse(cboEntidad.SelectedValue.ToString());
                        obj.Clave                      = txtClave.Text;
                        obj.Nombre                     = txtNombre.Text;
                        obj.Moneda.Moneda              = cboMonedas.SelectedValue.ToString();
                        obj.Precio                     = decimal.Parse(txtPrecio.Text);
                        obj.DatosUsuario.Estatus       = false;
                        obj.DatosUsuario.IdUsuarioCreo = BaseWinBP.UsuarioLogueado.ID;

                        int Result = oEnsamble.ENS_Servicios_Actualizar(obj);
                        if (Result == 0)
                        {
                            RadMessageBox.Show("Ocurrió un error al modificar los datos", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                        }
                        else
                        {
                            RadMessageBox.Show("Información actualizada correctamente", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                            LimpiarCampos();
                            CargarDatos();
                        }
                    }
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrio un error al dar de baja el servicio\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            } finally {
                oCatalogos = null;
            }
        }
Exemple #23
0
        private void cboProductos_SelectedIndexChanged(object sender, EventArgs e)
        {
            oEnsamble  = new WCF_Ensamble.Hersan_EnsambleClient();
            oCatalogos = new WCF_Catalogos.Hersan_CatalogosClient();
            try {
                if (cboProductos.SelectedValue != null)
                {
                    var Ficha = oProductos.Find(item => item.Producto.Id == int.Parse(cboProductos.SelectedValue.ToString()));
                    /* COLORES DE CARCASA */
                    cboColores.DisplayMember = "Nombre";
                    cboColores.ValueMember   = "Id";
                    cboColores.DataSource    = oEnsamble.ENS_CarcasasCotizacion_Combo(Ficha.Id);

                    /* REFLEJANTES */
                    cboReflejantes.DisplayMember = "Nombre";
                    cboReflejantes.ValueMember   = "Id";
                    cboReflejantes.DataSource    = oEnsamble.ENS_ReflejanteCotizacion_Combo(Ficha.Id);

                    /* ACCESORIOS */
                    cboAccesorios.DisplayMember = "Nombre";
                    cboAccesorios.ValueMember   = "Id";
                    cboAccesorios.DataSource    = oCatalogos.ENS_AccesoriosCotizacion_Combo(Ficha.Id);

                    extender.AssociatedRadMultiColumnComboBox = cboReflejantes;
                    extender.AutoCompleteBoxElement.Items.CollectionChanged += Items_CollectionChanged;

                    txtCavidades.Text = Ficha.Reflejantes.ToString();
                    txtPrecio.Text    = Ficha.Precio.Precio.ToString();
                    oReflejantes.Clear();
                }
            } catch (Exception ex) {
                throw ex;
            } finally {
                oEnsamble  = null;
                oCatalogos = null;
            }
        }
Exemple #24
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            int Result = 0;

            try {
                if (!ValidarCampos())
                {
                    RadMessageBox.Show("Los datos de la cotización están incompletos\nSi es exportación capture los gastos.", this.Text, MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                    return;
                }

                if (RadMessageBox.Show("Desea guardar la información capturada...?", this.Text, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.No)
                {
                    return;
                }

                PedidosBE obj = new PedidosBE();
                obj.Id             = int.Parse(txtId.Text);
                obj.Cliente.Id     = int.Parse(txtClave.Text);
                obj.Pedido         = false;
                obj.Proyecto       = txtProyecto.Text;
                obj.Semaforo       = rbVerde.IsChecked ? 1 : rbAmarillo.IsChecked ? 2 : 3;
                obj.Condiciones.Id = Nacional ? 0 : int.Parse(cboCondiciones.SelectedValue.ToString());
                obj.Gastos         = decimal.Parse(txtGastos.Text);
                obj.Moneda.Moneda  = cboMonedas.SelectedValue.ToString();
                obj.DatosUsuario.IdUsuarioModif = BaseWinBP.UsuarioLogueado.ID;
                obj.DatosUsuario.Estatus        = true;


                /* ALTA DE COTIZACION */
                if (int.Parse(txtId.Text) == 0)
                {
                    Result = oEnsamble.ENS_Cotizacion_Guardar(obj, CrearTablasAuxiliares());
                    if (Result != 0)
                    {
                        RadMessageBox.Show("Cotización guardada correctamente, con folio: " + Result.ToString(), this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                    }
                    else
                    {
                        RadMessageBox.Show("Ocurrió un error al guardar la cotización", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                    }
                }
                else
                {
                    Result = oEnsamble.ENS_Cotizacion_Actualizar(obj, CrearTablasAuxiliares());
                    if (Result != 0)
                    {
                        RadMessageBox.Show("Cotización actualizada correctamente", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                    }
                    else
                    {
                        RadMessageBox.Show("Ocurrió un error al actualizar la cotización", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                    }
                }
                if (Result != 0)
                {
                    LimpiarCampos();
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al guardar la cotización\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            } finally {
                oEnsamble = null;
            }
        }
Exemple #25
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            DataTable oData;
            DataRow   oRow;

            try {
                if (cboMonedas.SelectedValue != null)
                {
                    if (RadMessageBox.Show("Desea guardar los cambios...?", this.Text, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes)
                    {
                        #region Carga de Datos
                        oData = new DataTable("Precios");
                        oData.Columns.Add("PRE_Id");
                        oData.Columns.Add("TPR_Id");
                        oData.Columns.Add("PRE_Precio");
                        oData.Columns.Add("PRE_CantVolumen");
                        oData.Columns.Add("PRE_Volumen");
                        oData.Columns.Add("PRE_CantMayoreo");
                        oData.Columns.Add("PRE_Mayoreo");
                        oData.Columns.Add("PRE_AAA");
                        oData.Columns.Add("PRE_ExWorks");

                        oList.ForEach(item => {
                            if (item.Precio > 0)
                            {
                                oRow                    = oData.NewRow();
                                oRow["PRE_Id"]          = item.Id;
                                oRow["TPR_Id"]          = item.Producto.Id;
                                oRow["PRE_Precio"]      = decimal.Parse(item.Precio.ToString());
                                oRow["PRE_CantVolumen"] = int.Parse(item.CantidadVol.ToString());
                                oRow["PRE_Volumen"]     = decimal.Parse(item.Volumen.ToString());
                                oRow["PRE_CantMayoreo"] = int.Parse(item.CantidadMay.ToString());
                                oRow["PRE_Mayoreo"]     = decimal.Parse(item.Mayoreo.ToString());
                                oRow["PRE_AAA"]         = decimal.Parse(item.AAA.ToString());
                                oRow["PRE_ExWorks"]     = decimal.Parse(item.ExWorks.ToString());

                                oData.Rows.Add(oRow);
                            }
                        });
                        #endregion

                        //PROCESO DE GUARDADO Y ACTUALIZACION
                        int Result = oEnsamble.ENS_Precios_Guardar(BaseWinBP.UsuarioLogueado.Empresa.Id, oData, cboMonedas.SelectedValue.ToString(), BaseWinBP.UsuarioLogueado.ID);
                        if (Result == 0)
                        {
                            RadMessageBox.Show("Ocurrió un error al guardar los precios", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                        }
                        else
                        {
                            RadMessageBox.Show("Precios guardados correctamente", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                            LimpiarCampos();
                            CargarDatos();
                        }
                    }
                }
                else
                {
                    RadMessageBox.Show("Debe seleccionar una moneda", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al guardar los datos\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            } finally {
                oEnsamble = null;
                oData     = null;
                oRow      = null;
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            ServiciosBE obj = new ServiciosBE();

            try {
                if (txtClave.Text.Trim().Length == 0 || txtNombre.Text.Trim().Length == 0 || txtPrecio.Text.Trim() == "0")
                {
                    RadMessageBox.Show("Debe capturar todos los datos para continuar", this.Text, MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                    return;
                }
                foreach (GridViewRowInfo oRow in gvDatos.Rows)
                {
                    if ((oRow.Cells["Nombre"].Value.ToString() == txtNombre.Text.Trim() ||
                         oRow.Cells["Clave"].Value.ToString() == txtClave.Text.Trim()) &&
                        int.Parse(txtId.Text) == 0)
                    {
                        RadMessageBox.Show("El Servicio capturado ya existe", this.Text, MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                        LimpiarCampos();
                        return;
                    }
                }

                obj.Id                         = int.Parse(txtId.Text);
                obj.Entidad.Id                 = int.Parse(cboEntidad.SelectedValue.ToString());
                obj.Clave                      = txtClave.Text;
                obj.Nombre                     = txtNombre.Text;
                obj.Moneda.Moneda              = cboMonedas.SelectedValue.ToString();
                obj.Precio                     = decimal.Parse(txtPrecio.Text);
                obj.DatosUsuario.Estatus       = chkEstatus.Checked;
                obj.DatosUsuario.IdUsuarioCreo = BaseWinBP.UsuarioLogueado.ID;

                //PROCESO DE GUARDADO Y ACTUALIZACION
                if (txtId.Text == "0")
                {
                    int Result = oEnsamble.ENS_Servicios_Guardar(obj);
                    if (Result == 0)
                    {
                        RadMessageBox.Show("Ocurrió un error al guardar el servicio", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                    }
                    else
                    {
                        RadMessageBox.Show("Servicio guardado correctamente", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                        LimpiarCampos();
                        CargarDatos();
                    }
                }
                else
                {
                    int Result = oEnsamble.ENS_Servicios_Actualizar(obj);
                    if (Result == 0)
                    {
                        RadMessageBox.Show("Ocurrió un error al actualizar los datos", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                    }
                    else
                    {
                        RadMessageBox.Show("Información actualizada correctamente", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                        LimpiarCampos();
                        CargarDatos();
                    }
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al actualizar la información\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            } finally {
                oEnsamble = null;
            }
        }
        private void CargarFicha()
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();
            try {
                ProductoEnsambleBE obj = new ProductoEnsambleBE();
                obj.Id          = int.Parse(txtId.Text);
                obj.Entidad.Id  = int.Parse(cboEntidad.SelectedValue.ToString());
                obj.Familia.Id  = int.Parse(cboFamilia.SelectedValue.ToString());
                obj.Producto.Id = int.Parse(cboTipo.SelectedValue.ToString());

                oProducto = oEnsamble.ENS_ProductosFicha_Obtener(obj);
                if (oProducto.Count > 0)
                {
                    /*SE LIMPIAN LOS ITEMS SELECCIONADOS */
                    lstCarcasa.CheckedItems.Clear();
                    lstAccesorios.CheckedItems.Clear();
                    lstReflejantes.CheckedItems.Clear();

                    txtId.Text         = oProducto[0].Id.ToString();
                    txtCantidad.Value  = oProducto[0].Reflejantes;
                    txtCantAcce.Value  = oProducto[0].CantAccesorios;
                    txtAlto.Text       = oProducto[0].Dimensiones.Alto.ToString();
                    txtAncho.Text      = oProducto[0].Dimensiones.Ancho.ToString();
                    txtCircun.Text     = oProducto[0].Dimensiones.Cirunferencia.ToString();
                    txtDiam.Text       = oProducto[0].Dimensiones.Diametro.ToString();
                    txtLargo.Text      = oProducto[0].Dimensiones.Largo.ToString();
                    txtPeso.Text       = oProducto[0].Dimensiones.Peso.ToString();
                    txtPiezas.Text     = oProducto[0].Dimensiones.Empaque.ToString();
                    txtRuta.Text       = oProducto[0].Dimensiones.RutaImagen;
                    chkEstatus.Checked = oProducto[0].DatosUsuario.Estatus;

                    oProducto[0].Detalle.ForEach(aux => {
                        if (aux.Tipo == "CARCASA")
                        {
                            foreach (var x in lstCarcasa.Items)
                            {
                                if (x.Value.ToString() == aux.Id.ToString())
                                {
                                    x.CheckState = Telerik.WinControls.Enumerations.ToggleState.On;
                                }
                            }
                        }
                        else
                        {
                            if (aux.Tipo == "REFLEJANTE")
                            {
                                foreach (var x in lstReflejantes.Items)
                                {
                                    if (x.Value.ToString() == aux.Id.ToString())
                                    {
                                        x.CheckState = Telerik.WinControls.Enumerations.ToggleState.On;
                                    }
                                }
                            }
                            else
                            {
                                foreach (var x in lstAccesorios.Items)
                                {
                                    if (x.Value.ToString() == aux.Id.ToString())
                                    {
                                        x.CheckState = Telerik.WinControls.Enumerations.ToggleState.On;
                                    }
                                }
                            }
                        }
                    });

                    if (oProducto[0].Foto != null)
                    {
                        Imagen        = oProducto[0].Foto;
                        picFoto.Image = ConvertImage.ByteToImage(Imagen);
                    }
                    else
                    {
                        picFoto.Image = null;
                    }
                }
                else
                {
                    oList.Clear();
                    txtId.Text = "0";

                    txtAlto.Text      = "0";
                    txtAncho.Text     = "0";
                    txtCantAcce.Value = 0;
                    txtCantidad.Value = 0;
                    txtCircun.Text    = "0";
                    txtDiam.Text      = "0";
                    txtLargo.Text     = "0";
                    txtPeso.Text      = "0";
                    txtPiezas.Text    = "0";
                    txtRuta.Text      = "";
                    lstAccesorios.CheckedItems.Clear();
                    lstCarcasa.CheckedItems.Clear();
                    lstReflejantes.CheckedItems.Clear();
                    gvResult.DataSource = null;
                    picFoto.Image       = null;
                }
            } catch (Exception ex) {
                throw ex;
            } finally {
                oEnsamble = null;
            }
        }
Exemple #28
0
        private void CargaCliente(int IdCliente)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();

            try {
                oClientes = oEnsamble.ABC_Clientes_Obtener(IdCliente);
                if (oClientes.Count > 0)
                {
                    var item = oClientes[0];

                    #region  SE CARGA EL ENCABEZADO
                    cboTipoCliente.SelectedValue = item.TipoCliente.Id;
                    txtId.Text         = item.Id.ToString();
                    txtClave.Text      = item.Id.ToString();
                    txtNombre.Text     = item.Nombre;
                    txtRFC.Text        = item.RFC;
                    txtIdentidad.Text  = item.IdFiscal;
                    txtDireccion.Text  = item.Direccion;
                    txtTelefono.Text   = item.Telefono;
                    txtColonia.Text    = item.Colonia;
                    txtCP.Text         = item.CP.ToString();
                    txtCiudad.Text     = item.Ciudad;
                    txtPais.Text       = item.Pais;
                    txtEstado.Text     = item.Estado;
                    txtFecha.Text      = item.DatosUsuario.FechaCreacion.ToShortDateString();
                    rbNacional.Checked = item.Nacional ? true : false;
                    rbExporta.Checked  = !rbNacional.Checked;
                    chkVIP.Checked     = item.VIP ? true : false;
                    txtCorreo1.Text    = item.Correo1;
                    txtCorreo2.Text    = item.Correo2;
                    chkActivo.Checked  = item.DatosUsuario.Estatus;


                    /*COMPRAS*/
                    txtCompras.Text   = item.Compras.Nombre;
                    txtCorreoCom.Text = item.Compras.Correo;
                    txtTelCom.Text    = item.Compras.Telefono;
                    txtExtCom.Text    = item.Compras.Extension.ToString();

                    /*PAGOS*/
                    txtPagos.Text     = item.Pagos.Nombre;
                    txtCorreoPag.Text = item.Pagos.Correo;
                    txtTelPag.Text    = item.Pagos.Telefono;
                    txtExtPag.Text    = item.Pagos.Extension.ToString();
                    cboPago.Text      = item.Pagos.DiasPago;
                    cboRecibo.Text    = item.Pagos.Contrarecibo;
                    txtHorario.Text   = item.Pagos.Horario;
                    txtPlazo.Text     = item.Pagos.Plazo.ToString();
                    #endregion

                    #region ENTIDADES
                    oClientes.ForEach(aux => {
                        aux.Entidades.ForEach(y => {
                            foreach (var x in lstEntidades.Items)
                            {
                                if (x.Value.ToString() == y.Entidad.Id.ToString())
                                {
                                    x.CheckState = Telerik.WinControls.Enumerations.ToggleState.On;
                                }
                            }
                        });
                    });
                    #endregion

                    #region RECEPCIÓN MCIA
                    oClientes.ForEach(aux => {
                        aux.Recepcion.ForEach(y => {
                            if (txtContacto1.Text.Trim().Length == 0)
                            {
                                txtContacto1.Text = y.Nombre;
                                txtPuesto1.Text   = y.Puesto;
                            }
                            else
                            {
                                txtContacto2.Text = y.Nombre;
                                txtPuesto2.Text   = y.Puesto;
                            }
                        });
                    });
                    #endregion

                    #region REFERENCIAS
                    oClientes.ForEach(aux => {
                        aux.Referencias.ForEach(y => {
                            if (txtRefer1.Text.Trim().Length == 0)
                            {
                                txtRefer1.Text  = y.Nombre;
                                txtDirec1.Text  = y.Direccion;
                                txtTel1.Text    = y.Telefono;
                                txtContac1.Text = y.Contacto;
                            }
                            else
                            {
                                txtRefer2.Text  = y.Nombre;
                                txtDirec2.Text  = y.Direccion;
                                txtTel2.Text    = y.Telefono;
                                txtContac2.Text = y.Contacto;
                            }
                        });
                    });
                    #endregion

                    #region CONDICIONES COMERCIALES
                    cboForma.SelectedValue  = item.Condiciones.FormaPago;
                    cboMetodo.SelectedValue = item.Condiciones.MetodoPago;
                    cboUso.SelectedValue    = item.Condiciones.UsoCFDI;
                    txtDias.Text            = item.Condiciones.DiasCredito.ToString();
                    txtMonto.Text           = item.Condiciones.MontoCredito.ToString();
                    txtDescto.Text          = item.Condiciones.Descuento.ToString();
                    #endregion
                }
                else
                {
                    RadMessageBox.Show("Cliente no existe o está inactivo", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                }
            } catch (Exception ex) {
                throw ex;
            } finally {
                oEnsamble = null;
            }
        }
Exemple #29
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            oEnsamble = new WCF_Ensamble.Hersan_EnsambleClient();

            int Result = 0;

            try {
                if (!ValidarCampos())
                {
                    RadMessageBox.Show("Debe asignar un Tipo de Cliente y Seleccionar al menos una Entidad", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                    return;
                }

                if (RadMessageBox.Show("Desea guardar la información capturada...?", this.Text, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.No)
                {
                    return;
                }

                /* VALIDAR SI ES NUEVO O ACTUALIZACIÓN */
                if (int.Parse(txtId.Text) == 0)
                {
                    ClientesBE obj = new ClientesBE();
                    obj.Nombre = txtNombre.Text;
                    obj.RFC    = txtRFC.Text;
                    var oItem = oEnsamble.ABC_Clientes_Buscar(obj, "");
                    if (oItem.Count > 0)
                    {
                        RadMessageBox.Show("EL cliente capturado ya existe: " + oItem[0].Nombre, this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                        obj = null;
                        return;
                    }
                }

                #region Entidades Seleccionadas
                string Entidades = string.Empty;
                foreach (var item in lstEntidades.Items)
                {
                    if (item.CheckState == Telerik.WinControls.Enumerations.ToggleState.On)
                    {
                        Entidades += item.Value.ToString() + ",";
                    }
                }
                #endregion

                /* ALTA DE CLIENTE */
                if (int.Parse(txtId.Text) == 0)
                {
                    Result = oEnsamble.ABC_Clientes_Guardar(CrearTablasAuxiliares(), Entidades, BaseWinBP.UsuarioLogueado.ID);
                    if (Result != 0)
                    {
                        RadMessageBox.Show("Cliente guardado correctamente\nEl No. Cliente asignado es: " + Result.ToString(), this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                    }
                    else
                    {
                        RadMessageBox.Show("Ocurrió un error al guardar la información", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                    }
                }
                else
                {
                    Result = oEnsamble.ABC_Clientes_Actualizar(CrearTablasAuxiliares(), Entidades, BaseWinBP.UsuarioLogueado.ID, chkActivo.Checked);
                    if (Result != 0)
                    {
                        RadMessageBox.Show("Cliente actualizado correctamente", this.Text, MessageBoxButtons.OK, RadMessageIcon.Info);
                    }
                    else
                    {
                        RadMessageBox.Show("Ocurrió un error al guardar la información", this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
                    }
                }
                if (Result != 0)
                {
                    LimpiarCampos();
                    this.docContactos.Select();
                }
            } catch (Exception ex) {
                RadMessageBox.Show("Ocurrió un error al guardar los datos\n" + ex.Message, this.Text, MessageBoxButtons.OK, RadMessageIcon.Error);
            }
        }