Esempio n. 1
0
        public static void Open_Conection_Common()
        {
            OleDbConnection conn = new
                                   OleDbConnection
            {
                // TODO: Modify the connection string and include any
                // additional required properties for your database.
                ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
                                   @"Data source=" + FileLocation.DataBase + "Comun.mdb"
            };

            try
            {
                bool flag = false;

                int i = 0;
                conn.Open();
                OleDbCommand    Command   = new OleDbCommand("SELECT Cod_Fiscal,Nume_Firma,DataBaseFile,Nr_Inregistrare,Key_Inregistrare from Firme", conn);
                OleDbDataReader DB_Reader = Command.ExecuteReader();
                if (DB_Reader.HasRows)
                {
                    DB_Reader.Read();
                    Firma.CodFiscal    = DB_Reader[0].ToString();
                    Firma.NumeFirma    = DB_Reader[1].ToString();
                    CONSTANTE.vs[i, 0] = DB_Reader[0].ToString();
                    CONSTANTE.vs[i, 1] = DB_Reader[1].ToString();
                    while (DB_Reader.Read())
                    {
                        flag = true;
                        i++;
                        CONSTANTE.vs[i, 0] = DB_Reader[0].ToString();
                        CONSTANTE.vs[i, 1] = DB_Reader[1].ToString();
                    }
                    if (flag == true)
                    {
                        Frm_Selectie_Firma frm_Selectie_Firma = new Frm_Selectie_Firma(CONSTANTE.vs, true);
                        frm_Selectie_Firma.Show();
                    }
                    // textbox1.Text = DB_Reader.GetString("your_column_name");
                }
                else
                {
                    Frm_Creare_Firma frm_Creare_Firma = new Frm_Creare_Firma(false);
                    frm_Creare_Firma.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to connect to data source");
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 2
0
        private void SelectareFirma_Click(object sender, RoutedEventArgs e)
        {
            Frm_Selectie_Firma _Selectie_Firma = new Frm_Selectie_Firma(CONSTANTE.vs, false);

            _Selectie_Firma.Show();
        }