Beispiel #1
0
        public List <PedidosBE> ENS_Cotizacion_Buscar(int IdCliente, string Nombre, string Inicial, string Final)
        {
            List <PedidosBE> oList = new List <PedidosBE>();

            try {
                using (SqlConnection conn = new SqlConnection(RecuperarCadenaDeConexion("coneccionSQL"))) {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(CONS_USP_ENS_COTIZACION_BUSCAR, conn)) {
                        cmd.Parameters.AddWithValue("@IdCliente", IdCliente);
                        cmd.Parameters.AddWithValue("@Nombre", Nombre);
                        cmd.Parameters.AddWithValue("@Inicial", Inicial);
                        cmd.Parameters.AddWithValue("@Final", Final);

                        cmd.CommandType = CommandType.StoredProcedure;

                        using (IDataReader reader = cmd.ExecuteReader()) {
                            while (reader.Read())
                            {
                                PedidosBE obj = new PedidosBE();

                                obj.Id                         = int.Parse(reader["COT_Id"].ToString());
                                obj.Cliente.Id                 = int.Parse(reader["CLI_Id"].ToString());
                                obj.Cliente.Nombre             = reader["CLI_Nombre"].ToString();
                                obj.DatosUsuario.FechaCreacion = DateTime.Parse(reader["COT_FechaCreacion"].ToString());

                                oList.Add(obj);
                            }
                        }
                    }
                }
                return(oList);
            } catch (Exception ex) {
                throw ex;
            }
        }
Beispiel #2
0
        public int ENS_Cotizacion_Actualizar(PedidosBE obj, DataTable oDetalle)
        {
            int Result = 0;

            try {
                using (SqlConnection conn = new SqlConnection(RecuperarCadenaDeConexion("coneccionSQL"))) {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(CONS_USP_ENS_COTIZACION_ACTUALIZAR, conn)) {
                        cmd.Parameters.AddWithValue("@IdCotiza", obj.Id);
                        cmd.Parameters.AddWithValue("@Moneda", obj.Moneda.Moneda);
                        cmd.Parameters.AddWithValue("@IdCliente", obj.Cliente.Id);
                        cmd.Parameters.AddWithValue("@EsPedido", obj.Pedido);
                        cmd.Parameters.AddWithValue("@Proyecto", obj.Proyecto);
                        cmd.Parameters.AddWithValue("@Semaforo", obj.Semaforo);
                        cmd.Parameters.AddWithValue("@Condicion", obj.Condiciones.Id);
                        cmd.Parameters.AddWithValue("@Gastos", obj.Gastos);
                        cmd.Parameters.AddWithValue("@Detalle", oDetalle);
                        cmd.Parameters.AddWithValue("@IdUsuario", obj.DatosUsuario.IdUsuarioModif);
                        cmd.Parameters.AddWithValue("@Estatus", obj.DatosUsuario.Estatus);

                        cmd.CommandType = CommandType.StoredProcedure;
                        Result          = Convert.ToInt32(cmd.ExecuteScalar());
                    }
                }
                return(Result);
            } catch (Exception ex) {
                throw ex;
            }
        }
Beispiel #3
0
        public List <PedidosBE> ENS_Cotizacion_Consulta(int IdAgente, int IdCotiza, string Inicial, string Final)
        {
            List <PedidosBE> oList = new List <PedidosBE>();

            try {
                using (SqlConnection conn = new SqlConnection(RecuperarCadenaDeConexion("coneccionSQL"))) {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(CONS_USP_ENS_COTIZACION_CONSULTA, conn)) {
                        cmd.Parameters.AddWithValue("@Agente", IdAgente);
                        cmd.Parameters.AddWithValue("@IdCotiza", IdCotiza);
                        cmd.Parameters.AddWithValue("@FechaIni", Inicial);
                        cmd.Parameters.AddWithValue("@Fechafin", Final);

                        cmd.CommandType = CommandType.StoredProcedure;

                        using (IDataReader reader = cmd.ExecuteReader()) {
                            while (reader.Read())
                            {
                                PedidosBE obj = new PedidosBE();

                                obj.Id            = int.Parse(reader["COT_Id"].ToString());
                                obj.Moneda.Moneda = reader["MON_Moneda"].ToString();
                                obj.Proyecto      = reader["COT_Proyecto"].ToString();
                                obj.Semaforo      = int.Parse(reader["Semaforo"].ToString());
                                obj.NoPedido      = int.Parse(reader["COT_Pedido"].ToString());
                                obj.DatosUsuario.FechaCreacion = DateTime.Parse(reader["COT_FechaCreacion"].ToString());
                                obj.Agente.Clave    = reader["AGE_Clave"].ToString();
                                obj.Cliente.Id      = int.Parse(reader["CLI_Id"].ToString());
                                obj.Cliente.Nombre  = reader["CLI_Nombre"].ToString();
                                obj.Cliente.Correo1 = reader["CLI_Correo1"].ToString();
                                obj.Cliente.Correo2 = reader["CLI_Correo2"].ToString();
                                obj.Monto           = decimal.Parse(reader["Monto"].ToString());
                                obj.NoPedido        = int.Parse(reader["COT_Pedido"].ToString());
                                obj.Semaforo        = int.Parse(reader["COT_Semaforo"].ToString());

                                oList.Add(obj);
                            }
                        }
                    }
                }
                return(oList);
            } catch (Exception ex) {
                throw ex;
            }
        }
Beispiel #4
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;
            }
        }
Beispiel #5
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;
            }
        }
Beispiel #6
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;
            }
        }
Beispiel #7
0
 public int ENS_Cotizacion_Actualizar(PedidosBE obj, DataTable oDetalle)
 {
     return(new PedidosBP().ENS_Cotizacion_Actualizar(obj, oDetalle));
 }
Beispiel #8
0
        public List <PedidosBE> ENS_Cotizacion_Obtener(int IdCotizacion)
        {
            List <PedidosBE> oList = new List <PedidosBE>();

            try {
                using (SqlConnection conn = new SqlConnection(RecuperarCadenaDeConexion("coneccionSQL"))) {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(CONS_USP_ENS_COTIZACION_OBTENER, conn)) {
                        cmd.Parameters.AddWithValue("@IdCotizacion", IdCotizacion);
                        cmd.CommandType = CommandType.StoredProcedure;

                        using (IDataReader reader = cmd.ExecuteReader()) {
                            while (reader.Read())
                            {
                                PedidosBE obj = new PedidosBE();

                                /* ENCABEZADO DE COTIZACION */
                                obj.Id                         = int.Parse(reader["COT_Id"].ToString());
                                obj.Cliente.Id                 = int.Parse(reader["CLI_Id"].ToString());
                                obj.Cliente.Nombre             = reader["CLI_Nombre"].ToString();
                                obj.Cliente.VIP                = bool.Parse(reader["CLI_VIP"].ToString());
                                obj.Proyecto                   = reader["COT_Proyecto"].ToString();
                                obj.Semaforo                   = int.Parse(reader["COT_Semaforo"].ToString());
                                obj.Condiciones.Id             = int.Parse(reader["CEX_Id"].ToString());
                                obj.Agente.Id                  = int.Parse(reader["AGE_Id"].ToString());
                                obj.Agente.Nombre              = reader["AGE_Nombre"].ToString();
                                obj.DatosUsuario.FechaCreacion = DateTime.Parse(reader["Fecha"].ToString());
                                obj.Moneda.Moneda              = reader["MON_Moneda"].ToString();

                                oList.Add(obj);
                            }

                            if (oList.Count > 0)
                            {
                                /* DETALLE DE COTIZACION */
                                if (reader.NextResult())
                                {
                                    while (reader.Read())
                                    {
                                        PedidoDetalleBE oDetalle = new PedidoDetalleBE();
                                        oDetalle.Id                = int.Parse(reader["COD_Id"].ToString());
                                        oDetalle.Tipo              = reader["COD_Tipo"].ToString();
                                        oDetalle.Entidad.Nombre    = reader["ENT_Nombre"].ToString();
                                        oDetalle.Producto.Id       = int.Parse(reader["COD_Id_ProdServ"].ToString());
                                        oDetalle.Producto.Nombre   = reader["TPR_Nombre"].ToString();
                                        oDetalle.Accesorios.Id     = int.Parse(reader["ACC_Id"].ToString());
                                        oDetalle.Accesorios.Nombre = reader["ACC_Nombre"].ToString();
                                        oDetalle.Precio            = decimal.Parse(reader["COD_Precio"].ToString());
                                        oDetalle.Descto            = decimal.Parse(reader["COD_Descto"].ToString());
                                        oDetalle.Cantidad          = int.Parse(reader["COD_Cantidad"].ToString());
                                        oDetalle.Total             = (oDetalle.Cantidad * oDetalle.Precio) - oDetalle.Descto;


                                        oList[0].Detalle.Add(oDetalle);
                                    }
                                }

                                /* REFLEJANTES DE COTIZACION */
                                if (oList[0].Detalle.Count > 0)
                                {
                                    if (reader.NextResult())
                                    {
                                        while (reader.Read())
                                        {
                                            var aux = oList[0].Detalle.Find(item => item.Id == int.Parse(reader["COD_Id"].ToString()));
                                            if (aux != null)
                                            {
                                                aux.Reflec = reader["Tipo"].ToString();
                                                aux.Reflejantes.Add(new Entidades.Catalogos.ReflejantesBE {
                                                    Id     = int.Parse(reader["COM_Id"].ToString()),
                                                    Nombre = reader["Tipo"].ToString(),
                                                });
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return(oList);
            } catch (Exception ex) {
                throw ex;
            }
        }
Beispiel #9
0
 public int ENS_Cotizacion_Guardar(PedidosBE obj, System.Data.DataTable oDetalle)
 {
     return(new PedidosDA().ENS_Cotizacion_Guardar(obj, oDetalle));
 }