private void btnRegistrar_Click(object sender, EventArgs e) { if (this.txtCarrera.Text == "") { MessageBox.Show("Seleccione la carrera"); return; } if (this.txtPeriodo.Text == "") { MessageBox.Show("Seleccione el periodo"); return; } if (this.txtCurso.Text == "") { MessageBox.Show("Seleccione el curso"); return; } if (this.operacion == "actualizar") { this.curso.IDCarrera = ((KeyValuePair<string, string>)this.txtCarrera.SelectedItem).Key; this.curso.year = this.txtYear.Text; this.curso.periodo = this.txtPeriodo.Text; this.curso.curso = this.txtCurso.Text; this.curso.paralelo = this.txtParalelo.Text; string tabla = "cursos"; Dictionary<string, string[]> datos = new Dictionary<string, string[]>(); datos.Add("IDCarrera", new string[] { "=", this.curso.IDCarrera, "," }); datos.Add("year", new string[] { "=", string.Format("'{0}'", this.curso.year), "," }); datos.Add("periodo", new string[] { "=", string.Format("'{0}'", this.curso.periodo), "," }); datos.Add("curso", new string[] { "=", string.Format("'{0}'", this.curso.curso), "," }); datos.Add("paralelo", new string[] { "=", string.Format("'{0}'", this.curso.paralelo), "" }); Dictionary<string, string[]> llaves = new Dictionary<string, string[]>(); llaves.Add("ID", new string[] { "=", this.curso.ID, "" }); if (controller.actualizar(tabla, datos, llaves)) { this.Close(); } return; } Modelos.IModelo curso = new Modelos.Curso( ((KeyValuePair<string, string>)this.txtCarrera.SelectedItem).Key, this.txtYear.Value.ToString(), this.txtPeriodo.Text, this.txtCurso.Text, this.txtParalelo.Text); if (controller.registrar(curso)) { this.Close(); } }
public Registrar(string operacion, Dictionary<string, string> carreras, Dictionary<string, string> curso) { InitializeComponent(); this.controller = new Controladores.Curso(); this.carreras = carreras; this.operacion = operacion; this.curso = curso != null ? new Modelos.Curso(curso["ID"], curso["IDCarrera"], curso["year"], curso["periodo"], curso["curso"], curso["paralelo"]) : null; }