Пример #1
0
 public Registrar(Dictionary<string, string> carreras, string operacion, Dictionary<string, string> estudiante)
 {
     InitializeComponent();
     this.controller = new Controladores.Estudiante();
     this.usuario = new Controladores.Encargado();
     this.carreras = carreras;
     this.operacion = operacion;
     this.estudiante = estudiante != null ? new Modelos.Estudiante(estudiante["ID"], estudiante["ci"], estudiante["nombre"],
         estudiante["apellidoPaterno"], estudiante["apellidoMaterno"], estudiante["codigo"], estudiante["IDCarrera"],
         estudiante["telefono"], estudiante["direccion"]) : null;
 }
Пример #2
0
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            if (this.operacion == "actualizar")
            {
                this.estudiante.carrera = ((KeyValuePair<string, string>)this.txtCarrera.SelectedItem).Key;
                this.estudiante.codigo = this.txtCodigo.Text;
                this.estudiante.ci = this.txtCI.Text;
                this.estudiante.nombre = this.txtNombre.Text;
                this.estudiante.apellidoPaterno = this.txtApellidoPaterno.Text;
                this.estudiante.apellidoMaterno = this.txtApellidoMaterno.Text;
                this.estudiante.telefono = this.txtTelefono.Text;
                this.estudiante.direccion = this.txtDireccion.Text;

                string tabla = "estudiantes";

                Dictionary<string, string[]> datos = new Dictionary<string, string[]>();
                datos.Add("carrera", new string[] { "=", this.estudiante.carrera, "," });
                datos.Add("codigo", new string[] { "=", string.Format("'{0}'", this.estudiante.codigo), "," });
                datos.Add("ci", new string[] { "=", string.Format("'{0}'", this.estudiante.ci), "," });
                datos.Add("nombre", new string[] { "=", string.Format("'{0}'", this.estudiante.nombre), "," });
                datos.Add("apellidoPaterno", new string[] { "=", string.Format("'{0}'", this.estudiante.apellidoPaterno), "," });
                datos.Add("apellidoMaterno", new string[] { "=", string.Format("'{0}'", this.estudiante.apellidoMaterno), "," });
                datos.Add("telefono", new string[] { "=", string.Format("'{0}'", this.estudiante.telefono), "," });
                datos.Add("direccion", new string[] { "=", string.Format("'{0}'", this.estudiante.direccion), "" });

                Dictionary<string, string[]> llaves = new Dictionary<string, string[]>();
                llaves.Add("ID", new string[] { "=", this.estudiante.id, "" });

                if (controller.actualizar(tabla, datos, llaves))
                {
                    this.Close();
                }
                return;
            }

            Modelos.IModelo estudiante = new Modelos.Estudiante(
                this.txtCI.Text,
                this.txtNombre.Text,
                this.txtApellidoPaterno.Text,
                this.txtApellidoMaterno.Text,
                this.txtCodigo.Text,
                ((KeyValuePair<string, string>)this.txtCarrera.SelectedItem).Key,
                this.txtTelefono.Text,
                this.txtDireccion.Text);

            Modelos.IModelo cuenta = new Modelos.Usuario(
                this.txtNombre.Text, this.txtApellidoPaterno.Text, this.txtApellidoMaterno.Text, this.txtCodigo.Text, this.txtCodigo.Text, "estudiante");

            if (controller.registrar(estudiante) && usuario.registrar(cuenta))
            {
                this.Close();
            }
        }