Ejemplo n.º 1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";
                if (this.txtnombre.Text == string.Empty)
                {
                    mensajeerror("Falta ingresar algunos datos, serán remarcados");

                    if (this.textBox3.Text.Length == 0)
                    {
                        errorProvider1.SetError(this.textBox3, "ingrese una Nombre");
                    }
                    else
                    {
                        errorProvider1.SetError(this.textBox3, "");
                    }

                    if (this.textBox2.Text.Length == 0)
                    {
                        errorProvider1.SetError(this.textBox2, "ingrese una Nombre");
                    }
                    else
                    {
                        errorProvider1.SetError(this.textBox2, "");
                    }

                    if (this.textBox4.Text.Length == 0)
                    {
                        errorProvider1.SetError(this.textBox4, "ingrese una Nombre");
                    }
                    else
                    {
                        errorProvider1.SetError(this.textBox4, "");
                    }
                }
                else
                {
                    if (this.isnuevo)
                    {
                        rpta = NCursoAlumno.Insertar(Convert.ToInt32(this.textBox1.Text), Convert.ToInt32(this.txtnombre.Text));;
                    }
                    else
                    {
                        rpta = NCursoAlumno.Editar(Convert.ToInt32(this.txtiddamnificado.Text), Convert.ToInt32(this.textBox1.Text), Convert.ToInt32(this.txtnombre.Text));
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.isnuevo)
                        {
                            this.mensajeok("Se Insertó de forma correcta el registro");
                        }
                        else
                        {
                            this.mensajeok("Se Actualizó de forma correcta el registro");
                        }
                    }
                    else
                    {
                        this.mensajeok("Se Insertó de forma correcta el registro");
                    }

                    this.isnuevo  = false;
                    this.iseditar = false;
                    this.buscarnombre();
                }
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Ejemplo n.º 2
0
 private void buscarnombre()
 {
     this.dataGridView1.DataSource = NCursoAlumno.buscarnombre(this.txtbuscar.Text);
     this.OcultarColumnas();
     label10.Text = "Total de Registros: " + Convert.ToString(dataGridView1.Rows.Count);
 }