Beispiel #1
0
        protected override TreeNode AddNodeItem(TreeNode aTn, OleDbDataReader aReader, ref int aSI)
        {
            /// В pSQLString должен быть определен примерно такой select:
              /// ...
              /// SELECT
              ///		refCode, refBName, 1, ...
              /// FROM
              ///		rbRef
              /// ...

              TreeNode ntn = new TreeNode(aReader.GetString(1));
              PCTVItemData tid = new PCTVItemData();
              ntn.Tag = tid;
              tid.pPC.code = aReader.GetInt32(0);
              /// Added M.Tor 25.06.2008:
              tid.pText = aReader.GetString(1);
              if (aReader.GetInt32(2) > 0)
            ntn.Nodes.Add(new TreeNode());

              if (aTn == null)
              {
            Nodes.Add(ntn);
            tid.pPath = tid.pCode.ToString();
              }
              else
              {
            aTn.Nodes.Add(ntn);
            tid.pPath = ((PCTVItemData)aTn.Tag).pPath + pPathDelim + tid.pCode;
              }

              aSI = 3;

              return ntn;
        }
Beispiel #2
0
        public void Initialise()
        {
            string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=phonebook.accdb";
            OleDbConnection conn = new OleDbConnection(connectionString);

            string sql = "SELECT * FROM task ORDER BY id";

            OleDbCommand cmd = new OleDbCommand(sql, conn);

            try
            {
                conn.Open();

                reader = cmd.ExecuteReader();
                reader.Read();

                lblTask.Text = reader.GetString(1).ToString();
                txtTask.Text = reader.GetString(2).ToString();

                reader.Close();
                conn.Close();
            }
            catch
            {
                //MessageBox.Show(e.Message);
            }
        }
Beispiel #3
0
        // Constructor for searched login
        public Login(uint gloid)
        {
            // Declarations
            uint gvoid = 0, modifiedby = 0;
            string username = null, password = null, note = null, status = null;
            bool active = false;
            DateTime datemodified = new DateTime(1901, 1, 1);

            // Command
            string query = string.Format("SELECT glo_username, glo_password, glo_note, glo_active, glo_status, gvo_id, date_modified, modified_by FROM gfrc_login" +
                                            " WHERE glo_id = {0}", gloid);

            try
            {
                using (conn)
                {
                    conn.Open();
                    cmd = new OleDbCommand(query, conn);
                    rdr = cmd.ExecuteReader();

                    while (rdr.Read())
                    {
                        username = rdr.GetString(0);
                        password = rdr.GetString(1);
                        note = rdr.GetString(2);
                        active = rdr.GetBoolean(3);
                        status = rdr.GetString(4);
                        if (!UInt32.TryParse(rdr.GetValue(5).ToString(), out gvoid))
                            gvoid = 0;
                        if (!DateTime.TryParse(rdr.GetValue(6).ToString(), out datemodified))
                            datemodified = new DateTime(1901, 1, 1);
                        if (!UInt32.TryParse(rdr.GetValue(7).ToString(), out modifiedby))
                            modifiedby = 0;
                    }
                }
            }
            finally
            {
                if (rdr != null)
                    rdr.Close();
            }
            if (conn != null)
            {
                conn.Close();
            }

            _gloID = gloid;
            _Username = username;
            _Password = password;
            _Note = note;
            _Active = active;
            _Status = status;
            _gvoID = gvoid;
            _DateModified = datemodified;
            _ModifiedBy = modifiedby;
        }
 public Advertisement(OleDbDataReader reader)
 {
     this.StrId = reader.GetString(0);
     if (!reader.IsDBNull(1))
         this.IntType = reader.GetInt32(1);
     else
         this.IntType = 3;
     if (!reader.IsDBNull(2))
         this.StrContent = reader.GetString(2);
     else
         this.StrContent = "";
 }
        public Form_Update(OleDbDataReader oddr)
        {
            InitializeComponent();

            connector = new DBconnector();

            while (oddr.Read())
            {
                tb_Name.Text = oddr.GetString(0);
                tb_Desc.Text = oddr.GetString(2);
                tb_Seq.Text = oddr.GetString(3);
            }
        }
Beispiel #6
0
        public Form1()
        {
            InitializeComponent();
            PC.list = new List<PC>();
            PC.total = new List<PC>();
            data.Columns.Add("Id", "Id");
            data.Columns.Add("PC", "PC");
            data.Columns.Add("Inicio", "Inicio");
            data.Columns.Add("Tiempo", "Tiempo");
            data.Columns.Add("Total", "Total");
            data.Columns[3].Width = 130;
            data.Columns[3].Width = 130;
            r = MSAConnection.read("select * from item");
            while (r.Read())
            {
                String d = "";
                PC p = new PC();
                p.id = r.GetInt32(0);
                p.precio = r.GetInt32(2);
                if (!r.IsDBNull(3))
                {
                    //d = r.GetDateTime(3).ToString();
                    DateTime x = r.GetDateTime(3);
                    d = x.Hour + ":" + x.Minute + ":" + x.Second;
                    p.inicio = r.GetDateTime(3);
                    PC.list.Add(p);
                }
                PC.total.Add(p);
                data.Rows.Add(r.GetInt32(0), r.GetString(1), d);
            }
            //            MessageBox.Show(PC.total.Count + "");

            thetimer.Start();
        }
 public Coupon(OleDbDataReader reader)
 {
     this.StrId = reader.GetString(0);
     if (!reader.IsDBNull(1))
         this.StrSmallImg = reader.GetString(1);
     else
         this.strSmallImg = "";
     if (!reader.IsDBNull(2))
         this.StrLargeImg = reader.GetString(2);
     else
         this.StrLargeImg = "";
     if (!reader.IsDBNull(3))
         this.StrPrintImg = reader.GetString(3);
     else
         this.StrPrintImg = "";
 }
        public static void consultaUmLivro()
        {
            String aux = "select * from TabLivro where codigo ='" + Livro.getCodigo() + "'";

            conecta();
            strSQL = new OleDbCommand(aux, conn);
            result = strSQL.ExecuteReader();
            Erro.setErro(false);
            if (result.Read())
            {
                Livro.setTitulo(result.GetString(1));
                Livro.setAutor(result.GetString(2));
                Livro.setEditora(result.GetString(3));
                Livro.setAno(result.GetString(4));
            }
            else
                Erro.setMsg("Livro não cadastrado.");
            desconecta();
        }
Beispiel #9
0
        //
        //  Validar o Utilizador que se ligou ao servidor
        //      nome: O Nome de Utilizador
        //      pass: Password
        //  
        //  Retorna: true se o utilizador foi encontrado na Base de Dados e se a password estava correcta
        //           false se o utilizador não existe ou a password estava incorrecta
        //
        public bool ValidarUtilizador(String nome, String pass)
        {
            try
            {
                OleDbCommand cmdSQL = LigacaoBD.CreateCommand();
                cmdSQL.CommandText = "SELECT * FROM tabela_utilizadores_src";
                LeitorBD = cmdSQL.ExecuteReader();

                while (LeitorBD.Read())
                {
                    if (LeitorBD.GetString(0) == nome && LeitorBD.GetString(1) == pass)
                    {
                        return true;
                    }
                }
            }
            catch (OleDbException) { }
                
            return false;
            
        }
        public Kontaktdaten()
        {
            InitializeComponent();
            try
            {
                dBVerbindung = new OleDbConnection(verbindungsstring);
                dBVerbindung.Open();
                offen = true;
                befehl = dBVerbindung.CreateCommand();
                //Übersicht (DataGHridView) anzeigen
                befehl.CommandText = "select * from Kontakte;";
                datenleser = befehl.ExecuteReader();
                int row = 0;
                while (datenleser.Read())
                {
                    //leere zeile hinzufügen
                    string[] row_init = { "", "", "", "", "" };
                    dataGridViewKontakte.Rows.Add(row_init);
                    //GridView füllen
                    dataGridViewKontakte.Rows[row].Cells[0].Value = datenleser.GetInt32(0).ToString();
                    dataGridViewKontakte.Rows[row].Cells[1].Value = datenleser.GetString(1);
                    dataGridViewKontakte.Rows[row].Cells[2].Value = datenleser.GetString(2);
                    dataGridViewKontakte.Rows[row].Cells[3].Value = datenleser.GetString(3);
                    dataGridViewKontakte.Rows[row].Cells[4].Value = datenleser.GetString(4);
                    dataGridViewKontakte.Rows[row].Cells[5].Value = datenleser.GetString(5);
                    row = row + 1;
                }

            }
            catch (Exception ausnahme)
            {
                MessageBox.Show("Datenbankfehler: " + ausnahme.Message);
            }
            finally
            {
                if (offen == true) dBVerbindung.Close();
            }
        }
 public static void Load(this DataObject dataObj, OleDbDataReader reader)
 {
     try
     {
         foreach (ColumnDefinition columnDef in dataObj.ColumnDefs())
         {
             if (reader.GetValue(columnDef.ColumnIndex) != DBNull.Value)
             {
                 switch (columnDef.ColumnFieldType)
                 {
                     case ColumnDefinition.FieldType.String:
                         dataObj.GetColumnValues()[columnDef.ColumnIndex] = reader.GetString(columnDef.ColumnIndex);
                         break;
                     case ColumnDefinition.FieldType.Int32:
                         dataObj.GetColumnValues()[columnDef.ColumnIndex] = reader.GetInt32(columnDef.ColumnIndex);
                         break;
                     case ColumnDefinition.FieldType.Boolean:
                         dataObj.GetColumnValues()[columnDef.ColumnIndex] = reader.GetBoolean(columnDef.ColumnIndex);
                         break;
                 }
             }
             else //default values for nulls
             {
                 switch (columnDef.ColumnFieldType)
                 {
                     case ColumnDefinition.FieldType.String:
                         dataObj.GetColumnValues()[columnDef.ColumnIndex] = string.Empty;
                         break;
                     case ColumnDefinition.FieldType.Int32:
                         dataObj.GetColumnValues()[columnDef.ColumnIndex] = 0;
                         break;
                     case ColumnDefinition.FieldType.Boolean:
                         dataObj.GetColumnValues()[columnDef.ColumnIndex] = false;
                         break;
                 }
             }
         }
     }
     catch (Exception e)
     {
         //TODO: what to do here?
     }
 }
Beispiel #12
0
        private void SaveColumnValues(OleDb.OleDbConnection conn, List <string> indexNames, ref Dictionary <string, int> dictionary)
        {
            //Call ReadColumnNames first!
            int indexNumber = 0;

            //just making sure column names are populated
            if (indexNames.Count() == 0)
            {
                return;
            }

            foreach (string index in indexNames)
            {
                //no need to prepare this command
                OleDb.OleDbCommand selectAll = new OleDb.OleDbCommand("SELECT `" + index + "` FROM `Sheet1$`", conn);
                try {
                    OleDb.OleDbDataReader reader = selectAll.ExecuteReader();
                    while (reader.Read())
                    {
                        //potentially throws invalid cast exception (null)
                        if (!reader.IsDBNull(0))
                        {
                            string word = reader.GetString(0);
                            //clean word
                            string cleanWord = Globals.ThisAddIn.HighlightManager.CleanWord(word);
                            //save word
                            if (Globals.ThisAddIn.HighlightManager.CanAddToDictionary(cleanWord))
                            {
                                dictionary.Add(cleanWord, indexNumber);
                            }
                        }
                    }
                    reader.Close();
                } catch (OleDb.OleDbException)
                {
                    Forms.MessageBox.Show(Strings.error, Strings.errorCaption);
                }
                indexNumber++;
            }
        }
Beispiel #13
0
        // Constructor for searched volunteer qualification
        public vQualification(uint gvqid)
        {
            // Declarations
            uint gvoid = 0;
            string qualification = null;

            // Command
            string query = string.Format("SELECT gvo_id, gvq_qual " +
                                            "FROM gfrc_volunteer_qualification WHERE gvq_id = {0}", gvqid);

            try
            {
                using (conn)
                {
                    conn.Open();
                    cmd = new OleDbCommand(query, conn);
                    rdr = cmd.ExecuteReader();

                    while (rdr.Read())
                    {
                        UInt32.TryParse(rdr.GetValue(0).ToString(), out gvoid);
                        qualification = rdr.GetString(1);
                    }
                }
            }
            finally
            {
                if (rdr != null)
                    rdr.Close();
            }
            if (conn != null)
            {
                conn.Close();
            }

            _gvqID = gvqid;
            _gvoID = gvoid;
            _Qualification = qualification;
        }
Beispiel #14
0
		public String ExecutaComando(string comandoSql) 
		{
            StringBuilder lido = new StringBuilder();

			cmd.CommandText = comandoSql;
            try
            {
                using (leitor = cmd.ExecuteReader())
                {

                    while (leitor.Read())
                    {
                        lido.Append(leitor.GetString(0));
                    }
                }
            }
            finally
            {
                if (leitor != null)
                    leitor.Close();
            }

			return lido.ToString();
		}
Beispiel #15
0
 private static Penerbit MappingDtrToObject(OleDbDataReader dtr)
 {
     Penerbit penerbit = new Penerbit();
     penerbit.PenerbitID = dtr[0] is DBNull ? 0 : dtr.GetInt32(0);
     penerbit.Nama = dtr[1] is DBNull ? string.Empty : dtr.GetString(1);
     return penerbit;
 }
Beispiel #16
0
        private void Username_TextChanged(object sender, EventArgs e)
        {
            btnDelete.Enabled = true;
            btnUpdate_record.Enabled = true;
            try
            {
                txtUsername.Text = txtUsername.Text.TrimEnd();
                con = new OleDbConnection(cs);

                con.Open();
                cmd = con.CreateCommand();

                cmd.CommandText = "SELECT username,user_password,nameofuser,contactno,email FROM registration WHERE username = '******'";
                rdr = cmd.ExecuteReader();

                if (rdr.Read())
                {
                    txtPassword.Text = (rdr.GetString(1).Trim());
                    txtName.Text = (rdr.GetString(2).Trim());
                    txtContact_no.Text = (rdr.GetString(3).Trim());
                    txtEmail_Address.Text = (rdr.GetString(4).Trim());
                }

                if ((rdr != null))
                {
                    rdr.Close();
                }
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #17
0
    private void GetPhotoData(string strLocation)
    {
        try
        {

            //Open our connection, provided that it isn't already open
            if (oleDbConnection1.State != ConnectionState.Open)
            {
                oleDbConnection1.Open();
            }
            //Find out how many photos in our DB correspond to the selected location.
            m_intPhotoCount = GetPhotoCount(strLocation);
            //store m_intPhotoCount in a Session variable
            Session["s_intPhotoCount"] = m_intPhotoCount;
            //Use that value to size our TravelInfo array.
            if (m_intPhotoCount == 0)
            {	//Exit this function if the PhotoCount query returned 0 results
                Console.WriteLine("PhotoCount returned 0 results.  Please investigate.");
                return;
            }
            m_strTravelInfo = new string[m_intPhotoCount, 3];
            //Initialize the location parameter to our GetPhotoInfoByLocation ADO Command Object
            oleDbCommandGetPhotoInfoByLocation = new OleDbCommand("GetPhotoInfoByLocation_sp", oleDbConnection1);
            oleDbCommandGetPhotoInfoByLocation.CommandType = CommandType.StoredProcedure;
            oleDbCommandGetPhotoInfoByLocation.Parameters.Clear();
            oleDbCommandGetPhotoInfoByLocation.Parameters.Add("@Location", OleDbType.VarChar, 25);
            oleDbCommandGetPhotoInfoByLocation.Parameters["@Location"].Value = strLocation;
            //Use a DataReader to get the info from our database
            oleDbDataReader1 = oleDbCommandGetPhotoInfoByLocation.ExecuteReader(CommandBehavior.CloseConnection);
            int intLoopCounter = 0;
            //Loop through this data to populate our TravelInfo array.
            while (oleDbDataReader1.Read() == true)
            {
                m_strTravelInfo[intLoopCounter, 0] = oleDbDataReader1.GetString(0);	//Filename
                m_strTravelInfo[intLoopCounter, 1] = oleDbDataReader1.GetString(1);	//Caption
                m_strTravelInfo[intLoopCounter, 2] = oleDbDataReader1.GetString(2);	//TravelDate
                intLoopCounter++;
            }

            oleDbDataReader1.Close();
            //Display the first photo from our collection matching this location.
            m_intCurrentIndex = 0;
            //Store m_intCurrentIndex in a Session variable
            Session["s_intCurrentIndex"] = m_intCurrentIndex;
            //store the array in a Session object
            Session["s_strTravelInfo"] = m_strTravelInfo;
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        finally
        {
            oleDbConnection1.Close();
        }
    }
Beispiel #18
0
        // Constructor for searched volunteer position
        public Position(uint gvid, char gvo_gvp)
        {
            // Declarations
            uint gvoid = 0, gvpid = 0;
            string position = null, drivercat = null, drivercatdoc = null, drivertrans = null;
            string query = "";

            // Command
            if (gvo_gvp == 'o')
                query = string.Format("SELECT gvo_id, gvp_id, gvp_position, gvp_driver_cat, gvp_driver_cat_doc, gvp_driver_trans " +
                                            "FROM gfrc_volunteer_position WHERE gvo_id = {0}", gvid);
            else if (gvo_gvp == 'p')
                query = string.Format("SELECT gvo_id, gvp_id, gvp_position, gvp_driver_cat, gvp_driver_cat_doc, gvp_driver_trans " +
                                            "FROM gfrc_volunteer_position WHERE gvp_id = {0}", gvid);

            try
            {
                using (conn)
                {
                    conn.Open();
                    cmd = new OleDbCommand(query, conn);
                    rdr = cmd.ExecuteReader();

                    while (rdr.Read())
                    {
                        UInt32.TryParse(rdr.GetValue(0).ToString(), out gvoid);
                        UInt32.TryParse(rdr.GetValue(1).ToString(), out gvpid);
                        position = rdr.GetString(2);
                        drivercat = rdr.GetString(3);
                        drivercatdoc = rdr.GetString(4);
                        drivertrans = rdr.GetString(5);
                    }
                }
            }
            catch (Exception e)
            {
                string exception = e.ToString();
                gvoid = 0;
                gvpid = 0;
                position = "";
                drivercat = "";
                drivercatdoc = "";
                drivertrans = "";
            }
            finally
            {
                if (rdr != null)
                    rdr.Close();
            }
            if (conn != null)
            {
                conn.Close();
            }

            _gvpID = gvpid;
            _gvoID = gvoid;
            _Position = position;
            _DriverCat = drivercat;
            _DriverCatDoc = drivercatdoc;
            _DriverTrans = drivertrans;
        }
 internal static List<User> searchUsers(string key)
 {
     List<User> list = new List<User>();
     try
     {
         cmd = new OleDbCommand("SELECT * FROM Users WHERE Username LIKE '%" + key + "%';", conn);
         reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             User u = new User(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4),
                reader.GetString(5), reader.GetString(6), reader.GetString(7), reader.GetDateTime(8), reader.GetInt32(9), reader.GetInt32(10));
             list.Add(u);
         }
         return list;
     }
     catch (Exception e)
     {
         MessageBox.Show("Error getting usersList in searchUsers: " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return null;
     }
 }
 internal static List<User> GetUsers()
 {
     List<User> usersList = new List<User>();
     try
     {
         cmd = new OleDbCommand("SELECT * FROM Users ORDER BY ID;", conn);
         reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             User u = new User(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4),
                 reader.GetString(5), reader.GetString(6), reader.GetString(7), reader.GetDateTime(8), reader.GetInt32(9), reader.GetInt32(10));
             usersList.Add(u);
         }
         reader.Close();
         return usersList;
     }
     catch (Exception e)
     {
         MessageBox.Show("Error getting usersList: " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return null;
     }
 }
Beispiel #21
0
        protected List<DBItem> GetVotesQueryCallback(OleDbDataReader reader)
        {
            List<DBItem> returnList = new List<DBItem> { };

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    DBItem item = new DBItem();
                    item.Votes = reader.GetString(reader.GetOrdinal("Votes"));
                    returnList.Add(item);
                }
            }
            return returnList;
        }
 internal static List<string> getFoodTypes()
 {
     List<string> foodTypeList = new List<string>();
     try
     {
         cmd = new OleDbCommand("SELECT DISTINCT FoodType FROM FoodList;", conn);
         reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             foodTypeList.Add(reader.GetString(0));
         }
     }
     catch (Exception ee)
     {
         reader.Close();
         MessageBox.Show("getFoodTypes() error: " + ee.ToString());
     }
     reader.Close();
     return foodTypeList;
 }
Beispiel #23
0
        //Image mainBackGroundImage;
        public frmMainForm()
        {
            byte i = 0;
            PrivateDataEncode pde = new PrivateDataEncode();

            myConn = new OleDbConnection();
            myCom  = new OleDbCommand();

            myCom.CommandText       = "Select M_ID, M_Name, M_Type, M_Description From tblMasterInfor ORDER BY M_Type";
            myCom.Connection        = myConn;
            myConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Data.mdb;Jet OLEDB:Database Password=whatthehellisgoingon";
            try{
                myConn.Open();
            }catch (Exception e)
            {
                MessageBox.Show(ERROR_WHILE_LOADING_DATABASE + e.Message.ToString(), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Dispose();
                Application.Exit();
            }
            myReader = myCom.ExecuteReader();
            System.ComponentModel.ComponentResourceManager resources1 = new System.ComponentModel.ComponentResourceManager(typeof(frmMainForm));
            InitializeComponent();
            if (myReader.HasRows)
            {
                while (myReader.Read())
                {
                    this.tbTmp4LoadDynamic          = new System.Windows.Forms.ToolStripButton();
                    this.tbTmp4LoadDynamic.Overflow = ToolStripItemOverflow.Never;
                    if (myReader.GetByte(2) == frmAddNewMasterItem.ENUM_INTEGER_CATOGERY_DIAGNOSIS)
                    {
                        try{
                            this.tbTmp4LoadDynamic.Image = Image.FromFile(Application.StartupPath + @"\image\diagnosis.bmp");
                        }catch (System.IO.FileNotFoundException) {}
                    }
                    else if (myReader.GetByte(2) == frmAddNewMasterItem.ENUM_INTEGER_CATOGERY_TREATMENT)
                    {                                                                                                         //treatment
                        try{
                            this.tbTmp4LoadDynamic.Image = Image.FromFile(Application.StartupPath + @"\image\treatment.bmp"); //career.bmp
                        }catch (System.IO.FileNotFoundException) {}
                    }
                    else
                    {
                        try{
                            this.tbTmp4LoadDynamic.Image = Image.FromFile(Application.StartupPath + @"\image\career.bmp");
                        }catch (System.IO.FileNotFoundException) {}
                    }
                    //this.tbTmp4LoadDynamic.Image = ((System.Drawing.Image)(resources.GetObject("mnuBtnPatientRecord.Image")));
                    this.tbTmp4LoadDynamic.ImageAlign            = System.Drawing.ContentAlignment.MiddleLeft;
                    this.tbTmp4LoadDynamic.ImageScaling          = System.Windows.Forms.ToolStripItemImageScaling.None;
                    this.tbTmp4LoadDynamic.ImageTransparentColor = System.Drawing.Color.Magenta;
                    this.tbTmp4LoadDynamic.Name                  = "tb" + myReader.GetValue(0).ToString();
                    this.tbTmp4LoadDynamic.Size                  = new System.Drawing.Size(90, 40);
                    this.tbTmp4LoadDynamic.TextAlign             = System.Drawing.ContentAlignment.MiddleRight;
                    this.tbTmp4LoadDynamic.Click                += new System.EventHandler(this.DynamicToolBarClick);
                    this.tbTmp4LoadDynamic.ImageTransparentColor = System.Drawing.Color.Magenta;
                    this.tbTmp4LoadDynamic.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText;
                    this.tbTmp4LoadDynamic.Text                  = myReader.GetString(1);
                    this.tbTmp4LoadDynamic.TextImageRelation     = System.Windows.Forms.TextImageRelation.ImageBeforeText;
                    this.tbTmp4LoadDynamic.DoubleClick          += new EventHandler(DynamicToolBarClick);
                    sepTmp      = new ToolStripSeparator();
                    sepTmp.Name = "auto" + i++.ToString();
                    sepTmp.Size = new System.Drawing.Size(6, 1);
                    this.tbMainToolBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { sepTmp, tbTmp4LoadDynamic });
                }        //	myReader.Read()
            }            //myReader.HasRows
            myReader.Close();

            this.frmMainForm_SizeChanged(null, null);
        }
 public Result getUserInfo(string username)
 {
     Result r = new Result();
     try
     {
         cmd = new OleDbCommand("SELECT * FROM Users WHERE Username = ?;", conn);
         cmd.Parameters.Add("Username", OleDbType.VarChar).Value = username;
         reader = cmd.ExecuteReader();
         if (reader.Read())
         {
             User u = new User(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4),
                 reader.GetString(5), reader.GetString(6), reader.GetString(7), reader.GetDateTime(8), reader.GetInt32(9), reader.GetInt32(10));
             r.user = u;
             r.success = true;
         }
         return r;
     }
     catch (Exception e)
     {
         MessageBox.Show("Error getting userInfo: " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return null;
     }
 }
Beispiel #25
0
        private static Buku MappingDtrToObject(OleDbDataReader dtr)
        {
            Buku buku = new Buku();
            buku.ISBN = dtr[0] is DBNull ? string.Empty : dtr.GetString(0);
            buku.Judul = dtr[1] is DBNull ? string.Empty : dtr.GetString(1);
            buku.Edisi = dtr[2] is DBNull ? string.Empty : dtr.GetString(2);
            buku.Bahasa = dtr[3] is DBNull ? string.Empty : dtr.GetString(3);
            buku.Penerbit.Nama = dtr[4] is DBNull ? string.Empty : dtr.GetString(4);

            return buku;
        }
Beispiel #26
0
        protected List<DBItem> GetSubmissionsQueryCallback(OleDbDataReader reader)
        {
            List<DBItem> returnList = new List<DBItem>();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    DBItem item = new DBItem();

                    item.ID = reader.GetInt32(reader.GetOrdinal("ID"));
                    item.User = reader.GetString(reader.GetOrdinal("User"));
                    item.DateTime = reader.GetDateTime(reader.GetOrdinal("DateTime"));
                    item.Person = reader.GetString(reader.GetOrdinal("Person"));
                    item.Rating = reader.GetString(reader.GetOrdinal("Rating"));
                    item.Description = reader.GetString(reader.GetOrdinal("Description"));
                    item.Votes = reader.GetString(reader.GetOrdinal("Votes"));

                    returnList.Add(item);
                }
            }
            return returnList;
        }
Beispiel #27
0
        public Vector<vQualification> listQualifications(uint gvoid)
        {
            // Declarations
            Vector<vQualification> quals = new Vector<vQualification>();
            uint gvqid = 0;
            string qualification = null;
            vQualification input = new vQualification();

            // Command
            string query = string.Format("SELECT gvq_id, gvq_qual " +
                                            "FROM gfrc_volunteer_qualification WHERE gvo_id = {0}", gvoid);

            try
            {
                using (conn)
                {
                    conn.Open();
                    cmd = new OleDbCommand(query, conn);
                    rdr = cmd.ExecuteReader();

                    while (rdr.Read())
                    {
                        if (!UInt32.TryParse(rdr.GetValue(0).ToString(), out gvqid))
                            gvqid = 0;
                        qualification = rdr.GetString(1);
                        if (gvqid != 0)
                        {
                            input = new vQualification(gvqid, gvoid, qualification);
                            quals.Add(input);
                        }

                    }
                }
            }
            finally
            {
                if (rdr != null)
                    rdr.Close();
            }
            if (conn != null)
            {
                conn.Close();
            }

            return quals;
        }
 internal static List<Order> getOrderList()
 {
     List<Order> ol = new List<Order>();
     try
     {
         //IFNULL(SUM(score),'N')
         cmd = new OleDbCommand("SELECT Orders.UserID, Orders.FoodID, Orders.Quantity, Orders.TotalExpense, Orders.OrderDate, Orders.ReportID, Orders.Status, FoodList.FoodName, Users.Username, Orders.ID FROM (Users INNER JOIN Orders ON Users.ID = Orders.UserID) INNER JOIN FoodList ON Orders.FoodID = FoodList.ID ORDER BY Orders.OrderDate;", conn);
         reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             Order o = new Order(reader.GetInt32(0),
                 reader.GetInt32(1),
                 reader.GetInt32(2),
                 reader.GetInt32(3),
                 reader.GetDateTime(4), reader.GetInt32(5), reader.GetString(6), reader.GetString(7), reader.GetString(8), reader.GetInt32(9));
             ol.Add(o);
         }
         reader.Close();
     }
     catch (Exception ex)
     {
         //runs perfectly fine but theres an ERROR. I DONT KNOW WHY --> line 295 (reader.GetInt32(0)) OH NO!
         MessageBox.Show("getOrderList() error: " + ex.ToString());
     }
     return ol;
 }
 internal static List<Admin> GetAdmins()
 {
     List<Admin> adminList = new List<Admin>();
     try
     {
         cmd = new OleDbCommand("SELECT * FROM Admins ORDER BY ID", conn);
         reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             Admin a = new Admin(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3),
                 reader.GetString(4), reader.GetString(5), reader.GetString(6), reader.GetString(7));
             adminList.Add(a);
         }
         reader.Close();
         return adminList;
     }
     catch (Exception e)
     {
         MessageBox.Show("Error getting admin list: " + e.Message, "Server Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return null;
     }
 }
    protected void Page_Load(object sender, EventArgs e) {
        paramSexo = "";
        paramNome = "";
        try {
          paramSexo = Request["RadioButtonList1"];
          paramNome = Request["TextBox1"];
          if (paramSexo == null) paramSexo = "";
          if (paramNome == null) paramNome = "";
        }
        catch(Exception){};

        Label1.Text = "Registros encontrados:";
        String filtro1 = "", filtro2 = "";

        if (paramSexo.Equals("Todos")) {
                filtro1 = " TRUE ";
        }
        else if (paramSexo.Equals("Masculino")) {
                filtro1 = " (sexo='M') ";
        }
        else if (paramSexo.Equals("Feminino"))
        {
            filtro1 = " (sexo='F') ";
        }
        else
        {
            filtro1 = " FALSE ";
            Label1.Text = "";
        }

        filtro2 = " (nomeprof LIKE '%" + paramNome + "%') ";

        try {
          conexao = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/temp/Escola.mdb");
          conexao.Open();

          string sql = "select * from professores WHERE " 
              + filtro1 + " AND " + filtro2 + " ORDER BY nomeprof";
          stm = new OleDbCommand(sql, conexao);
          dr = stm.ExecuteReader();

          String strHTML = "";
          if (dr.HasRows) { //mostramos o cabeçalho da <table> somente se temos registros
              strHTML = "<TABLE name=profs border=1 width='65%'> <TR style='font-size: 14px; font-family: verdana; text-align: center; font-weight: 900; color: #009;'>" 
                  + "<TD>&nbsp;Código&nbsp;</TD><TD>&nbsp;Nome&nbsp;</TD>"
                  + "<TD>&nbsp;Sexo&nbsp;</TD><TD>&nbsp;Salário&nbsp;</TD></TR>";
          }

          while (dr.Read()) {
              int codigo = dr.GetInt16(0); //codprof
              String nome = dr.GetString(1); //nome
              String sexo = dr.GetString(2); //sexo
              float salario = dr.GetFloat(3); //salário
              strHTML += "<TR><TD style='font-size: 12px; font-family: verdana; text-align: center;'>" + codigo
                      + "</TD><TD style='font-size: 12px; font-family: verdana; text-align: left;'>&nbsp;&nbsp;"
                      + nome + "</TD><TD style='font-size: 12px; font-family: verdana; text-align: center;'>"
                      + sexo + "</TD><TD style='font-size: 12px; font-family: verdana; text-align: center;'>" 
                      + salario + "</TD></TR>";
          }

          strHTML += "</TABLE> <br/><br/><br/>";
          LiteralControl lc = new LiteralControl(strHTML);
          Panel2.Controls.Add(lc);
          stm.Dispose();
          dr.Close();
          conexao.Close();
        } catch (Exception exc) {
            Label1.Text = "Erro no processamento do BD - " + exc.Message;
        }
    }
        /////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////
        private string GetNullableString(OleDbDataReader reader, int col)
        {
            if (reader.IsDBNull(col) == false)
            {
                return reader.GetString(col);
            }

            return null;
        }
        internal static List<FoodList> getFoodList()
        {
            List<FoodList> fl = new List<FoodList>();
            try
            {
                cmd = new OleDbCommand("SELECT ID, FoodName, FoodPrice, FoodType FROM FoodList ORDER BY FoodName;", conn);
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    FoodList fudList = new FoodList(reader.GetInt32(0).ToString(), reader.GetString(1), reader.GetInt32(2), reader.GetString(3));
                    fl.Add(fudList);
                }

            }
            catch (Exception ee)
            {
                reader.Close();
                MessageBox.Show("getFoodList() error: " + ee.ToString());
            }
            reader.Close();
            return fl;
        }