예제 #1
0
        private void BtnAgregar_Click(object sender, RoutedEventArgs e)
        {
            ServicioModel item    = (ServicioModel)comboxServicioR.SelectedItem;
            ClienteModel  cliente = (ClienteModel)comboxClienteR.SelectedItem;

            if (item != null && cliente != null)
            {
                if (RevisarFechas(item))
                {
                    int     qty      = (int)qtyPicker.Value;
                    decimal subtotal = item.Precio * qty;
                    decimal itbis    = subtotal * (decimal)0.18;
                    //decimal total = subtotal + itbis;

                    if (qty >= 1)
                    {
                        reservacion        = new ReservacionModel();
                        reservacionDetalle = new ReservacionDetalle();

                        reservacion.ClienteID = cliente.ID;
                        reservacion.Fecha     = dateReservacion.SelectedDate.Value.Date;

                        reservacionDetalle.Servicio = item;
                        reservacionDetalle.Cantidad = qty;
                        reservacionDetalle.Subtotal = subtotal;
                        reservacionDetalle.Itbis    = itbis;

                        Items.Add(reservacionDetalle);
                        dgReservacion.Items.Add(reservacionDetalle);
                        ActualizarPrecios(reservacionDetalle, null);

                        //item.CuposDisponibles -= qty;
                        qtyPicker.Value               = 1;
                        comboxClienteR.IsEnabled      = false;
                        txtClienteCodigo.IsEnabled    = false;
                        comboxServicioR.SelectedIndex = -1;
                    }
                    else
                    {
                        _ = MessageBox.Show("LA CANTIDAD SELECCIONADA NO ES VALIDA", "ERROR", MessageBoxButton.OK);
                    }
                }
                else
                {
                    _ = MessageBox.Show("FECHA DEL SERVICIO CHOCA CON OTRO SERVICIO SELECCIONADO", "ERROR", MessageBoxButton.OK);
                }
            }
            else
            {
                _ = MessageBox.Show("DEBE SELECCIONAR EL CLIENTE Y AL MENOS UN PRODUCTO", "ERROR", MessageBoxButton.OK);
            }
        }
        public string ObtenerReservaciones(string usuario, String fecha1, String fecha2)
        {
            List <ReservacionModel> categorias = new List <ReservacionModel>();

            conn.Open();
            SqlCommand com = new SqlCommand
            {
                Connection  = conn,
                CommandType = CommandType.StoredProcedure,
                CommandText = "sp_obtenerReservaciones"
            };

            com.Parameters.Add("@usuario", SqlDbType.VarChar).Value = usuario;
            com.Parameters.Add("@fecha1", SqlDbType.Date).Value     = fecha1;
            com.Parameters.Add("@fecha2", SqlDbType.Date).Value     = fecha2;


            SqlDataReader rdr = com.ExecuteReader();

            if (rdr.HasRows)
            {
                while (rdr.Read())
                {
                    ReservacionModel aux = new ReservacionModel();
                    aux.centro_nombre       = rdr.GetString(0);
                    aux.control_hora_bloque = rdr.GetString(1);
                    aux.control_hora_dia    = rdr.GetString(2);
                    categorias.Add(aux);
                }
                rdr.Close();
                conn.Close();
            }

            string j = JsonConvert.SerializeObject(categorias);

            return(j);
        }