示例#1
0
        // ********** AJOUTER UN JOUEUR  ************************

        public override void Ajouter(Joueur obj)
        {
            try
            {
                int idj;
                SqlCmd.CommandText = "select max(idj) + 1 from joueurs";
                SqlCmd.Parameters.Clear();
                SqlDataReader sqlReader = SqlCmd.ExecuteReader();
                sqlReader.Read();
                if (sqlReader[0] == DBNull.Value)
                {
                    idj = 1;
                }
                else
                {
                    idj = Convert.ToInt32(sqlReader[0]);
                }
                sqlReader.Close();
                SqlCmd.CommandText =
                    "insert into joueurs(idj,nom,prenom,style,nomImage) " +
                    "values(@idj,@nom,@prenom,@style,@nomImage)";
                SqlCmd.Parameters.Clear();
                SqlCmd.Parameters.Add("@idj", SqlDbType.Int).Value          = idj;
                SqlCmd.Parameters.Add("@nom", SqlDbType.VarChar).Value      = obj.Nom;
                SqlCmd.Parameters.Add("@prenom", SqlDbType.VarChar).Value   = obj.Prenom;
                SqlCmd.Parameters.Add("@style", SqlDbType.VarChar).Value    = obj.Style;
                SqlCmd.Parameters.Add("@nomImage", SqlDbType.VarChar).Value = obj.NomImage;

                SqlCmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                throw new ExceptionAccesBD(e.Message);
            }
        }
示例#2
0
        public void likeDislike(bool like_dislike)
        {
            SQLiteConnection Con = new SQLiteConnection(sqlCon);

            Con.Open();
            SQLiteCommand SqlCmd;

            if (theirProfileID == null)
            {
            }
            else
            {
                if (like_dislike)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Liked([profileID], [shownProfileID], [liked]) " +
                                               "VALUES('" + myProfileID + "', '" + theirProfileID + "', 1)", Con);
                }
                else
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Liked([profileID], [shownProfileID], [liked]) " +
                                               "VALUES('" + myProfileID + "', '" + theirProfileID + "', 0)", Con);
                }
                SqlCmd.ExecuteNonQuery();
            }
            Con.Close();
        }
示例#3
0
        public void UpdateCashback(Client client, double cback)
        {
            double newCash;

            if (cashback == 0.0)
            {
                newCash = cback;
            }
            else
            {
                newCash = client.Cashback + cback;
            }
            OpenConnection();
            SqlCmd.CommandText = @"UPDATE clients SET cashback = @cashback WHERE client_id = @clientid";
            SqlCmd.Parameters.Add(new SQLiteParameter("@cashback")
            {
                Value = newCash
            });
            SqlCmd.Parameters.Add(new SQLiteParameter("@clientid")
            {
                Value = client.Id
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();
            reader.Close();
            CloseConnection();
        }
示例#4
0
        public void UpdateTraderPricesChart(SqlServerSavableEntity entity)
        {
            PrepareCon();
            SqlCmd.CommandType = CommandType.StoredProcedure;
            string cmdText = "dbo.sp_" + entity.ElementName + "_update";

            SqlCmd.CommandText = cmdText;

            foreach (KeyValuePair <string, object> pair in entity.Attributes)
            {
                SqlCmd.Parameters.AddWithValue(pair.Key, pair.Value);
            }

            Outputs.Clear();
            foreach (int output in entity.OutputParameters)
            {
                SqlCmd.Parameters[output].Direction = ParameterDirection.Output;
                Outputs.Add(output, 0);
            }
            SqlCmd.ExecuteNonQuery();

            foreach (int output in entity.OutputParameters)
            {
                Outputs[output] = SqlCmd.Parameters[output].Value;
            }
            CloseCon();
        }
示例#5
0
        private Admin CheckAdmin(Admin admin)
        {
            OpenConnection();
            SqlCmd.CommandText = @"SELECT * FROM admins WHERE password = @password";
            SqlCmd.Parameters.Add(new SQLiteParameter("@password")
            {
                Value = admin.Password
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();
            if (reader.Read())
            {
                admin = new Admin(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4),
                                  reader.GetInt32(5), reader.GetString(6), reader.GetString(7), reader.GetString(8), reader.GetString(9));
                reader.Close();
                CloseConnection();
                return(admin);
            }
            else
            {
                return(null);
            }
        }
示例#6
0
        /// <summary>
        /// Save into database
        /// </summary>
        /// <param name="entries"></param>
        public void SubmitChanges(List <ResourceEntry> entries, bool deleteRowNotInResource)
        {
            SqlMaker gen = new SqlMaker(tname.FormalName)
            {
                PrimaryKeys = new string[] { name_column }
            };

            StringBuilder builder = new StringBuilder();
            int           count   = 0;
            int           max     = 1000;

            foreach (var entry in entries)
            {
                gen.Clear();
                gen.Add(name_column, entry.Name);
                gen.Add(value_column, entry.NewValue);
                if (order_column != null)
                {
                    gen.Add(order_column, entry.Index);
                }

                switch (entry.Action)
                {
                case DataRowAction.Add:
                    builder.AppendLine(gen.Insert());
                    break;

                case DataRowAction.Change:
                    builder.AppendLine(gen.Update());
                    break;

                case DataRowAction.Delete:
                    if (deleteRowNotInResource)
                    {
                        builder.AppendLine(gen.Delete());
                    }
                    break;
                }

                count = (count + 1) % max;
                if (count == 0)
                {
                    ExecuteNonQuery();
                }
            }

            ExecuteNonQuery();

            void ExecuteNonQuery()
            {
                string SQL = builder.ToString();

                builder.Clear();
                if (!string.IsNullOrEmpty(SQL))
                {
                    SqlCmd cmd = new SqlCmd(tname.Provider, SQL);
                    cmd.ExecuteNonQuery();
                }
            }
        }
示例#7
0
        public void UpdateMoneyBox(Client client, double mbox)
        {
            double newCash;

            if (mbox == 0.0)
            {
                newCash = mbox;
            }
            else
            {
                newCash = client.Moneybox + mbox;
            }
            OpenConnection();
            SqlCmd.CommandText = @"UPDATE clients SET moneybox = @moneybox WHERE client_id = @clientid";
            SqlCmd.Parameters.Add(new SQLiteParameter("@moneybox")
            {
                Value = newCash
            });
            SqlCmd.Parameters.Add(new SQLiteParameter("@clientid")
            {
                Value = client.Id
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();
            reader.Close();
            CloseConnection();
        }
示例#8
0
        public Company GetCompanyById(int compId)
        {
            OpenConnection();
            SqlCmd.CommandText = @"SELECT * FROM companies WHERE company_id = @companyId";
            SqlCmd.Parameters.Add(new SQLiteParameter("@companyId")
            {
                Value = compId
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();
            if (reader.Read())
            {
                Company comp = new Company(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.Close();
                CloseConnection();
                return(comp);
            }
            else
            {
                return(null);
            }
        }
示例#9
0
        public Client GetClientById(int clientId)
        {
            OpenConnection();
            SqlCmd.CommandText = @"SELECT * FROM clients WHERE client_id = @clientId";
            SqlCmd.Parameters.Add(new SQLiteParameter("@clientId")
            {
                Value = clientId
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();
            if (reader.Read())
            {
                Client client = new Client(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4),
                                           reader.GetInt32(5), reader.GetString(6), reader.GetString(7), reader.GetString(8), reader.GetString(9),
                                           reader.GetString(10), reader.GetDouble(11), reader.GetInt32(12));
                reader.Close();
                CloseConnection();
                return(client);
            }
            else
            {
                return(null);
            }
        }
示例#10
0
        // ********** AJOUTER UNE EQUIPE  ************************

        public override void Ajouter(Equipe obj)
        {
            try
            {
                int ide;
                SqlCmd.CommandText = "select max(ide) + 1 from equipe";
                SqlCmd.Parameters.Clear();
                SqlDataReader sqlReader = SqlCmd.ExecuteReader();
                sqlReader.Read();
                if (sqlReader[0] == DBNull.Value)
                {
                    ide = 1;
                }
                else
                {
                    ide = Convert.ToInt32(sqlReader[0]);
                }
                sqlReader.Close();
                SqlCmd.CommandText =
                    "insert into equipe(ide,nom,joueur1,joueur2) " +
                    "values(@ide,@nom,@joueur1,@joueur2)";
                SqlCmd.Parameters.Clear();
                SqlCmd.Parameters.Add("@ide", SqlDbType.Int).Value     = ide;
                SqlCmd.Parameters.Add("@nom", SqlDbType.VarChar).Value = obj.Nom;
                SqlCmd.Parameters.Add("@joueur1", SqlDbType.Int).Value = obj.Joueur1;
                SqlCmd.Parameters.Add("@joueur2", SqlDbType.Int).Value = obj.Joueur2;


                SqlCmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                throw new ExceptionAccesBD(e.Message);
            }
        }
示例#11
0
文件: SQLHelper.cs 项目: 123356/123
 /// <summary>
 /// 执行SQL语句操作(Update,Delete,Insert),返回受影响的行数
 /// </summary>
 /// <param name="sql">SQL语句</param>
 /// <param name="parms">参数集合</param>
 /// <returns>受影响的行数</returns>
 public int ExectueNonQueryBySql(string sql, SqlParameter[] parms = null)
 {
     try
     {
         if (SqlCon.State != ConnectionState.Open)
         {
             SqlCon.Open();
         }
         SqlCmd             = SqlTransactionFlag ? new SqlCommand(sql, SqlCon, SqlTran) : new SqlCommand(sql, SqlCon);
         SqlCmd.CommandType = CommandType.Text;
         if (parms != null)
         {
             AddParameters(parms);
         }
         return(SqlCmd.ExecuteNonQuery());
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         SqlCmd.Dispose();
         if (!SqlTransactionFlag)
         {
             SqlCon.Close();
             SqlCon.Dispose();
         }
     }
 }
示例#12
0
        private Company CheckCompany(Company comp)
        {
            OpenConnection();
            SqlCmd.CommandText = @"SELECT * FROM companies WHERE login = @login and password = @password";
            SqlCmd.Parameters.Add(new SQLiteParameter("@login")
            {
                Value = comp.Login
            });
            SqlCmd.Parameters.Add(new SQLiteParameter("@password")
            {
                Value = comp.Password
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();
            if (reader.Read())
            {
                comp = new Company(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.Close();
                CloseConnection();
                return(comp);
            }
            else
            {
                return(null);
            }
        }
示例#13
0
        public Card GetCurrentCard(Card card)
        {
            OpenConnection();
            SqlCmd.CommandText = @"SELECT * FROM cards WHERE cardnumber = @cardnumber";
            SqlCmd.Parameters.Add(new SQLiteParameter("@cardnumber")
            {
                Value = card.CardNumber
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();

            if (reader.Read())
            {
                card = new Card(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetInt32(3),
                                reader.GetInt32(4), reader.GetString(5), reader.GetString(6), reader.GetInt32(7), reader.GetInt32(8), CheckConfirm(reader.GetInt32(9)));
                reader.Close();
                CloseConnection();
                return(card);
            }
            else
            {
                return(null);
            }
        }
示例#14
0
        private Client CheckClient(Client client)
        {
            OpenConnection();
            SqlCmd.CommandText = @"SELECT * FROM clients WHERE login = @login and password = @password";
            SqlCmd.Parameters.Add(new SQLiteParameter("@login")
            {
                Value = client.Login
            });
            SqlCmd.Parameters.Add(new SQLiteParameter("@password")
            {
                Value = client.Password
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();
            if (reader.Read())
            {
                client = new Client(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4),
                                    reader.GetInt32(5), reader.GetString(6), reader.GetString(7), reader.GetString(8), reader.GetString(9),
                                    reader.GetString(10), reader.GetDouble(11), reader.GetInt32(12));
                reader.Close();
                CloseConnection();
                return(client);
            }
            else
            {
                return(null);
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                Con_UsersDB.Close();
                Con_UsersDB.Open();
                SQLiteCommand SqlCmd = new SQLiteCommand();

                if (comboBox1.SelectedIndex == 0)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Users(Username, [Password], Usertype) VALUES('" + textBox1.Text + "', '" + textBox2.Text + "', 'Bruger');", Con_UsersDB);
                }                                                                                                                                                                                                       //if you selected "Bruger" in the usertype drop down menu, then an insert query without values, will be saved in "SqlCmd"
                if (comboBox1.SelectedIndex == 1)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Users(Username, [Password], Usertype) VALUES('" + textBox1.Text + "', '" + textBox2.Text + "', 'Superbruger');", Con_UsersDB);
                }
                if (comboBox1.SelectedIndex == 2)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Users(Username, [Password], Usertype) VALUES('" + textBox1.Text + "', '" + textBox2.Text + "', 'Administrator');", Con_UsersDB);
                }

                object obj = SqlCmd.ExecuteNonQuery();
                textBox1.Clear();
                textBox2.Clear();
                MessageBox.Show("Data has been submitted");
                Con_UsersDB.Close();
            }
            catch (Exception exc) { MessageBox.Show(exc.Message); }
        }
示例#16
0
 public void AddNewCredit(Credit credit, Card card)
 {
     OpenConnection();
     SqlCmd.CommandText = "INSERT INTO credits ('duration', 'number','cardnumber','client_id','date') values ('" +
                          credit.Duration + "' , '" + credit.Number + "' , '" + credit.CardNumber + "' , '" + credit.ClientId + "' , '" + credit.DateCredit + "')";
     SqlCmd.ExecuteNonQuery();
     CloseConnection();
     CheckNewCredits(card, credit);
 }
示例#17
0
 public void AddNewRequest(Request request)
 {
     OpenConnection();
     SqlCmd.CommandText = "INSERT INTO requests ('client_id', 'admin_id', 'smth_id', 'date', 'descr') values ('" +
                          request.ClientId + "' , '" + request.AdminId + "' , '" + request.SmthId + "','" +
                          request.Date.ToString(CultureInfo.CurrentCulture) + "' , '" + request.Description + "')";
     SqlCmd.ExecuteNonQuery();
     CloseConnection();
 }
示例#18
0
 public void AddNewCompany(Company company)
 {
     OpenConnection();
     SqlCmd.CommandText = "INSERT INTO companies ('name', 'regnumber','adress', 'email','phone', 'login', 'password') values ('" +
                          company.Name + "' , '" + company.RegNumber + "' , '" + company.Adress + "', '" +
                          company.Email + "', '" + company.Phonenumber + "', '" + company.Login + "', '" +
                          company.Password + "', '" + 0 + "', '" + 0 + "')";
     SqlCmd.ExecuteNonQuery();
     CloseConnection();
 }
示例#19
0
        public void CheckTransaction(Card senderCard, string giveCard, int summ)
        {
            Card CardGive = new Card();

            CardGive = CheckGiveCard(giveCard);
            UpdateCards(senderCard, CardGive, summ);
            OpenConnection();
            SqlCmd.CommandText = "INSERT INTO transactions ('sendercard', 'givecard','sum') values ('" +
                                 senderCard.CardNumber + "' , '" + CardGive.CardNumber + "' , '" + summ + "')";
            SqlCmd.ExecuteNonQuery();
            CloseConnection();
        }
示例#20
0
 /// <summary>
 /// Method witch add new client to DataBase
 /// </summary>
 /// <param name="client"></param>
 public void AddNewClient(Client client)
 {
     OpenConnection();
     SqlCmd.CommandText = "INSERT INTO clients ('first_name', 'last_name', 'dateofbirth', " +
                          "'passportseries', 'passportnum', 'adress', 'email','phone', 'login', 'password', 'cashback','moneybox') values ('" +
                          client.Firstname + "' , '" + client.Surname + "' , '" + client.DateOfBirth + "', '" +
                          client.PassportSeries + "', '" + client.PassportNum + "', '" + client.Adress + "', '" +
                          client.Email + "', '" + client.Phonenumber + "', '" + client.Login + "', '" +
                          client.Password + "', '" + 0 + "', '" + 0 + "')";
     SqlCmd.ExecuteNonQuery();
     CloseConnection();
 }
示例#21
0
        public void DeleteSelectedCard(int cardId)
        {
            OpenConnection();
            SqlCmd.CommandText = @"DELETE FROM cards WHERE card_id = @smthid";
            SqlCmd.Parameters.Add(new SQLiteParameter("@smthid")
            {
                Value = cardId
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader = SqlCmd.ExecuteReader();

            CloseConnection();
        }
示例#22
0
        public void DeleteSelectedDeposit(int depositId)
        {
            OpenConnection();
            SqlCmd.CommandText = @"DELETE FROM deposits WHERE deposit_id = @smthid";
            SqlCmd.Parameters.Add(new SQLiteParameter("@smthid")
            {
                Value = depositId
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();
            CloseConnection();
        }
示例#23
0
 public bool AddNewDeposit(Deposit deposit, Card card)
 {
     if (CheckPayingCapacity(deposit.Number, card.Money))
     {
         OpenConnection();
         SqlCmd.CommandText = "INSERT INTO deposits ('duration', 'number','cardnumber','type', 'client_id', 'date') values ('" +
                              deposit.Duration + "' , '" + deposit.Number + "' , '" + deposit.CardNumber + "' , '" + deposit.Type +
                              "' , '" + deposit.ClientId + "' , '" + deposit.DateDeposit + "')";
         SqlCmd.ExecuteNonQuery();
         CloseConnection();
         return(true);
     }
     return(false);
 }
示例#24
0
        private void DeleteRequest(int req_id)
        {
            OpenConnection();
            SqlCmd.CommandText = @"DELETE FROM requests WHERE request_id = @reqId";
            SqlCmd.Parameters.Add(new SQLiteParameter("@reqId")
            {
                Value = req_id
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();
            reader.Close();
            CloseConnection();
        }
示例#25
0
 public void DeleteSelectedItem(string descr, int smthId, int reqId)
 {
     OpenConnection();
     if (descr == null)
     {
         throw new ArgumentNullException(nameof(descr));
     }
     if (descr.Contains("credit"))
     {
         SqlCmd.CommandText = @"DELETE FROM credits WHERE credit_id = @smthid";
         SqlCmd.Parameters.Add(new SQLiteParameter("@smthid")
         {
             Value = smthId
         });
         SqlCmd.ExecuteNonQuery();
         SQLiteDataReader reader;
         reader = SqlCmd.ExecuteReader();
         reader.Close();
     }
     else if (descr.Contains("deposit"))
     {
         SqlCmd.CommandText = @"DELETE FROM deposits WHERE deposit_id = @smthid";
         SqlCmd.Parameters.Add(new SQLiteParameter("@smthid")
         {
             Value = smthId
         });
         SqlCmd.ExecuteNonQuery();
         SQLiteDataReader reader;
         reader = SqlCmd.ExecuteReader();
         reader.Close();
     }
     else if (descr.Contains("card"))
     {
         SqlCmd.CommandText = @"DELETE FROM cards WHERE card_id = @smthid";
         SqlCmd.Parameters.Add(new SQLiteParameter("@smthid")
         {
             Value = smthId
         });
         SqlCmd.ExecuteNonQuery();
         SQLiteDataReader reader;
         reader = SqlCmd.ExecuteReader();
         reader.Close();
     }
     CloseConnection();
     DeleteRequest(reqId);
 }
示例#26
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                Con_fødselsrate_2017.Close();
                Con_fødselsrate_2017.Open();
                SQLiteCommand SqlCmd = new SQLiteCommand();

                if (comboBox1.SelectedIndex == 0)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Africa(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }
                if (comboBox1.SelectedIndex == 1)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Asien(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }
                if (comboBox1.SelectedIndex == 2)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Europa(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }
                if (comboBox1.SelectedIndex == 3)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Mellemamerika(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }
                if (comboBox1.SelectedIndex == 4)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Nordamerika(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }
                if (comboBox1.SelectedIndex == 5)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Oceanien(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }
                if (comboBox1.SelectedIndex == 6)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Sydamerika(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }

                object obj = SqlCmd.ExecuteNonQuery();
                textBox1.Clear();
                textBox2.Clear();
                MessageBox.Show("Data has been submitted");
                Con_fødselsrate_2017.Close();
            }
            catch (Exception exc) { MessageBox.Show(exc.Message); }
        }
示例#27
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                Con_fødselsrate_2017.Close();
                Con_fødselsrate_2017.Open();
                SQLiteCommand SqlCmd = new SQLiteCommand();

                if (comboBox1.SelectedIndex == 0)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Africa(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }                                                                                                                                                                                           //if you selected "Africa" in the drop down menu, then an insert query without values, will be saved in "SqlCmd"
                if (comboBox1.SelectedIndex == 1)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Asien(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }
                if (comboBox1.SelectedIndex == 2)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Europa(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }
                if (comboBox1.SelectedIndex == 3)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Mellemamerika(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }
                if (comboBox1.SelectedIndex == 4)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Nordamerika(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }
                if (comboBox1.SelectedIndex == 5)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Oceanien(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }
                if (comboBox1.SelectedIndex == 6)
                {
                    SqlCmd = new SQLiteCommand("INSERT INTO Sydamerika(Land, Fødselsrate) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "');", Con_fødselsrate_2017);
                }

                object obj = SqlCmd.ExecuteNonQuery();      //executes the query
                textBox1.Clear();                           //clears the "Land" text box
                textBox2.Clear();
                MessageBox.Show("Data has been submitted"); //gives a confirmation that the data has been submitted
                Con_fødselsrate_2017.Close();
            }
            catch (Exception exc) { MessageBox.Show(exc.Message); }
        }
示例#28
0
 /// <summary>
 /// 执行命令返回受影响行数
 /// </summary>
 /// <returns></returns>
 public int ExecNonCmd()
 {
     try
     {
         OpenDb();
         CreateSqlCmd();
         int i = 0;
         i = SqlCmd.ExecuteNonQuery();
         return(i);
     }catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
     finally
     {
         CloseDb();
     }
 }
示例#29
0
        public void UpdateLogin(string data, Client client)
        {
            OpenConnection();
            SqlCmd.CommandText = @"UPDATE clients SET login = @login WHERE client_id = @clientid";
            SqlCmd.Parameters.Add(new SQLiteParameter("@login")
            {
                Value = data
            });
            SqlCmd.Parameters.Add(new SQLiteParameter("@clientid")
            {
                Value = client.Id
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();
            reader.Close();
            CloseConnection();
        }
示例#30
0
        public void UpdateCardMoney(Card card, int moneyg)
        {
            OpenConnection();
            SqlCmd.CommandText = @"UPDATE cards SET money = @money WHERE card_id = @cardid";
            SqlCmd.Parameters.Add(new SQLiteParameter("@money")
            {
                Value = moneyg
            });
            SqlCmd.Parameters.Add(new SQLiteParameter("@cardid")
            {
                Value = card.Id
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();
            reader.Close();
            CloseConnection();
        }