Ejemplo n.º 1
0
        private void txtFileName_Leave(object sender, EventArgs e)
        {
            if (txtFileName.Text.Length <= 4)
            {
                Ep.SetError(txtFileName, "Type the File Name First..." +
                            "Name Should Be More Than 5 Characters");
                txtFileName.Focus();
                txtFileName.Text = "";
                return;
            }

            string l = txtFileName.Text.Substring(0, 4).ToString();

            if ((l == "PRJ_") || (l == "prj_") || (l == "Prj_"))
            {
                txtFileName.Text = "Prj_" + (txtFileName.Text.ToUpper().Substring(4));
                Ep.Clear();
                return;
            }
            else
            {
                txtFileName.Text = "Prj_" + txtFileName.Text.ToUpper();
                Ep.Clear();
            }
        }
Ejemplo n.º 2
0
        private void btnBoton1_Click(object sender, EventArgs e)
        {
            //Mensaje de advertencia de que no se han llenado los campos adecuados
            if (txtMatricula.Text == "")
            {
                Ep.SetError(txtMatricula, "No ha ingresado matricula");
            }


            if (txtNombre.Text == "")
            {
                Ep.SetError(txtNombre, "No ha ingresado Nombre");
            }

            if (txtSemestre.Text == "")
            {
                Ep.SetError(txtSemestre, "No ha ingresado semestre");
            }

            if (txtSemestre.Text == "")
            {
                Ep.SetError(txtCarrera, "No ha ingresado Carrera");
            }

            if (txtTelefono.Text == "")
            {
                Ep.SetError(txtTelefono, "No ha ingresado telefono");
            }

            if (txtCal.Text == "")
            {
                Ep.SetError(txtCal, "No ha ingresado Calificacion");
            }


            //try catch para mostrar al alumno en caso de que los datos que entren no sean adecuados
            try
            {
                Alumno Al = new Alumno();
                Al.Matricula = txtMatricula.Text;
                Al.Nombre    = txtNombre.Text;
                Al.Semestre  = Convert.ToInt32(txtSemestre.Text);
                Al.carrera   = txtCarrera.Text;
                Al.Telefono  = Convert.ToInt32(txtTelefono.Text);

                //confirmacion de que el usuario se ah creado
                throw new ExepcionEspecial("su alumno se creo exitosamente");
            }
            catch (FormatException ex)
            {
                //mensaje de error al ingresar un dato no adecuado
                MessageBox.Show("Error en registrar alumno" + ex.Message);
            }

            catch (ExepcionEspecial espEx)
            {
                MessageBox.Show(espEx.Message);
            }
        }
Ejemplo n.º 3
0
        public void btnBoton1_Click(object sender, EventArgs e)
        {
            //hacemos una condicion para saber si se cumple lo que se pide
            if (txtMatricula.Text == "")
            {
                Ep.SetError(txtMatricula, "No ha ingresado matricula");
            }


            if (txtNombre.Text == "")
            {
                Ep.SetError(txtNombre, "No ha ingresado Nombre");
            }

            if (txtSemestre.Text == "")
            {
                Ep.SetError(txtSemestre, "No ha ingresado semestre");
            }

            if (txtSemestre.Text == "")
            {
                Ep.SetError(txtCarrera, "No ha ingresado Carrera");
            }

            if (txtTelefono.Text == "")
            {
                Ep.SetError(txtTelefono, "No ha ingresado telefono");
            }

            //aqui se atrapan los errores y se regresan
            try
            {
                Alumno Al = new Alumno();
                Al.Matricula = txtMatricula.Text;
                Al.Nombre    = txtNombre.Text;
                Al.Semestre  = Convert.ToInt32(txtSemestre.Text);
                Al.carrera   = txtCarrera.Text;
                Al.Telefono  = Convert.ToInt32(txtTelefono.Text);
                throw new ExepcionEspecial("alumno no se creo exitosamente");
            }
            //atrapala excepcion y la muestra al usuario
            catch (FormatException ex)
            {
                MessageBox.Show("Error al registrar alumno" + ex.Message);
            }
            catch (ExepcionEspecial esp)
            {
                MessageBox.Show(Convert.ToString(esp));
            }
            finally
            {
                Ep.Clear();
            }
        }
Ejemplo n.º 4
0
        private void cmdAceptar_Click(object sender, EventArgs e)
        {
            if (txtMatricula.Text == "")
            {
                Ep.SetError(txtMatricula, "No ha ingresado matricula");
            }


            if (txtNombre.Text == "")
            {
                Ep.SetError(txtNombre, "No ha ingresado Nombre");
            }

            if (txtSemestre.Text == "")
            {
                Ep.SetError(txtSemestre, "No ha ingresado semestre");
            }

            if (txtSemestre.Text == "")
            {
                Ep.SetError(txtCarrera, "No ha ingresado Carrera");
            }

            if (txtTelefono.Text == "")
            {
                Ep.SetError(txtTelefono, "No ha ingresado telefono");
            }


            try
            {
                Alumno Al = new Alumno();
                Al.Matricula = txtMatricula.Text;
                Al.Nombre    = txtNombre.Text;
                Al.Semestre  = Convert.ToInt32(txtSemestre.Text);
                Al.carrera   = txtCarrera.Text;
                Al.Telefono  = Convert.ToDouble(txtTelefono.Text);

                //throw new ExepcionEspecial("su alumno se creo exitosamente");
            }
            catch (FormatException ex)
            {
                MessageBox.Show("Error en registrar alumno" + ex.Message);
            }

            catch (Excepcion_Especial espex)
            {
                MessageBox.Show(espex.Message);
            }
            finally
            {
                Ep.Clear();
            }
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == " ")                                     //Condicion por si el TextBox esta vacio
            {
                Ep.SetError(textBox1, "No ha Ingresado Matricula");       //Mensaje de aviso
            }
            else if (textBox2.Text == " ")                                //Condicion por si el TextBox esta vacio
            {
                Ep.SetError(textBox2, "No se ha Ingresado el Nombre");    //Mensaje de aviso
            }
            else if (textBox3.Text == " ")                                //Condicion por si el TextBox esta vacio
            {
                Ep.SetError(textBox3, "No se ha Ingresado el Semestre");  //Mensaje de aviso
            }
            else if (textBox4.Text == " ")                                //Condicion por si el TextBox esta vacio
            {
                Ep.SetError(textBox4, "No se ha Ingresasddo la Carrera"); //Mensaje de aviso
            }
            else if (textBox5.Text == " ")                                //Condicion por si el TextBox esta vacio
            {
                Ep.SetError(textBox5, "No se ha Ingresado el Telefono");  //Mensaje de aviso
            }

            try                                                 //Try-Catch por si el TextBox de la matricula no es un valor numerico
            {
                A.Matricula = Convert.ToInt32(textBox1.Text);   //Convertimos a Int la Matricula

                MessageBox.Show(Convert.ToString(A.Matricula)); //Mensaje de la matricula ingresada
            }
            catch (FormatException ex)
            {
                MessageBox.Show(ex.ToString());                         //Mensaje con toda esa madre del error

                MessageBox.Show("Error, ingrese valores Numericos..."); //Mensaje de aviso
            }

            try                                                         //Try-Catch por si se crea el alumno con los valores que se deben o no
            {
                throw new Excepcion_Especial("¡Creado Correctamente!"); //Mensaje de aviso
            }
            catch (FormatException ex)
            {
                MessageBox.Show("Error en registrar alumno... " + ex.Message); //Mensaje de aviso mas el error
            }
            catch (Excepcion_Especial espex)
            {
                MessageBox.Show(espex.Message); //Mensaje de aviso
            }
            finally
            {
                Ep.Clear(); //Limpiamos el eeror...
            }
        }
Ejemplo n.º 6
0
        private void ButtonAceptar_Click(object sender, EventArgs e)
        {
            Dato data = new Dato();

            if (TxtMatricula.Text == " ")
            {
                Ep.SetError(TxtMatricula, "Matricula no ha sido ingresada");
            }
            else if (TxtNombre.Text == " ")
            {
                Ep.SetError(TxtNombre, "Nombre sin ingresar");
            }
            else if (TxtSemestre.Text == " ")
            {
                Ep.SetError(TxtSemestre, "Escribe un semestre");
            }
            else if (TxtCarrera.Text == " ")
            {
                Ep.SetError(TxtCarrera, "Coloca una carrera");
            }
            else if (TxtTelefono.Text == " ")
            {
                Ep.SetError(TxtTelefono, "Teclea un numero de telefono");
            }
            try
            {
                data.Matricula = Convert.ToInt32(TxtMatricula.Text);
                MessageBox.Show(Convert.ToString(data.Matricula));
            }
            catch (FormatException ex)
            {
                MessageBox.Show(ex.ToString());
                MessageBox.Show("Favor de ingresar exclusivamente numeros");
            }
            try
            {
                throw new Excepcion_Especial("ha sido creado de modo correcto");
            }
            catch (FormatException ex)
            {
                MessageBox.Show("Error al registrar al alumno" + ex.Message);
            }
            catch (Excepcion_Especial espEx)
            {
                MessageBox.Show(espEx.Message);
            }
            finally
            {
                Ep.Clear();
            }
        }
Ejemplo n.º 7
0
        private void Button3_Click(object sender, EventArgs e)
        {
            try
            {
                int X = 0;
                if (txtFileName.Text == "")
                {
                    Ep.SetError(txtFileName, "please select/Enter fileName.....");
                    txtFileName.Focus();
                    return;
                }
                if (ComboBox2.Text == "")
                {
                    Ep.SetError(ComboBox2, "please select Engine File.....");
                    ComboBox2.Focus();
                    return;
                }
                if (ComboBox3.Text == "")
                {
                    Ep.SetError(ComboBox3, "please select Sequence File.....");
                    ComboBox3.Focus();
                    return;
                }

                if (ComboBox4.Text == "")
                {
                    Ep.SetError(ComboBox4, "please select Limit File.....");
                    ComboBox4.Focus();
                    return;
                }

                if (ComboBox5.Text == "")
                {
                    Ep.SetError(ComboBox5, "please select Correction Standard.....");
                    ComboBox5.Focus();
                    return;
                }
                if (ComboBox6.Text == "")
                {
                    Ep.SetError(ComboBox6, "please Test Type Standard.....");
                    ComboBox6.Focus();
                    return;
                }
                for (X = 1; X < (DGPrj.RowCount); X++)
                {
                    if (DGPrj[1, X].Value == null)
                    {
                        Ep.SetError(DGPrj, "please Enter the Value .....");
                        DGPrj.Focus();
                        return;
                    }
                    else
                    {
                        Ep.Clear();
                    }
                }
                Format_Cells();
                X       = 0;
                flg_New = true;
                while (X < PrjGV.RowCount - 1)
                {
                    if (txtFileName.Text == PrjGV[0, X].Value.ToString())
                    {
                        flg_New = false;
                        Rw      = PrjGV.CurrentRow.Index;
                        break;
                    }
                    else
                    {
                        flg_New = true;
                    }
                    X++;
                }

                Rw = PrjGV.CurrentRow.Index;

                if (flg_New == false)
                {
                    Global.Open_Connection("General", "con");
                    MySqlCommand cmd = new MySqlCommand();
                    cmd.CommandText = "UPDATE tblProject SET " +
                                      " EngFile  = '" + ComboBox2.Text + "'," +
                                      " ProgFile  = '" + ComboBox3.Text + "'," +
                                      " LimitFile  = '" + ComboBox4.Text + "'," +
                                      " CorrFile  = '" + ComboBox5.Text + "'," +
                                      " Test_Type  = '" + ComboBox6.Text + "'," +
                                      " R_power  = '" + DGPrj[1, 0].Value.ToString() + "'," +
                                      " R_rpm  = '" + DGPrj[1, 1].Value.ToString() + "'," +
                                      " MT_Torque  = '" + DGPrj[1, 2].Value.ToString() + "'," +
                                      " MT_rpm  = '" + DGPrj[1, 3].Value.ToString() + "'," +
                                      " Fly_rpm  = '" + DGPrj[1, 4].Value.ToString() + "'," +
                                      " Idle_rpm  = '" + DGPrj[1, 5].Value.ToString() + "'," +
                                      " Max_Tq  = '" + DGPrj[1, 6].Value.ToString() + "'," +
                                      " Tq_Range  = '" + DGPrj[1, 7].Value.ToString() + "'," +
                                      " PTO_Ratio  = '" + DGPrj[1, 8].Value.ToString() + "'," +
                                      " PM_Log  = '" + DGPrj[1, 9].Value.ToString() + "'" +
                                      " WHERE ProjectFile = '" + txtFileName.Text + "'";
                    cmd.Connection = Global.con;
                    cmd.ExecuteNonQuery();
                    Load_DataGrid();
                    MessageBox.Show("File Updated .....");
                }
                else if (flg_New == true)
                {
                    Global.Open_Connection("General", "con");
                    MySqlCommand cmd = new MySqlCommand();
                    cmd.CommandText = "INSERT INTO tblProject VALUES ('" +
                                      txtFileName.Text + "','" +
                                      ComboBox2.Text + "','" +
                                      ComboBox3.Text + "','" +
                                      ComboBox4.Text + "','" +
                                      ComboBox5.Text + "','" +
                                      ComboBox6.Text + "','" +
                                      DGPrj[1, 0].Value + "','" +
                                      DGPrj[1, 1].Value + "','" +
                                      DGPrj[1, 2].Value + "','" +
                                      DGPrj[1, 3].Value + "','" +
                                      DGPrj[1, 4].Value + "','" +
                                      DGPrj[1, 5].Value + "','" +
                                      DGPrj[1, 6].Value + "','" +
                                      DGPrj[1, 7].Value + "','" +
                                      DGPrj[1, 8].Value + "','" +
                                      DGPrj[1, 9].Value + "')";
                    cmd.Connection = Global.con;
                    cmd.ExecuteNonQuery();
                    Load_DataGrid();
                    MessageBox.Show("File Saved .....");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Code:- 11004" + ex.Message);
            }
        }
Ejemplo n.º 8
0
        private void ButtonAceptar_Click(object sender, EventArgs e)
        {
            // Aqui instanciamos nuestro objeto despues de eso creamos varias condiciones donde decimos que si el usuario deja un
            // espacio donde se supone que tiene que ingresar un valor alfanumerico entonces ahi entran nuestras condiciones
            // donde si el usuario no ingresa nada le manda un aviso
            Dato d = new Dato();

            if (TxtMatricula.Text == " ")
            {
                Ep.SetError(TxtMatricula, "No ha ingresado la Matricula");
            }
            else if (TxtNombre.Text == " ")
            {
                Ep.SetError(TxtNombre, "No ha ingresado el Nombre");
            }
            else if (TxtSemestre.Text == " ")
            {
                Ep.SetError(TxtSemestre, "No ha ingresado el Semestre");
            }
            else if (TxtCarrera.Text == " ")
            {
                Ep.SetError(TxtCarrera, "No ha ingresado la Carrera");
            }
            else if (TxtTelefono.Text == " ")
            {
                Ep.SetError(TxtTelefono, "No ha ingresado el Telefono");
            }
            // Aqui ya comenzamos con nuestros Try catch el cual lo que hacemos es que le asignamos que nuestro valor de
            // nuestro Txt sea int, asi arrojamos un mensaje de nuestra matricula, si no es asi aqui entra nuestro catch el cual
            // tiene una excepcion la cual nos dira en que linea esta el error o la falla y igual nos mostrara un mensaje
            try
            {
                d.Matricula = Convert.ToInt32(TxtMatricula.Text);
                MessageBox.Show(Convert.ToString(d.Matricula));
            }
            catch (FormatException ex)
            {
                MessageBox.Show(ex.ToString());
                MessageBox.Show("Valor incorrecto, ingrese solo numeros");
            }
            // Aqui volvemos a hacer otro try catch pero en este no influye mucho ya que nuestras variables son de tipo string
            // y lo que hacemos solo es imprimir por mensaje lo que el usuario ingreso
            try
            {
                d.Nombre   = TxtNombre.Text;
                d.Semestre = TxtSemestre.Text;
                d.Carrera  = TxtCarrera.Text;
                d.Telefono = TxtTelefono.Text;
                MessageBox.Show(d.Nombre);
                MessageBox.Show(d.Semestre);
                MessageBox.Show(d.Carrera);
                MessageBox.Show(d.Telefono);
            }
            catch
            {
                MessageBox.Show("Listo");
            }
            // Aqui en este Try catch usamos nuestra sobrecarga la cual habiamos creado en la clase Excepcion Especial
            // la cual enviamos como parametro un string y aplicamos un AplicationExcepcion, en nuestro catch si hay un error
            // nos mostraria solo un mensaje donde nos diria error al registrar junto con el mensaje
            try
            {
                throw new Excepcion_Especial("Se creo correctamente");
            }
            catch (FormatException ex)
            {
                MessageBox.Show("Error en registrar alumno" + ex.Message);
            }
            catch (Excepcion_Especial espEx)
            {
                MessageBox.Show(espEx.Message);
            }
            finally
            {
                Ep.Clear();
            }
        }
Ejemplo n.º 9
0
        private void btnBoton1_Click(object sender, EventArgs e)
        {
            /* try
             * {
             *   int telefono = Convert.ToInt32(txtTelefono.Text);
             *   int Matricula = Convert.ToInt32(txtMatricula.Text);
             *   int Semestre = Convert.ToInt32(txtSemestre.Text);
             *
             *
             *   MessageBox.Show("Hello");
             * }
             * catch (Exception eX)
             * {   //El primero es un mensaje para el usuario
             *   MessageBox.Show("Valor incorrecto, Ingrese un nuevi valor");
             *   //El segundo es un mensaje pero para el desarollador
             *   MessageBox.Show(eX.ToString());
             * }
             * finally { txtTelefono.Focus(); };
             */

            //estos procesos ven si la condicion se cumple para hacer lo que esta alli senalado
            if (txtMatricula.Text == "")
            {
                Ep.SetError(txtMatricula, "No ha ingresado matricula");
            }


            if (txtNombre.Text == "")
            {
                Ep.SetError(txtNombre, "No ha ingresado Nombre");
            }

            if (txtSemestre.Text == "")
            {
                Ep.SetError(txtSemestre, "No ha ingresado semestre");
            }

            if (txtSemestre.Text == "")
            {
                Ep.SetError(txtCarrera, "No ha ingresado Carrera");
            }

            if (txtTelefono.Text == "")
            {
                Ep.SetError(txtTelefono, "No ha ingresado telefono");
            }

            //este proceso del try hace lo que esta dentro de los corchetes para atrapar errores con el catch y se regrese al error que senalo
            try
            {
                Alumno Al = new Alumno();
                Al.Matricula = txtMatricula.Text;
                Al.Nombre    = txtNombre.Text;
                Al.Semestre  = Convert.ToInt32(txtSemestre.Text);
                Al.carrera   = txtCarrera.Text;
                Al.Telefono  = Convert.ToInt32(txtTelefono.Text);
                throw new ExepcionEspecial("alumno no se creo exitosamente");
            }
            //atrapala excepcion del evento ex y la muestra al usuario con un mbox
            catch (FormatException ex)
            {
                MessageBox.Show("Error al registrar alumno" + ex.Message);
            }
            catch (ExepcionEspecial esp)
            {
                MessageBox.Show(Convert.ToString(esp));
            }
            finally
            {
                Ep.Clear();
            }
        }