예제 #1
0
        public static bool ReadAll()
        {
            OleDbDataReader dr = null;
            Patient         pt;
            bool            error;

            if (ConnectionBD.Open())
            {
                return(true);
            }
            if (!(error = Data.Read("SELECT * FROM tablePatient", ref dr)))
            {
                while (dr.Read())
                {
                    pt         = new Patient();
                    pt.Name    = dr.GetString(1);
                    pt.Surname = dr.GetString(2);
                    pt.Idcard  = dr.GetString(3);
                    pt.Age     = dr.GetString(4);
                    ListPatient.Add(pt);
                }
            }
            if (dr != null)
            {
                dr.Close();
            }
            ConnectionBD.Connection.Close();
            return(error);
        }
예제 #2
0
        public static bool InsertCommand(string command)
        { /* Comandos como UPDATE, DELETE, INSERT. */
            if (ConnectionBD.Open())
            {
                return(true);
            }
            bool err = false;

            try
            {
                Cmd.Connection  = ConnectionBD.Connection;
                Cmd.CommandText = command;
                Cmd.ExecuteNonQuery();
            }
            catch (InvalidOperationException e)
            {
                MessageBox.Show("Error: " + e.Message);
                err = true;
            }
            ConnectionBD.Connection.Close();
            return(err);
        }
예제 #3
0
        public static bool IsRepeatData(string nameTable, string nameCampus, string data)
        {
            OleDbDataReader dr    = null;
            bool            error = false;
            string          cmd   = "SELECT * FROM " + nameTable + " WHERE " + nameCampus + " = ?";

            if (ConnectionBD.Open())
            {
                return(true);
            }
            Data.Cmd.Parameters.AddWithValue("?", data);
            if (Data.Read(cmd, ref dr) || dr.Read())
            {
                error = true;
            }
            if (dr != null)
            {
                dr.Close();
            }
            Data.Cmd.Parameters.Clear();
            ConnectionBD.Connection.Close();
            return(error);
        }
예제 #4
0
        public static bool Read(string typeSearch, string txt, int index)
        {
            SCompare        txtEntry = new SCompare(txt);
            OleDbDataReader dr       = null;
            Patient         pt;
            string          cmd = "";
            bool            error;

            if (ConnectionBD.Open())
            {
                return(true);
            }
            cmd = "SELECT * FROM tablePatient WHERE " + typeSearch + " = ?";
            Data.Cmd.Parameters.AddWithValue("?", txt);
            if (!(error = Data.Read(cmd, ref dr)))
            {
                while (dr.Read())
                {
                    if (txtEntry == dr.GetString(index))
                    {
                        pt         = new Patient();
                        pt.Name    = dr.GetString(1);
                        pt.Surname = dr.GetString(2);
                        pt.Idcard  = dr.GetString(3);
                        pt.Age     = dr.GetString(4);
                        ListPatient.Add(pt);
                    }
                }
            }
            if (dr != null)
            {
                dr.Close();
            }
            ConnectionBD.Connection.Close();
            Data.Cmd.Parameters.Clear();
            return(error);
        }
예제 #5
0
        public static bool Read()
        {
            SCompare        txt = new SCompare(CardPatient);
            string          cmd;
            Recipe          rp;
            bool            error;
            OleDbDataReader dr = null;

            if (ConnectionBD.Open())
            {
                return(true);
            }
            cmd = "SELECT * FROM tableRecipe WHERE Cedula = ?";
            Data.Cmd.Parameters.AddWithValue("?", CardPatient);
            if (!(error = Data.Read(cmd, ref dr)))
            {
                while (dr.Read())
                {
                    if (txt == dr.GetString(3))
                    {
                        rp              = new Recipe();
                        rp.Drugs        = dr.GetString(1);
                        rp.Prescription = dr.GetString(2);
                        rp.DateBegin    = dr.GetDateTime(4);
                        rp.DateDest     = dr.GetDateTime(5);
                        ListRecipe.Add(rp);
                    }
                }
            }
            if (dr != null)
            {
                dr.Close();
            }
            ConnectionBD.Connection.Close();
            Data.Cmd.Parameters.Clear();
            return(error);
        }