Exemple #1
0
        // se cambia a la ventana elegida
        private void Button_Agregar(object sender, RoutedEventArgs e)
        {
            AgregarServicio w = new AgregarServicio();

            w.Show();
            this.Close();
        }
Exemple #2
0
        private void Button_Agregar(object sender, RoutedEventArgs e)
        {
            // se cambia a la ventana elegida
            AgregarServicio w = new AgregarServicio();

            w.Show();

            this.Close();
        }
Exemple #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            /*AgregarServicio w = new AgregarServicio();
             * w.Show();
             * this.Close();
             */
            String res = Conexion.comprobarPwd(txUsuario.Text, txContraseña.Text);

            if (res.Equals("Contraseña correcta"))
            {
                //MessageBox.Show("Mandar a la siguiente pantalla");
                AgregarServicio w = new AgregarServicio();
                w.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show(res);
            }
        }
Exemple #4
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.btAgregar = ((Homologacion.AgregarServicio)(target));
                return;

            case 2:
                this.txLugar = ((System.Windows.Controls.TextBox)(target));
                return;

            case 3:

            #line 27 "..\..\AgregarServicio.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);

            #line default
            #line hidden
                return;

            case 4:
                this.cbTipo = ((System.Windows.Controls.ComboBox)(target));

            #line 28 "..\..\AgregarServicio.xaml"
                this.cbTipo.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.CbTipo_SelectionChanged);

            #line default
            #line hidden
                return;

            case 5:
                this.cbMateria = ((System.Windows.Controls.ComboBox)(target));

            #line 29 "..\..\AgregarServicio.xaml"
                this.cbMateria.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.cbMateria_SelectionChanged);

            #line default
            #line hidden
                return;

            case 6:
                this.cbDepartamento = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 7:
                this.lbInicio = ((System.Windows.Controls.ListBox)(target));

            #line 35 "..\..\AgregarServicio.xaml"
                this.lbInicio.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.LbInicio_SelectionChanged);

            #line default
            #line hidden
                return;

            case 8:
                this.lbFin = ((System.Windows.Controls.ListBox)(target));
                return;

            case 9:
                this.btEliminar = ((System.Windows.Controls.Button)(target));

            #line 38 "..\..\AgregarServicio.xaml"
                this.btEliminar.Click += new System.Windows.RoutedEventHandler(this.Button_Eliminar);

            #line default
            #line hidden
                return;

            case 10:
                this.btAgregar1 = ((System.Windows.Controls.Button)(target));

            #line 39 "..\..\AgregarServicio.xaml"
                this.btAgregar1.Click += new System.Windows.RoutedEventHandler(this.Button_Agregar);

            #line default
            #line hidden
                return;

            case 11:
                this.btModificar = ((System.Windows.Controls.Button)(target));

            #line 40 "..\..\AgregarServicio.xaml"
                this.btModificar.Click += new System.Windows.RoutedEventHandler(this.BtModificar_Click);

            #line default
            #line hidden
                return;

            case 12:
                this.btBuscar = ((System.Windows.Controls.Button)(target));

            #line 41 "..\..\AgregarServicio.xaml"
                this.btBuscar.Click += new System.Windows.RoutedEventHandler(this.BtBuscar_Click);

            #line default
            #line hidden
                return;

            case 13:
                this.btRegresar1 = ((System.Windows.Controls.Button)(target));

            #line 42 "..\..\AgregarServicio.xaml"
                this.btRegresar1.Click += new System.Windows.RoutedEventHandler(this.BtRegresar_Click);

            #line default
            #line hidden
                return;

            case 14:
                this.cbLunes = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 15:
                this.cbMartes = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 16:
                this.cbMiercoles = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 17:
                this.cbJueves = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 18:
                this.cbViernes = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 19:
                this.lbProfesor = ((System.Windows.Controls.ListBox)(target));
                return;
            }
            this._contentLoaded = true;
        }
Exemple #5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //si se quiere agregar un servicio se instancian los elementos necesarios para la conexion
                Int16         id = 0;// se pone el id provisionalmente en 0 para que no marque error
                SqlCommand    cmd;
                SqlDataReader rd;
                SqlConnection con;
                try
                {
                    con = Conexion.conectar();
                    cmd = new SqlCommand("select max(servicios.idServicio) from servicios", con);//se encuentra el actual id servicio maximo para poner uno mayor
                    rd  = cmd.ExecuteReader();
                    rd.Read();
                    id = Int16.Parse(rd[0].ToString());
                    id++;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Id maximo no encontrado. \n " + ex.Message);
                }

                String lugar      = txLugar.Text; // es posible dejar el lugar en blanco si asi se desea
                String tipo       = cbTipo.SelectedItem.ToString();
                String horaInicio = lbInicio.SelectedItem.ToString();
                String horaFin    = lbFin.SelectedItem.ToString();
                String curso;
                int    idProf;
                // si se ingresa el servicio en los primeros 5 meses es que es de Primavera
                if (int.Parse(DateTime.Now.Month.ToString()) < 6)
                {
                    curso = "Primavera";
                }
                else if (int.Parse(DateTime.Now.Month.ToString()) < 7)
                {
                    // antes del 7 es en verano
                    curso = "Verano";
                }
                else
                {
                    // despues es en otoño
                    curso = "Otoño";
                }
                // se pone el año actual
                int año       = int.Parse(DateTime.Now.Year.ToString());
                int idMateria = -1;
                // checa que alguna materia este seleccionada, el departamento es opcional para reducir la lista de materias
                if (cbDepartamento.SelectedIndex != -1)
                {
                    try
                    {
                        //se abre una conexion y se obtiene el id del nombre de la materia seleccionada
                        con = Conexion.conectar();
                        cmd = new SqlCommand(String.Format("select materias.idMateria from materias where materias.nombre='{0}'", cbDepartamento.SelectedItem.ToString()), con);
                        rd  = cmd.ExecuteReader();
                        rd.Read();
                        idMateria = int.Parse(rd[0].ToString());
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Materia no encontrada \n " + ex.Message);
                    }
                    idProf = int.Parse(lbProfesor.SelectedItem.ToString());
                    Servicio s;
                    //checa que al menos un dia este seleccionado
                    if (cbLunes.IsChecked.HasValue && cbLunes.IsChecked.Value || cbMartes.IsChecked.HasValue && cbMartes.IsChecked.Value || cbMiercoles.IsChecked.HasValue && cbMiercoles.IsChecked.Value ||
                        cbJueves.IsChecked.HasValue && cbJueves.IsChecked.Value || cbViernes.IsChecked.HasValue && cbViernes.IsChecked.Value)
                    {
                        if (cbLunes.IsChecked.HasValue && cbLunes.IsChecked.Value)
                        {
                            //si se selecciono este dia de la semana, se da de alta un servicio en este dia
                            s = new Servicio(id, lugar, tipo, horaInicio, horaFin, curso, año, idMateria, idProf, "Lunes");
                            s.agregar(s);
                            id++;
                        }

                        if (cbMartes.IsChecked.HasValue && cbMartes.IsChecked.Value)
                        {
                            //si se selecciono este dia de la semana, se da de alta un servicio en este dia
                            s = new Servicio(id, lugar, tipo, horaInicio, horaFin, curso, año, idMateria, idProf, "Martes");
                            s.agregar(s);
                            id++;
                        }

                        if (cbMiercoles.IsChecked.HasValue && cbMiercoles.IsChecked.Value)
                        {
                            //si se selecciono este dia de la semana, se da de alta un servicio en este dia
                            s = new Servicio(id, lugar, tipo, horaInicio, horaFin, curso, año, idMateria, idProf, "Miercoles");
                            s.agregar(s);
                            id++;
                        }

                        if (cbJueves.IsChecked.HasValue && cbJueves.IsChecked.Value)
                        {
                            //si se selecciono este dia de la semana, se da de alta un servicio en este dia
                            s = new Servicio(id, lugar, tipo, horaInicio, horaFin, curso, año, idMateria, idProf, "Jueves");
                            s.agregar(s);
                            id++;
                        }

                        if (cbViernes.IsChecked.HasValue && cbViernes.IsChecked.Value)
                        {
                            //si se selecciono este dia de la semana, se da de alta un servicio en este dia
                            s = new Servicio(id, lugar, tipo, horaInicio, horaFin, curso, año, idMateria, idProf, "Viernes");
                            s.agregar(s);
                            id++;
                        }
                        System.Media.SystemSounds.Asterisk.Play(); // se reproduce un sonidito
                        MessageBox.Show("Alta exitosa");
                        AgregarServicio w = new AgregarServicio();
                        w.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Ningun dia seleccionado ");
                    }
                }
                else
                {
                    MessageBox.Show("Materia no seleccionada ");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se pudo dar de alta, parametros incompletos  ");
            }
        }