Ejemplo n.º 1
0
        public int iExecuteNonQuery(string FileData, string sSql, int where)
        {
            int n = 0;
            //try
            //{
                using (SQLiteConnection con = new SQLiteConnection())
                {
                    if (where == 0)
                    {
                        con.ConnectionString = @"Data Source=" + FileData + "; Version=3; New=True;";
                    }
                    else
                    {
                        con.ConnectionString = @"Data Source=" + FileData + "; Version=3; New=False;";
                    }
                    con.Open();
                    using (SQLiteCommand sqlCommand = con.CreateCommand())
                    {
                        sqlCommand.CommandText = sSql;
                        n = sqlCommand.ExecuteNonQuery();
                    }
                    con.Close();
                }
            //}
            //catch
            //{
            //    n = 0;
            //}
            return n;

        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();
            AddDinValues();
            AddPCBValues();
            AddRKValues();

            // create a new database connection:
            sqlite_conn = new SQLiteConnection("Data Source=ICTSupportInventory.db;Version=3;New=False;Compress=True;");

            // open the table for connection
            sqlite_conn.Open();

            // create a new SQL command:
            sqlite_cmd = sqlite_conn.CreateCommand();

            // create a new table to work with
            sqlite_cmd.CommandText = "CREATE TABLE Items (ProductType varchar(100), SerialNumber varchar(100), Location varchar(100), Availability varchar(50), Owner varchar(100), ETR varchar(100), Comments varchar(100));";

            // close the connection
            sqlite_conn.Close();

            // get values to populate all items 
            PopulateAllLists();
        }
Ejemplo n.º 3
0
 // Functie pentru a sterge un capitol din baza de date
 public static void delete_capitole(string decizie, string title)
 {
     SQLiteConnection sqlite_conn;
     SQLiteCommand sqlite_cmd;
     string database_title = get_databaseName_tableName.get_databaseName(decizie, "capitole");
     string table_title = get_databaseName_tableName.get_tableName(decizie, "capitole");
        /* if (decizie == "info") { database_title = "Capitole.db"; table_title = "capitole";}
     if (decizie == "mate") { database_title = "Capitole_mate.db"; table_title = "capitole_mate"; }
     if (decizie == "bio") { database_title = "Capitole_bio.db"; table_title = "capitole_bio"; }*/
     try
     {
         sqlite_conn = new SQLiteConnection("Data Source=" + database_title + ";Version=3;New=False;Compress=True;");
         sqlite_conn.Open();
         sqlite_cmd = sqlite_conn.CreateCommand();
         sqlite_cmd.CommandText = "delete from " + table_title + " where titlu = @titlu_capitol";
         SQLiteParameter parameter = new SQLiteParameter("@titlu_capitol", DbType.String);
         parameter.Value = title;
         sqlite_cmd.Parameters.Add(parameter);
         sqlite_cmd.ExecuteNonQuery();
         MessageBox.Show("Lectia a fost stearsa cu succes!");
         sqlite_conn.Close();
     }
     catch(Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 4
0
        public DataRow[] drExecute(string FileData, string sSql)
        {
            DataRow[] datarows = null;
            SQLiteDataAdapter dataadapter = null;
            DataSet dataset = new DataSet();
            DataTable datatable = new DataTable();
            try
            {
                using (SQLiteConnection con = new SQLiteConnection())
                {
                    con.ConnectionString = @"Data Source=" + FileData + "; Version=3; New=False;";
                    con.Open();
                    using (SQLiteCommand sqlCommand = con.CreateCommand())
                    {
                        dataadapter = new SQLiteDataAdapter(sSql, con);
                        dataset.Reset();
                        dataadapter.Fill(dataset);
                        datatable = dataset.Tables[0];
                        datarows = datatable.Select();
                        k = datarows.Count();
                    }
                    con.Close();
                }
            }
            catch(Exception ex)
            {
            //    throw ex;
                datarows = null;
            }
            return datarows;

        }
Ejemplo n.º 5
0
        /// <summary>
        /// OnDelDir delete dir from DB if its there
        /// </summary>
        /// <param name="args">input arguments</param>
        /// <returns><c>true</c> if dir was deleted</returns>
        public static bool CheckDupeDelDir(string[] args)
        {
            Log.Info("DelDir.CheckDupeDelDir");

            if (!SkipDupe.CheckSkipDupe(args))
            {
                Log.Info("DelDir.CheckDupeDelDir");
                return true;
            }

            SQLiteConnection sqlite_conn;
            SQLiteCommand sqlite_cmd;

            string dbName = ConfigReader.GetConfig("dbDupeDir");
            string db = String.Format(CultureInfo.InvariantCulture,
                @"Data Source={0};Version=3;New=False;Compress=True;", dbName);
            sqlite_conn = new SQLiteConnection(db);
            sqlite_conn.Open();
            sqlite_cmd = sqlite_conn.CreateCommand();

            string dbCommand = String.Format(CultureInfo.InvariantCulture,
                @"DELETE FROM dirDupe WHERE ReleaseName = '{0}'", Global.dupe_name);

            Log.InfoFormat("{0}", dbCommand);

            sqlite_cmd.CommandText = dbCommand;
            sqlite_cmd.ExecuteNonQuery();

            sqlite_conn.Close();

            Log.Info("DelDir.CheckDupeDelDir");

            return true;
        }
Ejemplo n.º 6
0
        public static void UnDupeDir(string[] args)
        {
            Log.Info("UnDupe.UnDupeDir");

            Global.undupe_dir = args[1];
            Log.InfoFormat("Un Dupe String = '{0}'", Global.undupe_dir);

            SQLiteConnection sqlite_conn;
            SQLiteCommand sqlite_cmd;
            SQLiteDataReader sqlite_datareader;

            string dbName = ConfigReader.GetConfig("dbDupeDir");
            string db = String.Format(CultureInfo.InvariantCulture,
                @"Data Source={0};Version=3;New=False;Compress=True;", dbName);

            sqlite_conn = new SQLiteConnection(db);
            sqlite_conn.Open();
            sqlite_cmd = sqlite_conn.CreateCommand();

            string cmdText =
                String.Format(CultureInfo.InvariantCulture,
                "SELECT COUNT(*) FROM dirDupe WHERE ReleaseName = '{0}'", Global.undupe_dir);
            sqlite_cmd.CommandText = cmdText;
            sqlite_datareader=sqlite_cmd.ExecuteReader();

            int count = 0;

            while (sqlite_datareader.Read())
            {
                count = Int32.Parse(sqlite_datareader.GetValue(0).ToString());
            }

            sqlite_datareader.Close();

            if ( count > 0 )
            {
                string deleteCommand =
                    String.Format(CultureInfo.InvariantCulture,
                    @"DELETE FROM dirDupe WHERE ReleaseName = '{0}'", Global.undupe_dir);

                Log.InfoFormat("{0}", deleteCommand);

                sqlite_cmd.CommandText = deleteCommand;
                sqlite_cmd.ExecuteNonQuery();

                Console.WriteLine(
                    Format.FormatStr1ng(ConfigReader.GetConfig("msgUnDupes_ok"), 0, null));

            }
            else
            {
                Console.WriteLine(
                    Format.FormatStr1ng(ConfigReader.GetConfig("msgUnDupes_fail"), 0, null));
            }

            sqlite_conn.Close();

            Log.Info("UnDupe.UnDupeDir");
        }
        private void Adaugare_Intrebare_Load(object sender, EventArgs e)
        {
            btn_home = home.Size;
            btn_adauga_intrebarea = adauga_intrebarea.Size;
            if (decizie == "info")
            {
                SQLiteConnection sqlite_conn;
                SQLiteCommand sqlite_cmd;
                SQLiteDataReader sqlite_datareader;
                sqlite_conn = new SQLiteConnection("Data Source=Capitole.db;Version=3;New=False;Compress=True;");
                sqlite_conn.Open();
                sqlite_cmd = sqlite_conn.CreateCommand();
                sqlite_cmd.CommandText = "SELECT * FROM capitole";
                sqlite_datareader = sqlite_cmd.ExecuteReader();
                while (sqlite_datareader.Read())
                {
                    String myr = sqlite_datareader.GetString(0);
                    checkedListBox1.Items.Add(myr);
                }
                sqlite_conn.Close();
            }
            if (decizie == "mate")
            {
                SQLiteConnection sqlite_conn;
                SQLiteCommand sqlite_cmd;
                SQLiteDataReader sqlite_datareader;
                sqlite_conn = new SQLiteConnection("Data Source=Capitole_mate.db;Version=3;New=False;Compress=True;");
                sqlite_conn.Open();
                sqlite_cmd = sqlite_conn.CreateCommand();
                sqlite_cmd.CommandText = "SELECT * FROM capitole_mate";
                sqlite_datareader = sqlite_cmd.ExecuteReader();
                while (sqlite_datareader.Read())
                {
                    String myr = sqlite_datareader.GetString(1);
                    checkedListBox1.Items.Add(myr);
                }
                sqlite_conn.Close();
            }
            if (decizie == "bio")
            {
                SQLiteConnection sqlite_conn;
                SQLiteCommand sqlite_cmd;
                SQLiteDataReader sqlite_datareader;
                sqlite_conn = new SQLiteConnection("Data Source=Capitole_bio.db;Version=3;New=False;Compress=True;");
                sqlite_conn.Open();
                sqlite_cmd = sqlite_conn.CreateCommand();
                sqlite_cmd.CommandText = "SELECT * FROM capitole_bio";
                sqlite_datareader = sqlite_cmd.ExecuteReader();
                while (sqlite_datareader.Read())
                {
                    String myr = sqlite_datareader.GetString(1);
                    checkedListBox1.Items.Add(myr);
                }
                sqlite_conn.Close();

            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            // [snip] - As C# is purely object-oriented the following lines must be put into a class:

            // We use these three SQLite objects:
            SQLiteConnection sqlite_conn;
            SQLiteCommand sqlite_cmd;
            SQLiteDataReader sqlite_datareader;

            // create a new database connection:
            sqlite_conn = new SQLiteConnection("Data Source=database.db;Version=3;New=True;Compress=True;");

            // open the connection:
            sqlite_conn.Open();

            // create a new SQL command:
            sqlite_cmd = sqlite_conn.CreateCommand();

            // Let the SQLiteCommand object know our SQL-Query:
            sqlite_cmd.CommandText = "CREATE TABLE test (id integer primary key, text varchar(100));";

            // Now lets execute the SQL ;D
            sqlite_cmd.ExecuteNonQuery();

            // Lets insert something into our new table:
            sqlite_cmd.CommandText = "INSERT INTO test (id, text) VALUES (1, 'Test Text 1');";

            // And execute this again ;D
            sqlite_cmd.ExecuteNonQuery();

            // ...and inserting another line:
            sqlite_cmd.CommandText = "INSERT INTO test (id, text) VALUES (2, 'Test Text 2');";

            // And execute this again ;D
            sqlite_cmd.ExecuteNonQuery();

            // But how do we read something out of our table ?
            // First lets build a SQL-Query again:
            sqlite_cmd.CommandText = "SELECT * FROM test";

            // Now the SQLiteCommand object can give us a DataReader-Object:
            sqlite_datareader = sqlite_cmd.ExecuteReader();

            // The SQLiteDataReader allows us to run through the result lines:
            while (sqlite_datareader.Read()) // Read() returns true if there is still a result line to read
            {
                // Print out the content of the text field:
                // System.Console.WriteLine(sqlite_datareader["text"]);
                string a = sqlite_datareader.GetString(0);
                MessageBox.Show(a);
            }

            // We are ready, now lets cleanup and close our connection:
            sqlite_conn.Close();
        }
Ejemplo n.º 9
0
 private void pictureBox2_Click(object sender, EventArgs e)
 {
     if (nume.Text == "" || prenume.Text == "" || repass.Text == "" || password.Text == "" || username.Text == "")
         MessageBox.Show("Trebuie sa completati toate campurile!");
     else
         if (cross.Visible == true)
             MessageBox.Show("Parolele nu corespund!");
         else
         {
             string parola_criptata;
             parola_criptata = RC4Class.RC4_Class.RC4(password.Text, "38577af7-379f-421d-ad29-cd1994521704");
             SQLiteConnection sqlite_conn;
             SQLiteCommand sqlite_cmd;
             FileStream fstream;
             sqlite_conn = new SQLiteConnection("Data Source=LOGIN.db;Version=3;New=False;Compress=True;");
             try
             {
                 sqlite_conn.Open();
                 byte[] imageBt = null;
                 fstream = new FileStream(this.image_path.Text, FileMode.Open, FileAccess.Read);
                 BinaryReader br = new BinaryReader(fstream);
                 imageBt = br.ReadBytes((int)fstream.Length);
                 sqlite_cmd = sqlite_conn.CreateCommand();
                 sqlite_cmd.CommandText = "INSERT INTO utilizatori(nume, prenume, username, password,avatar) " +
                                                             "Values('" + nume.Text + "', '" + prenume.Text + "', '" + username.Text + "', '" + parola_criptata + "', @IMG);";
                 SQLiteParameter parameter = new SQLiteParameter("@IMG", System.Data.DbType.Binary);
                 SQLiteParameter parameter1 = new SQLiteParameter("@nume", System.Data.DbType.String);
                 SQLiteParameter parameter2 = new SQLiteParameter("@prenume", System.Data.DbType.String);
                 SQLiteParameter parameter3 = new SQLiteParameter("@username", System.Data.DbType.String);
                 SQLiteParameter parameter4 = new SQLiteParameter("@parola", System.Data.DbType.String);
                 parameter.Value = imageBt;
                 parameter1.Value = nume.Text;
                 parameter2.Value = prenume.Text;
                 parameter3.Value = username.Text;
                 parameter4.Value = parola_criptata;
                 sqlite_cmd.Parameters.Add(parameter);
                 sqlite_cmd.Parameters.Add(parameter1);
                 sqlite_cmd.Parameters.Add(parameter2);
                 sqlite_cmd.Parameters.Add(parameter3);
                 sqlite_cmd.Parameters.Add(parameter4);
                 sqlite_cmd.ExecuteNonQuery();
                 sqlite_conn.Close();
                 MessageBox.Show("Tocmai te-ai inscris in baza noastra de date!");
                 Login lg = new Login();
                 this.Hide();
                 lg.Show();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
 }
Ejemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            //clean history
            SQLiteConnection sql_con;
            SQLiteCommand sql_cmd;
            
            {
                sql_con = new SQLiteConnection("Data Source=History.db;Version=3;New=False;Compress=True;");
                sql_con.Open();

                sql_cmd = sql_con.CreateCommand();
                sql_cmd.CommandText = "delete from mains";

                sql_cmd.ExecuteNonQuery();
                sql_con.Close();

                MessageBox.Show("操作成功!");
            }
        }
        /** private void ButtonYes_Click(object sender, System.Windows.RoutedEventArgs e)
         * delete reminder
         */
		private void ButtonYes_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            SQLiteConnection  new_con = new  SQLiteConnection(customwindow.Properties.Settings.Default.ConnectionString.ToString());
            new_con.Open();
            if  (delete_status == 1)
            {  
                SQLiteCommand  get = new  SQLiteCommand("DELETE FROM reminder WHERE rid ='"  + Convert.ToInt32(id) + "'", new_con);
                get.ExecuteNonQuery();
                MainWindowStart  mainWindow = MainWindowStart.Instance;
                mainWindow.mainWindowUpdate();
            }
            else
            {
                SQLiteCommand  get = new  SQLiteCommand("DELETE FROM contact_detail WHERE cid ='"  + Convert.ToInt32(id) + "'", new_con);
                 get.ExecuteNonQuery();
                MainWindowStart  mainWindow = MainWindowStart.Instance;
                mainWindow.mainWindowUpdateContact();
            }
            new_con.Close();
             this.Close();
		}
Ejemplo n.º 12
0
        internal void DelMnuUserItem(string user)
        {
            string file = AppDomain.CurrentDomain.BaseDirectory +
                     "Database\\Shamia.db";
            if (Connection.State != ConnectionState.Closed) { Connection.Close(); }
            Connection = new SQLiteConnection("Data Source=" + file + ";Version=3" +
                                              ";New=False;Compress=True");

            try
            {
                Connection.Open();
                C = Connection.CreateCommand();
                C.CommandText = "DELETE from myusers WHERE user='******'";
                C.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MyDelegates.OnDebugMessageCallBack(ex.StackTrace);
            }
            finally
            {
                if (Connection.State != ConnectionState.Closed) { Connection.Close(); }
            }
        }
        private void ButtonOk_Click(object sender, RoutedEventArgs e)
        {
            int index = 0, n = 0;
            int[] array = new int[10000];
            string firstname = ReplaceApostrophe(TextBoxFirstName.Text);
            string lastname = ReplaceApostrophe(TextBoxLastName.Text);
            string mail = ReplaceApostrophe(TextBoxMail.Text);
            string address = ReplaceApostrophe(TextBoxAddress.Text);
            try
            {
                 int number= Convert.ToInt32(TextBoxPhone.Text);
                 SQLiteConnection new_con = new SQLiteConnection(customwindow.Properties.Settings.Default.ConnectionString.ToString());
                 new_con.Open();
                 SQLiteCommand new_cnt = new SQLiteCommand("SELECT cid FROM  contact_detail", new_con);
                 SQLiteDataReader reader;
                 reader = new_cnt.ExecuteReader();
                 while (reader.Read())
                 {
                     array[index] = Convert.ToInt32(reader[0].ToString());
                     index++;
                 }

                 if (!(index == 0))
                 {
                     n = index;
                     insertionSort(array, n);
                     index = 0;
                     while (index < n)
                     {
                         if (!(array[index] == index))
                             break;
                         index++;
                     }
                 }
                 SQLiteCommand get = new SQLiteCommand("INSERT INTO contact_detail VALUES ('" + index + "', '" + firstname + "', '" + lastname + "', '" + Convert.ToInt32(number) + "', '" + address + "', '" + mail + "','','')", new_con);
                 get.ExecuteNonQuery();
                 new_con.Close();
                 this.Close();
                 MainWindowStart mainWindow = MainWindowStart.Instance;
                 mainWindow.mainWindowUpdateContact();
            }
            catch
            {                
                MessageBox.Show("Phone number is invalid!");
            }
                

            
        }
Ejemplo n.º 14
0
        public static void tbox_to_default(SQLiteConnection sql_con)
        {
            sql_con.Open();
            SQLiteCommand sql_cmd = sql_con.CreateCommand();
            string CommandText = "SELECT * FROM settings";
            SQLiteDataAdapter DB = new SQLiteDataAdapter(CommandText, sql_con);
            GlobalVar.DS.Reset();
            DB.Fill(DS);
            DataTable DT = DS.Tables[0];

            for (int i = 0; i < 16; i++)
            {
                GlobalVar.defCars[i] = Convert.ToInt32(DT.Rows[i][0]);
                GlobalVar.defCoeff[i] = Convert.ToInt32(DT.Rows[i][1]);
                GlobalVar.defRebate[i] = Convert.ToInt32(DT.Rows[i][2]);
            }
            sql_con.Close();
        }
Ejemplo n.º 15
0
        public static bool CheckDupeDB(string dbName)
        {
            Log.Info("SQLiteCheck.CheckDupeDB");

            string fileName = ConfigReader.GetConfig(dbName);

            if ( File.Exists(fileName) )
            {
                Log.DebugFormat("DirDupe DB File '{0}/{1}' Is There.", dbName, fileName);
            }
            else
            {
                Log.DebugFormat("DirDupe DB File '{0}/{1}' Is Not There. Creating It...", dbName, fileName);

                SQLiteConnection sqlite_conn;
                SQLiteCommand sqlite_cmd;
                SQLiteDataReader sqlite_datareader;

                string db = String.Format(CultureInfo.InvariantCulture,
                    @"Data Source={0};Version=3;New=True;Compress=True;", fileName);
                sqlite_conn = new SQLiteConnection(db);

                sqlite_conn.Open();
                sqlite_cmd = sqlite_conn.CreateCommand();

                sqlite_cmd.CommandText = @"CREATE TABLE dirDupe (
                    Id integer primary key,
                    ReleaseTime int(10),
                    ReleaseDateTime varchar(19),
                    ReleaseName varchar(256),
                    Pwd varchar(256),
                    Section varchar(32),
                    UserName varchar(64),
                    GroupName varchar(64),
                    Wiped integer(1),
                    Nuked integer(1),
                    NukeReason varchar(64)
                    );";
                sqlite_cmd.ExecuteNonQuery();

                sqlite_cmd.CommandText = @"CREATE INDEX DirDupeIndex ON dirDupe (ReleaseName);";
                sqlite_cmd.ExecuteNonQuery();

                Log.InfoFormat("Created Table dirDupe '{0}/{1}'", dbName, fileName);

                sqlite_cmd.CommandText = @"INSERT INTO dirDupe
                    (ReleaseTime, ReleaseName, Pwd, Section, UserName, GroupName)
                    VALUES (0, 'ReleaseName', '/test/ReleaseName', 'test', 'jcScripts', 'NoGroup');";
                sqlite_cmd.ExecuteNonQuery();

                Log.DebugFormat("SELECT * FROM dirDupe =");

                sqlite_cmd.CommandText = "SELECT * FROM dirDupe";
                sqlite_datareader=sqlite_cmd.ExecuteReader();

                // The SQLiteDataReader allows us to run through the result lines:
                while (sqlite_datareader.Read()) // Read() returns true if there is still a result line to read
                {
                    Log.DebugFormat("{1} {0}", sqlite_datareader["ReleaseName"], sqlite_datareader["Id"] );
                }

                sqlite_conn.Close();
            }

            Log.Info("SQLiteCheck.CheckDupeDB");

            return true;
        }
 /** private void ButtonOk_Click(object sender, RoutedEventArgs e)
  *  update reminder
  */
 private void ButtonOk_Click(object sender, RoutedEventArgs e)
 {
     string date = ReplaceApostrophe(DatePicker1.SelectedDate.Value.ToShortDateString());
     string name = ReplaceApostrophe(ReminderName.Text);
     string note = ReplaceApostrophe(Note.Text);
     string snooze = ReplaceApostrophe(NumericUpDown1.Value.ToString());
     string time = ReplaceApostrophe(TimePicker.SelectedTime.Value.ToString());
     SQLiteConnection new_up = new SQLiteConnection(customwindow.Properties.Settings.Default.ConnectionString.ToString());
     new_up.Open();
     SQLiteCommand get = new SQLiteCommand("Update reminder set date='" + date + "',name='" + name + "', note='" + note + "',snooze='" + snooze + "',time='" + time + "' where rid='" + Convert.ToInt32(cnt) + "'", new_up);
     get.ExecuteNonQuery();
     new_up.Close();
     this.Close();
     MainWindowStart mainWindow = MainWindowStart.Instance;
     mainWindow.mainWindowUpdate();
 }
Ejemplo n.º 17
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if(decizie == "info")
            {
                current_number++;
                panel1.Visible = true;
                panel2.Visible = true;
                panel3.Visible = true;
                question.Text = current_number.ToString();
                continua.Visible = true;
                start.Visible = false;
                random_id = rand.Next(0, maximum);
                while (search(random_id) == false)
                    random_id = rand.Next(0, maximum);
                passed_questions[current_number] = random_id;
                SQLiteConnection sqlite_conn;
                SQLiteCommand sqlite_cmd;
                SQLiteDataReader sqlite_datareader;
                sqlite_conn = new SQLiteConnection("Data Source=Intrebari.db;Version=3;New=False;Compress=True;");
                sqlite_conn.Open();
                sqlite_cmd = sqlite_conn.CreateCommand();
                sqlite_cmd.CommandText = "SELECT * FROM intrebari";
                sqlite_datareader = sqlite_cmd.ExecuteReader();
                while (sqlite_datareader.Read())
                {
                    String string_id = sqlite_datareader.GetString(0);
                    int id = Int32.Parse(string_id);
                    String text_intrebare = sqlite_datareader.GetString(1);
                    String var_1 = sqlite_datareader.GetString(2);
                    String var_2 = sqlite_datareader.GetString(3);
                    String var_3 = sqlite_datareader.GetString(4);
                    String var_corecta = sqlite_datareader.GetString(5);

                    if (id == random_id)
                    {
                        richTextBox1.Text = text_intrebare;
                        varianta_1.Text = var_1;
                        varianta_2.Text = var_2;
                        varianta_3.Text = var_3;
                        write_answer = var_corecta;
                        cap_parental = sqlite_datareader.GetString(6);
                    }
                }
                sqlite_conn.Close();
            }

            if(decizie == "mate")
            {
                current_number++;
                panel1.Visible = true;
                panel2.Visible = true;
                panel3.Visible = true;
                question.Text = current_number.ToString();
                continua.Visible = true;
                start.Visible = false;
                random_id = rand.Next(0, maximum);
                while (search(random_id) == false)
                    random_id = rand.Next(0, maximum);
                passed_questions[current_number] = random_id;
                SQLiteConnection sqlite_conn;
                SQLiteCommand sqlite_cmd;
                SQLiteDataReader sqlite_datareader;
                sqlite_conn = new SQLiteConnection("Data Source=Intrebari_mate.db;Version=3;New=False;Compress=True;");
                sqlite_conn.Open();
                sqlite_cmd = sqlite_conn.CreateCommand();
                sqlite_cmd.CommandText = "SELECT * FROM intrebari_mate";
                sqlite_datareader = sqlite_cmd.ExecuteReader();
                while (sqlite_datareader.Read())
                {
                    String string_id = sqlite_datareader.GetString(0);
                    int id = Int32.Parse(string_id);
                    String text_intrebare = sqlite_datareader.GetString(1);
                    String var_1 = sqlite_datareader.GetString(2);
                    String var_2 = sqlite_datareader.GetString(3);
                    String var_3 = sqlite_datareader.GetString(4);
                    String var_corecta = sqlite_datareader.GetString(5);
                    if (id == random_id)
                    {
                        richTextBox1.Text = text_intrebare;
                        varianta_1.Text = var_1;
                        varianta_2.Text = var_2;
                        varianta_3.Text = var_3;
                        write_answer = var_corecta;
                        cap_parental = sqlite_datareader.GetString(6);
                    }
                }
                sqlite_conn.Close();
            }

            if(decizie == "bio")
            {
                current_number++;
                panel1.Visible = true;
                panel2.Visible = true;
                panel3.Visible = true;
                question.Text = current_number.ToString();
                continua.Visible = true;
                start.Visible = false;
                random_id = rand.Next(0, maximum);
                while (search(random_id) == false)
                    random_id = rand.Next(0, maximum);
                passed_questions[current_number] = random_id;
                SQLiteConnection sqlite_conn;
                SQLiteCommand sqlite_cmd;
                SQLiteDataReader sqlite_datareader;
                sqlite_conn = new SQLiteConnection("Data Source=Intrebari_bio.db;Version=3;New=False;Compress=True;");
                sqlite_conn.Open();
                sqlite_cmd = sqlite_conn.CreateCommand();
                sqlite_cmd.CommandText = "SELECT * FROM intrebari_bio";
                sqlite_datareader = sqlite_cmd.ExecuteReader();
                while (sqlite_datareader.Read())
                {
                    String string_id = sqlite_datareader.GetString(0);
                    int id = Int32.Parse(string_id);
                    String text_intrebare = sqlite_datareader.GetString(1);
                    String var_1 = sqlite_datareader.GetString(2);
                    String var_2 = sqlite_datareader.GetString(3);
                    String var_3 = sqlite_datareader.GetString(4);
                    String var_corecta = sqlite_datareader.GetString(5);
                    if (id == random_id)
                    {
                        richTextBox1.Text = text_intrebare;
                        varianta_1.Text = var_1;
                        varianta_2.Text = var_2;
                        varianta_3.Text = var_3;
                        write_answer = var_corecta;
                    }
                }
                sqlite_conn.Close();
            }
        }
Ejemplo n.º 18
0
        private void button2_Click(object sender, EventArgs e)
        {
            int temp_rows=0;
            String update_value = "";
            SQLiteConnection sqlite_conn;
            SQLiteCommand sqlite_cmd;
            DataTable dt = new DataTable();

            // create a new database connection:
            sqlite_conn = new SQLiteConnection("Data Source=database.db;Version=3;New=False;Compress=True;");

            // open the connection:
            sqlite_conn.Open();
            sqlite_cmd = sqlite_conn.CreateCommand();
            sqlite_cmd.CommandText = "DELETE FROM EMPLOYEE;";
            sqlite_cmd.ExecuteNonQuery();
            dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);

            for (temp_rows = 0; temp_rows < dataGridView1.Rows.Count-1;temp_rows++)
            {
                DataGridViewRow dr = dataGridView1.Rows[temp_rows];
                DataRow de = (dr.DataBoundItem as DataRowView).Row;
                foreach (object obj in de.ItemArray)
                {
                    update_value = update_value +"'"+obj.ToString()+"'" + ",";
                }
                sqlite_cmd.CommandText = "INSERT INTO EMPLOYEE VALUES(" + update_value.Remove(update_value.Length - 1).Trim() + ");";
                sqlite_cmd.ExecuteNonQuery();
                update_value = "";
            }
                MessageBox.Show("DATA UPDATED SUCCESFULLY", "UPDATE", MessageBoxButtons.OK, MessageBoxIcon.Information);
                sqlite_conn.Close();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// update table config channel used and por
        /// </summary>
        internal void UpdateServerUsedAndPort()
        {
            string file = AppDomain.CurrentDomain.BaseDirectory +
                      "Database\\Shamia.db";
            if (Connection.State != ConnectionState.Closed) { Connection.Close(); }
            Connection = new SQLiteConnection("Data Source=" + file + ";Version=3" +
                                              ";New=False;Compress=True");

            try
            {
                Connection.Open();
                C = Connection.CreateCommand();
                C.CommandText = "UPDATE config SET port='" + MainWindow.Configuration.StConfiguration.Port + "'," +
                                "server='" + MainWindow.Configuration.StConfiguration.Server + "'";
                    
                C.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MyDelegates.OnDebugMessageCallBack(ex.StackTrace);
            }
            finally
            {
                if (Connection.State != ConnectionState.Closed) { Connection.Close(); }
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// metodo atualiza table users
        /// </summary>
        /// <param name="user"></param>
        public void UpdateSaved()
        {
            // delete users and new insert
            DeleteAllUser();

            string file = AppDomain.CurrentDomain.BaseDirectory +
                      "Database\\Shamia.db";
            if (Connection.State != ConnectionState.Closed) { Connection.Close(); }
            Connection = new SQLiteConnection("Data Source=" + file + ";Version=3" +
                                              ";New=False;Compress=True");

            try
            {
                Connection.Open();
                C = Connection.CreateCommand();
                C.CommandText = "INSERT INTO users VALUES('" + MainWindow.Configuration.StConfiguration.Nick + "','" +
                    MainWindow.Configuration.StConfiguration.Password +"','"+
                    MainWindow.Configuration.StConfiguration.AuthSsl + "','" +
                    MainWindow.Configuration.StConfiguration.Owner + "','" +
                    MainWindow.Configuration.StConfiguration.Port + "','"+
                    MainWindow.Configuration.StConfiguration.Channel +"')";
                C.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MyDelegates.OnDebugMessageCallBack(ex.StackTrace);
            }
            finally
            {
                if (Connection.State != ConnectionState.Closed) { Connection.Close(); }
            }
        }
Ejemplo n.º 21
0
        private void button1_Click(object sender, EventArgs e)
        {
            button2.Visible = true;
            // We use these three SQLite objects:
            SQLiteConnection sqlite_conn;
            SQLiteCommand sqlite_cmd;
            SQLiteDataReader sqlite_datareader;

            // create a new database connection:
            sqlite_conn = new SQLiteConnection("Data Source=database.db;Version=3;New=False;Compress=True;");

            // open the connection:
            sqlite_conn.Open();

            // create a new SQL command:
            sqlite_cmd = sqlite_conn.CreateCommand();
            try
            {

                // Let the SQLiteCommand object know our SQL-Query:
                sqlite_cmd.CommandText = "CREATE TABLE EMPLOYEE (EMP_ID varchar(20) PRIMARY KEY, EMP_NAME varchar(20) NOT NULL, JOB_TITLE varchar(20) NOT NULL);";

                // Now lets execute the SQL ;D
                //try
                sqlite_cmd.ExecuteNonQuery();
            }
            catch (SQLiteException e1)
            {
                sqlite_cmd.CommandText = "DELETE FROM EMPLOYEE";
                sqlite_cmd.ExecuteNonQuery();

            }

            finally
            {
                try
                {
                    // Lets insert something into our new table:
                    sqlite_cmd.CommandText = "INSERT INTO EMPLOYEE VALUES (2210311146, 'MONISH', 'DBA');";

                    // And execute this again ;D
                    sqlite_cmd.ExecuteNonQuery();

                    // ...and inserting another line:
                    sqlite_cmd.CommandText = "INSERT INTO EMPLOYEE VALUES (2210311130, 'VARSHA', 'DBA');";

                    // And execute this again ;D
                    sqlite_cmd.ExecuteNonQuery();

                    // But how do we read something out of our table ?
                    // First lets build a SQL-Query again:
                    sqlite_cmd.CommandText = "SELECT * FROM EMPLOYEE;";

                    // Now the SQLiteCommand object can give us a DataReader-Object:
                    sqlite_datareader = sqlite_cmd.ExecuteReader();

                    DataTable dt = new DataTable();                                //CODE TO DISPLAY DATA ON A GRIDVIEW.
                    SQLiteDataAdapter adp = new SQLiteDataAdapter(sqlite_cmd);
                    adp.Fill(dt);
                    dataGridView1.DataSource = dt;
                    adp.Update(dt);
                    sqlite_conn.Close();
                }
                catch (SQLiteException se)
                {
                    MessageBox.Show((se.ToString()));
                }
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// retorna o usuario para ser editado ou deletado
        /// </summary>
        /// <returns></returns>
        /// <param name="user">user nick</param>
        internal TemplateMyUsersDataBase GetUserEdit(string user)
        {
            TemplateMyUsersDataBase t = new TemplateMyUsersDataBase();

            string file = AppDomain.CurrentDomain.BaseDirectory +
                     "Database\\Shamia.db";
            if (Connection.State != ConnectionState.Closed) { Connection.Close(); }
            Connection = new SQLiteConnection("Data Source=" + file + ";Version=3" +
                                              ";New=False;Compress=True");
            try
            {
                Connection.Open();
                C = Connection.CreateCommand();
                C.CommandText = @"SELECT user, password , owner FROM myusers WHERE user ='******'";
                DataReader = C.ExecuteReader();
                while (DataReader.Read())
                {
                    t.User = DataReader["user"].ToString();
                    t.Password = DataReader["password"].ToString();
                    t.Owner = DataReader["owner"].ToString();
                }
            }
            catch (Exception ex)
            {
                MyDelegates.OnDebugMessageCallBack(ex.StackTrace);
                return null;
            }
            finally
            {
                if (Connection.State != ConnectionState.Closed) { Connection.Close(); }
            }

            return t;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// check OnNewDir if dir is a dupe
        /// </summary>
        /// <param name="args">input arguments</param>
        /// <returns><c>true</c> if dir is a dupe</returns>
        public static bool CheckDupeNewDir(string[] args)
        {
            Log.Info("->");

            if (!SkipDupe.CheckSkipDupe(args))
            {
                return false;
            }

            SQLiteConnection sqlite_conn;
            SQLiteCommand sqlite_cmd;
            SQLiteDataReader sqlite_datareader;

            string dbName = ConfigReader.GetConfig("dbDupeDir");
            string db = String.Format(CultureInfo.InvariantCulture,
                @"Data Source={0};Version=3;New=False;Compress=True;", dbName);
            sqlite_conn = new SQLiteConnection(db);
            sqlite_conn.Open();
            sqlite_cmd = sqlite_conn.CreateCommand();

            string dbCommand = String.Format(CultureInfo.InvariantCulture,
            @"SELECT DISTINCT ReleaseDateTime, UserName, ReleaseName FROM dirDupe WHERE ReleaseName = '{0}'", Global.dupe_name);

            Log.InfoFormat("{0}", dbCommand);

            sqlite_cmd.CommandText = dbCommand;
            //sqlite_cmd.CommandText = "SELECT * FROM dirDupe";
            sqlite_datareader=sqlite_cmd.ExecuteReader();

            bool found = false;
            DateTime CurrTime = DateTime.Now;
            string skipDateFormat = ConfigReader.GetConfig("skipDateFormat");

            while (sqlite_datareader.Read())
            {
                Global.dupe_creator = sqlite_datareader["UserName"].ToString();
                Global.dupe_datetime = sqlite_datareader["ReleaseDateTime"].ToString();
                Global.dupe_name = sqlite_datareader["ReleaseName"].ToString();
                Global.dupe_tryer = Global.user;

                Console.WriteLine(
                    Format.FormatStr1ng(
                        ConfigReader.GetConfig("msgDirIsDupe"), 0, null
                    ));

                string anounceDirIsDupe = ConfigReader.GetConfig("anounceDirIsDupe");
                if ( (anounceDirIsDupe != null) && (anounceDirIsDupe == "true") )
                {
                    Console.WriteLine(
                        Format.FormatStr1ng(ConfigReader.GetConfig("mircDirIsDupe"), 0, null));
                }

                Log.InfoFormat("Dir Is A Dupe! It Was Created By {0} On {1}",
                    sqlite_datareader["UserName"], sqlite_datareader["ReleaseDateTime"]);
                found = true;
            }
            sqlite_datareader.Close();

            if ( !found )
            {
                string what = "(ReleaseTime, ReleaseDateTime, ReleaseName, Pwd, UserName, GroupName)";
                string values = String.Format(CultureInfo.InvariantCulture,
                    "({4}, '{5}', '{0}', '{1}', '{2}', '{3}')",
                    Global.dupe_name,
                    Global.dupe_pwd,
                    Environment.GetEnvironmentVariable("USER"),
                    Environment.GetEnvironmentVariable("GROUP"),
                    CurrTime.Ticks,
                    CurrTime.ToString(skipDateFormat));

                string insertCommand =
                    String.Format(CultureInfo.InvariantCulture,
                    @"INSERT INTO dirDupe {0} VALUES {1};", what, values);

                Log.InfoFormat("{0}", insertCommand);

                sqlite_cmd.CommandText = insertCommand;
                sqlite_cmd.ExecuteNonQuery();
            }

            sqlite_conn.Close();

            Log.Info("<-");

            if ( !found )
                return false;
            else
                return true;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// update user 
        /// </summary>
        /// <param name="user"></param>
        /// <param name="password"></param>
        /// <param name="owner"></param>
        /// <param name="oldnick"></param>
        internal void UpdateUserIn(string user, string password, string owner ,string oldnick)
        {
            string file = AppDomain.CurrentDomain.BaseDirectory +
                      "Database\\Shamia.db";
            if (Connection.State != ConnectionState.Closed) { Connection.Close(); }
            Connection = new SQLiteConnection("Data Source=" + file + ";Version=3" +
                                              ";New=False;Compress=True");

            try
            {
                Connection.Open();
                C = Connection.CreateCommand();
                C.CommandText = "UPDATE myusers SET user ='******',"+
                    "password='******'," +
                    "owner='" + owner + "'" +
                    " WHERE user='******'";
                C.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MyDelegates.OnDebugMessageCallBack(ex.StackTrace);
            }
            finally
            {
                if (Connection.State != ConnectionState.Closed) { Connection.Close(); }
            }
        }
Ejemplo n.º 25
0
        private void continua_Click(object sender, EventArgs e)
        {
            if (decizie == "info")
            {
                panel1.Enabled = true;
                panel2.Enabled = true;
                panel3.Enabled = true;
                current_number++;
                if (current_number <= number_of_questions)
                {

                    question.Text = current_number.ToString();
                    random_id = rand.Next(0, maximum);
                    while (search(random_id) == false)
                        random_id = rand.Next(0, maximum);
                    passed_questions[current_number] = random_id;
                    SQLiteConnection sqlite_conn;
                    SQLiteCommand sqlite_cmd;
                    SQLiteDataReader sqlite_datareader;
                    sqlite_conn = new SQLiteConnection("Data Source=Intrebari.db;Version=3;New=False;Compress=True;");
                    sqlite_conn.Open();
                    sqlite_cmd = sqlite_conn.CreateCommand();
                    sqlite_cmd.CommandText = "SELECT * FROM intrebari";
                    sqlite_datareader = sqlite_cmd.ExecuteReader();
                    while (sqlite_datareader.Read())
                    {
                        String string_id = sqlite_datareader.GetString(0);
                        int id = Int32.Parse(string_id);
                        String text_intrebare = sqlite_datareader.GetString(1);
                        String var_1 = sqlite_datareader.GetString(2);
                        String var_2 = sqlite_datareader.GetString(3);
                        String var_3 = sqlite_datareader.GetString(4);
                        String var_corecta = sqlite_datareader.GetString(5);

                        if (id == random_id)
                        {
                            richTextBox1.Text = text_intrebare;
                            varianta_1.Text = var_1;
                            varianta_2.Text = var_2;
                            varianta_3.Text = var_3;
                            write_answer = var_corecta;
                            cap_parental = sqlite_datareader.GetString(6);
                        }
                    }
                    sqlite_conn.Close();
                }
                else
                {
                    MessageBox.Show("Intrebarile s-au terminat, te rugam sa astepti rezultatul...");
                    float procentaj;

                    procentaj = write_questions * 100 / number_of_questions;
                    Procentaj = procentaj;
                    Debug.WriteLine("---------------------------");
                    Debug.WriteLine(write_questions);
                    Debug.WriteLine("---------------------------");
                    Debug.WriteLine(procentaj);
                    MessageBox.Show("Procentrajul tau este de " + procentaj.ToString() + "%");
                    for (int i = 1; i <= j; i++)
                        {
                           // MessageBox.Show(capitole[i].ToString());
                            down.capitole_revizuit[i] = capitole[i];
                        }
                    /*bck inc = new bck();
                    this.Hide();
                    inc.ShowDialog();*/
                    string procent = Procentaj.ToString();
                    procent = procent + "%";
                    SQLiteConnection conn;
                    SQLiteCommand sqlite_cmd;
                    SQLiteDataReader sqlite_datareader;
                    conn = new SQLiteConnection("Data Source=LOGIN.db;Version=3;New=False;Compress=True;");
                    conn.Open();
                    sqlite_cmd = conn.CreateCommand();
                    sqlite_cmd.CommandText = "SELECT * FROM utilizatori where username='******'";
                    sqlite_datareader = sqlite_cmd.ExecuteReader();
                    while (sqlite_datareader.Read())
                    {
                        punctaj1 = sqlite_datareader.GetString(5);
                        punctaj2 = sqlite_datareader.GetString(6);
                        punctaj3 = sqlite_datareader.GetString(7);
                        punctaj4 = sqlite_datareader.GetString(8);
                        punctaj5 = sqlite_datareader.GetString(9);
                    }
                    if (punctaj1 == "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct1 ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj2 == "" && punctaj1 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct2 ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj3 == "" && punctaj1 != "" && punctaj2 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct3 ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj4 == "" && punctaj1 != "" && punctaj2 != "" && punctaj3 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct4 ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj5 == "" && punctaj1 != "" && punctaj2 != "" && punctaj3 != "" && punctaj4 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct5 ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj5 != "" && punctaj1 != "" && punctaj2 != "" && punctaj3 != "" && punctaj4 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct1 ='" + punctaj2 + "', pct2 ='" + punctaj3 + "', pct3 ='" + punctaj4 + "', pct4 ='" + punctaj5 + "', pct5 ='" + procent + "'where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    conn.Close();
                    down rt = new down();
                    this.Hide();
                    rt.ShowDialog();

                }
            }

            if(decizie == "mate")
            {
                panel1.Enabled = true;
                panel2.Enabled = true;
                panel3.Enabled = true;
                current_number++;
                if (current_number <= number_of_questions)
                {

                    question.Text = current_number.ToString();
                    random_id = rand.Next(0, maximum);
                    while (search(random_id) == false)
                        random_id = rand.Next(0, maximum);
                    passed_questions[current_number] = random_id;
                    SQLiteConnection sqlite_conn;
                    SQLiteCommand sqlite_cmd;
                    SQLiteDataReader sqlite_datareader;
                    sqlite_conn = new SQLiteConnection("Data Source=Intrebari_mate.db;Version=3;New=False;Compress=True;");
                    sqlite_conn.Open();
                    sqlite_cmd = sqlite_conn.CreateCommand();
                    sqlite_cmd.CommandText = "SELECT * FROM intrebari_mate";
                    sqlite_datareader = sqlite_cmd.ExecuteReader();
                    while (sqlite_datareader.Read())
                    {
                        String string_id = sqlite_datareader.GetString(0);
                        int id = Int32.Parse(string_id);
                        String text_intrebare = sqlite_datareader.GetString(1);
                        String var_1 = sqlite_datareader.GetString(2);
                        String var_2 = sqlite_datareader.GetString(3);
                        String var_3 = sqlite_datareader.GetString(4);
                        String var_corecta = sqlite_datareader.GetString(5);

                        if (id == random_id)
                        {
                            richTextBox1.Text = text_intrebare;
                            varianta_1.Text = var_1;
                            varianta_2.Text = var_2;
                            varianta_3.Text = var_3;
                            write_answer = var_corecta;
                            cap_parental = sqlite_datareader.GetString(6);
                        }
                    }
                    sqlite_conn.Close();
                }
                else
                {
                    MessageBox.Show("Intrebarile s-au terminat, te rugam sa astepti rezultatul...");
                    float procentaj;

                    procentaj = write_questions * 100 / number_of_questions;
                    Procentaj = procentaj;
                    Debug.WriteLine("---------------------------");
                    Debug.WriteLine(write_questions);
                    Debug.WriteLine("---------------------------");
                    Debug.WriteLine(procentaj);
                    MessageBox.Show("Procentrajul tau este de " + procentaj.ToString() + "%");
                    for (int i = 1; i <= j; i++)
                    {
                        // MessageBox.Show(capitole[i].ToString());
                        down.capitole_revizuit[i] = capitole[i];
                    }
                    /*bck inc = new bck();
                    this.Hide();
                    inc.ShowDialog();*/
                    string procent = Procentaj.ToString();
                    procent = procent + "%";
                    SQLiteConnection conn;
                    SQLiteCommand sqlite_cmd;
                    SQLiteDataReader sqlite_datareader;
                    conn = new SQLiteConnection("Data Source=LOGIN.db;Version=3;New=False;Compress=True;");
                    conn.Open();
                    sqlite_cmd = conn.CreateCommand();
                    sqlite_cmd.CommandText = "SELECT * FROM utilizatori where username='******'";
                    sqlite_datareader = sqlite_cmd.ExecuteReader();
                    while (sqlite_datareader.Read())
                    {
                        punctaj1 = sqlite_datareader.GetString(10);
                        punctaj2 = sqlite_datareader.GetString(11);
                        punctaj3 = sqlite_datareader.GetString(12);
                        punctaj4 = sqlite_datareader.GetString(13);
                        punctaj5 = sqlite_datareader.GetString(14);
                    }
                    if (punctaj1 == "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct1_mate ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj2 == "" && punctaj1 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct2_mate ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj3 == "" && punctaj1 != "" && punctaj2 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct3_mate ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj4 == "" && punctaj1 != "" && punctaj2 != "" && punctaj3 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct4_mate ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj5 == "" && punctaj1 != "" && punctaj2 != "" && punctaj3 != "" && punctaj4 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct5_mate ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj5 != "" && punctaj1 != "" && punctaj2 != "" && punctaj3 != "" && punctaj4 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct1_mate ='" + punctaj2 + "', pct2_mate ='" + punctaj3 + "', pct3_mate ='" + punctaj4 + "', pct4_mate ='" + punctaj5 + "', pct5_mate ='" + procent + "'where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    conn.Close();
                    down rt = new down();
                    this.Hide();
                    rt.ShowDialog();

                }
            }

            if (decizie == "bio")
            {
                panel1.Enabled = true;
                panel2.Enabled = true;
                panel3.Enabled = true;
                current_number++;
                if (current_number <= number_of_questions)
                {

                    question.Text = current_number.ToString();
                    random_id = rand.Next(0, maximum);
                    while (search(random_id) == false)
                        random_id = rand.Next(0, maximum);
                    passed_questions[current_number] = random_id;
                    SQLiteConnection sqlite_conn;
                    SQLiteCommand sqlite_cmd;
                    SQLiteDataReader sqlite_datareader;
                    sqlite_conn = new SQLiteConnection("Data Source=Intrebari_bio.db;Version=3;New=False;Compress=True;");
                    sqlite_conn.Open();
                    sqlite_cmd = sqlite_conn.CreateCommand();
                    sqlite_cmd.CommandText = "SELECT * FROM intrebari_bio";
                    sqlite_datareader = sqlite_cmd.ExecuteReader();
                    while (sqlite_datareader.Read())
                    {
                        String string_id = sqlite_datareader.GetString(0);
                        int id = Int32.Parse(string_id);
                        String text_intrebare = sqlite_datareader.GetString(1);
                        String var_1 = sqlite_datareader.GetString(2);
                        String var_2 = sqlite_datareader.GetString(3);
                        String var_3 = sqlite_datareader.GetString(4);
                        String var_corecta = sqlite_datareader.GetString(5);

                        if (id == random_id)
                        {
                            richTextBox1.Text = text_intrebare;
                            varianta_1.Text = var_1;
                            varianta_2.Text = var_2;
                            varianta_3.Text = var_3;
                            write_answer = var_corecta;
                            cap_parental = sqlite_datareader.GetString(6);
                        }
                    }
                    sqlite_conn.Close();
                }
                else
                {
                    MessageBox.Show("Intrebarile s-au terminat, te rugam sa astepti rezultatul...");
                    float procentaj;

                    procentaj = write_questions * 100 / number_of_questions;
                    Procentaj = procentaj;
                    Debug.WriteLine("---------------------------");
                    Debug.WriteLine(write_questions);
                    Debug.WriteLine("---------------------------");
                    Debug.WriteLine(procentaj);
                    MessageBox.Show("Procentrajul tau este de " + procentaj.ToString() + "%");
                    for (int i = 1; i <= j; i++)
                    {
                        // MessageBox.Show(capitole[i].ToString());
                        down.capitole_revizuit[i] = capitole[i];
                    }
                    /*bck inc = new bck();
                    this.Hide();
                    inc.ShowDialog();*/
                    string procent = Procentaj.ToString();
                    procent = procent + "%";
                    SQLiteConnection conn;
                    SQLiteCommand sqlite_cmd;
                    SQLiteDataReader sqlite_datareader;
                    conn = new SQLiteConnection("Data Source=LOGIN.db;Version=3;New=False;Compress=True;");
                    conn.Open();
                    sqlite_cmd = conn.CreateCommand();
                    sqlite_cmd.CommandText = "SELECT * FROM utilizatori where username='******'";
                    sqlite_datareader = sqlite_cmd.ExecuteReader();
                    while (sqlite_datareader.Read())
                    {
                        punctaj1 = sqlite_datareader.GetString(15);
                        punctaj2 = sqlite_datareader.GetString(16);
                        punctaj3 = sqlite_datareader.GetString(17);
                        punctaj4 = sqlite_datareader.GetString(18);
                        punctaj5 = sqlite_datareader.GetString(19);
                    }
                    if (punctaj1 == "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct1_bio ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj2 == "" && punctaj1 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct2_bio ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj3 == "" && punctaj1 != "" && punctaj2 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct3_bio ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj4 == "" && punctaj1 != "" && punctaj2 != "" && punctaj3 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct4_bio ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj5 == "" && punctaj1 != "" && punctaj2 != "" && punctaj3 != "" && punctaj4 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct5_bio ='" + procent.ToString() + "' where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    if (punctaj5 != "" && punctaj1 != "" && punctaj2 != "" && punctaj3 != "" && punctaj4 != "")
                    {
                        SQLiteCommand sql_command;
                        sql_command = conn.CreateCommand();
                        sql_command.CommandText = ("update utilizatori set pct1_bio ='" + punctaj2 + "', pct2_bio ='" + punctaj3 + "', pct3_bio ='" + punctaj4 + "', pct4_bio ='" + punctaj5 + "', pct5_bio ='" + procent + "'where username ='******'");
                        sql_command.ExecuteNonQuery();
                    }
                    conn.Close();
                    down rt = new down();
                    this.Hide();
                    rt.ShowDialog();

                }
            }
        }
Ejemplo n.º 26
0
        private void creeaza_Click(object sender, EventArgs e)
        {
            if (checkBox1.Checked == true && textBox1.Text != null && richTextBox1.Text != null)
            {
                if(decizie=="info")
                    {
                        try
                        {
                            SQLiteConnection sqlite_conn;
                            SQLiteCommand sqlite_cmd;
                            sqlite_conn = new SQLiteConnection("Data Source=Capitole.db;Version=3;New=False;Compress=True;");
                            sqlite_conn.Open();
                            sqlite_cmd = sqlite_conn.CreateCommand();
                            sqlite_cmd.CommandText = "INSERT INTO capitole(titlu, teorie, id_html) " +
                                                                      "Values(@titlu, @teorie, @fd)";
                            SQLiteParameter param1 = new SQLiteParameter("@titlu", DbType.String);
                            SQLiteParameter param2 = new SQLiteParameter("@teorie", DbType.String);
                            SQLiteParameter param3 = new SQLiteParameter("@fd", DbType.String);
                            param1.Value = textBox1.Text;
                            param2.Value = richTextBox1.Text;
                            param3.Value = folder_guid.ToString();
                            sqlite_cmd.Parameters.Add(param1);
                            sqlite_cmd.Parameters.Add(param2);
                            sqlite_cmd.Parameters.Add(param3);
                            sqlite_cmd.ExecuteNonQuery();
                            MessageBox.Show("Capitolul a fost adaugat cu succes!");
                            sqlite_conn.Close();
                            textBox1.Clear();
                            richTextBox1.Clear();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }

                if(decizie=="mate")
                {
                    try
                    {
                        SQLiteConnection sqlite_conn;
                        SQLiteCommand sqlite_cmd;
                        sqlite_conn = new SQLiteConnection("Data Source=Capitole_mate.db;Version=3;New=False;Compress=True;");
                        sqlite_conn.Open();
                        sqlite_cmd = sqlite_conn.CreateCommand();
                        sqlite_cmd.CommandText = "INSERT INTO capitole_mate(titlu, teorie, id_html) values (@titlu, @teorie, @fd)";
                        SQLiteParameter param4 = new SQLiteParameter("@titlu", DbType.String);
                        SQLiteParameter param5 = new SQLiteParameter("@teorie", DbType.String);
                        SQLiteParameter param6 = new SQLiteParameter("@fd", DbType.String);
                        param4.Value = textBox1.Text;
                        param5.Value = richTextBox1.Text;
                        param6.Value = folder_guid.ToString();
                        sqlite_cmd.Parameters.Add(param4);
                        sqlite_cmd.Parameters.Add(param5);
                        sqlite_cmd.Parameters.Add(param6);
                        sqlite_cmd.ExecuteNonQuery();
                        MessageBox.Show("Capitolul a fost adaugat cu succes!");
                        sqlite_conn.Close();
                        textBox1.Clear();
                        richTextBox1.Clear();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                if (decizie == "bio")
                {
                    try
                    {
                        SQLiteConnection sqlite_conn;
                        SQLiteCommand sqlite_cmd;
                        sqlite_conn = new SQLiteConnection("Data Source=Capitole_bio.db;Version=3;New=False;Compress=True;");
                        sqlite_conn.Open();
                        sqlite_cmd = sqlite_conn.CreateCommand();
                        sqlite_cmd.CommandText = "INSERT INTO capitole_bio(titlu, teorie, id_html) " +
                                                                      "Values(@titlu, @teorie, @fd)";
                        SQLiteParameter param1 = new SQLiteParameter("@titlu", DbType.String);
                        SQLiteParameter param2 = new SQLiteParameter("@teorie", DbType.String);
                        SQLiteParameter param3 = new SQLiteParameter("@fd", DbType.String);
                        param1.Value = textBox1.Text;
                        param2.Value = richTextBox1.Text;
                        param3.Value = folder_guid.ToString();
                        sqlite_cmd.Parameters.Add(param1);
                        sqlite_cmd.Parameters.Add(param2);
                        sqlite_cmd.Parameters.Add(param3);
                        sqlite_cmd.ExecuteNonQuery();
                        MessageBox.Show("Capitolul a fost adaugat cu succes!");
                        sqlite_conn.Close();
                        textBox1.Clear();
                        richTextBox1.Clear();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            else if (checkBox2.Checked == true && textBox1.Text != null && richTextBox1.Text != null)
            {
                if (decizie == "info")
                {
                    try
                    {
                        SQLiteConnection sqlite_conn;
                        SQLiteCommand sqlite_cmd;
                        sqlite_conn = new SQLiteConnection("Data Source=Subcapitole.db;Version=3;New=False;Compress=True;");
                        sqlite_conn.Open();
                        sqlite_cmd = sqlite_conn.CreateCommand();
                        sqlite_cmd.CommandText = "INSERT INTO subcapitole(nume_subcapitol,text_subcapitol,nume_capitol,id_animatie, id_html) " +
                                                                  "Values(@ns,@ts,@nc,@ida,@idh)";
                        SQLiteParameter param1 = new SQLiteParameter("@ns", DbType.String);
                        SQLiteParameter param2 = new SQLiteParameter("@ts", DbType.String);
                        SQLiteParameter param3 = new SQLiteParameter("@nc", DbType.String);
                        SQLiteParameter param4 = new SQLiteParameter("@ida", DbType.String);
                        SQLiteParameter param5 = new SQLiteParameter("@idh", DbType.String);
                        param1.Value = textBox1.Text;
                        param2.Value = richTextBox1.Text;
                        param3.Value = capitol_parental;
                        param4.Value = cod_guid;
                        param5.Value = folder_guid.ToString();
                        sqlite_cmd.Parameters.Add(param1);
                        sqlite_cmd.Parameters.Add(param2);
                        sqlite_cmd.Parameters.Add(param3);
                        sqlite_cmd.Parameters.Add(param4);
                        sqlite_cmd.Parameters.Add(param5);
                        sqlite_cmd.ExecuteNonQuery();
                        MessageBox.Show("Subcapitolul a fost adaugat cu succes!");
                        sqlite_conn.Close();
                        textBox1.Clear();
                        richTextBox1.Clear();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                if (decizie == "bio")
                {
                    try
                    {
                        SQLiteConnection sqlite_conn;
                        SQLiteCommand sqlite_cmd;
                        sqlite_conn = new SQLiteConnection("Data Source=Subcapitole_bio.db;Version=3;New=False;Compress=True;");
                        sqlite_conn.Open();
                        sqlite_cmd = sqlite_conn.CreateCommand();
                        sqlite_cmd.CommandText = "INSERT INTO subcapitole_bio(nume_subcapitol,text_subcapitol,nume_capitol,id_animatie, id_html) " +
                                                                  "Values(@ns,@ts,@nc,@ida,@idh)";
                        SQLiteParameter param1 = new SQLiteParameter("@ns", DbType.String);
                        SQLiteParameter param2 = new SQLiteParameter("@ts", DbType.String);
                        SQLiteParameter param3 = new SQLiteParameter("@nc", DbType.String);
                        SQLiteParameter param4 = new SQLiteParameter("@ida", DbType.String);
                        SQLiteParameter param5 = new SQLiteParameter("@idh", DbType.String);
                        param1.Value = textBox1.Text;
                        param2.Value = richTextBox1.Text;
                        param3.Value = capitol_parental;
                        param4.Value = cod_guid;
                        param5.Value = folder_guid.ToString();
                        sqlite_cmd.Parameters.Add(param1);
                        sqlite_cmd.Parameters.Add(param2);
                        sqlite_cmd.Parameters.Add(param3);
                        sqlite_cmd.Parameters.Add(param4);
                        sqlite_cmd.Parameters.Add(param5);

                        sqlite_cmd.ExecuteNonQuery();
                        MessageBox.Show("Subcapitolul a fost adaugat cu succes!");
                        sqlite_conn.Close();
                        textBox1.Clear();
                        richTextBox1.Clear();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                if (decizie == "mate")
                {
                    try
                    {
                        SQLiteConnection sqlite_conn;
                        SQLiteCommand sqlite_cmd;
                        sqlite_conn = new SQLiteConnection("Data Source=Subcapitole_mate.db;Version=3;New=False;Compress=True;");
                        sqlite_conn.Open();
                        sqlite_cmd = sqlite_conn.CreateCommand();
                        sqlite_cmd.CommandText = "INSERT INTO subcapitole_mate(nume_subcapitol,text_subcapitol,nume_capitol,id_animatie, id_html) " +
                                                                  "Values(@ns,@ts,@nc,@ida,@idh)";
                        SQLiteParameter param1 = new SQLiteParameter("@ns", DbType.String);
                        SQLiteParameter param2 = new SQLiteParameter("@ts", DbType.String);
                        SQLiteParameter param3 = new SQLiteParameter("@nc", DbType.String);
                        SQLiteParameter param4 = new SQLiteParameter("@ida", DbType.String);
                        SQLiteParameter param5 = new SQLiteParameter("@idh", DbType.String);
                        param1.Value = textBox1.Text;
                        param2.Value = richTextBox1.Text;
                        param3.Value = capitol_parental;
                        param4.Value = cod_guid;
                        param5.Value = folder_guid.ToString();
                        sqlite_cmd.Parameters.Add(param1);
                        sqlite_cmd.Parameters.Add(param2);
                        sqlite_cmd.Parameters.Add(param3);
                        sqlite_cmd.Parameters.Add(param4);
                        sqlite_cmd.Parameters.Add(param5);
                        sqlite_cmd.ExecuteNonQuery();
                        MessageBox.Show("Subcapitolul a fost adaugat cu succes!");
                        sqlite_conn.Close();
                        textBox1.Clear();
                        richTextBox1.Clear();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            else
                MessageBox.Show("Toate campurile trebuie sa fie completate iar un checkBox selectat!");
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            SQLiteConnection new_con = new SQLiteConnection(customwindow.Properties.Settings.Default.ConnectionString.ToString());            
            new_con.Open();
            SQLiteCommand addAr = new SQLiteCommand("Select * from reminder where rid='" + Convert.ToInt32(cnt) + "'", new_con);
            SQLiteDataReader reader;
            reader = addAr.ExecuteReader();
            while (reader.Read())
            {
                ReminderName.Text = reader[2].ToString();
                DatePicker1.Text = reader[1].ToString();
                TimePicker.DateTimeText =  Convert.ToDateTime(reader[5].ToString()).ToShortTimeString();               
                Note.Text = reader[3].ToString();
                NumericUpDown1.Value = Convert.ToDouble(reader[4].ToString());

            }
            new_con.Close();
        }
Ejemplo n.º 28
0
        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            adauga_animatie.Visible = true;
            var items = checkedListBox1.Items;
            richTextBox1.Enabled = true;
            if (checkBox2.Checked == true)
            {
                checkBox1.Checked = false;
                label3.Visible = true;
                checkedListBox1.Visible = true;
                foreach (var item in checkedListBox1.Items.OfType<string>().ToList())
                {
                    checkedListBox1.Items.Remove(item);
                }
            }
            else
            {
                    checkBox2.Checked = false;
                    label3.Visible = false;
                    checkedListBox1.Visible = false;
                    foreach (var item in checkedListBox1.Items.OfType<string>().ToList())
                    {
                        checkedListBox1.Items.Remove(item);
                    }
            }

            if (decizie == "info")
            {
                SQLiteConnection sqlite_conn;
                SQLiteCommand sqlite_cmd;
                SQLiteDataReader sqlite_datareader;
                sqlite_conn = new SQLiteConnection("Data Source=Capitole.db;Version=3;New=False;Compress=True;");
                sqlite_conn.Open();
                sqlite_cmd = sqlite_conn.CreateCommand();
                sqlite_cmd.CommandText = "SELECT * FROM capitole";
                sqlite_datareader = sqlite_cmd.ExecuteReader();
                while (sqlite_datareader.Read())
                {
                    String myr = sqlite_datareader.GetString(0);
                    items.Add(myr);
                }
                sqlite_conn.Close();
            }
            if (decizie == "mate")
            {
                SQLiteConnection sqlite_conn;
                SQLiteCommand sqlite_cmd;
                SQLiteDataReader sqlite_datareader;
                sqlite_conn = new SQLiteConnection("Data Source=Capitole_mate.db;Version=3;New=False;Compress=True;");
                sqlite_conn.Open();
                sqlite_cmd = sqlite_conn.CreateCommand();
                sqlite_cmd.CommandText = "SELECT * FROM capitole_mate";
                sqlite_datareader = sqlite_cmd.ExecuteReader();
                while (sqlite_datareader.Read())
                {
                    String myr = sqlite_datareader.GetString(1);
                    items.Add(myr);
                }
                sqlite_conn.Close();
            }
            if (decizie == "bio")
            {
                SQLiteConnection sqlite_conn;
                SQLiteCommand sqlite_cmd;
                SQLiteDataReader sqlite_datareader;
                sqlite_conn = new SQLiteConnection("Data Source=Capitole_bio.db;Version=3;New=False;Compress=True;");
                sqlite_conn.Open();
                sqlite_cmd = sqlite_conn.CreateCommand();
                sqlite_cmd.CommandText = "SELECT * FROM capitole_bio";
                sqlite_datareader = sqlite_cmd.ExecuteReader();
                while (sqlite_datareader.Read())
                {
                    String myr = sqlite_datareader.GetString(1);
                    items.Add(myr);
                }
                sqlite_conn.Close();
            }
        }
        private bool verific_numarul(int number_of_questions)
        {
            int max = 0;
            String current_number;
            if (decizie == "info")
            {

                SQLiteConnection sqlite_conn;
                SQLiteCommand sqlite_cmd;
                SQLiteDataReader sqlite_datareader;
                sqlite_conn = new SQLiteConnection("Data Source=Intrebari.db;Version=3;New=False;Compress=True;");
                sqlite_conn.Open();
                sqlite_cmd = sqlite_conn.CreateCommand();
                sqlite_cmd.CommandText = "SELECT * FROM intrebari";
                sqlite_datareader = sqlite_cmd.ExecuteReader();
                while (sqlite_datareader.Read())
                {
                    current_number = sqlite_datareader.GetString(0);
                    Debug.WriteLine(current_number);
                    max = Int32.Parse(current_number);
                }
                sqlite_conn.Close();

            }

            else
                if(decizie == "bio")
                {

                    SQLiteConnection sqlite_conn;
                    SQLiteCommand sqlite_cmd;
                    SQLiteDataReader sqlite_datareader;
                    sqlite_conn = new SQLiteConnection("Data Source=Intrebari_bio.db;Version=3;New=False;Compress=True;");
                    sqlite_conn.Open();
                    sqlite_cmd = sqlite_conn.CreateCommand();
                    sqlite_cmd.CommandText = "SELECT * FROM intrebari_bio";
                    sqlite_datareader = sqlite_cmd.ExecuteReader();
                    while (sqlite_datareader.Read())
                    {
                        current_number = sqlite_datareader.GetString(0);
                        Debug.WriteLine(current_number);
                        max = Int32.Parse(current_number);
                    }
                    sqlite_conn.Close();

                }
                else
                    if(decizie == "mate")
                    {

                        SQLiteConnection sqlite_conn;
                        SQLiteCommand sqlite_cmd;
                        SQLiteDataReader sqlite_datareader;
                        sqlite_conn = new SQLiteConnection("Data Source=Intrebari_mate.db;Version=3;New=False;Compress=True;");
                        sqlite_conn.Open();
                        sqlite_cmd = sqlite_conn.CreateCommand();
                        sqlite_cmd.CommandText = "SELECT * FROM intrebari_mate";
                        sqlite_datareader = sqlite_cmd.ExecuteReader();
                        while (sqlite_datareader.Read())
                        {
                            current_number = sqlite_datareader.GetString(0);
                            Debug.WriteLine(current_number);
                            max = Int32.Parse(current_number);
                        }
                        sqlite_conn.Close();
                    }
            Debug.WriteLine("---------------------------");
            maximum = max;
            if (max <= number_of_questions)
                return false;
            else
                return true;
        }
Ejemplo n.º 30
0
 /** private void MenuViewContacts_Click(object sender, System.Windows.RoutedEventArgs e)
  *  view Contacts
  */
 public void createUserControlContact()
 {
     int i = 0;
     UserControlExpanderContact[] uc = new UserControlExpanderContact[200];
     SQLiteConnection new_con = new SQLiteConnection(customwindow.Properties.Settings.Default.ConnectionString.ToString());
     new_con.Open();
     SQLiteCommand  get = new SQLiteCommand("SELECT * FROM  contact_detail ORDER BY firstname ASC LIMIT 0 , 30", new_con);
     SQLiteDataReader reader;
     reader = get.ExecuteReader();
     String header;
     while (reader.Read())
     {
         header = reader[1].ToString() + "\t\t\t" + reader[2].ToString();
         uc[i] = new UserControlExpanderContact();
         uc[i].setContent(Convert.ToInt32(reader[0].ToString()), reader[2].ToString(), reader[3].ToString(), reader[5].ToString(), reader[4].ToString(), header);
         WrapPanel1.Children.Add(uc[i]);
         i++;
     }
     new_con.Close();
 }