示例#1
0
        private void btnGuardar_Click_1(object sender, EventArgs e)
        {
            try
            {
                DialogResult Opcion;
                Opcion = MessageBox.Show("¿Está seguro de guardar estos datos?", "SEGURIDAD DEL SISTEMA", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (Opcion == DialogResult.Yes)
                {
                    string rpta = "";
                    if (this.txtCui.Text == string.Empty || this.txtNombre1.Text == string.Empty ||
                        this.txtApellido1.Text == string.Empty || this.txtIdEncargado.Text == string.Empty)
                    {
                        MensajeError("Falta ingresar algunos datos, serán remarcados");
                        errorIcono.SetError(txtCui, "Ingrese un Valor");
                        errorIcono.SetError(txtNombre1, "Ingrese un Valor");
                        errorIcono.SetError(txtApellido1, "Ingrese un Valor");
                        errorIcono.SetError(txtIdEncargado, "Ingrese un Valor");
                    }
                    else
                    {
                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
                        this.pxFoto.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

                        byte[] imagen = ms.GetBuffer();


                        if (this.IsNuevo)
                        {
                            rpta = NAlumno.Insertar(this.txtCodigoAlumno.Text, this.txtCui.Text, this.txtNombre1.Text, this.txtNombre2.Text, this.txtNombre3.Text, this.txtApellido1.Text, this.txtApellido2.Text, this.txtApellido3.Text,
                                                    this.dtFechaNac.Value, this.cbSexo.Text, this.txtDireccion.Text, Convert.ToInt32(this.cbMunicipio.SelectedValue), this.txtTelefono.Text, imagen, Convert.ToInt32(this.txtIdEncargado.Text),
                                                    this.cbEstado.Text);
                        }
                        else
                        {
                            rpta = NAlumno.Editar(Convert.ToInt32(this.txtCodigoAlumno.Text),
                                                  this.txtCodigoAlumno.Text, this.txtCui.Text, this.txtNombre1.Text, this.txtNombre2.Text, this.txtNombre3.Text, this.txtApellido1.Text, this.txtApellido2.Text, this.txtApellido3.Text,
                                                  this.dtFechaNac.Value, this.cbSexo.Text, this.txtDireccion.Text, Convert.ToInt32(this.cbMunicipio.Text), this.txtTelefono.Text, imagen, Convert.ToInt32(this.txtIdEncargado.Text),
                                                  this.cbEstado.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.MensajeError(rpta);
                        }

                        this.IsNuevo  = false;
                        this.IsEditar = false;
                        this.Botones();
                        this.Limpiar();
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
示例#2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length < 8)
            {
                MessageBox.Show("Ingrese 8 caracteres para el DNI");
            }
            else
            {
                try
                {
                    string rpta = "";
                    if (this.textBox3.Text == string.Empty)
                    {
                        mensajeerror("Falta ingresar algunos datos, serán remarcados");

                        if (this.textBox11.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox11, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox11, "");
                        }

                        if (this.textBox15.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox15, "ingrese el Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox15, "");
                        }

                        if (this.textBox14.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox14, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox14, "");
                        }
                        //
                        if (this.textBox19.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox19, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox19, "");
                        }

                        if (this.textBox23.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox23, "ingrese el Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox23, "");
                        }

                        if (this.textBox29.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox29, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox29, "");
                        }

                        if (this.textBox12.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox12, "ingrese el Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox12, "");
                        }

                        if (this.textBox13.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox13, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox13, "");
                        }

                        if (this.textBox4.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox4, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox4, "");
                        }

                        if (this.textBox3.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox3, "ingrese el Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox3, "");
                        }

                        if (this.textBox6.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox6, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox6, "");
                        }

                        if (this.textBox7.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox7, "ingrese el Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox7, "");
                        }

                        if (this.textBox28.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox28, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox28, "");
                        }

                        if (this.textBox18.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox18, "ingrese el Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox18, "");
                        }

                        if (this.textBox17.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox17, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox17, "");
                        }

                        if (this.textBox16.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox16, "ingrese el Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox16, "");
                        }

                        if (this.textBox5.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox5, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox5, "");
                        }

                        if (this.textBox1.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox1, "ingrese el Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox1, "");
                        }

                        if (this.textBox24.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox24, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox24, "");
                        }

                        if (this.textBox25.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox25, "ingrese el Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox25, "");
                        }

                        if (this.textBox21.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox21, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox21, "");
                        }

                        if (this.textBox20.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.textBox20, "ingrese el Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.textBox20, "");
                        }

                        if (this.dateTimePicker1.Text.Length == 0)
                        {
                            errorProvider1.SetError(this.dateTimePicker1, "ingrese el Nombre del Año");
                        }
                        else
                        {
                            errorProvider1.SetError(this.dateTimePicker1, "");
                        }
                    }
                    else
                    {
                        if (this.isnuevo)
                        {
                            rpta = NAlumno.Insertar(this.textBox4.Text.Trim().ToUpper(), textBox3.Text, textBox1.Text, dateTimePicker1.Value, textBox6.Text, textBox7.Text,
                                                    Convert.ToInt32(this.textBox9.Text), Convert.ToInt32(this.textBox8.Text), Convert.ToInt32(this.textBox10.Text), textBox5.Text,
                                                    textBox18.Text, textBox17.Text, textBox16.Text, textBox15.Text, textBox14.Text, textBox13.Text, textBox11.Text, textBox21.Text,
                                                    textBox20.Text, textBox19.Text, textBox12.Text);
                        }
                        else
                        {
                            rpta = NAlumno.Editar(Convert.ToInt32(this.textBox2.Text), this.textBox4.Text.Trim().ToUpper(), textBox3.Text, textBox1.Text, dateTimePicker1.Value, textBox6.Text, textBox7.Text,
                                                  Convert.ToInt32(this.textBox9.Text), Convert.ToInt32(this.textBox8.Text), Convert.ToInt32(this.textBox10.Text), textBox5.Text,
                                                  textBox18.Text, textBox17.Text, textBox16.Text, textBox15.Text, textBox14.Text, textBox13.Text, textBox11.Text, textBox21.Text,
                                                  textBox20.Text, textBox19.Text, textBox12.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.mensajeerror(rpta);
                        }

                        this.isnuevo  = false;
                        this.iseditar = false;


                        this.buscarnombre();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + ex.StackTrace);
                }
            }
        }