Beispiel #1
0
        private string getNombre(int cedula)
        {
            string sql = "SELECT Nombre_Estudiante FROM Estudiantes WHERE PK_Cedula_Estudiante = @cedula";

            using (SqlConnection conx = new SqlConnection(ValidacionDatos.RetornaDataConfig()))
            {
                SqlCommand cmd = new SqlCommand(sql, conx);
                try
                {
                    cmd.Parameters.AddWithValue("@cedula", cedula);
                    conx.Open();
                    return((string)cmd.ExecuteScalar());
                }catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return("");
                }
            }
        }
Beispiel #2
0
        private int ultimafactura()
        {
            int    facturaid = 0;
            string sql       = "SELECT MAX(PK_ID_Factura) FROM Facturas";

            using (SqlConnection conn = new SqlConnection(ValidacionDatos.RetornaDataConfig()))
            {
                SqlCommand cmd = new SqlCommand(sql, conn);
                try
                {
                    conn.Open();
                    facturaid = (int)cmd.ExecuteScalar();
                    return(facturaid);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return(0);
                }
            }
        }