private static Materia rowToDto(MateriaDS.MateriaRow row)
 {
     Materia objMateria = new Materia();
     objMateria.Codigo = row.codigo;
     objMateria.Nombre = row.nombre;
     objMateria.Id = row.id;
     objMateria.Semestre = row.semestre;
     return objMateria;
 }
Пример #2
0
        public int AgregarMateria(Materia materia)
        {
            materia.v_TipoEvento = "I";
            DatosSistema datos = new DatosSistema();
            string[] parametros = { "@v_nombre",
                                    "@v_clave",
                                    "@v_descripcion",
                                    "@v_Dfacultad",
                                    "@v_usuarioI",
                                    "@v_TipoEvento"};

            return datos.Ejecutar("proAgregarMateria", parametros,
                                   materia.v_nombre,
                                   materia.v_clave,
                                   materia.v_descripcion,
                                   materia.v_Dfacultad,
                                   materia.v_usuario_i,
                                   materia.v_TipoEvento);
        }
    public void setInfo(GameObject bloco)
    {
        if (_contador == 1)
        {
            M1 = bloco;
            ++_contador;
            Invoke("Reset", _tempoDeEsperaParaDesativar);
        }
           else if(_contador == 2)
        {
            if (bloco == M1){ Reset(); }

            else
            {
                Materia aux = new Materia(bloco.GetComponent<Materia>());
                bloco.GetComponent<Materia>().setParams(M1.GetComponent<Materia>());
                M1.GetComponent<Materia>().setParams(aux);
                _contador = 1;
            }
        }
    }
Пример #4
0
        private void mnuExecuteScripts_Click(object sender, EventArgs e)
        {
            if (!mnuExecuteScripts.Enabled)
            {
                return;
            }

            OpenFileDialog _dialog = new OpenFileDialog();

            _dialog.CheckFileExists = true;
            _dialog.CheckPathExists = true;
            _dialog.DefaultExt      = SCMS.ScriptFileExtension;
            _dialog.Filter          = "SCMS Database Script Files (*." + SCMS.ScriptFileExtension + ")|*." + SCMS.ScriptFileExtension;
            _dialog.Title           = "Browse Database Script File";

            string _filename = "";

            if (_dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                _filename = (_dialog.FileName);
            }
            _dialog.Dispose(); _dialog = null;
            Materia.RefreshAndManageCurrentProcess();

            if (!string.IsNullOrEmpty(_filename.RLTrim()))
            {
                if (File.Exists(_filename))
                {
                    string _tempdir = Application.StartupPath + "\\Temp";

                    if (!Directory.Exists(_tempdir))
                    {
                        try { Directory.CreateDirectory(_tempdir); }
                        catch { }
                    }

                    if (Directory.Exists(_tempdir))
                    {
                        FileInfo _file      = new FileInfo(_filename);
                        string   _decrypted = _file.Decrypt(SCMS.EncryptionKey);
                        string   _tempfile  = _tempdir + "\\" + Path.GetFileNameWithoutExtension(_filename) + ".xml";

                        FileInfo _xmlfile = Materia.WriteToFile(_tempfile, _decrypted, false);
                        if (_xmlfile != null)
                        {
                            DataTable _table = SCMS.XmlToTable(_xmlfile.FullName);
                            if (_table != null)
                            {
                                if (_table.TableName == "scripts")
                                {
                                    if (_table.Rows.Count > 0)
                                    {
                                        DatabaseScriptInfo            _script = new DatabaseScriptInfo(_table);
                                        DatabaseScriptExecutionResult _result = _script.Execute();
                                    }
                                    else
                                    {
                                        MsgBoxEx.Shout("The specified file does not contain anyt releveant database script information.", "Execute Database Script");
                                    }
                                }
                                else
                                {
                                    MsgBoxEx.Shout("The specified file does not contain anyt releveant database script information.", "Execute Database Script");
                                }
                            }
                            else
                            {
                                MsgBoxEx.Alert("Failed to extract script information from the specified file.", "Execute Database Script");
                            }
                        }
                        else
                        {
                            MsgBoxEx.Alert("Failed to extract script information from the specified file.", "Execute Database Script");
                        }
                    }
                    else
                    {
                        MsgBoxEx.Alert("Failed to extract script information from the specified file.", "Execute Database Script");
                    }
                }
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            List <Registro_Estudiante.Estudiante> Estudiantes = new List <Registro_Estudiante.Estudiante>();
            List <RegistroMateria.Materia>        Materias    = new List <RegistroMateria.Materia>();

            Data  data  = new Data("Estudiante.bd");
            Data2 dataM = new Data2("Materia.bd");

            Boolean Open       = true;
            int     id_materia = 101;
            int     est        = 0;
            int     id;

            while (Open)
            {
                if (File.Exists("Estudiante.bd"))
                {
                    Estudiantes = data.deserializar();
                }
                if (File.Exists("Materia.bd"))
                {
                    Materias = dataM.deserializarMateria();
                }

MenuPrincipal:
                Console.Clear();
                Console.WriteLine("Seleccione un menu: \n 1) Estudiantes \n 2) Materias \n 3) Salir");
                try
                {
                    int opc = Convert.ToInt32(Console.ReadLine());
                    switch (opc)
                    {
                    case 1:
                    {
                        Console.Clear();
MenuEstudiantes:

                        Console.WriteLine("Bienvenido al sistema de registro de estudiante \n\n 1) Crear nuevo estudiante \n 2) Listar todos los estudiantes \n 3) Editar \n 4) Eliminar estudiante \n 5) Buscar estudiante \n 6) Salir");
                        int opcion = Convert.ToInt32(Console.ReadLine());

                        if (opcion < 7 || opcion >= 0)
                        {
                            switch (opcion)
                            {
                            case 1:
                            {
                                Console.Clear();
                                if (Estudiantes.Count == 0)
                                {
                                    id = 1080001;
                                }
                                else
                                {
                                    id  = Estudiantes[Estudiantes.Count - 1].ID + 1;
                                    id += est;
                                }
                                Estudiante Prueba = new Estudiante(id);
                                Prueba.CrearEstudiante();
                                Estudiantes.Add(Prueba);

                                data.serializar(Estudiantes);
                                Console.ReadKey();
                                Console.Clear();
                                goto MenuEstudiantes;
                            }

                            case 2:
                            {
                                Console.Clear();
                                if (Estudiantes.Count > 0)
                                {
                                    Console.WriteLine("          LISTA DE TODOS LOS ESTUDIANTES           \n");
                                    Console.WriteLine("ID :        |  Nombres y Apellidos             | Estatus :           | Carrera :                   | Documento de Identidad :          | Nacionalidad :        | F. Nacimiento :                ");
                                    Console.Write("-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
                                    for (int i = 0; i < Estudiantes.Count; i++)
                                    {
                                        Estudiantes[i].ListarEstudiantes((i + 6));
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("No hay estudiantes registrados!");
                                }
                                Console.ReadKey();
                                Console.Clear();
                                goto MenuEstudiantes;
                            }

                            case 3:
                            {
                                Console.Clear();
                                int idEditar = 0, campo;
                                Console.WriteLine("Ingrese el id a modificar: ");
                                idEditar = Convert.ToInt32(Console.ReadLine());
                                Console.Clear();
                                foreach (Estudiante A in Estudiantes)
                                {
                                    if (A.ID == idEditar)
                                    {
                                        Console.WriteLine("Campos a Modificar");
                                        Console.WriteLine("1. Nombre");
                                        Console.WriteLine("2. Apellido");
                                        Console.WriteLine("3. Carrera");
                                        Console.WriteLine("4. Estatus");
                                        Console.WriteLine("5. Fecha de nacimiento");
                                        Console.WriteLine("6. Nacionalidad");
                                        Console.WriteLine("7. Documentos");



                                        Console.Write("\nQue campo quiere editar?  ");
                                        campo = Convert.ToInt32(Console.ReadLine());

                                        Console.Clear();
                                        switch (campo)
                                        {
                                        case 1:
                                        {
                                            string nombrenuevo;
                                            Console.Write("Digite el nuevo nombre: ");
                                            nombrenuevo = Console.ReadLine().ToUpper();
                                            A.Nombre    = nombrenuevo;
                                            data.serializar(Estudiantes);
                                            Console.WriteLine("\n Se modifico el campo !");
                                            Console.ReadKey();
                                            Console.Clear();
                                            goto MenuEstudiantes;
                                        }

                                        case 2:
                                        {
                                            string apellidonuevo;
                                            Console.Write("\nDigite el nuevo apellido: ");
                                            apellidonuevo = Console.ReadLine().ToUpper();
                                            A.Apellido    = apellidonuevo;
                                            data.serializar(Estudiantes);
                                            Console.WriteLine("\n Se modifico el campo !");
                                            Console.ReadKey();
                                            Console.Clear();
                                            goto MenuEstudiantes;
                                        }

                                        case 3:
                                        {
                                            string carreranueva;
                                            Console.Write("\nDigite la nueva carrera: ");
                                            carreranueva = Console.ReadLine();
                                            A.Carrera    = carreranueva;
                                            data.serializar(Estudiantes);
                                            Console.WriteLine("\n Se modifico el campo !");
                                            Console.ReadKey();
                                            Console.Clear();
                                            goto MenuEstudiantes;
                                        }

                                        case 4:
                                        {
                                            Console.Write("\nEscoja el estatus del estudiante \n 1) En proceso \n 2) Activo \n 3) Prueba academica \n 4) Inactivo \n >");
                                            Console.Write("\nDigite el nuevo estatus:");
                                            int opcion1 = Convert.ToInt32(Console.ReadLine());

                                            if (opcion1 >= 1 || opcion <= 4)
                                            {
                                                switch (opcion1)
                                                {
                                                case 1:
                                                    A.Estatus = "En proceso";
                                                    data.serializar(Estudiantes);
                                                    break;

                                                case 2:
                                                    A.Estatus = "Activo";
                                                    data.serializar(Estudiantes);
                                                    break;

                                                case 3:
                                                    A.Estatus = "Prueba academica";
                                                    data.serializar(Estudiantes);
                                                    break;

                                                case 4:
                                                    A.Estatus = "Inactivo";
                                                    data.serializar(Estudiantes);
                                                    break;
                                                }
                                            }


                                            Console.WriteLine("\n Se modifico el campo !");
                                            Console.ReadKey();
                                            Console.Clear();
                                            goto MenuEstudiantes;;
                                        }


                                        case 5:
                                        {
Fecha:

                                            {
                                                try
                                                {
                                                    Console.Write("\nIngrese la fecha de nacimiento dd/mm/yyyy: ");
                                                    A.Nacimiento = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy", null);
                                                    data.serializar(Estudiantes);
                                                }

                                                catch (FormatException)
                                                {
                                                    Console.WriteLine("\nEso no es un formato valido! \n");
                                                    goto Fecha;
                                                }
                                            }
                                            Console.WriteLine("\n Se modifico el campo !");
                                            Console.ReadKey();
                                            Console.Clear();
                                            goto MenuEstudiantes;;
                                        }

                                        case 6:
                                        {
                                            Console.WriteLine("\nEl estudiante es : \n 1) Dominicano \n 2) Extranjero");
                                            int opt = Convert.ToInt32(Console.ReadLine());

                                            if (opt >= 1 || opt <= 2)
                                            {
                                                switch (opt)
                                                {
                                                case 1:
                                                    A.Nacionalidad = "Dominicano";
                                                    data.serializar(Estudiantes);
                                                    break;

                                                case 2:
                                                    A.Nacionalidad = "Extranjero";
                                                    data.serializar(Estudiantes);
                                                    break;
                                                }
                                            }
                                        }
                                            Console.WriteLine("\n Se modifico el campo !");
                                            Console.ReadKey();
                                            Console.Clear();
                                            goto MenuEstudiantes;;

                                        case 7:
                                        {
                                            if (A.Nacionalidad == "Dominicano")
                                            {
                                                Console.Write("\nDigite el numero de cedula sin espacios o guiones: ");
                                                string intento = Console.ReadLine();
                                                data.serializar(Estudiantes);

                                                if (intento.Length != 11)
                                                {
                                                    Console.WriteLine("\nLa cedula no tiene 11 digitos, porfavor intente otra vez! ");
                                                    goto case 7;
                                                }
                                                else
                                                {
                                                    A.Cedula = intento;
                                                }
                                                data.serializar(Estudiantes);
                                            }

                                            else
                                            {
                                                Console.Write("\nDigite el numero de pasaporte del estudiante: ");
                                                A.Cedula = Console.ReadLine();
                                                data.serializar(Estudiantes);
                                            }
                                        }
                                            Console.WriteLine("\n Se modifico el campo !");
                                            Console.ReadKey();
                                            Console.Clear();
                                            goto MenuEstudiantes;;
                                        }
                                    }
                                }
                                Console.WriteLine("\nNo se encontro ningun estudiante con ese ID!");
                                Console.ReadKey();
                                Console.Clear();
                                goto MenuEstudiantes;
                            }

                            case 4:
                            {
                                Console.Clear();
                                Console.Write("Ingrese el ID del estudiante : ");
                                int ID_Borrar = Convert.ToInt32(Console.ReadLine());


                                try
                                {
                                    foreach (Estudiante b in Estudiantes)
                                    {
                                        if (b.ID == ID_Borrar)
                                        {
                                            Estudiantes.Remove(b);
                                            data.serializar(Estudiantes);
                                            Console.WriteLine("\nSe elimino el estudiante satisfactoriamente\n");
                                            Console.ReadKey();
                                            Console.Clear();
                                            goto MenuEstudiantes;
                                        }
                                    }
                                    Console.WriteLine("\nNo se ha encontrado un estudiante con ese ID\n");
                                    Console.ReadKey();
                                    Console.Clear();
                                }
                                catch (System.InvalidOperationException)
                                {
                                    Console.WriteLine("\nNo hay estudientes con ese ID \n");
                                    Console.ReadKey();
                                    Console.Clear();
                                    goto MenuEstudiantes;
                                }

                                Console.Clear();
                                goto MenuEstudiantes;
                            }

                            case 5:

                            {
                                Console.Clear();
                                Console.WriteLine("Nombre o cedula a buscar: ");
                                string idBuscar = (Console.ReadLine().ToUpper());

                                foreach (Estudiante b in Estudiantes)
                                {
                                    if (b.Nombre == idBuscar || b.Cedula == idBuscar)
                                    {
                                        Console.WriteLine("------------------------");
                                        Console.WriteLine("ID: " + b.ID);
                                        Console.WriteLine("Nombre: " + b.Nombre);
                                        Console.WriteLine("Apellido: " + b.Apellido);
                                        Console.WriteLine("Carrera: " + b.Carrera);
                                        Console.WriteLine("Cedula: " + b.Cedula);
                                        Console.WriteLine("Estatus: " + b.Estatus);
                                        Console.WriteLine("Nacimiento: {0}/{1}/{2}", b.Nacimiento.Day, b.Nacimiento.Month, b.Nacimiento.Year);
                                        Console.WriteLine("Nacionalidad: " + b.Nacionalidad);
                                        Console.ReadKey();
                                        Console.Clear();
                                        goto MenuEstudiantes;
                                    }
                                }
                                Console.WriteLine("No se ha encontrado ningun estudiante");
                                Console.ReadKey();
                                Console.Clear();

                                goto MenuEstudiantes;
                            }

                            case 6:
                            {
                                break;
                            }
                            }
                        }

                        else
                        {
                            Console.WriteLine("\nPorfavor ingrese una de las opciones mostradas !");
                            Console.ReadKey();
                            Console.Clear();
                            goto MenuEstudiantes;
                        }
                    }
                    break;

                    case 2:
                    {
MenuMaterias:
                        Console.Clear();

                        Console.WriteLine("Seleccione una opcion: \n 1) Crear materia nueva \n 2) Listar todas las materias \n 3) Borrar Materias \n 4) Editar Materia \n 5) Buscar Materia \n 6) Salir");
                        int option = Convert.ToInt32(Console.ReadLine());
                        switch (option)
                        {
                        case 1:
                        {
                            Console.Clear();
                            try
                            {
                                if (Materias.Count == 0)
                                {
                                    id_materia = 101;
                                }
                                else
                                {
                                    id_materia = Materias[Materias.Count - 1].ID + 1;
                                }

                                Materia nuevamat = new Materia(id_materia);
                                Materias.Insert(0, nuevamat);
                                nuevamat.CrearMateria();

                                dataM.serializar(Materias);
                                Console.WriteLine(" El ID de la materia es: {0} \n", id_materia);
                                Console.ReadKey();
                            }
                            catch (ArgumentOutOfRangeException)
                            {
                                Console.WriteLine("Usted no ha ingresado un area o materia \n");
                                goto MenuMaterias;
                            }

                            goto MenuMaterias;
                        }

                        case 2:

                        {
                            Console.Clear();
                            if (Materias.Count > 0)
                            {
                                Console.WriteLine("               LISTA DE MATERIAS          ");
                                Console.WriteLine("   Codigo    |            Nombre           |   Area   |");
                                Console.WriteLine("------------------------------------------------------");
                                for (int i = 0; i < Materias.Count; i++)
                                {
                                    Materias[i].ListarMaterias(i + 3);
                                }
                                Console.ReadKey();
                                Console.Clear();
                            }
                            else
                            {
                                Console.WriteLine("No hay materias registradas!");
                                Console.ReadKey();
                                Console.Clear();
                            }
                            goto MenuMaterias;
                        }

                        case 3:

                        {
                            Console.Clear();
                            Console.Write("Ingrese el ID de la materia : ");
                            int id_Borrar = Convert.ToInt32(Console.ReadLine());


                            try
                            {
                                foreach (Materia a in Materias)
                                {
                                    if (a.ID == id_Borrar)
                                    {
                                        Materias.Remove(a);
                                        dataM.serializar(Materias);
                                        Console.WriteLine("\nSe elimino la materia satisfactoriamente\n");
                                        Console.ReadKey();
                                        goto MenuMaterias;
                                    }
                                }
                                Console.WriteLine("\nNo se ha encontrado resultados !!\n");
                                Console.ReadKey();
                                goto MenuMaterias;
                            }
                            catch (System.InvalidOperationException)
                            {
                                Console.WriteLine("\nNo hay materias con ese ID \n");
                                goto MenuMaterias;
                            }
                        }



                        case 4:
                        {
                            Console.Clear();
                            int idEditar = 0, campo;
                            Console.WriteLine("Ingrese el id a modificar: \n");
                            idEditar = Convert.ToInt32(Console.ReadLine());
                            Console.Clear();
                            foreach (Materia A in Materias)
                            {
                                if (A.ID == idEditar)
                                {
                                    Console.WriteLine("Campos a Modificar");
                                    Console.WriteLine("1. Nombre");
                                    Console.WriteLine("2. Area");


                                    Console.Write("\nQue campo quiere editar?  ");
                                    campo = Convert.ToInt32(Console.ReadLine());


                                    switch (campo)
                                    {
                                    case 1:
                                        Console.Clear();
                                        {
                                            string nombrematerianuevo;
                                            Console.Write("Digite el nuevo nombre: ");
                                            nombrematerianuevo = Console.ReadLine().ToUpper();
                                            A.Nombre           = nombrematerianuevo;
                                            dataM.serializar(Materias);
                                            Console.WriteLine("\nSe ha editado el nombre de la materia satisfactoriamente");
                                            Console.ReadKey();
                                            Console.Clear();
                                            goto MenuMaterias;
                                        }

                                    case 2:
                                        Console.Clear();
                                        {
                                            string areanueva;
                                            Console.Write("\nDigite la nueva area: ");
                                            areanueva = Console.ReadLine().ToUpper();
                                            A.Area    = areanueva;
                                            dataM.serializar(Materias);
                                            Console.WriteLine("\nSe ha editado el area de la materia satisfactoriamente");
                                            Console.ReadKey();
                                            Console.Clear();
                                            goto MenuMaterias;
                                        }
                                    }
                                }
                            }
                            Console.WriteLine("\n No encontramos resultados!\n");
                            Console.ReadKey();
                            Console.Clear();

                            goto MenuMaterias;
                        }

                        case 5:
                        {
                            Console.Clear();
                            Console.WriteLine("Nombre o area a buscar: ");
                            string Buscarmateria = (Console.ReadLine().ToUpper());

                            foreach (Materia b in Materias)
                            {
                                if (b.Nombre == Buscarmateria || b.Area == Buscarmateria)
                                {
                                    Console.WriteLine("------------------------");
                                    Console.WriteLine("ID: " + b.ID);
                                    Console.WriteLine("Nombre: " + b.Nombre);
                                    Console.WriteLine("Area: " + b.Area);
                                    Console.WriteLine("Codigo: " + b.Codigo);
                                    Console.ReadKey();
                                    Console.Clear();
                                    goto MenuMaterias;
                                }
                            }
                            Console.WriteLine("\n No se encontro ningun resultado \n");
                            Console.ReadKey();
                            Console.Clear();
                            goto MenuMaterias;
                        }

                        case 6:
                        {
                            break;
                        }

                        default:
                            goto MenuMaterias;
                        }
                        break;
                    }

                    case 3:
                    {
                        Console.WriteLine("\nGracias por utilizar el sistema de registro!");
                        Console.ReadKey();
                        Environment.Exit(0);
                        break;
                    }

                    default:
                        Console.WriteLine("\nIngrese una de las opciones validas...");
                        Console.ReadKey();
                        goto MenuPrincipal;
                    }
                }
                catch (FormatException)
                {
                    Console.WriteLine("Por favor, ingrese una de las opciones validas");
                    Console.ReadKey();
                    goto MenuPrincipal;
                }
            }
        }
Пример #6
0
 public void Initialize()
 {
     materia = new Materia();
 }
Пример #7
0
 private void mnuLogout_Click(object sender, EventArgs e)
 {
     SCMS.CleanUp(); SCMS.CurrentSystemUser.LogOut(); Close();
     SCMS.CurrentSystemUser = null; Materia.RefreshAndManageCurrentProcess();
 }
Пример #8
0
        public List <Materia> ListarMaterias(string colunas, string tabela, string condicao)
        {
            List <Materia> materias = new List <Materia>();

            NpgsqlConnection conexao = null;

            try
            {
                conexao = ConectaDB.getConexao();
                string sql = condicao == null
                    ? $"SELECT {colunas} FROM {tabela}"
                    : $"SELECT {colunas} FROM {tabela} WHERE {condicao}";
                NpgsqlCommand    cmd = new NpgsqlCommand(sql, conexao);
                NpgsqlDataReader dr  = cmd.ExecuteReader();

                // Para cada 'Materia' ("linha" do DB pelo dr.Read()), atribui
                // os valores das colunas 'ler' contidos em 'dr'
                string[] ler = colunas.Split(new string[] { ", " }, StringSplitOptions.None); // Resgata as colunas
                while (dr.Read())                                                             // Cada loop é uma linha encontrada
                {
                    Materia materia = new Materia();
                    for (int i = 0; i < ler.Length; i++) // Para cada "coluna"
                    {
                        switch (ler[i])                  // Descobre qual é a coluna e atribui ao atributo
                        {
                        case "materias.curso":
                        case "curso":
                            materia.Curso = dr["curso"].ToString();
                            break;

                        case "materias.sigla":
                        case "sigla":
                            materia.Sigla = dr["sigla"].ToString();
                            break;

                        case "materias.nome":
                        case "nome":
                            materia.Nome = dr["nome"].ToString();
                            break;

                        case "lecionador_id":
                            materia.Lecionador = dr["lecionador_id"] is DBNull ? -1 : Convert.ToInt16(dr["lecionador_id"]);
                            break;

                        case "notas":
                            materia.Notas = dr["notas"] is DBNull ? new string[0] : (string[])dr["notas"];
                            break;

                        case "pesos":
                            materia.Pesos = dr["pesos"] is DBNull ? new float[0] : (float[])dr["pesos"];
                            break;

                        case "estudantes_id":
                            materia.Estudantes = dr["estudantes_id"] is DBNull ? new int[0] : (int[])dr["estudantes_id"];
                            break;

                        case "*":
                            materia.Curso = dr["curso"].ToString();
                            materia.Sigla = dr["sigla"].ToString();
                            materia.Nome  = dr["nome"].ToString();
                            // Checagem para não tentar converter DBNull em algo
                            materia.Lecionador = dr["lecionador_id"] is DBNull ? -1 : Convert.ToInt16(dr["lecionador_id"]);
                            materia.Notas      = dr["notas"] is DBNull ? new string[0] : (string[])dr["notas"];
                            materia.Pesos      = dr["pesos"] is DBNull ? new float[0] : (float[])dr["pesos"];
                            materia.Estudantes = dr["estudantes_id"] is DBNull ? new int[0] : (int[])dr["estudantes_id"];
                            break;
                        }
                    }
                    materias.Add(materia);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + "\n\nColunas: \"" + colunas + "\"\nTabela: \"" + tabela + "\"\nCondicao: \"" + condicao + "\"");
            }
            finally
            {
                if (conexao != null)
                {
                    conexao.Close();
                }
            }

            return(materias);
        }
        private void BotaoExcluir_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Tem certeza que deseja excluir este registro?", "Aviso", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {

                try
                {
                    //Tenta deletar o registro
                    using (var context = new Proxy.SistemaHorariosServiceClient())
                    {
                        var item = new Materia() { Codigo = Convert.ToInt16(TextBoxCodigo.Text) };
                        context.DeleteMateria(item);
                    }

                    MessageBox.Show("Registro deletado com sucesso! =)");

                    AtualizarLista();

                    //Seta o modo da tela para o modo standard
                    mudarModo(ModoDeTela.Cancelar);
                }
                catch (Exception)
                {
                    MessageBox.Show("Erro ao deletar o registro");
                }
            }
        }
Пример #10
0
 public void Editar(Materia materia)
 {
     Db.Update(_sqlUpdate, Take2(materia));
 }
Пример #11
0
 public float Media(Materia materia)
 {
     float sum = 0;
     int dim = 0;
     for (var i = 0; i < _dimensione; i++)
     {
         if (_voti[i].Materia == materia)
         {
             sum += _voti[i].Valore;
             dim++;
         }
     }
     return dim == 0 ? 0 : sum / dim;
 }
Пример #12
0
        public List <Materia> GetByNome(Materia materia)
        {
            //Dictionary<string, object> parms = new Dictionary<string, object> { { "NomeMateria", nome } };

            return(Db.GetAll(_sqlSelectNome, Make, Take2(materia)));
        }
Пример #13
0
 public Materia Adicionar(Materia materia)
 {
     materia.Id = Db.Insert(_sqlInsert, Take2(materia));
     return(materia);
 }
        public Materia CrearMateria(Materia materia)
        {
            MateriasParaCrear.Add(materia);

            return(materia);
        }
        public Materia ActualizarMateria(Materia materiaActualizada)
        {
            MateriasParaActualizar.Add(materiaActualizada);

            return(materiaActualizada);
        }
Пример #16
0
 public void Save(Materia mat)
 {
     MateriaData.Save(mat);
 }
Пример #17
0
        public int ModificarMateria(Materia materia)
        {
            materia.v_TipoEvento = "M";
            DatosSistema datos = new DatosSistema();
            string[] parametros = { "@v_nombre",
                                    "@v_clave",
                                    "@v_descripcion",
                                    "@v_Dfacultad",
                                    "@v_estado",
                                    "@v_usuarioM",
                                    "@v_TipoEvento"};

            return datos.Ejecutar("proModificarMateria", parametros,
                                   materia.v_nombre,
                                   materia.v_clave,
                                   materia.v_descripcion,
                                   materia.v_Dfacultad,
                                   materia.v_estado,
                                   materia.v_usuario_m,
                                   materia.v_TipoEvento);
        }
        public void InsertarRegistro(Materia materia)
        {
            SqlConnection connectionEpsSql = Conexion.GetConexionSql();
            SqlDataAdapter dataAdapter = null;

            DataSet dataSet = new DataSet();
            DataRow dr;

            try
            {
                string sqlCadena = "SELECT * FROM cMateriasSGA WHERE id = 0";

                dataAdapter = new SqlDataAdapter();
                dataAdapter.SelectCommand = new SqlCommand(sqlCadena, connectionEpsSql);

                dataAdapter.Fill(dataSet, "Materias");

                dr = dataSet.Tables["Materias"].NewRow();
                dr["Id"] = materia.MateriaInt;
                dr["Nivel"] = materia.Nivel;
                dr["Padre"] = materia.Padre;
                dr["Descripcion"] = materia.Descripcion;
                dr["SeccionPadre"] = materia.SeccionPadre;
                dr["Historica"] = materia.Historica;
                dr["Consec"] = materia.Consec;
                dr["Hoja"] = materia.Hoja;
                dr["NvlImpresion"] = materia.NvlImpresion;

                dataSet.Tables["Materias"].Rows.Add(dr);

                dataAdapter.InsertCommand = connectionEpsSql.CreateCommand();
                dataAdapter.InsertCommand.CommandText = "INSERT INTO cMateriasSGA(Id,Nivel,Padre,Descripcion,SeccionPadre,Historica,Consec,Hoja,NvlImpresion)" +
                                                        " VALUES(@Id,@Nivel,@Padre,@Descripcion,@SeccionPadre,@Historica,@Consec,@Hoja,@NvlImpresion)";

                dataAdapter.InsertCommand.Parameters.Add("@Id", SqlDbType.BigInt, 0, "Id");
                dataAdapter.InsertCommand.Parameters.Add("@Nivel", SqlDbType.Int, 0, "Nivel");
                dataAdapter.InsertCommand.Parameters.Add("@Padre", SqlDbType.Int, 0, "Padre");
                dataAdapter.InsertCommand.Parameters.Add("@Descripcion", SqlDbType.VarChar, 0, "Descripcion");
                dataAdapter.InsertCommand.Parameters.Add("@SeccionPadre", SqlDbType.Int, 0, "SeccionPadre");
                dataAdapter.InsertCommand.Parameters.Add("@Historica", SqlDbType.Int, 0, "Historica");
                dataAdapter.InsertCommand.Parameters.Add("@Consec", SqlDbType.Int, 0, "Consec");
                dataAdapter.InsertCommand.Parameters.Add("@Hoja", SqlDbType.Int, 0, "Hoja");
                dataAdapter.InsertCommand.Parameters.Add("@NvlImpresion", SqlDbType.Int, 0, "NvlImpresion");

                dataAdapter.Update(dataSet, "Materias");
            }
            catch (SqlException) { }
            finally
            {
                dataSet.Dispose();
                dataAdapter.Dispose();
                connectionEpsSql.Close();
            }
        }
Пример #19
0
        private List <Professor> SelecionarProfessoresDosColegiosPorMateriaUtilizandoForEach(Materia materia)
        {
            List <Professor> professores = new List <Professor>();

            foreach (Colegio colegio in colegios)
            {
                foreach (Professor professor in FiltrarProfessoresQueConhecemMateria(colegio.Professores, materia))
                {
                    professores.Add(professor);
                }
            }

            return(professores);
        }
Пример #20
0
 private void SaveEntity(Materia mat)
 {
     this.Logic.Save(mat);
 }
Пример #21
0
 public Voti InserisciVoto(Materia materia, TipoVoto tipo, float voto, DateTime dataora)
 {
     if (_dimensione <= DimensioneMassima)
     {
         _voti[_dimensione] = new Voto(materia, tipo, voto, dataora);
         _dimensione++;
         return this;
     }
     return null;
 }
Пример #22
0
        private List <Professor> SelecionarProfessoresDosColegiosPorMateriaUtilizandoSelectMany(Materia materia)
        {
            List <Professor> professoresQueConhecemAMateria = colegios.SelectMany(colegio => FiltrarProfessoresQueConhecemMateria(colegio.Professores, materia)).ToList();

            return(professoresQueConhecemAMateria);
        }
        public ObservableCollection<Materia> GetMateriasForReport(int idPadre)
        {
            ObservableCollection<Materia> materiasSga = new ObservableCollection<Materia>();

            string sql = @"select * from cMateriasSGA WHERE Padre = @IdPadre Order by consec";
            SqlConnection conn = Conexion.GetConexionSql();
            SqlCommand cmd;
            SqlDataReader reader;

            try
            {
                conn.Open();

                cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@IdPadre", idPadre);

                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Materia materia = new Materia();

                    materia.MateriaInt = Convert.ToInt32(reader["ID"]);
                    materia.Descripcion = reader["Descripcion"].ToString();
                    materia.MateriasHijas = this.GetMateriasForReport(materia.MateriaInt);

                    materiasSga.Add(materia);
                }

            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e);
            }
            finally
            {
                conn.Close();
            }
            return materiasSga;
        }
Пример #24
0
        private List <string> SelecionarNomeDosProfessoresDosColegiosPorMateriaUtilizandoSelectMany(Materia materia)
        {
            List <string> nomesProfessoresQueConhecemAMateria = colegios.SelectMany(colegio => FiltrarProfessoresQueConhecemMateria(colegio.Professores, materia),
                                                                                    (professores, professor) => professor.Nome).ToList();

            return(nomesProfessoresQueConhecemAMateria);
        }
Пример #25
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!btnDelete.Enabled)
            {
                return;
            }
            if (!grdStockAdjustments.Redraw)
            {
                return;
            }
            if (grdStockAdjustments.DataSource == null)
            {
                return;
            }
            if (grdStockAdjustments.RowSel < grdStockAdjustments.Rows.Fixed)
            {
                return;
            }
            if (Materia.IsNullOrNothing(grdStockAdjustments[grdStockAdjustments.RowSel, "ReferenceNo"]))
            {
                return;
            }

            string    _referenceno      = grdStockAdjustments[grdStockAdjustments.RowSel, "ReferenceNo"].ToString();
            DataTable _stockadjustments = Cache.GetCachedTable("stockadjustments");

            if (_stockadjustments != null)
            {
                DataRow[] _rows = _stockadjustments.Select("[ReferenceNo] LIKE '" + _referenceno.ToSqlValidString(true) + "'");
                if (_rows.Length > 0)
                {
                    DataRow _row = _rows[0];
                    if (VisualBasic.IsNumeric(_row["Closed"]))
                    {
                        if (VisualBasic.CBool(_row["Closed"]))
                        {
                            MsgBoxEx.Shout("Cannot delete stock adjustment : <font color=\"blue\">" + _referenceno + "</font> because it is already marked as final.", "Delete Stock Adjustment");
                            return;
                        }
                    }

                    if (MsgBoxEx.Ask("Delete stock adjustment <font color=\"blue\">" + _referenceno + "</font> permanently from the list?", "Delete Stock Adjustments") != System.Windows.Forms.DialogResult.Yes)
                    {
                        return;
                    }

                    string       _query      = "DELETE FROM `stockadjustments` WHERE (`ReferenceNo` LIKE '" + _referenceno.ToSqlValidString(true) + "')";
                    IAsyncResult _execresult = Que.BeginExecution(SCMS.Connection, _query);

                    btnNew.Enabled     = false; btnEdit.Enabled = false; btnDelete.Enabled = false;
                    btnRefresh.Enabled = false; txtSearch.Enabled = false;

                    while (!_execresult.IsCompleted &&
                           !_cancelled)
                    {
                        Thread.Sleep(1); Application.DoEvents();
                    }

                    if (_cancelled)
                    {
                        if (!_execresult.IsCompleted)
                        {
                            try { _execresult = null; }
                            catch { }
                            finally { Materia.RefreshAndManageCurrentProcess(); }
                        }

                        return;
                    }
                    else
                    {
                        QueResult _result = Que.EndExecution(_execresult);
                        if (string.IsNullOrEmpty(_result.Error.RLTrim()))
                        {
                            _row.Delete(); _stockadjustments.AcceptChanges();

                            if (grdStockAdjustments.Redraw)
                            {
                                grdStockAdjustments.BeginUpdate();
                            }

                            DataTable _datasource = null;

                            try { _datasource = (DataTable)grdStockAdjustments.DataSource; }
                            catch { }

                            if (_datasource != null)
                            {
                                DataRow[] _currows = _datasource.Select("[ReferenceNo] LIKE '" + _referenceno.ToSqlValidString(true) + "'");
                                if (_currows.Length > 0)
                                {
                                    _currows[0].Delete();
                                }
                                _datasource.AcceptChanges();
                            }

                            FormatGrid(); ResizeGrid();

                            Cursor = Cursors.WaitCursor;
                            IAsyncResult _logresult = SCMS.CurrentSystemUser.LogActionAsync(UserAction.Delete, "Deletes stock adjustment : " + _referenceno + ".", _referenceno);
                            _logresult.WaitToFinish(); Cursor = Cursors.Default;

                            while (!grdStockAdjustments.Redraw)
                            {
                                grdStockAdjustments.EndUpdate();
                            }
                        }
                        else
                        {
                            SCMS.LogError(this.GetType().Name, new Exception(_result.Error));
                            MsgBoxEx.Alert("Failed to delete the specified stock adjustment.", "Delete Stock Adjustment");
                        }

                        _result.Dispose(); EnableButtons(); DisplayInfo();
                    }
                }
            }
        }
Пример #26
0
 private List <Professor> FiltrarProfessoresQueConhecemMateria(List <Professor> professores, Materia materia)
 {
     return(professores.Where(prof => prof.MateriasConhecidas.Contains(materia)).ToList());
 }
Пример #27
0
        private void InitializeModules(ModuleGroup modules)
        {
            string    _path  = Application.StartupPath + "\\Xml\\modules.xml";
            DataTable _table = SCMS.XmlToTable(_path);

            if (_table != null)
            {
                DataRow[] _rows = _table.Select("[Group] = " + VisualBasic.CInt(modules).ToString(), "[Order]");
                if (_rows != null)
                {
                    if (_rows.Length > 0)
                    {
                        brModules.Items.Clear();

                        for (int i = 0; i <= (_rows.Length - 1); i++)
                        {
                            DataRow _row        = _rows[i];
                            Image   _image      = (Image)Properties.Resources.Brick.Clone();
                            bool    _begingroup = VisualBasic.CBool(brModules.Items.Count > 0);

                            ButtonItem _button = new ButtonItem("btnModule" + _row["Id"].ToString(), _row["Text"].ToString());
                            _button.ButtonStyle = eButtonStyle.ImageAndText;
                            if (_moduleimages.Images.ContainsKey(_row["ImageKey"].ToString()))
                            {
                                _image = _moduleimages.Images[_row["ImageKey"].ToString()];
                            }
                            _button.Image         = _image; _button.ImageFixedSize = new Size(32, 32);
                            _button.ImagePosition = eImagePosition.Top;
                            _button.Tag           = _row["Id"]; _button.FixedSize = new Size(120, 75);
                            _button.BeginGroup    = _begingroup; _button.Cursor = Cursors.Hand;
                            _button.Click        += new EventHandler(_button_Click);
                            brModules.Items.Add(_button);
                        }

                        _selectedmodulegroup = modules;
                    }
                }

                _table.Dispose(); _table = null;
                Materia.RefreshAndManageCurrentProcess();
            }

            ButtonItem _modulebutton      = null;
            Image      _modulebuttonimage = (Image)Properties.Resources.Brick.Clone();

            switch (modules)
            {
            case ModuleGroup.Operations:
                _modulebutton = new ButtonItem("btnFinance", "Finance");
                if (_moduleimages.Images.ContainsKey("Finance"))
                {
                    _modulebuttonimage = _moduleimages.Images["Finance"];
                }
                _modulebutton.Image = _modulebuttonimage;
                _modulebutton.Tag   = ModuleGroup.Finance;
                break;

            case ModuleGroup.Finance:
                _modulebutton = new ButtonItem("btnOperations", "Operations");
                if (_moduleimages.Images.ContainsKey("Operations"))
                {
                    _modulebuttonimage = _moduleimages.Images["Operations"];
                }
                _modulebutton.Image = _modulebuttonimage;
                _modulebutton.Tag   = ModuleGroup.Operations;
                break;

            default: break;
            }

            if (_modulebutton != null)
            {
                _modulebutton.ButtonStyle    = eButtonStyle.ImageAndText;
                _modulebutton.ImageFixedSize = new Size(32, 32);
                _modulebutton.FixedSize      = new Size(120, 75);
                _modulebutton.ImagePosition  = eImagePosition.Top;
                bool _begingroup = VisualBasic.CBool(brModules.Items.Count > 0);
                _modulebutton.BeginGroup = _begingroup;
                _modulebutton.Click     += new EventHandler(_button_Click);
                _modulebutton.Cursor     = Cursors.Hand;
                brModules.Items.Add(_modulebutton);
            }

            brModules.RecalcSize();
            brModules.Refresh(); brModules.Update();

            Materia.RefreshAndManageCurrentProcess();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!btnSave.Enabled)
            {
                return;
            }

            Validator _validator = SCMS.Validators[this];

            if (!Materia.Valid(_validator, txtPaymentTerm, !string.IsNullOrEmpty(txtPaymentTerm.Text.RLTrim()), "Please specify payment term."))
            {
                return;
            }
            if (!Materia.Valid(_validator, cboTerms, cboTerms.SelectedIndex >= 0, "Please specify term."))
            {
                return;
            }

            DataTable _paymentterms = Cache.GetCachedTable("paymentterms");

            if (_paymentterms != null)
            {
                DataRow[] _rows = _paymentterms.Select("([PaymentTerm] LIKE '" + txtPaymentTerm.Text.ToSqlValidString(true) + "') AND\n" +
                                                       "NOT ([PaymentTerm] LIKE '" + _paymentterm.ToSqlValidString(true) + "')");

                if (!Materia.Valid(_validator, txtPaymentTerm, _rows.Length <= 0, "Payment term already exists."))
                {
                    return;
                }

                string _query = "";
                DataColumnCollection _cols = _paymentterms.Columns;

                if (_isnew)
                {
                    _query = "INSERT INTO `paymentterms`\n" +
                             "(`PaymentTerm`, `Description`, `Term`, `Days`, `Months`, `DateCreated`)\n" +
                             "VALUES\n" +
                             "('" + txtPaymentTerm.Text.ToSqlValidString() + "', '" + txtDescription.Text.ToSqlValidString(true) + "', '" + cboTerms.SelectedValue.ToString().ToSqlValidString(true) + "', " + txtDays.Value.ToString() + ", " + txtMonths.Value.ToString() + ", NOW());";

                    object[] _values = new object[_cols.Count];
                    _values[_cols["PaymentTerm"].Ordinal]  = txtPaymentTerm.Text;
                    _values[_cols["Description"].Ordinal]  = txtDescription.Text;
                    _values[_cols["Term"].Ordinal]         = cboTerms.SelectedValue;
                    _values[_cols["Days"].Ordinal]         = txtDays.Value;
                    _values[_cols["Months"].Ordinal]       = txtMonths.Value;
                    _values[_cols["DateCreated"].Ordinal]  = DateTime.Now;
                    _values[_cols["LastModified"].Ordinal] = DateTime.Now;
                    _paymentterms.Rows.Add(_values);
                }
                else
                {
                    _query = "UPDATE `paymentterms` SET\n" +
                             "`PaymentTerm` = '" + txtPaymentTerm.Text.ToSqlValidString() + "', `Description` = '" + txtDescription.Text.ToSqlValidString() + "', `Term` = '" + cboTerms.SelectedValue.ToString().ToSqlValidString() + "', `Days` = " + txtDays.Value.ToString() + ", `Months` = " + txtMonths.Value.ToString() + "\n" +
                             "WHERE\n" +
                             "(`PaymentTerm` LIKE '" + _paymentterm.ToSqlValidString() + "');";

                    DataRow[] _existing = _paymentterms.Select("[PaymentTerm] LIKE '" + _paymentterm.ToSqlValidString(true) + "'");
                    if (_existing.Length > 0)
                    {
                        _existing[0]["PaymentTerm"] = txtPaymentTerm.Text;
                        _existing[0]["Description"] = txtDescription.Text;
                        _existing[0]["Term"]        = cboTerms.SelectedValue;
                        _existing[0]["Days"]        = txtDays.Value;
                        _existing[0]["Months"]      = txtMonths.Value;
                    }
                }

                if (!string.IsNullOrEmpty(_query.RLTrim()))
                {
                    btnSave.Enabled = false; btnSaveAndClose.Enabled = false;

                    IAsyncResult _result = Que.BeginExecution(SCMS.Connection, _query);

                    while (!_result.IsCompleted &&
                           !_cancelled)
                    {
                        Thread.Sleep(1); Application.DoEvents();
                    }

                    if (_cancelled)
                    {
                        if (!_result.IsCompleted)
                        {
                            try { _result = null; }
                            catch { }
                            finally { Materia.RefreshAndManageCurrentProcess(); }
                        }

                        return;
                    }
                    else
                    {
                        QueResult _queresult = Que.EndExecution(_result);

                        if (string.IsNullOrEmpty(_queresult.Error.RLTrim()))
                        {
                            UserAction _action = UserAction.Add;
                            if (!_isnew)
                            {
                                _action = UserAction.Edit;
                            }

                            string _log = "Added a new payment term : " + txtPaymentTerm.Text + ".";
                            if (!_isnew)
                            {
                                _log = "Updated payment term : " + _paymentterm + (_paymentterm != txtPaymentTerm.Text ? " to " + txtPaymentTerm.Text : "").ToString() + ".";
                            }

                            _paymentterms.AcceptChanges(); _paymentterm = txtPaymentTerm.Text;
                            if (_isnew)
                            {
                                _isnew = false;
                            }
                            if (_updated)
                            {
                                _updated = false;
                            }
                            if (!_withupdates)
                            {
                                _withupdates = true;
                            }
                            Text   = Text.Replace(" *", "").Replace("*", "");
                            Cursor = Cursors.WaitCursor;

                            IAsyncResult _logresult = SCMS.CurrentSystemUser.LogActionAsync(_action, _log);
                            _logresult.WaitToFinish();

                            Cursor = Cursors.Default;

                            if (sender == btnSaveAndClose)
                            {
                                DialogResult = System.Windows.Forms.DialogResult.OK; Close();
                            }
                        }
                        else
                        {
                            if (_queresult.Error.Contains("duplicate"))
                            {
                                bool _invalid = Materia.Valid(_validator, txtPaymentTerm, false, "Payment term already exists.");
                            }
                            else
                            {
                                SCMS.LogError(this.GetType().Name, new Exception(_queresult.Error));
                                MsgBoxEx.Alert("Failed to save the current payment term.", "Save Payment Term");
                            }

                            _paymentterms.RejectChanges();
                        }

                        _queresult.Dispose();
                    }

                    btnSave.Enabled = true; btnSaveAndClose.Enabled = true;
                }
            }
            else
            {
                if (sender == btnSaveAndClose)
                {
                    DialogResult = System.Windows.Forms.DialogResult.None; Close();
                }
            }
        }
Пример #29
0
        private void mnuPickList_Click(object sender, EventArgs e)
        {
            if (sender == null)
            {
                return;
            }
            if (sender.GetType() != typeof(ButtonItem))
            {
                return;
            }
            ButtonItem mnuButton = (ButtonItem)sender;

            if (!mnuButton.Enabled)
            {
                return;
            }

            PickList _list = PickList.None;

            if (mnuButton.Name == mnuDepartments.Name)
            {
                _list = PickList.Departments;
            }
            else if (mnuButton.Name == mnuPositions.Name)
            {
                _list = PickList.Positions;
            }
            else if (mnuButton.Name == mnuAdditionalCharges.Name)
            {
                _list = PickList.AdditionalCharges;
            }
            else if (mnuButton.Name == mnuBankingCompanies.Name)
            {
                _list = PickList.Bank;
            }
            else if (mnuButton.Name == mnuBankMisc.Name)
            {
                _list = PickList.BankMiscellaneous;
            }
            else if (mnuButton.Name == mnuBrands.Name)
            {
                _list = PickList.Brands;
            }
            else if (mnuButton.Name == mnuCurrencies.Name)
            {
                _list = PickList.Currencies;
            }
            else if (mnuButton.Name == mnuCurrencyDenominations.Name)
            {
                _list = PickList.CurrencyDenominations;
            }
            else if (mnuButton.Name == mnuCustomerGroups.Name)
            {
                _list = PickList.CustomerGroups;
            }
            else if (mnuButton.Name == mnuPaymentTerms.Name)
            {
                _list = PickList.PaymentTerms;
            }
            else if (mnuButton.Name == mnuSignatories.Name)
            {
                _list = PickList.Signatories;
            }
            else if (mnuButton.Name == mnuLocations.Name)
            {
                _list = PickList.Locations;
            }
            else if (mnuButton.Name == mnuMeasurements.Name)
            {
                _list = PickList.Measurements;
            }
            else if (mnuButton.Name == mnuModels.Name)
            {
                _list = PickList.Models;
            }
            else if (mnuButton.Name == mnuPartNames.Name)
            {
                _list = PickList.PartNames;
            }
            else if (mnuButton.Name == mnuPartsCategory.Name)
            {
                _list = PickList.PartCategories;
            }
            else
            {
            }

            if (_list != PickList.None)
            {
                PickListDialog _dialog = new PickListDialog(_list);
                _dialog.ShowDialog(); _dialog.Dispose(); _dialog = null;
                Materia.RefreshAndManageCurrentProcess();
            }
        }
Пример #30
0
 public Materia(Materia M)
 {
     setParams(M);
 }
Пример #31
0
 public void Save(Materia mat)
 {
     materiaDatos.Save(mat);
 }
Пример #32
0
 public void setParams(Materia M)
 {
     _idBanco = M._idBanco;
     _nome = M._nome;
     _nomeProfessor = M._nomeProfessor;
 }
Пример #33
0
 /// <summary>
 /// Se invoca para guardar a la entidad
 /// </summary>
 /// <param name="materia"></param>
 public void SaveEntity(Materia materia)
 {
     Logic.Save(materia);
 }
Пример #34
0
        /// <summary>
        /// Perform file / directory compression.
        /// </summary>
        /// <returns></returns>
        public FileInfo Archive()
        {
            FileInfo _file = null; bool _pathexists = false; _archivedpath = "";

            if (System.IO.Path.HasExtension(_path))
            {
                _pathexists = File.Exists(_path);
            }
            else
            {
                _pathexists = Directory.Exists(_path);
            }

            if (_pathexists)
            {
                //ExtractResourceApplications();

                switch (_archivingtool)
                {
                case ArchivingToolEnum.SevenZip:
                    if (File.Exists(Application.StartupPath + "\\7z.exe"))
                    {
                        string _compressfilename = System.IO.Path.GetFileNameWithoutExtension(_path) + ".7z";
                        string _compressdir      = System.IO.Path.GetDirectoryName(_path);
                        string _compressfile     = _compressdir + (_compressdir.RLTrim().EndsWith("\\") ? "" : "\\") + _compressfilename;

                        if (File.Exists(_compressfile))
                        {
                            try { File.Delete(_compressfile); }
                            catch { }
                        }

                        string   _batfilename     = Application.StartupPath + "\\archiver.bat";
                        string   _batfilecontents = "7z a \"" + _compressfile + "\" \"" + _path + "\"";
                        FileInfo _batfile         = Materia.WriteToFile(_batfilename, _batfilecontents);
                        string   _error           = "";

                        if (_batfile != null)
                        {
                            Process _process = new Process();
                            _process.StartInfo.FileName              = _batfilename;
                            _process.StartInfo.CreateNoWindow        = VisualBasic.CBool(_processwindowstyle == ProcessWindowStyle.Hidden);
                            _process.StartInfo.WindowStyle           = _processwindowstyle;
                            _process.StartInfo.UseShellExecute       = false;
                            _process.StartInfo.RedirectStandardError = true;
                            _process.Start();

                            while (!_process.HasExited)
                            {
                                Application.DoEvents();
                            }

                            if (_process.StandardError != null)
                            {
                                try { _error = _process.StandardError.ReadToEnd(); }
                                catch { _error = ""; }
                            }
                            else
                            {
                                _error = "";
                            }

                            _process.Dispose(); Materia.RefreshAndManageCurrentProcess();

                            try { _batfile.Delete(); }
                            catch { }
                        }
                        else
                        {
                            _error = "Can't create executable archive batch file.";
                        }

                        _error = _error.Replace("\nThe handle is invalid.", "").Replace("The handle is invalid.", "");
                        if (!String.IsNullOrEmpty(_error.RLTrim()))
                        {
                            Materia.LogError(_error, "7Zip Archiving Error");
                        }

                        if (File.Exists(_compressfile))
                        {
                            _archivedpath = _compressfile;

                            if (_archivingmethod == ArchivingMethodEnum.Insert)
                            {
                                try
                                {
                                    for (int i = 0; i <= 30; i++)
                                    {
                                        Thread.Sleep(10); Application.DoEvents();
                                    }

                                    if (System.IO.Path.HasExtension(_path))
                                    {
                                        File.Delete(_path);
                                    }
                                    else
                                    {
                                        Directory.Delete(_path, true);
                                    }
                                }
                                catch { }
                            }

                            //RemoveResourceApplications();
                            _file = new FileInfo(_archivedpath);
                        }
                    }
                    break;

                case ArchivingToolEnum.WinRar:
                    if (File.Exists(Application.StartupPath + "\\WinRar.exe"))
                    {
                        string _compressfilename = System.IO.Path.GetFileNameWithoutExtension(_path) + ".rar";
                        string _compressdir      = System.IO.Path.GetDirectoryName(_path);
                        string _compressfile     = _compressdir + (_compressdir.RLTrim().EndsWith("\\") ? "" : "\\") + _compressfilename;

                        if (File.Exists(_compressfile))
                        {
                            try { File.Delete(_compressfile); }
                            catch { }
                        }

                        string   _batfilename     = Application.StartupPath + "\\archiver.bat";
                        string   _batfilecontents = "WinRar a -ep \"" + _compressfile + "\" \"" + _path + "\"";
                        FileInfo _batfile         = Materia.WriteToFile(_batfilename, _batfilecontents);
                        string   _error           = "";

                        if (_batfile != null)
                        {
                            Process _process = new Process();
                            _process.StartInfo.FileName              = _batfilename;
                            _process.StartInfo.CreateNoWindow        = VisualBasic.CBool(_processwindowstyle == ProcessWindowStyle.Hidden);
                            _process.StartInfo.WindowStyle           = _processwindowstyle;
                            _process.StartInfo.UseShellExecute       = false;
                            _process.StartInfo.RedirectStandardError = true;
                            _process.Start();

                            while (!_process.HasExited)
                            {
                                Application.DoEvents();
                            }

                            if (_process.StandardError != null)
                            {
                                try { _error = _process.StandardError.ReadToEnd(); }
                                catch { _error = ""; }
                            }
                            else
                            {
                                _error = "";
                            }

                            _process.Dispose(); Materia.RefreshAndManageCurrentProcess();

                            try { _batfile.Delete(); }
                            catch { }
                        }
                        else
                        {
                            _error = "Can't create executable archive batch file.";
                        }

                        _error = _error.Replace("\nThe handle is invalid.", "").Replace("The handle is invalid.", "");
                        if (!String.IsNullOrEmpty(_error.RLTrim()))
                        {
                            Materia.LogError(_error, "WinRar Archiving Error");
                        }

                        if (File.Exists(_compressfile))
                        {
                            _archivedpath = _compressfile;

                            if (_archivingmethod == ArchivingMethodEnum.Insert)
                            {
                                try
                                {
                                    for (int i = 0; i <= 30; i++)
                                    {
                                        Thread.Sleep(10); Application.DoEvents();
                                    }

                                    if (System.IO.Path.HasExtension(_path))
                                    {
                                        File.Delete(_path);
                                    }
                                    else
                                    {
                                        Directory.Delete(_path, true);
                                    }
                                }
                                catch { }
                            }

                            //RemoveResourceApplications();
                            _file = new FileInfo(_archivedpath);
                        }
                    }
                    break;

                default: break;
                }
            }

            return(_file);
        }
Пример #35
0
        public int EliminarMateria(Materia materia)
        {
            materia.v_TipoEvento = "E";
            DatosSistema datos = new DatosSistema();
            string[] parametros = { "@v_nombre",
                                    "@v_clave",
                                    "@v_usuarioM",
                                    "@v_TipoEvento"};

            return datos.Ejecutar("proEliminarMateria", parametros,
                                   materia.v_nombre,
                                   materia.v_clave,
                                   materia.v_usuario_m,
                                   materia.v_TipoEvento);
        }
Пример #36
0
        /// <summary>
        /// Performs archive extraction using the chosen archiving tool.
        /// </summary>
        /// <param name="destination">Destination path for the extracted file(s)</param>
        /// <returns></returns>
        public bool Extract(string destination)
        {
            bool _extracted = false; string _error = "";
            //ExtractResourceApplications();
            string _archiverfile = "";

            switch (_archivingtool)
            {
            case ArchivingToolEnum.SevenZip:
                _archiverfile = Application.StartupPath + "\\7z.exe";

                if (File.Exists(_archiverfile))
                {
                    Process _process = new Process();
                    _process.StartInfo.Arguments             = "e \"" + _path + "\" -o\"" + destination + "\" *.* -r";
                    _process.StartInfo.FileName              = _archiverfile;
                    _process.StartInfo.CreateNoWindow        = VisualBasic.CBool(_processwindowstyle == ProcessWindowStyle.Hidden);
                    _process.StartInfo.WindowStyle           = _processwindowstyle;
                    _process.StartInfo.RedirectStandardError = true;
                    _process.StartInfo.UseShellExecute       = false;
                    _process.Start();

                    while (!_process.HasExited)
                    {
                        Application.DoEvents();
                    }

                    if (_process.StandardError != null)
                    {
                        try { _error = _process.StandardError.ReadToEnd(); }
                        catch { _error = ""; }
                    }
                    else
                    {
                        _error = "";
                    }
                    _process.Dispose(); Materia.RefreshAndManageCurrentProcess();
                }
                break;

            case ArchivingToolEnum.WinRar:
                _archiverfile = Application.StartupPath + "\\WinRar.exe";

                if (File.Exists(_archiverfile))
                {
                    Process _process = new Process();
                    _process.StartInfo.Arguments             = "e \"" + _path + "\" *.* \"" + destination + "\"";
                    _process.StartInfo.FileName              = _archiverfile;
                    _process.StartInfo.CreateNoWindow        = VisualBasic.CBool(_processwindowstyle == ProcessWindowStyle.Hidden);
                    _process.StartInfo.WindowStyle           = _processwindowstyle;
                    _process.StartInfo.RedirectStandardError = true;
                    _process.StartInfo.UseShellExecute       = false;
                    _process.Start();

                    while (!_process.HasExited)
                    {
                        Application.DoEvents();
                    }

                    if (_process.StandardError != null)
                    {
                        try { _error = _process.StandardError.ReadToEnd(); }
                        catch { _error = ""; }
                    }
                    else
                    {
                        _error = "";
                    }
                    _process.Dispose(); Materia.RefreshAndManageCurrentProcess();
                }
                break;

            default: break;
            }

            _extracted = String.IsNullOrEmpty(_error.Replace("\nThe handle is invalid.", "").Replace("The handle is invalid.", "").RLTrim());
            if (!_extracted)
            {
                Materia.LogError(_error.Replace("\nThe handle is invalid.", "").Replace("The handle is invalid.", "").RLTrim(), Enum.GetName(typeof(ArchivingToolEnum), _archivingtool) + " File Extraction Error");
            }
            //RemoveResourceApplications();

            return(_extracted);
        }
Пример #37
0
        public Materia OptenerFacultad(Materia materia)
        {
            DatosSistema datos = new DatosSistema();
            materia.v_TipoEvento = "F";
            var dt = new DataTable();
            string[] parametros = { "@v_TipoEvento" };
            dt = datos.getDatosTabla("proDevolverDatos", parametros, materia.v_TipoEvento);
            foreach (DataRow fila in dt.Rows)
            {
                materia.v_facultad.Add(fila["facultad"].ToString());

            }
            return materia;
        }
Пример #38
0
 public int InsertarMateria(Materia pMateria)
 {
     return(materiaDAL.InsertarMateria(pMateria));
 }
Пример #39
0
 public Materia ConsultarMateria(Materia materia)
 {
     DatosSistema datos = new DatosSistema();
     materia.v_TipoEvento = "C";
     var dt = new DataTable();
     string[] parametros = { "@v_nombre", "@v_TipoEvento" };
     dt = datos.getDatosTabla("proConsultarMateria", parametros, materia.v_nombre, materia.v_TipoEvento);
     foreach (DataRow fila in dt.Rows)
     {
         materia.v_nombre = fila["nombre"].ToString();
         materia.v_clave= fila["clave"].ToString();
         materia.v_descripcion = fila["descripcion"].ToString();
         materia.v_Dfacultad = fila["facultad"].ToString();
     }
     return materia;
 }
Пример #40
0
 public int ModificarMateria(Materia pMateria)
 {
     return(materiaDAL.ModificarMateria(pMateria));
 }
Пример #41
0
 public Voto(Materia materia, TipoVoto tipo, float voto, DateTime data)
 {
     Valore = voto;
     Tipo = tipo;
     Data = data;
     Materia = materia;
 }
Пример #42
0
        public Materia Adicionar(Materia materia)
        {
            DB.Add(sqlInsertMateria, GetParam(materia));

            return(materia);
        }
Пример #43
0
 public Calificacion(Alumno Alumno, Materia Materia, decimal Valor)
 {
     this.Alumno = Alumno;
     this.Materia = Materia;
     this.Valor = Valor;
 }
Пример #44
0
        public Materia Atualizar(Materia materia)
        {
            DB.Update(sqlUpdateMateria, GetParam(materia));

            return(materia);
        }
        public void ActualizaRegistroMaterias(Materia materia)
        {
            SqlConnection sqlConne = Conexion.GetConexionSql();
            SqlDataAdapter dataAdapter;
            SqlCommand cmd;
            cmd = sqlConne.CreateCommand();
            cmd.Connection = sqlConne;

            try
            {
                sqlConne.Open();

                DataSet dataSet = new DataSet();
                DataRow dr;

                string sqlCadena = "SELECT * FROM cMateriasSGA WHERE id = " + materia.MateriaInt;

                dataAdapter = new SqlDataAdapter();
                dataAdapter.SelectCommand = new SqlCommand(sqlCadena, sqlConne);

                dataAdapter.Fill(dataSet, "Materia");

                dr = dataSet.Tables[0].Rows[0];
                dr.BeginEdit();
                dr["Id"] = materia.MateriaInt;
                dr["Nivel"] = materia.Nivel;
                dr["Padre"] = materia.Padre;
                dr["Descripcion"] = materia.Descripcion;
                dr["SeccionPadre"] = materia.SeccionPadre;
                dr["Historica"] = materia.Historica;
                dr["Consec"] = materia.Consec;
                dr["Hoja"] = materia.Hoja;
                dr["NvlImpresion"] = materia.NvlImpresion;

                dr.EndEdit();

                dataAdapter.UpdateCommand = sqlConne.CreateCommand();

                string sSql = "UPDATE cMateriasSGA " +
                              "SET Nivel = @Nivel, " +
                              " Padre = @Padre, Descripcion = @Descripcion, SeccionPadre = @SeccionPadre, Historica = @Historica," +
                              " Consec = @Consec, Hoja = @Hoja,NvlImpresion = @NvlImpresion" +
                              " WHERE Id = @Id";

                dataAdapter.UpdateCommand.CommandText = sSql;

                dataAdapter.UpdateCommand.Parameters.Add("@Nivel", SqlDbType.Int, 0, "Nivel");
                dataAdapter.UpdateCommand.Parameters.Add("@Padre", SqlDbType.Int, 0, "Padre");
                dataAdapter.UpdateCommand.Parameters.Add("@Descripcion", SqlDbType.VarChar, 0, "Descripcion");
                dataAdapter.UpdateCommand.Parameters.Add("@SeccionPadre", SqlDbType.Int, 0, "SeccionPadre");
                dataAdapter.UpdateCommand.Parameters.Add("@Historica", SqlDbType.Int, 0, "Historica");
                dataAdapter.UpdateCommand.Parameters.Add("@Consec", SqlDbType.Int, 0, "Consec");
                dataAdapter.UpdateCommand.Parameters.Add("@Hoja", SqlDbType.Int, 0, "Hoja");
                dataAdapter.UpdateCommand.Parameters.Add("@NvlImpresion", SqlDbType.Int, 0, "NvlImpresion");
                dataAdapter.UpdateCommand.Parameters.Add("@Id", SqlDbType.BigInt, 0, "Id");

                dataAdapter.Update(dataSet, "Materia");
                dataSet.Dispose();
                dataAdapter.Dispose();

            }
            catch (SqlException sql)
            {
                MessageBox.Show("Error ({0}) : {1}" + sql.Source + sql.Message, "Error Interno");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error ({0}) : {1}" + ex.Source + ex.Message, "Error Interno");
            }
            finally
            {
                sqlConne.Close();
            }
        }
Пример #46
0
 public void Update(Materia entidade)
 {
     Db.Update(_sqlUpdate, Take(entidade));
 }
Пример #47
0
        public Materia Add(Materia entidade)
        {
            entidade.ID = Db.Insert(_sqlInsert, Take(entidade));

            return(entidade);
        }
        private void BotaoConfirmar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Verifica o modo atual da tela
                switch (modo)
                {
                    case ModoDeTela.Novo:
                        using (var context = new Proxy.SistemaHorariosServiceClient())
                        {
                            var item = new Materia() { Nome = TextBoxNome.Text, 
                                                        Sigla = TextBoxSigla.Text };
                            context.AddMateria(item);
                        }
                        break;

                    case ModoDeTela.Editar:
                        using (var context = new Proxy.SistemaHorariosServiceClient())
                        {
                            var item = new Materia()
                            {
                                Codigo = Convert.ToInt16(TextBoxCodigo.Text),
                                Nome = TextBoxNome.Text,
                                Sigla = TextBoxSigla.Text
                            };
                            context.UpdateMateria(item);
                        }
                        break;

                    default:
                        MessageBox.Show("Modo de tela inválido!");
                        break;
                }

                MessageBox.Show("Registro atualizado/cadastrado com sucesso! =)");

                AtualizarLista();

                //Seta o modo da tela para o modo standard
                mudarModo(ModoDeTela.Cancelar);
            }
            catch (Exception)
            {
                MessageBox.Show("Erro ao criar/atualizar registro");
            }
        }