public List <ParticularsSubType> GetParticularsSubTypeList()
        {
            List <ParticularsSubType> subtypeList = new List <ParticularsSubType>();
            ParticularsSubType        subType;

            try
            {
                using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection(BaseDbContext.databasestring))
                {
                    using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
                    {
                        con.Open();                                                               // Open the connection to the database
                        com.CommandText = "Select SubTypeID,SubTypeName FROM ParticularsSubType"; // Select all rows from our database table
                        using (System.Data.SQLite.SQLiteDataReader reader = com.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                subType             = new ParticularsSubType();
                                subType.SubTypeID   = Convert.ToInt32(reader["SubTypeID"]);
                                subType.SubTypeName = Convert.ToString(reader["SubTypeName"]);
                                subtypeList.Add(subType);
                            }
                        }
                        con.Close();        // Close the connection to the database
                    }
                }
                return(subtypeList);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemple #2
0
        public List <Particulars> GetParticularList()
        {
            List <Particulars> verticalList = new List <Particulars>();
            Particulars        vertical;

            try
            {
                using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection(BaseDbContext.databasestring))
                {
                    using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
                    {
                        con.Open();                                                              // Open the connection to the database
                        com.CommandText = "Select ParticularID,ParticularName FROM Particulars"; // Select all rows from our database table
                        using (System.Data.SQLite.SQLiteDataReader reader = com.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                vertical = new Particulars();
                                vertical.ParticularsID   = Convert.ToInt32(reader["ParticularID"]);
                                vertical.ParticularsName = Convert.ToString(reader["ParticularName"]);
                                verticalList.Add(vertical);
                            }
                        }
                        con.Close();        // Close the connection to the database
                    }
                }
                return(verticalList);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemple #3
0
 public CustomButton(System.Data.SQLite.SQLiteDataReader data)
 {
     InitializeComponent();
     id          = int.Parse(data["id"].ToString());
     groupID     = int.Parse(data["groupid"].ToString());
     title       = data["title"].ToString();
     description = data["description"].ToString();
     group       = data["name"].ToString();
     creation    = data.GetDateTime(data.GetOrdinal("CreationDate"));
     if (data["endDate"].ToString() != "")
     {
         end = data.GetDateTime(data.GetOrdinal("endDate"));
     }
     deadline   = data.GetDateTime(data.GetOrdinal("deadline"));
     complete   = data.GetBoolean(data.GetOrdinal("Complete"));
     L1.Content = title;
     L2.Content = deadline.ToString("dddd");
     L3.Content = deadline.ToString("dd MMMM yyyy");
     L4.Content = group;
     tex.Text   = description;
     if (complete)
     {
         Background = new SolidColorBrush(Colors.Gray)
         {
             Opacity = 0.5
         };
     }
     else
     {
         Background = Tools.GetTaskBrush(groupID, id);
     }
 }
Exemple #4
0
        public SqLiteReader(string filepath, string tablename)
        {
            _tableName  = tablename;
            _connection = new System.Data.SQLite.SQLiteConnection("Data Source=" + filepath + ";Version=3;");
            List <Int64> ids = new List <Int64>();
            int          idx = 0;

            Open();
            using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand("SELECT rowid FROM '" + _tableName + "'", _connection))
            {
                using (System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            object tmp = reader[0]; //why does "rowid" not work?
                            ids.Add((Int64)tmp);
                        }
                    }
                }
            }
            Close();
            _rowIds      = ids.ToArray();
            _columnNames = ColumnNames();
        }
Exemple #5
0
        private bool GetYongciAttribute(System.Data.SQLite.SQLiteDataReader reader)
        {
            _yongciAttribute.Add(new AttributeItem(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2),
                                                   reader.GetInt32(3), reader.GetDouble(4), reader.GetString(5)));

            return(true);
        }
Exemple #6
0
        public static List <CardInfo> SelectBound(Int64 id)
        {
            string cmdtext = string.Format(" SELECT Cid,CardNumber,CardType,CardTime,CardDistance,CardLock,CardReportLoss,CardPartition,ParkingRestrictions,Electricity,Synchronous,InOutState,CardCount,ViceCardCount FROM CardInfo where cid in ( select vid from BundledInfo where Cid={0})  ", id);

            System.Data.SQLite.SQLiteDataReader dr = null;
            List <CardInfo> cardinfos = new List <CardInfo>();

            try
            {
                dr = DbHelper.Db.ExecuteReader(cmdtext) as System.Data.SQLite.SQLiteDataReader;
                if (dr.HasRows)
                {
                    PropertyInfo[] pis = typeof(CardInfo).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
                    while (dr.Read())
                    {
                        CardInfo info = new CardInfo();
                        foreach (PropertyInfo item in pis)
                        {
                            item.SetValue(info, dr[item.Name], null);
                        }
                        cardinfos.Add(info);
                    }
                }
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
            }
            return(cardinfos);
        }
Exemple #7
0
        /// <summary>
        /// Get fresh info about Tasks from database and put them into TaskBox
        /// </summary>
        void RefreshTask()
        {
            dataObject.OpenConnection();
            TaskBox.Items.Clear();
            System.Data.SQLite.SQLiteDataReader data = dataObject.Select(filter, CCalendar.selectedDay.Month, CCalendar.selectedDay.Year);

            Tasks.Clear();
            TaskBox.Items.Clear();
            if (data != null && data.HasRows)
            {
                while (data.Read())
                {
                    Tasks.Add(new CustomButton(data));
                }
                foreach (CustomButton b in Tasks)
                {
                    if (!DayFilterOn || DayFilterOn && CCalendar.selectedDay.Day == b.deadline.Day)
                    {
                        TaskBox.Items.Add(b);
                    }
                }
            }
            dataObject.CloseConnection();
            CCalendar.UpdateCalendar(Tasks);
        }
Exemple #8
0
        private void btn_cancel_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Sei sicuro di voler uscire? Le modifiche apportatate non verranno salvate",
                                                  "Attenzione", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                //return to stored data
                if (preChargeNeed)
                {
                    tableRate.Clear();
                    using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=gestionalePalestra.db"))
                    {
                        using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand(conn))
                        {
                            conn.Open();
                            string command = "Select * from Rata where CodIscritto='" + (Ntess) + "'";
                            cmd.CommandText = command;
                            using (System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    tableRate.Rows.Add(reader["Costo"], reader["PagamentoAvv"], reader["DataPagam"]);
                                }
                            }
                            conn.Close();
                        }
                    }
                }
                this.Close();
            }
        }
Exemple #9
0
        public object[] Row(int index, string[] columnNames)
        {
            List <object> row       = new List <object>();
            string        cmdstring = "SELECT [" + columnNames[0] + "]";

            for (int i = 1; i < columnNames.Count(); i++)
            {
                cmdstring += ",[" + columnNames[i] + "]";
            }
            int idx = 0;

            using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand(cmdstring + " FROM [" + _tableName + "] WHERE rowid=" + _rowIds[index], _connection))
            {
                using (System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            foreach (string s in columnNames)
                            {
                                row.Add(reader[s]);
                            }
                        }
                    }
                }
            }
            return(row.ToArray());
        }
        private void cb_selCorsoMod_SelectedIndexChanged(object sender, EventArgs e)
        {
            string selectedItem = cb_selCorsoMod.SelectedItem.ToString();
            string codSelected  = cb_selCorsoMod.SelectedItem.ToString().Split(':')[1].Substring(0, 2);

            using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=gestionalePalestra.db"))
            {
                using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand(conn))
                {
                    conn.Open();
                    string command = "SELECT * From Corso where Id='" + codSelected + "'";
                    cmd.CommandText = command;
                    using (System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            tb_NomeMod.Text     = reader["Nome"].ToString();
                            tb_dataInMod.Text   = reader["DataIn"].ToString();
                            tb_dataFineMod.Text = reader["DataFin"].ToString();
                        }
                    }
                    conn.Close();
                }
            }
        }
Exemple #11
0
        private void UnLoad_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(Rwebidtxt.Text))
            {
                MessageBox.Show("Error in WebId Field, Please Check it again.", "UnLoading Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            else
            {
                // MessageBox.Show("Thanks, This Part is UnderDevelopment, Please Wait for The next Update", "Work In Progress", MessageBoxButton.OK, MessageBoxImage.Information);

                if (!string.IsNullOrWhiteSpace(Rwebidtxt.Text))
                {
                    sqlcon.Open();
                    //MessageBox.Show(sqlcon.ToString());
                    string query = "Select password from Record where EmailID='" + Rwebidtxt.Text + "';";
                    System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(query, sqlcon);
                    com.ExecuteNonQuery();
                    System.Data.SQLite.SQLiteDataReader dr = com.ExecuteReader();
                    dr.Read();

                    Rpasstxt.Text = dr["Password"].ToString();


                    //MessageBox.Show("Congrats , You have successefully Loaded the Data ", "Data Loaded  ", MessageBoxButton.OK, MessageBoxImage.Information);
                    sqlcon.Close();
                }
            }
        }
Exemple #12
0
        public void Initialize(System.Data.SQLite.SQLiteDataReader data, List <BattlerClass> classesData, List <State> statesData, List <Player> playersData, List <Enemy> enemiesData)
        {
            Initialize(data);
            Id = Int(data["Skill_ID"]);
            ReadTool(this, data["ToolID"], classesData, statesData);
            SPConsume     = Int(data["SPConsume"]);
            NumberOfUsers = Int(data["NumberOfUsers"]) + 1;
            ShareTurns    = (bool)data["ShareTurns"];
            Charge        = Int(data["Charge"]);
            Warmup        = Int(data["Warmup"]);
            Cooldown      = Int(data["CoolDown"]);
            Steal         = (bool)data["Steal"];
            List <int> enemiesList = ReadDBList(data, "Skill", "Enemy", "Response");
            List <int> playersList = ReadDBList(data, "Skill", "Player", "Response");

            for (int i = 0; i < playersList.Count;)
            {
                SummonedPlayers.Add(ReadObj(playersData, playersList[i++]));
                SummonPlayerChances.Add(playersList[i++]);
            }
            for (int i = 0; i < enemiesList.Count;)
            {
                SummonedEnemies.Add(ReadObj(enemiesData, enemiesList[i++]));
                SummonEnemyChances.Add(enemiesList[i++]);
            }
        }
Exemple #13
0
        // GET api/values
        public IEnumerable <string> Get()
        {
            //return strings;
            strings.Clear();
            string selectQuery = @"SELECT * FROM MyTable";

            using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=|DataDirectory|/databaseFile2.db3"))
            {
                using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(conn))
                {
                    conn.Open();                       // Open the connection to the database

                    com.CommandText = selectQuery;     // Set CommandText to our query that will select all rows from the table
                    com.ExecuteNonQuery();             // Execute the query

                    using (System.Data.SQLite.SQLiteDataReader reader = com.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            strings.Add(reader["Key"] + ":" + reader["Value"]);     // Display the value of the key and value column for every row
                        }
                    }
                    conn.Close();        // Close the connection to the database
                }
            }
            return(strings);
        }
Exemple #14
0
        public void Initialize(System.Data.SQLite.SQLiteDataReader data, List <string> elementsData,
                               List <State> statesData, List <BattlerClass> classesData, List <Player> playersData, List <Skill> skillsData)
        {
            Initialize(data);
            Id                = Int(data["Player_ID"]);
            ElementRates      = ReadRatesList(data, "Player", elementsData, "ElementRates");
            StateRates        = ReadRatesList(data, "Player", statesData, "Vulnerability");
            NaturalStats      = ReadStats(data["NaturalStats"], false);
            Companionship     = Int(data["Companionship"]);
            SavePartnerRate   = Int(data["SavePartnerRate"]);
            CounterattackRate = Int(data["CounterattackRate"]);
            AssistDamageRate  = Int(data["AssistDamageRate"]);
            List <int> classesList = ReadDBList(data, "Player", "BattlerClass");

            for (int i = 0; i < classesList.Count; i++)
            {
                ClassSet.Add(ReadObj(classesData, classesList[i]));
            }
            PlayerCompanionships = ReadRatesList(data, "Player", playersData, "CompanionshipTo");
            List <int> skillsList = ReadDBList(data, "Player", "Skill", "LevelRequired");

            for (int i = 0; i < skillsList.Count;)
            {
                SkillSet.Add(ReadObj(skillsData, skillsList[i++]));
                SkillSetLevels.Add(skillsList[i++]);
            }
        }
Exemple #15
0
        /// <summary>
        /// Returns the list of all the articles
        /// </summary>
        /// <returns>list of all the articles</returns>
        public List <Models.Article> Get_Articles_List()
        {
            List <Models.Article> Articles = new List <Models.Article>();

            System.Data.SQLite.SQLiteCommand cmd = SQL_Connection.CreateCommand();
            cmd.CommandText = "SELECT RefArticle, Description, SousFamilles.Nom as SousFamille, m.Nom as Marque, PrixHT, Quantite FROM Articles natural join SousFamilles inner join Marques m on m.RefMarque = Articles.refMarque";

            System.Data.SQLite.SQLiteDataReader Articles_Reader = cmd.ExecuteReader();

            int Article_Index     = Articles_Reader.GetOrdinal("RefArticle");
            int Description_Index = Articles_Reader.GetOrdinal("Description");
            int Sub_Familly_Index = Articles_Reader.GetOrdinal("SousFamille");
            int Brand_Index       = Articles_Reader.GetOrdinal("Marque");
            int Price_Index       = Articles_Reader.GetOrdinal("PrixHT");
            int Quantity_Index    = Articles_Reader.GetOrdinal("Quantite");

            while (Articles_Reader.Read())
            {
                Models.Article A = new Models.Article();


                A.Ref_Article      = Articles_Reader.GetString(Article_Index);
                A.Description      = Articles_Reader.GetString(Description_Index);
                A.Sub_Familly_Name = Articles_Reader.GetString(Sub_Familly_Index);
                A.Brand_Name       = Articles_Reader.GetString(Brand_Index);
                A.Price_HT         = Articles_Reader.GetFloat(Price_Index);
                A.Quantity         = Articles_Reader.GetInt32(Quantity_Index);

                Articles.Add(A);
            }

            return(Articles);
        }
Exemple #16
0
        public List <BU> GetBUList()
        {
            List <BU> accountList = new List <BU>();
            BU        account;

            try
            {
                using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection(BaseDbContext.databasestring))
                {
                    using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
                    {
                        con.Open();                                                   // Open the connection to the database
                        com.CommandText = "Select BUID,BUName,BUDescription FROM BU"; // Select all rows from our database table
                        using (System.Data.SQLite.SQLiteDataReader reader = com.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                account               = new BU();
                                account.BUID          = Convert.ToInt32(reader["BUID"]);
                                account.BUName        = Convert.ToString(reader["BUName"]);
                                account.BUDescription = Convert.ToString(reader["BUDescription"]);
                                accountList.Add(account);
                            }
                        }
                        con.Close();        // Close the connection to the database
                    }
                }
                return(accountList);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemple #17
0
        private List <string> getPartsList()
        {
            List <string> parts = new List <string>();

            System.Data.SQLite.SQLiteConnection con = Sql.GetConnection();
            //using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection("data source=" + _dbasePath))
            {
                using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
                {
                    com.CommandText = "Select * FROM PartsTable";

                    try
                    {
                        //con.Open();
                        using (System.Data.SQLite.SQLiteDataReader reader = com.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                string c = (reader["Category"] as string) + "|" + (reader["Description"] as string) + "|" + (reader["Price"] as string);

                                parts.Add(c);
                            }
                        }
                    }
                    catch (SqlException ex)
                    {
                        MessageBox.Show(this, "Database error: " + ex.Message);
                    }
                }
            }

            return(parts);
        }
Exemple #18
0
        private void loadInfo()
        {
            using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=gestionalePalestra.db"))
            {
                using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand(conn))
                {
                    conn.Open();
                    string command = "Select * from Iscritto left join Certificato on Iscritto.CodIscritto = Certificato.CodIscritto where Iscritto.CodIscritto = '" + nTessera + "'";
                    cmd.CommandText = command;
                    using (System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            tb_nome.Text      = reader["Nome"].ToString();
                            tb_cognome.Text   = reader["Cognome"].ToString();
                            tb_dataN.Text     = reader["DataN"].ToString();
                            tb_residenza.Text = reader["Residenza"].ToString();
                            tb_via.Text       = reader["Via"].ToString();
                            tb_recapito.Text  = reader["Recapito"].ToString();
                            tb_nTessera.Text  = reader["Ntessera"].ToString();
                            tb_dataIn.Text    = reader["DataIn"].ToString();
                            tb_dataFine.Text  = reader["DataFine"].ToString();
                            tb_costo.Text     = reader["Costo"].ToString();
                            tb_ingressi.Text  = reader["NIngressi"].ToString();

                            tb_pres.Text     = reader["Presente"].ToString();
                            tb_dataScad.Text = reader["DataScadenza"].ToString();
                        }
                    }
                    conn.Close();
                }
            }
        }
Exemple #19
0
        private static void player_leaderboard(ChatMessage c)
        {
            long chan_id = get_channel_id(c.Channel);

            using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
            {
                con.Open();

                com.CommandText = @"SELECT nickname, points
                                    FROM players
                                    WHERE chan_id = @chanid
                                    ORDER BY points DESC LIMIT 5";
                com.CommandType = System.Data.CommandType.Text;
                com.Parameters.AddWithValue("@chanid", chan_id);

                long   pos  = 1;
                string list = "Leaderboard for #" + c.Channel + ": ";
                using (System.Data.SQLite.SQLiteDataReader r = com.ExecuteReader())
                {
                    while (r.Read())
                    {
                        list = list + " (" + pos + ") " + ((string)r["nickname"]).Trim() + " - " + r["points"] + ", ";
                        pos++;
                    }
                }

                // then tell the player their position
                com.CommandText = @"SELECT count(*) AS rank 
                                    FROM players 
                                    WHERE chan_id = @chanid AND points > (SELECT points from players where nickname = @nickname)
                                    ORDER BY points DESC";

                com.CommandType = System.Data.CommandType.Text;
                com.Parameters.AddWithValue("@nickname", c.Username);
                com.Parameters.AddWithValue("@chanid", chan_id);
                object res  = com.ExecuteScalar();
                long   rank = 0;
                if (res != null)
                {
                    rank = (long)res;
                }

                com.CommandText = @"SELECT count(*) from players where chan_id = @chanid";
                com.CommandType = System.Data.CommandType.Text;
                com.Parameters.AddWithValue("@chanid", chan_id);
                res = com.ExecuteScalar();
                long total = 0;
                if (res != null)
                {
                    total = (long)res;
                }

                con.Close();

                cl.SendWhisper(c.Username, list + " you are ranked " + (rank != 0?rank:total) + "/" + total);
            }
            verb("Leaderboard req from " + c.Username);
        }
Exemple #20
0
        private void Btn_startPersonInfo_Click(object sender, System.EventArgs e)
        {
            listview_personInfos.Items.Clear();
            System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection(sDataBaseStr);
            conn.Open();
            //
            string sql_findInfo = "select * from RentPersonInfo order by personCardNum";

            if (cb_personCondition.SelectedIndex == 1)
            {
                sql_findInfo = string.Format("select * from RentPersonInfo where personName = '{0}'", tb_personCondition.Text);
            }
            else if (cb_personCondition.SelectedIndex == 2)
            {
                sql_findInfo = string.Format("select * from RentPersonInfo where personCardNum = '{0}'", tb_personCondition.Text);
            }
            else if (cb_personCondition.SelectedIndex == 3)
            {
                sql_findInfo = string.Format("select * from RentPersonInfo where mobile = '{0}'", tb_personCondition.Text);
            }

            System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand();
            cmd.CommandText = sql_findInfo;
            cmd.Connection  = conn;
            System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader();
            if (reader.HasRows)
            {
                this.listview_personInfos.BeginUpdate();
                while (reader.Read())
                {
                    string personName   = reader.GetString(0);
                    string personNum    = reader.GetString(1);
                    string personCardNo = reader.GetString(2);
                    string mobile       = reader.GetString(3);

                    //
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = personName;
                    lvi.SubItems.Add(personNum);
                    lvi.SubItems.Add(personCardNo);
                    lvi.SubItems.Add(mobile);

                    if (personName.Contains("已销卡"))
                    {
                        lvi.ForeColor = Color.ForestGreen;
                    }
                    listview_personInfos.Items.Add(lvi);
                }
                this.listview_personInfos.EndUpdate();
            }
            //
            reader.Close();
            cmd.Dispose();
            conn.Close();
            conn.Dispose();
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();
        }
Exemple #21
0
        public static System.Data.DataTable SQLiteDataReader2Table(this System.Data.SQLite.SQLiteDataReader d)
        {
            //Create a new DataTable.
            System.Data.DataTable dt = new System.Data.DataTable("Result");

            //Load DataReader into the DataTable.
            dt.Load(d);
            return(dt);
        }
Exemple #22
0
 public void Initialize(System.Data.SQLite.SQLiteDataReader data, List <string> elementsData, List <State> statesData, List <BattlerClass> classesData)
 {
     Initialize(data);
     Id           = Int(data["Enemy_ID"]);
     ElementRates = ReadRatesList(data, "Enemy", elementsData, "ElementRates");
     StateRates   = ReadRatesList(data, "Enemy", statesData, "Vulnerability");
     ScaledStats  = ReadStats(data["ScaledStats"], false);
     Class        = ReadObj(classesData, data["EnemyClass"]);
 }
Exemple #23
0
        private void draw()
        {
            //string drawQuery = "select top 1 name from LotContestents where ObjectGuid = '" + objectGuid + "' and LotDrawNumber = '" + rdr["ActiveDrawNumber"].ToString() + "' ORDER BY NEWID()";
            string lotNumberSelectQuery = "select * from LotObjectsInWorld where ObjectGuid = '" + objectGuid + "'";
            string winnerUpdateSql      = "";
            string lotNumber            = "";
            string winner = "";

            using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection("data source=" + HttpContext.Current.Server.MapPath("~/App_Data/Raffle.db")))
            {
                using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
                {
                    con.Open();                             // Open the connection to the database

                    com.CommandText = lotNumberSelectQuery; // Set CommandText to our query that will create the table

                    using (System.Data.SQLite.SQLiteDataReader reader = com.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            string drawQuery = "select name from LotContestents where ObjectGuid = '" + objectGuid + "' and LotDrawNumber = '" + reader["LotDrawNumber"].ToString() + "' ORDER BY RANDOM() LIMIT 1";
                            lotNumber = reader["LotDrawNumber"].ToString();
                            reader.Close();
                            com.CommandText = drawQuery;
                            using (System.Data.SQLite.SQLiteDataReader reader1 = com.ExecuteReader())
                            {
                                if (reader1.Read())
                                {
                                    winnerUpdateSql = "update LotDrawHistory set Winner = '" + reader1[0].ToString() + "' where ObjectGuid = '" + objectGuid + "' and LotDrawNumber = '" + lotNumber + "'";
                                    winner          = reader1[0].ToString();
                                    reader1.Close();
                                    com.CommandText = winnerUpdateSql;
                                    com.ExecuteNonQuery();
                                    pageResponse.Write(winner.Replace("$", " "));
                                    pageResponse.Flush();
                                    pageResponse.SuppressContent = true;
                                }
                                else
                                {
                                    winnerUpdateSql = "update LotDrawHistory set Winner = '$$$' where ObjectGuid = '" + objectGuid + "' and LotDrawNumber = '" + lotNumber + "'";
                                    reader1.Close();
                                    com.CommandText = winnerUpdateSql;
                                    com.ExecuteNonQuery();
                                    pageResponse.Write("$$$"); // code for no winners
                                    pageResponse.Flush();
                                    pageResponse.SuppressContent = true;
                                }
                            }
                        }
                    }

                    con.Close();
                }
            }
            this.closeRaffle(true);
        }
Exemple #24
0
 public void Initialize(System.Data.SQLite.SQLiteDataReader data, List <BattlerClass> classesData, List <State> statesData, List <Item> itemsData)
 {
     Initialize(data);
     Id = Int(data["Item_ID"]);
     ReadTool(this, data["ToolID"], classesData, statesData);
     PermantentStatChanges = ReadStats(data["PermStatMods"], false);
     DefaultPrice          = Int(data["DefaultPrice"]);
     Consumable            = (bool)data["Consumable"];
     TurnsInto             = ReadObj(itemsData, data["TurnsInto"]);
 }
 public InfosFilm(SqlDataReader reader)
 {
     _realisateur = reader.GetString(reader.GetOrdinal(BaseFilms.ALTERNATIVES_REALISATEUR));
     _acteurs     = reader.GetString(reader.GetOrdinal((BaseFilms.ALTERNATIVES_ACTEURS)));
     _genres      = reader.GetString(reader.GetOrdinal((BaseFilms.ALTERNATIVES_GENRES)));
     _nationalite = reader.GetString(reader.GetOrdinal((BaseFilms.ALTERNATIVES_NATIONALITE)));
     _resume      = reader.GetString(reader.GetOrdinal((BaseFilms.ALTERNATIVES_RESUME)));
     _dateSortie  = reader.GetString(reader.GetOrdinal((BaseFilms.ALTERNATIVES_DATESORTIE)));
     _image       = BaseFilms.readImage(reader, reader.GetOrdinal((BaseFilms.ALTERNATIVES_IMAGE)));
 }
Exemple #26
0
        private void Btn_checkPersonCanRent_Click(object sender, System.EventArgs e)
        {
            System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection(sDataBaseStr);
            conn.Open();
            //
            string sql = string.Format("select bookValue from RentBookInfo where personCardNum = '{0}'", tb_checkPersonCanRent.Text);

            System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand();
            cmd.CommandText = sql;
            cmd.Connection  = conn;
            System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader();
            //
            int    iCount = 0;
            double value  = 0.0;

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    value += System.Double.Parse(reader.GetString(0));
                    ++iCount;
                }
            }
            //
            reader.Close();
            cmd.Dispose();
            conn.Close();
            conn.Dispose();
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();

            if (value >= 100 && value < 200 && iCount < 3)
            {
                string currentval = string.Format("读者当前已经借出总价大于100元的书,但还小于200元({0}元),请注意", value);
                System.Windows.Forms.MessageBox.Show(currentval, "提示");
                return;
            }
            else if (value >= 200)
            {
                System.Windows.Forms.MessageBox.Show("读者当前已经借出总价大于200元的书,不可再借!", "提示");
                return;
            }
            else if (iCount >= 3)
            {
                System.Windows.Forms.MessageBox.Show("读者当前已经借出3本书,不可再借!", "提示");
                return;
            }
            else
            {
                string currentval = string.Format("读者当前可以借书!({0}元)", value);
                System.Windows.Forms.MessageBox.Show(currentval, "提示");
                return;
            }
        }
        //读取所有videolist
        public List <string> GetVideoList()
        {
            List <string> lists = new List <string>();

            System.Data.SQLite.SQLiteDataReader sr = helper.ExecuteQuery("select * from videolist");
            while (sr.Read())
            {
                lists.Add(sr.GetString(sr.GetOrdinal("name")));
            }
            return(lists);
        }
        //查询指定name的listid
        public List <string> GetVideoList(string name)
        {
            List <string> result = new List <string>();

            System.Data.SQLite.SQLiteDataReader sr = helper.Query("videolist", "name", "=", name);
            while (sr.Read())
            {
                result.Add(sr[0].ToString());
            }
            return(result);
        }
Exemple #29
0
 public BattleEnemy(System.Data.SQLite.SQLiteDataReader data, List <Enemy> enemiesData, List <PassiveSkill> pSkillsData)
 {
     Id            = Int(data["BattleEnemy_ID"]);
     Enemy         = new Enemy(ReadObj(enemiesData, data["EnemyID"]));
     Level         = Int(data["Level"]);
     GridPositionZ = Int(data["GridPositionZ"]);
     GridPositionX = Int(data["GridPositionX"]);
     HPMultiplier  = Int(data["HPMultiplier"]);
     PassiveSkill1 = ReadObj(pSkillsData, data["PassiveSkill1"]);
     PassiveSkill2 = ReadObj(pSkillsData, data["PassiveSkill2"]);
 }
        //获取指定listid的视频,返回文件地址的list
        public List <string> GetFileFromList(string listid)
        {
            System.Data.SQLite.SQLiteDataReader sr = helper.Query("video", "listid", "=", listid.ToString());
            List <string> result = new List <string>();

            while (sr.Read())
            {
                result.Add(sr.GetString(sr.GetOrdinal("address")));
            }
            return(result);
        }
        public override void Close()
        {
            if (reader != null)
            {
                if (con.State != System.Data.ConnectionState.Closed)
                    reader.Close();
                currentIndex = 0;
                packettotalcount = null;

            }
            if (con != null)
            {
                con.Close();
                con = null;
            }
            header = null;
            reader = null;
        }
        public Result ValidateFields()
        {
            var result = new Result();

            using (var sqlcommand = Con.CreateCommand())
            {
                sqlcommand.CommandText = "select * from packets Limit(1)";
                reader = sqlcommand.ExecuteReader();
                var total = reader.RecordsAffected;
                if (reader.FieldCount != 5)
                {
                    result.AddResult(Result.NewError("Invalid FieldCount."));
                }
            }

            return result;
        }
 public override void Load(string pCustomerQuery)
 {
     try
     {
         System.Data.SQLite.SQLiteCommand tSQLiteCommand = Con.CreateCommand();
         tSQLiteCommand.CommandText = string.Format("select id, timestamp, direction, opcode, data from packets where id >= {0} {1} Limit({2})", currentIndex, pCustomerQuery, maxProcessCount); ;
         reader = tSQLiteCommand.ExecuteReader();
     }
     catch (Exception exc)
     {
         Console.WriteLine(exc.Message);
     }
 }
 public override void Load(string filter)
 {
     try
     {
         var sqlcommand = Con.CreateCommand();
         sqlcommand.CommandText = string.Format("select id, timestamp, direction, opcode, data from packets where id >= {0} {1} Limit({2})", currentIndex, filter, maxProcessCount);
         reader = sqlcommand.ExecuteReader();
     }
     catch (Exception exc)
     {
         delegatemanager.AddException(exc);
     }
 }
        public bool ValidateFields()
        {
            System.Data.SQLite.SQLiteCommand tSQLiteCommand = Con.CreateCommand();
            tSQLiteCommand.CommandText = "select * from packets Limit(1)";
            reader = tSQLiteCommand.ExecuteReader();
            int tTotal = reader.RecordsAffected;


            //for (int i = 0; i < reader.FieldCount; i++)
            //{
            //    if (i == 0 && !(reader.GetName(i) == "id"))
            //    {
            //        return false;
            //    }
            //    else if (i == 2 && !(reader.GetName(i) == "timestamp"))
            //    {
            //        return false;
            //    }
            //    else if (i == 3 && !(reader.GetName(i) == "direction"))
            //    {
            //        return false;
            //    }
            //    else if (i == 4 && !(reader.GetName(i) == "opcode"))
            //    {
            //        return false;
            //    }
            //    else if (i == 5 && !(reader.GetName(i) == "data"))
            //    {
            //        return false;
            //    }
            //}

            return reader.FieldCount == 5;
        }