Exemplo n.º 1
0
        private static IEnumerable <EcCard> LoadFromReader(OleDbDataReader reader)
        {
            if (reader == null)
            {
                yield break;
            }

            int idIndex     = reader.GetOrdinal("ID");
            int custIndex   = reader.GetOrdinal("KndNr");
            int projIndex   = reader.GetOrdinal("ProjNr");
            int cardNoIndex = reader.GetOrdinal("Kartennr");
            int cardIdIndex = reader.GetOrdinal("CardZK");
            int textIndex   = reader.GetOrdinal("Text");

            int[] flagIndexes = new int[13];
            for (int i = 0; i < FlagNames.Length; i++)
            {
                flagIndexes[i] = reader.GetOrdinal(FlagNames[i]);
            }

            while (reader.Read())
            {
                var card = new EcCard();
                card.ID             = reader.GetInt32(idIndex);
                card.CustomerNumber = (int)reader.GetDouble(custIndex);
                card.ProjectNumber  = (int)reader.GetDouble(projIndex);
                card.CardNumber     = reader.GetInt16(cardNoIndex);
                card.CardIdentity   = reader.GetString(cardIdIndex);
                card.Text           = reader.GetValue(textIndex) as string;
                for (int i = 0; i < FlagNames.Length; i++)
                {
                    card._flags[i] = reader.GetBoolean(flagIndexes[i]);
                }
                yield return(card);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// this function returns all published posts.
        /// </summary>
        /// <returns>all the posts that are published.</returns>
        public Dictionary <int, Post> getAllPublishedPosts()
        {
            Dictionary <int, Post> res = new Dictionary <int, Post>();

            dataset.Open();
            string          query   = "SELECT * FROM posts WHERE [isPublished] = " + true.ToString();
            OleDbCommand    checker = new OleDbCommand(query, dataset);
            OleDbDataReader reader  = checker.ExecuteReader();

            while (reader.Read())
            {
                Post postToAdd = new Post(reader.GetString(0), reader.GetString(1),
                                          new List <string>(), reader.GetString(2), reader.GetString(3),
                                          reader.GetBoolean(4));

                int postid = reader.GetInt32(5);
                postToAdd.id = postid.ToString();
                res.Add(postid, postToAdd);
            }
            dataset.Close();
            dataset.Open();
            foreach (int i in res.Keys)
            {
                string          queryForAreas = "SELECT area FROM PostsAreas WHERE postid = " + i;
                OleDbCommand    checker1      = new OleDbCommand(queryForAreas, dataset);
                OleDbDataReader reader1       = checker1.ExecuteReader();
                List <string>   area          = new List <string>();
                while (reader1.Read())
                {
                    area.Add(reader1.GetString(0));
                }
                res[i].postAreas = area;
            }
            dataset.Close();
            return(res);
        }
Exemplo n.º 3
0
        /////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////
        // Private methods

        /////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////
        private ProfileInfoCollection GetProfilesForQuery(string sqlQuery, OleDbParameter[] args, int pageIndex, int pageSize, out int totalRecords)
        {
            if (pageIndex < 0)
            {
                throw new ArgumentException("Page index must be non-negative", "pageIndex");
            }
            if (pageSize < 1)
            {
                throw new ArgumentException("Page size must be positive", "pageSize");
            }

            long lBound = (long)pageIndex * pageSize;
            long uBound = lBound + pageSize - 1;

            if (uBound > System.Int32.MaxValue)
            {
                throw new ArgumentException("pageIndex*pageSize too large");
            }
            try {
                AccessConnectionHolder holder   = AccessConnectionHelper.GetConnection(_DatabaseFileName, true);
                ProfileInfoCollection  profiles = new ProfileInfoCollection();
                OleDbDataReader        reader   = null;
                try {
                    OleDbCommand cmd = new OleDbCommand(sqlQuery, holder.Connection);
                    cmd.Parameters.Add(new OleDbParameter("@AppId", GetApplicationId(holder)));
                    int len = args.Length;
                    for (int iter = 0; iter < len; iter++)
                    {
                        cmd.Parameters.Add(args[iter]);
                    }
                    reader       = cmd.ExecuteReader(CommandBehavior.SequentialAccess);
                    totalRecords = 0;
                    while (reader.Read())
                    {
                        totalRecords++;
                        if (totalRecords - 1 < lBound || totalRecords - 1 > uBound)
                        {
                            continue;
                        }

                        string   username;
                        DateTime dtLastActivity, dtLastUpdated;
                        bool     isAnon;

                        username       = reader.GetString(0);
                        isAnon         = reader.GetBoolean(1);
                        dtLastActivity = reader.GetDateTime(2);
                        dtLastUpdated  = reader.GetDateTime(3);
                        int size = reader.GetInt32(4);
                        profiles.Add(new ProfileInfo(username, isAnon, dtLastActivity, dtLastUpdated, size));
                    }
                    return(profiles);
                }
                catch (Exception e) {
                    throw AccessConnectionHelper.GetBetterException(e, holder);
                }
                finally {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                    holder.Close();
                }
            }
            catch {
                throw;
            }
        }
Exemplo n.º 4
0
        //Onglet  1a1
        private void init1a1(int ligne)
        {
            try
            {
                lvPersonne.Items.Clear();
                List <int>   max             = new List <int>();
                string       jointure        = "";
                int          codeTransaction = 0;
                List <int>   Personne        = new List <int>();
                OleDbCommand cd0             = new OleDbCommand("SELECT [codeTransaction] FROM[Transaction]", connec);
                connec.Open();
                OleDbDataReader dr0 = cd0.ExecuteReader();
                while (dr0.Read())
                {
                    max.Add(dr0.GetInt32(0));
                }

                if (ligne == -2)
                {
                    ligne      = 1;
                    ligneTable = 1;
                }
                else if (ligne == -1)
                {
                    if (ligneTable == 1)
                    {
                        ligne = 1;
                    }
                    else
                    {
                        ligneTable--;
                        ligne = ligneTable;
                    }
                }
                else if (ligne == 1)
                {
                    if (ligneTable == max.Count)
                    {
                        ligne = max.Count;
                    }
                    else
                    {
                        ligneTable++;
                        ligne = ligneTable;
                    }
                }
                else
                {
                    ligne      = max.Count;
                    ligneTable = max.Count;
                }

                OleDbCommand    cd1 = new OleDbCommand("SELECT [Transaction].* FROM[Transaction] where [codeTransaction] = " + ligne, connec);
                OleDbDataReader dr1 = cd1.ExecuteReader();

                while (dr1.Read())
                {
                    lblCode.Text         = dr1.GetInt32(0).ToString();
                    codeTransaction      = dr1.GetInt32(0);
                    dtp1a1.Value         = dr1.GetDateTime(1);
                    lblDescription.Text  = dr1.GetString(2);
                    lblValeur.Text       = dr1.GetValue(3).ToString() + " €";
                    checkRecette.Checked = dr1.GetBoolean(4);
                    chkPercu.Checked     = dr1.GetBoolean(5);
                    if (dr1[6].ToString() == "")
                    {
                        jointure = "";
                    }
                    else
                    {
                        jointure = dr1.GetInt32(6).ToString();
                    }
                }

                if (jointure != "")
                {
                    //Pour eviter de faire une requette avec une jointure
                    OleDbCommand    cd2 = new OleDbCommand("SELECT [TypeTransaction].* FROM [TypeTransaction] where [codeType] = " + jointure, connec);
                    OleDbDataReader dr2 = cd2.ExecuteReader();
                    while (dr2.Read())
                    {
                        lblType.Text = dr2.GetString(1);
                    }
                }
                else
                {
                    lblType.Text = "Type NULL";
                }


                OleDbCommand    cd3 = new OleDbCommand("SELECT [CodePersonne] FROM[Beneficiaires] where [codeTransaction] =" + codeTransaction, connec);
                OleDbDataReader dr3 = cd3.ExecuteReader();
                while (dr3.Read())
                {
                    Personne.Add(dr3.GetInt32(0));
                }
                for (int i = 0; i < Personne.Count(); i++)
                {
                    OleDbCommand    cd4 = new OleDbCommand("SELECT [nomPersonne],[pnPersonne] FROM[Personne] where [codePersonne] =" + Personne[i].ToString(), connec);
                    OleDbDataReader dr4 = cd4.ExecuteReader();
                    while (dr4.Read())
                    {
                        lvPersonne.Items.Add(dr4.GetString(0) + dr4.GetString(1));
                    }
                }

                connec.Close();
            }
            catch (InvalidOperationException erreur)
            {
                MessageBox.Show("Erreur de chaine de connexion ! 1a1");
            }
            catch (OleDbException erreur)
            {
                MessageBox.Show("Erreur de requete SQL ! 1a1");
            }
        }
Exemplo n.º 5
0
        private void Modifier_Bien_Load(object sender, EventArgs e)
        {
            string          ChaineBd     = "Provider=SQLOLEDB;Data Source=INFO-joyeux;Initial Catalog=IMMOBILLY_JACKYTEAM;Persist Security Info=True; Integrated Security=sspi;";
            OleDbConnection dbConnection = new OleDbConnection(ChaineBd);

            dbConnection.Open();
            string sql = "select b.code_bien, b.surface_habitable, b.surface_parcelle, b.nb_piéces, b.nb_chambres, b.nb_Salle_de_bain, b.garage, b.cave, b.prix_vendeur, b.adresse, b.date_Mise_en_Vente, b.commentaire, b.statut,  vi.nom_ville, vi.code_postal, ve.nom_client, ve.prénom_client, ve.téléphone, ve.e_mail from bien b left join ville vi on vi.code_ville = b.code_ville left join vendeur ve on ve.num_client = b.num_client where b.code_bien = '" + ApplicationState.id_bien + "' ";

            OleDbCommand    cmd    = new OleDbCommand(sql, dbConnection);
            OleDbDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                textBox1.Text        = reader.GetInt16(0).ToString();
                textBox2.Text        = reader.GetInt32(1).ToString();
                textBox3.Text        = reader.GetInt32(2).ToString();
                numericUpDown1.Value = reader.GetInt32(3);
                numericUpDown2.Value = reader.GetInt32(4);
                numericUpDown3.Value = reader.GetInt32(5);
                if (reader.GetBoolean(6) == true)
                {
                    Garage.Checked = true;
                }
                if (reader.GetBoolean(7) == true)
                {
                    Cave.Checked = true;
                }
                textBox4.Text        = reader.GetInt32(8).ToString();
                dateTimePicker1.Text = reader.GetDateTime(10).ToString();
                textBox12.Text       = reader.GetString(9);
                if (reader.GetString(12) == "D")
                {
                    Disponible.Checked = true;
                }
                if (reader.GetString(12) == "S")
                {
                    Sous_Sein.Checked = true;
                }
                if (reader.GetString(12) == "V")
                {
                    Vendu.Checked = true;
                }
                if (reader.GetString(12) == "R")
                {
                    Retire.Checked = true;
                }
                textBox9.Text  = reader.GetString(11);
                textBox11.Text = reader.GetString(13);
                textBox10.Text = reader.GetValue(14).ToString();
            }
            reader.Close();

            string          sql1    = "Select count (v.code_visite) nb_visite from bien b left join proposition p on p.code_bien = b.code_bien left join visite v on v.code_proposition = p.code_proposition where b.code_bien = '" + textBox1.Text + "' ";
            OleDbCommand    cmd1    = new OleDbCommand(sql1, dbConnection);
            OleDbDataReader reader1 = cmd1.ExecuteReader();

            while (reader1.Read())
            {
                textBox5.Text = reader1.GetValue(0).ToString();
            }
            reader1.Close();
        }
Exemplo n.º 6
0
        private static void visualizzaVeicoli()
        {
            if (connectionString != null)
            {
                OleDbConnection connection = new OleDbConnection(connectionString);
                using (connection)
                {
                    connection.Open();

                    OleDbCommand command = new OleDbCommand("SELECT * FROM Veicoli", connection);

                    try
                    {
                        OleDbDataReader exeReader = command.ExecuteReader();

                        if (exeReader.HasRows)
                        {
                            Console.WriteLine("\n");
                            while (exeReader.Read())
                            {
                                Console.WriteLine("{0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12}",
                                                  exeReader.GetInt32(0), exeReader.GetString(1), exeReader.GetString(2), exeReader.GetString(3), exeReader.GetString(4), exeReader.GetInt32(5), exeReader.GetInt32(6),
                                                  exeReader.GetDateTime(7).ToShortDateString(), exeReader.GetBoolean(8), exeReader.GetBoolean(9), exeReader.GetInt32(10), exeReader.GetString(11),
                                                  exeReader.GetString(12));
                            }
                        }
                        else
                        {
                            Console.WriteLine("\n\nIL DATABASE NON CONTIENE VEICOLI!");
                        }
                        exeReader.Close();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"\n{ex.Message}");
                    }
                }
                Thread.Sleep(8000);
            }
        }
Exemplo n.º 7
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                con.Open();

                string selectedGod = godsListComboBox.Text;
                cmd.Connection = con;

                //Constructing SQL Query
                string query = String.Format("select * from [{0}]", selectedGod);
                cmd.CommandText = query;
                cmd.ExecuteNonQuery();
                //Making reader object
                OleDbDataReader reader = cmd.ExecuteReader();

                //Reading and updating acquired skins box
                skinsAcquiredListBox.Update();
                skinsAcquiredListBox.Items.Clear();

                while (reader.Read())
                {
                    skinsAcquiredListBox.Items.Add(reader["Skins"]);
                    skinsAcquiredListBox.SetItemChecked(skinsAcquiredListBox.Items.IndexOf(reader.GetString(0)), reader.GetBoolean(1));
                }

                skinsAcquiredListBox.EndUpdate();

                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ryan's Error Catcher:\n\n" + ex);
                con.Close();
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Fetches all persons and resources from database
        /// </summary>
        /// <returns>Returns list of all person and resources, If return is null something has gone wrong</returns>
        internal int getPersonsResources(out SortedList retlist)
        {
            // Get all persons i database
            String          sqlcmd = "SELECT name, color, pass, administrator FROM Person WHERE name<>'admin'";
            OleDbDataReader reader = executeSql(sqlcmd);

            retlist = new SortedList();
            if (reader == null)
            {
                return(ErrorHandler.ERR_FETCH_PERSON);
            }

            // Add all persons to the sortedlist
            int i = 0;

            while (reader.Read())
            {
                Person person = new Person(reader.GetString(0), reader.GetString(1), reader.GetString(2), reader.GetBoolean(3));
                retlist.Add(i, person);
                i++;
            }
            reader.Close();

            // Get all resources from database
            sqlcmd = "SELECT name, color FROM Resource";
            reader = executeSql(sqlcmd);

            if (reader == null)
            {
                return(ErrorHandler.ERR_FETCH_RESOURCE);
            }

            // Add all resources to the sortedlist
            while (reader.Read())
            {
                Resource resurs = new Resource(reader.GetString(0), reader.GetString(1));
                retlist.Add(i, resurs);
                i++;
            }
            reader.Close();

            return(ErrorHandler.NO_ERROR);
        }
Exemplo n.º 9
0
        public Kurswahlen(string aktSj, Klasses klasses, Fachs fachs, Unterrichts unterrichts, int periode)
        {
            using (OleDbConnection oleDbConnection = new OleDbConnection(Global.ConnectionStringUntis))
            {
                try
                {
                    Console.Write("Kurswahlen ".PadRight(75, '.') + " ");

                    string queryString = @"SELECT 
StudentChoice.STUDENT_ID, 
Student.Longname, 
Student.FirstName, 
Student.BirthDate, 
StudentChoice.Number, 
StudentChoice.AlternativeCourses,
Student.Name,
Student.StudNumber,
StudentChoice.Deleted
FROM Student LEFT JOIN StudentChoice ON Student.STUDENT_ID = StudentChoice.STUDENT_ID
WHERE (((StudentChoice.SCHOOLYEAR_ID)= " + aktSj + ") AND ((StudentChoice.TERM_ID)=" + periode + ")) ORDER BY StudentChoice.STUDENT_ID;";

                    OleDbCommand oleDbCommand = new OleDbCommand(queryString, oleDbConnection);
                    oleDbConnection.Open();
                    OleDbDataReader oleDbDataReader = oleDbCommand.ExecuteReader();

                    while (oleDbDataReader.Read())
                    {
                        Kurswahl kurswahl = new Kurswahl(aktSj, periode);

                        kurswahl.StudentId = oleDbDataReader.GetInt32(0);


                        try
                        {
                            kurswahl.Nachname = Global.SafeGetString(oleDbDataReader, 1);
                            if (kurswahl.Nachname == "Dillhage")
                            {
                                string a = "";
                            }
                            kurswahl.Vorname      = Global.SafeGetString(oleDbDataReader, 2);
                            kurswahl.Geburtsdatum = DateTime.ParseExact((oleDbDataReader.GetInt32(3)).ToString(), "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
                            kurswahl.Number       = Convert.ToInt32(oleDbDataReader.GetValue(4));
                            kurswahl.AlternativeCourses.Add(Global.SafeGetString(oleDbDataReader, 5));
                            kurswahl.StudentKurzname = Global.SafeGetString(oleDbDataReader, 6);
                            kurswahl.Fach            = (from f in fachs where f.IdUntis.ToString() == kurswahl.AlternativeCourses[0].Split('/')[1] select f.KürzelUntis).FirstOrDefault();

                            kurswahl.Klasse = (from u in unterrichts
                                               where u.IdUntis.ToString() == kurswahl.AlternativeCourses[0].Split('/')[0]
                                               select u.Klasse.NameUntis).FirstOrDefault();
                            kurswahl.AtlantisId = Global.SafeGetString(oleDbDataReader, 7);
                            kurswahl.Deleted    = oleDbDataReader.GetBoolean(8);
                            this.Add(kurswahl);
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Schüler " + kurswahl.Nachname + " " + kurswahl.Vorname + " hat keine Klasse");
                        }
                    }
                    ;
                    oleDbDataReader.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                finally
                {
                    oleDbConnection.Close();
                    Console.WriteLine(this.Count);
                }
            }
        }
Exemplo n.º 10
0
        private void Form6_Load(object sender, EventArgs e)
        {
            OleDbConnection connection = new OleDbConnection("Provider=VFPOLEDB.1;" + "Data Source=C:\\Users\\igory\\Desktop\\gdk_db\\data1.dbc;");
            OleDbCommand    command    = new OleDbCommand("SELECT id, login, password, f, i, o, pol, admin from table1", connection);

            connection.Open();
            command.Connection = connection;
            OleDbDataReader reader = command.ExecuteReader();
            int             i      = 0;

            while (reader.Read())
            {
                dataGridView1.Rows.Add(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetBoolean(6), reader.GetBoolean(7));
            }

            connection.Close();
        }
        private static void visualizzaListaVeicoli()
        {
            if (connStr != null)
            {
                OleDbConnection connection = new OleDbConnection(connStr);
                using (connection)
                {
                    connection.Open();

                    OleDbCommand command = new OleDbCommand("SELECT * FROM Veicoli", connection);

                    try
                    {
                        OleDbDataReader rdr = command.ExecuteReader();

                        if (rdr.HasRows)
                        {
                            Console.WriteLine("\n");
                            while (rdr.Read())
                            {
                                Console.WriteLine("{0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11}",
                                                  rdr.GetInt32(0), rdr.GetString(1), rdr.GetString(2), rdr.GetString(3), rdr.GetString(4), rdr.GetInt32(5), rdr.GetInt32(6),
                                                  rdr.GetDateTime(7).ToShortDateString(), rdr.GetBoolean(8), rdr.GetBoolean(9), rdr.GetInt32(10), rdr.GetString(11));
                            }
                        }
                        else
                        {
                            Console.WriteLine("\n\nNel DB non sono presenti veicoli");
                        }
                        rdr.Close();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"\n{ex.Message}");
                    }
                }
                Thread.Sleep(7000);
            }
        }
Exemplo n.º 12
0
        private ProfileInfoCollection GetProfilesForQuery(OleDbParameter[] insertArgs, int pageIndex, int pageSize, StringBuilder insertQuery, out int totalRecords)
        {
            if (pageIndex < 0)
            {
                throw new ArgumentException("pageIndex");
            }
            if (pageSize < 1)
            {
                throw new ArgumentException("pageSize");
            }

            long lowerBound = (long)pageIndex * pageSize;
            long upperBound = lowerBound + pageSize - 1;

            if (upperBound > Int32.MaxValue)
            {
                throw new ArgumentException("pageIndex and pageSize");
            }

            OleDbConnection conn   = null;
            OleDbDataReader reader = null;
            OleDbCommand    cmd    = null;

            try
            {
                conn = new OleDbConnection(SqlHelper.ConnString);
                conn.Open();

                StringBuilder cmdStr = new StringBuilder(200);
                // Create a temp table TO store the select results
                cmd = new OleDbCommand("CREATE TABLE #PageIndexForProfileUsers(IndexId int IDENTITY (0, 1) NOT NULL, UserId int)", conn);
                cmd.CommandTimeout = CommandTimeout;
                cmd.ExecuteNonQuery();
                cmd.Dispose();

                insertQuery.Append(" ORDER BY UserName");
                cmd = new OleDbCommand(insertQuery.ToString(), conn);
                cmd.CommandTimeout = CommandTimeout;
                if (insertArgs != null)
                {
                    foreach (OleDbParameter arg in insertArgs)
                    {
                        cmd.Parameters.Add(arg);
                    }
                }

                cmd.ExecuteNonQuery();
                cmd.Dispose();

                cmdStr = new StringBuilder(200);
                cmdStr.AppendFormat("SELECT u.M_NAME, u.M_LASTHEREDATE, p.M_LASTUPDATED FROM {0}MEMBERS u, ", Config.MemberTablePrefix).AppendLine(TableName);
                cmdStr.Append(" p, #PageIndexForProfileUsers i WHERE u.MEMBER_ID = p.UserId AND p.UserId = i.UserId AND i.IndexId >= ");
                cmdStr.Append(lowerBound).Append(" AND i.IndexId <= ").Append(upperBound);
                cmd = new OleDbCommand(cmdStr.ToString(), conn);
                cmd.CommandTimeout = CommandTimeout;

                reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess);
                ProfileInfoCollection profiles = new ProfileInfoCollection();
                while (reader.Read())
                {
                    string   username;
                    DateTime dtLastActivity, dtLastUpdated = DateTime.UtcNow;
                    bool     isAnon;

                    username       = reader.GetString(0);
                    isAnon         = reader.GetBoolean(1);
                    dtLastActivity = DateTime.SpecifyKind(reader.GetDateTime(2), DateTimeKind.Utc);
                    dtLastUpdated  = DateTime.SpecifyKind(reader.GetDateTime(3), DateTimeKind.Utc);
                    profiles.Add(new ProfileInfo(username, isAnon, dtLastActivity, dtLastUpdated, 0));
                }
                totalRecords = profiles.Count;

                if (reader != null)
                {
                    reader.Close();
                    reader = null;
                }

                cmd.Dispose();

                // Cleanup, REVIEW: should move to finally?
                cmd = new OleDbCommand("DROP TABLE #PageIndexForProfileUsers", conn);
                cmd.ExecuteNonQuery();

                return(profiles);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }

                if (cmd != null)
                {
                    cmd.Dispose();
                }

                if (conn != null)
                {
                    conn.Close();
                    conn = null;
                }
            }
        }
Exemplo n.º 13
0
        public void generateTimeTable()
        {
            OleDbConnection con = new OleDbConnection(connectionString);

            con.Open();

            OleDbCommand cmd = new OleDbCommand("SELECT count(*) FROM Lessons", con);

            int[] lessonsID = new int[Convert.ToInt32(cmd.ExecuteScalar())];

            cmd = new OleDbCommand("SELECT ID FROM Lessons", con);
            OleDbDataReader odr = cmd.ExecuteReader();

            for (int i = 0; i < lessonsID.Length; i++)
            {
                odr.Read();
                lessonsID[i] = odr.GetInt32(0);
            }

            con.Close();

            lessonsID = sortLessonsByDegreeOfFreedom(lessonsID);


            timetable = new Lesson[count, 5, 5];
            for (int i = 0; i < lessonsID.Length; i++)
            {
                con.Open();
                cmd = new OleDbCommand("SELECT * FROM Lessons WHERE Lessons.ID = " + lessonsID[i], con);
                odr = cmd.ExecuteReader();
                odr.Read();
                bool isLect = odr.GetBoolean(2);
                int  group  = odr.GetInt32(3);
                int  tID    = odr.GetInt32(4);


                // Вытащим массив всех подходящих аудиторий
                cmd = new OleDbCommand("SELECT Room FROM Rooms WHERE (Capacity >= " +
                                       "(SELECT Population FROM Groups WHERE Number = " + group + ")" +
                                       ") AND (Projector = " +
                                       "(SELECT Projector FROM Lessons WHERE ID = " + lessonsID[i] + ")" +
                                       ") AND (Laboratory = " +
                                       "(SELECT Laboratory FROM Lessons WHERE ID = " + lessonsID[i] + ")" +
                                       ") AND (Computers = " +
                                       "(SELECT Computers FROM Lessons WHERE ID = " + lessonsID[i] + ")" +
                                       ") AND (Gym = " +
                                       "(SELECT Gym FROM Lessons WHERE ID = " + lessonsID[i] + "))", con);
                OleDbDataReader reader = cmd.ExecuteReader();
                List <int>      rooms  = new List <int>();
                while (reader.Read())
                {
                    rooms.Add(reader.GetInt32(0));
                }


                // Заменим фактический номер группы на ее порядковый номер, как индекс массива
                int groupIndex = 0;
                cmd    = new OleDbCommand("SELECT Number FROM Groups", con);
                reader = cmd.ExecuteReader();
                for (int num = 0; num < count; num++)
                {
                    reader.Read();
                    if (group == reader.GetInt32(0))
                    {
                        groupIndex = num;
                        break;
                    }
                }

                con.Close();



                double max     = -1.0;
                int    r_max   = -1;
                int    day_max = -1;
                int    pos_max = -1;
                foreach (int r in rooms)
                {
                    // Подберем нужное время
                    double R_max = -10.0;
                    int    d     = -1;
                    int    p     = -1;
                    double R;
                    for (int day = 0; day < 5; day++)
                    {
                        for (int pos = 0; pos < 5; pos++)
                        {
                            if (timetable[groupIndex, day, pos].id != 0)
                            {
                                continue;
                            }
                            bool flag = false;
                            for (int t = 0; t < count; t++)
                            {
                                if ((timetable[t, day, pos].id != 0) && (t != groupIndex) && ((timetable[t, day, pos].room == r) || (timetable[t, day, pos].tId == tID)))
                                {
                                    flag = true;
                                    break;
                                }
                            }
                            if (!flag)
                            {
                                R  = 0;
                                R += w[0] * measureOfQualityInTimeSpace(groupIndex, tID, 0, day, pos);
                                R += w[1] * measureOfQualityInTimeSpace(groupIndex, tID, 1, day, pos);
                                R += w[2] * measureOfQualityInTimeSpace(groupIndex, tID, 2, day, pos);
                                R += w[3] * measureOfQualityInTimeSpace(groupIndex, tID, 3, day, pos);
                                R += w[4] * measureOfQualityInTimeSpace(groupIndex, tID, 4, day, pos);

                                if (R > R_max)
                                {
                                    R_max = R;
                                    d     = day;
                                    p     = pos;
                                }
                            }
                        }
                    }

                    if (R_max + w[5] * measureOfQualityInRoomSpace(group, r) > max)
                    {
                        max     = R_max + w[5] * measureOfQualityInRoomSpace(group, r);
                        r_max   = r;
                        day_max = d;
                        pos_max = p;
                    }
                }


                timetable[groupIndex, day_max, pos_max] = new Lesson(lessonsID[i], isLect, tID, r_max);
            }
        }
Exemplo n.º 14
0
        static void BanUserMenu()
        {
            try
            {
                bool isBanned = false;

                ReadAllUsers();

                // target id
                Console.Write("\nSelect ID you want to BAN/UNBAN ('0' back to menu): ");
                int id = int.Parse(Console.ReadLine());
                if (id != 0)
                {
                    // check if banned and shows some basic info
                    myConnection.Open();
                    OleDbCommand myCommandSelectID = new OleDbCommand("SELECT * FROM RegisteredUsers WHERE ID=@id", myConnection);
                    myCommandSelectID.Parameters.AddWithValue("@id", id);
                    OleDbDataReader myReader = myCommandSelectID.ExecuteReader();
                    while (myReader.Read())
                    {
                        if (myReader.GetBoolean(8) == true)
                        {
                            isBanned = true;
                        }
                        else
                        {
                            isBanned = false;
                        }
                        Console.Write("\nid: {0} usrname: {1} \n\n ", myReader.GetInt32(0).ToString(), myReader.GetString(1));
                    }
                    myReader.Close();
                    myConnection.Close();


                    if (isBanned == true)
                    {
                        Console.Write("Do you want to UNBAN this user? (y/n) ");
                        string choice = Console.ReadLine();
                        do
                        {
                            if (choice == "y")
                            {
                                EditUserCommand("banned", "false", id);
                                Console.ReadLine();
                                BanUserMenu();
                            }
                            else if (choice == "n")
                            {
                                Console.WriteLine("\nYour choice was 'NO'. Press any key to continue ...");
                                Console.ReadLine();
                                BanUserMenu();
                            }
                        } while (choice == "");
                    }
                    else if (isBanned == false)
                    {
                        Console.Write("Do you want to BAN this user? (y/n) ");
                        string choice = Console.ReadLine();
                        do
                        {
                            if (choice == "y")
                            {
                                EditUserCommand("banned", "true", id);
                                Console.WriteLine("");
                                Console.ReadKey();
                                BanUserMenu();
                            }
                            else if (choice == "n")
                            {
                                Console.WriteLine("\nYour choice was 'NO'. Press any key to continue ...");
                                Console.ReadLine();
                                BanUserMenu();
                            }
                        } while (choice == "");
                    }
                }
                else
                {
                    Menu();
                }
            }
            catch (Exception e)
            {
                myConnection.Close();
                ErrorDisplay(e.StackTrace);
            }
        }
Exemplo n.º 15
0
        static void EditUserMenu()
        {
            try
            {
                ReadAllUsers();

                // target id
                Console.Write("\n\nSelect ID you want to change ('0' - back to menu): ");
                int id = int.Parse(Console.ReadLine());
                if (id != 0)
                {
                    // show target info
                    myConnection.Open();
                    OleDbCommand myCommandSelectID = new OleDbCommand("SELECT * FROM RegisteredUsers WHERE ID=@id", myConnection);
                    myCommandSelectID.Parameters.AddWithValue("@id", id);
                    OleDbDataReader myReader = myCommandSelectID.ExecuteReader();
                    while (myReader.Read())
                    {
                        Console.WriteLine("\nID: {0}\n1) username: {1}\n2) password: {2}\n3) email: {3}\n4) Realname: {4}\n5) birthday: {5}\n6) active: {6}", myReader.GetInt32(0).ToString(), myReader.GetString(1), myReader.GetString(2), myReader.GetString(3), myReader.GetString(4), myReader.GetDateTime(6).ToString("yyyy-MM-dd"), myReader.GetBoolean(7));
                    }
                    myReader.Close();
                    myConnection.Close();

                    // pick value to change
                    int    choice;
                    string newValue;
                    do
                    {
                        Console.Write("\nValue you want to change (write digit or '0' to change id): ");
                        choice = int.Parse(Console.ReadLine());

                        if (choice == 1)
                        {
                            Console.Write("\nWrite new username: "******"");
                            EditUserCommand("username", newValue, id);
                        }
                        else if (choice == 2)
                        {
                            Console.Write("\nWrite new password: "******"");
                            EditUserCommand("password", newValue, id);
                        }
                        else if (choice == 3)
                        {
                            Console.Write("\nWrite new email: ");
                            do
                            {
                                newValue = Console.ReadLine();
                            } while (newValue == "");
                            EditUserCommand("email", newValue, id);
                        }
                        else if (choice == 4)
                        {
                            Console.Write("\nWrite new name: ");
                            do
                            {
                                newValue = Console.ReadLine();
                            } while (newValue == "");
                            EditUserCommand("realname", newValue, id);
                        }
                        else if (choice == 5)
                        {
                            Console.Write("\nWrite new birthday(yyyy-mm-dd): ");
                            do
                            {
                                newValue = Console.ReadLine();
                            } while (newValue == "");
                            EditUserCommand("birthday", newValue, id);
                        }
                        else if (choice == 6)
                        {
                            Console.Write("\nIs user activated by email? (true/false): ");
                            do
                            {
                                newValue = Console.ReadLine();
                            } while (newValue == "");
                            EditUserCommand("activated", newValue, id);
                        }
                        else if (choice == 7)
                        {
                            Console.Write("\nIs user banned? (true/false): ");
                            do
                            {
                                newValue = Console.ReadLine();
                            } while (newValue == "");
                            EditUserCommand("banned", newValue, id);
                        }
                        else if (choice == 0)
                        {
                            EditUserMenu();
                            Console.ReadKey();
                        }
                    } while (choice != 0);
                }
                else
                {
                    Menu();
                }
            }
            catch (Exception e)
            {
                myConnection.Close();
                ErrorDisplay(e.Message);
            }
        }
Exemplo n.º 16
0
        public void WczytajRole(Konto konto)
        {
            conn.Open();

            var             zapytanie = $"Select * from Role WHERE Rola='{konto.rola}'";
            OleDbCommand    komenda   = new OleDbCommand(zapytanie, conn);
            OleDbDataReader reader    = komenda.ExecuteReader();

            role.Clear();
            while (reader.Read())
            {
                Rola rola = new Rola(
                    reader.GetString(0),        // rola
                    reader.GetBoolean(1),       // adresy odczyt
                    reader.GetBoolean(2),       // adresy zapis
                    reader.GetBoolean(3),       // konta odczyt
                    reader.GetBoolean(4),       // konta zapis
                    reader.GetBoolean(5),       // oceny odczyt
                    reader.GetBoolean(6),       // oceny zapis
                    reader.GetBoolean(7),       // produkty odczyt
                    reader.GetBoolean(8),       // produkty zapis
                    reader.GetBoolean(9),       // role odczyt
                    reader.GetBoolean(10),      // role zapis
                    reader.GetBoolean(11),      // transakcje odczyt
                    reader.GetBoolean(12),      // transakcje zapis
                    reader.GetBoolean(13),      // zamowienia odczyt
                    reader.GetBoolean(14)       // zamowienia zapis
                    );
                role.Add(rola);
            }

            conn.Close();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Get resourceboxes from the database
        /// </summary>
        /// <param name="startdate">Startdate of the resourceboxes to read, if DateTime(0) all resourceboxes are fetched</param>
        /// <param name="enddate">Enddate of the resourceboxes to read</param>
        /// <returns>0 - If all is ok</returns>
        internal int getResourceBoxes(DateTime startdate, DateTime enddate, out SortedList retlist)
        {
            /* Create SQL code for fetching resourceboxes */
            String sqlcmd = "SELECT id, starttime, endtime, name, free, locked, lockedstarttime, lockedendtime FROM ResourceBox";

            // If startdate and enddate is given, use them in a WHERE part of SQL
            if (startdate != new DateTime(0))
            {
                sqlcmd += " WHERE starttime BETWEEN #" + startdate.ToShortDateString() + " " + startdate.ToLongTimeString() + "# AND #" + enddate.ToShortDateString() + " " + enddate.ToLongTimeString() + "#";
            }

            // #1.01.003 - added line
            sqlcmd += " ORDER BY starttime";
            retlist = new SortedList();

            // Get data from database
            OleDbDataReader reader = executeSql(sqlcmd);

            if (reader == null)
            {
                return(ErrorHandler.ERR_UNEXPECTED_RESOURCEBOX_FETCH);
            }

            int i = 0;

            // #1.01.003 - added lines
            ResourceBox[] rbs;
            rbs = new ResourceBox[20000];

            // Add all data in the sortedlist
            while (reader.Read())
            {
                ResourceBox resursbox = new ResourceBox(reader.GetDateTime(1), reader.GetDateTime(2), reader.GetString(3), reader.GetBoolean(4), reader.GetBoolean(5), reader.GetDateTime(6), reader.GetDateTime(7));
                resursbox.Id = reader.GetInt32(0);
                // Get all overlaps of resourcebox
                retlist.Add(resursbox.Id, resursbox);

                rbs[i] = resursbox;                 // #1.01.003 - added line

                i++;
            }

            // #1.01.003 - added lines
            for (int o = 0; o < i - 1; o++)
            {
                for (int a = o + 1; rbs[a].StartTime <= rbs[o].EndTime && o < i; a++)
                {
                    if (rbs[a].StartTime != rbs[a].EndTime &&
                        rbs[o].StartTime != rbs[o].EndTime)
                    {
                        rbs[a].IdsNextTo.Add(rbs[o].Id, rbs[o].Id);
                        rbs[o].IdsNextTo.Add(rbs[a].Id, rbs[a].Id);
                    }
                    // #1.03 - added lines
                    if (a + 1 >= i)
                    {
                        break;
                    }
                }
            }
            // #1.01.003 - end

            reader.Close();
            return(ErrorHandler.NO_ERROR);
        }
Exemplo n.º 18
0
        public bool ImporteerSorteerFilms(string syntaxSQL)
        {
            bool            gelukt      = false;
            OleDbDataReader dbRead      = null;
            string          sqlOpdracht = syntaxSQL;

            try
            {
                dbConn.Open();
                sqlCommand = new OleDbCommand(sqlOpdracht, dbConn);
                dbRead     = sqlCommand.ExecuteReader();
                while (dbRead.Read())
                {
                    int    _id          = dbRead.GetInt16(0);
                    string _title       = dbRead.GetString(1).ToString();
                    int    _year        = dbRead.GetInt16(2);
                    int    _runTime     = dbRead.GetInt16(3);
                    string _genre       = dbRead.GetString(4).ToString();
                    string _director    = dbRead.GetString(5).ToString();
                    string _actor       = dbRead.GetString(6).ToString();
                    string _description = dbRead.GetString(7).ToString();
                    string _awards      = dbRead.GetString(8).ToString();
                    string _coverURL    = dbRead.GetString(9).ToString();
                    int    _metaScore   = dbRead.GetInt16(10);
                    double _imdbRating  = dbRead.GetDouble(11);
                    string _imdbID      = dbRead.GetString(12).ToString();
                    string _url         = dbRead.GetString(13).ToString();
                    bool   _watched     = dbRead.GetBoolean(14);
                    bool   _favorite    = dbRead.GetBoolean(15);


                    Movie film = new Movie
                    {
                        id          = (int)_id,
                        title       = _title,
                        year        = _year,
                        runTime     = _runTime,
                        genre       = _genre,
                        director    = _director,
                        actor       = _actor,
                        description = _description,
                        awards      = _awards,
                        coverURL    = _coverURL,
                        metaScore   = _metaScore,
                        imdbRating  = (float)_imdbRating,
                        imdbId      = _imdbID,
                        url         = _url,
                        watched     = _watched,
                        favorite    = _favorite
                    };

                    filmLijst.Add(film);
                }
                gelukt = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (dbRead != null)
                {
                    dbRead.Close();
                }
                if (dbConn != null)
                {
                    dbConn.Close();
                }
            }
            return(gelukt);
        }
        public Anrechnungs()
        {
            Anrechnungsgrunds anrechnungsgrunds = new Anrechnungsgrunds();

            using (OleDbConnection oleDbConnection = new OleDbConnection(Global.ConU))
            {
                try
                {
                    string queryString = @"SELECT 
CountValue.Deleted, 
CountValue.Text, 
CountValue.Value, 
CountValue.CV_REASON_ID, 
CountValue.TEACHER_ID, 
CountValue.DateFrom, 
CountValue.DateTo, 
Teacher.Name,
Teacher.PlannedWeek
FROM CountValue LEFT JOIN Teacher ON CountValue.TEACHER_ID = Teacher.TEACHER_ID
WHERE (((CountValue.SCHOOLYEAR_ID)=" + Global.AktSjUnt + @") AND ((CountValue.Deleted)=False) AND ((CountValue.Value)<>0) AND ((CountValue.TEACHER_ID)<>0) AND ((Teacher.SCHOOLYEAR_ID)=" + Global.AktSjUnt + @")) ORDER BY CountValue.TEACHER_ID;";

                    OleDbCommand oleDbCommand = new OleDbCommand(queryString, oleDbConnection);
                    oleDbConnection.Open();
                    OleDbDataReader oleDbDataReader = oleDbCommand.ExecuteReader();

                    double gesamtwert = 0;

                    while (oleDbDataReader.Read())
                    {
                        double wert;

                        try
                        {
                            wert = Convert.ToDouble(oleDbDataReader.GetInt32(2)) / 100000;
                        }
                        catch (Exception)
                        {
                            wert = 0;
                        }

                        Anrechnung anrechnung = new Anrechnung()
                        {
                            Gelöscht      = oleDbDataReader.GetBoolean(0),
                            Beschreibung  = Global.SafeGetString(oleDbDataReader, 1),
                            Wert          = wert,
                            Grund         = (from a in anrechnungsgrunds where a.UntisId == oleDbDataReader.GetInt32(3) select a).FirstOrDefault(),
                            LehrerIdUntis = oleDbDataReader.GetInt32(4),
                            Von           = oleDbDataReader.GetInt32(5) == 0 ? Global.ErsterTagDesSchuljahres : DateTime.ParseExact((oleDbDataReader.GetInt32(5)).ToString(), "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture),
                            Bis           = oleDbDataReader.GetInt32(6) == 0 ? Global.ErsterTagDesSchuljahres : DateTime.ParseExact((oleDbDataReader.GetInt32(6)).ToString(), "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture),
                            LehrerKürzel  = Global.SafeGetString(oleDbDataReader, 7),
                            DeputatSoll   = Convert.ToDouble(oleDbDataReader.GetInt32(8)) / 1000
                        };

                        // Wenn eine Anrechnung mit dem selben Lehrer und dem selben Grund schon existiert, dann wird der Wert addiert, ...

                        var anr = (from an in this where an.LehrerIdUntis == anrechnung.LehrerIdUntis where an.Grund == anrechnung.Grund select an).FirstOrDefault();

                        if (anr != null)
                        {
                            anr.Wert = anr.Wert + anrechnung.Wert;
                        }
                        else
                        {
                            this.Add(anrechnung);
                        }
                        gesamtwert = gesamtwert + anrechnung.Wert;
                    }
                    ;
                    oleDbDataReader.Close();
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    oleDbConnection.Close();
                }
            }
        }
Exemplo n.º 20
0
        private void ShowButtonClick(object sender, EventArgs e)
        {
            int counter = 0;

            try
            {
                fromDateDT = DateTime.Parse(fromDayTB.Text + "/" + fromMonthTB.Text + "/" + fromYearTB.Text);
                toDateDT   = DateTime.Parse(toDayTB.Text + "/" + toMonthTB.Text + "/" + toYearTB.Text);
                fromYear   = fromDateDT.Year;
                fromMonth  = fromDateDT.Month;
                fromDay    = fromDateDT.Day;
                toYear     = toDateDT.Year;
                toMonth    = toDateDT.Month;
                toDay      = toDateDT.Day;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Get date from user failed. Check your date values and try again " + ex.Message, "Errors",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                OleDbCommand datacommand = new OleDbCommand();
                datacommand.Connection  = dataConnection;
                datacommand.CommandText = "SELECT * " +
                                          "FROM tblAnnuals " +
                                          "WHERE ((annualYear BETWEEN " + fromYear + " AND " + toYear + ") " +
                                          "OR (" + fromYear + "=" + toYear + "= annualYear" + " AND (annualMonth BETWEEN " + fromMonth + " AND " + toMonth + ")) " +
                                          "OR (" + fromYear + "=" + toYear + "= annualYear" + " AND " + fromMonth + "=" + toMonth + "= annualMonth" + " AND (annualDay BETWEEN " + fromDay + " AND " + toDay + ")) " +
                                          "OR (" + fromYear + "=" + toYear + "= annualYear" + " AND " + fromMonth + "=" + toMonth + "= annualMonth" + " AND " + fromDay + "=" + toDay + "= annualDay" + ")) " +
                                          "ORDER BY annualID";
                OleDbDataReader dataReader = datacommand.ExecuteReader();
                while (dataReader.Read())
                {
                    annualID    = dataReader.GetInt32(0).ToString();
                    annualType  = dataReader.GetString(1);
                    annualName  = dataReader.GetString(2);
                    annualYear  = dataReader.GetInt32(3).ToString();
                    annualMonth = dataReader.GetInt32(4).ToString();
                    annualDay   = dataReader.GetInt32(5).ToString();
                    if (GregDateRadioButton.Checked && !dataReader.GetBoolean(6))
                    {
                        continue;
                    }
                    else if (HebDateRadioButton.Checked && dataReader.GetBoolean(6))
                    {
                        continue;
                    }
                    annualPicture = dataReader.GetString(7);
                    counter++;
                    EditListView(counter);
                }
                dataReader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ShowButtonClick failed. " + ex.Message, "Errors",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Exemplo n.º 21
0
        private void textBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (myport.IsOpen)
            {
                while (cflag == 0)          //接受下位机卡号
                {
                    byte[] data  = new byte[8];
                    byte[] rdata = new byte[6];
                    myport.Read(data, 0, 8);
                    if ((data[6] == 0x33) && (data[7] == 0x44))
                    {
                        for (int i = 0; i <= 5; i++)
                        {
                            rdata[i] = data[i];
                        }
                        cflag = 1;
                        ss    = byteToHexStr(rdata);
                    }
                }
                textBox1.Text = ss;

                //生成链接数据库字符串
                string conStr = "provider=Microsoft.ACE.OLEDB.12.0;Persist Security Info=False;Data Source=" + "myNewIC.mdb";
                //创建数据库连接
                OleDbConnection conn = new OleDbConnection(conStr);
                //打开数据库连接
                conn.Open();
                OleDbDataReader myReader = null;
                //sql语句
                string sql = "select * from myTable where cstr(卡号)='" + ss + "'";
                //命令
                OleDbCommand cmd = new OleDbCommand(sql, conn);
                myReader = cmd.ExecuteReader();

                if (myReader.Read())            //是否查到卡号
                {
                    if (myReader.GetBoolean(3)) //是否挂失
                    {
                        www();
                        MessageBox.Show("此卡已挂失", "Warning");

                        cflag            = 0;
                        ID.Visible       = false;
                        textBox1.Visible = false;
                        button1.Visible  = true;
                        textBox1.Text    = "";
                    }
                    else
                    {
                        if (myReader.GetBoolean(1)) //是否管理员
                        {
                            MessageBox.Show("请点击管理员登录", "Warning");
                            cflag = 0;
                            myport.Close();
                            ID.Visible       = false;
                            textBox1.Visible = false;
                            button1.Visible  = true;
                            textBox1.Text    = "";
                        }
                        else
                        {
                            //把余额转后后发送给下位机
                            decimal money = myReader.GetDecimal(4);
                            if (money >= 100)
                            {
                                string mm      = Convert.ToString(money * 10);
                                byte[] myMoney = new byte[8];
                                myMoney[0] = 0xaa;
                                myMoney[5] = 0x00;
                                myMoney[6] = 0x33;
                                myMoney[7] = 0x44;
                                for (int x = 0; x <= 3; x++)
                                {
                                    if (mm[x] == '0')
                                    {
                                        myMoney[4 - x] = 0x30;
                                    }
                                    if (mm[x] == '1')
                                    {
                                        myMoney[4 - x] = 0x31;
                                    }
                                    if (mm[x] == '2')
                                    {
                                        myMoney[4 - x] = 0x32;
                                    }
                                    if (mm[x] == '3')
                                    {
                                        myMoney[4 - x] = 0x33;
                                    }
                                    if (mm[x] == '4')
                                    {
                                        myMoney[4 - x] = 0x34;
                                    }
                                    if (mm[x] == '5')
                                    {
                                        myMoney[4 - x] = 0x35;
                                    }
                                    if (mm[x] == '6')
                                    {
                                        myMoney[4 - x] = 0x36;
                                    }
                                    if (mm[x] == '7')
                                    {
                                        myMoney[4 - x] = 0x37;
                                    }
                                    if (mm[x] == '8')
                                    {
                                        myMoney[4 - x] = 0x38;
                                    }
                                    if (mm[x] == '9')
                                    {
                                        myMoney[4 - x] = 0x39;
                                    }
                                }
                                myport.Write(myMoney, 0, 8);
                            }

                            tString = textBox1.Text;        //传递给user窗口

                            user form = new user();
                            form.ShowDialog();
                            this.Hide();
                            myport.Close();
                            cflag = 0;
                        }
                    }
                }
                else
                {
                    www();
                    MessageBox.Show("此卡无效", "Warning");

                    cflag            = 0;
                    ID.Visible       = false;
                    textBox1.Visible = false;
                    button1.Visible  = true;
                    textBox1.Text    = "";
                }
                myReader.Close();
                conn.Close();

                myport.Close();
            }
            else
            {
                MessageBox.Show("请打开串口", "Warning");
                ID.Visible       = false;
                textBox1.Visible = false;
                button1.Visible  = true;
            }
        }
Exemplo n.º 22
0
    public static List <ziyaretci> SelectAllziyaretci(OleDbCommand komut)
    {
        List <ziyaretci> Listziyaretci = new List <ziyaretci>();

        OleDbConnection baglanti = AcikBaglantiGetir();

        try
        {
            komut.Connection = baglanti;
            OleDbDataReader oku = komut.ExecuteReader();
            while (oku.Read())
            {
                ziyaretci yeniziyaretci = new ziyaretci();
                if (!oku.IsDBNull(0))
                {
                    yeniziyaretci.Id = oku.GetInt32(0);
                }
                if (!oku.IsDBNull(1))
                {
                    yeniziyaretci.Ip = oku.GetString(1);
                }
                if (!oku.IsDBNull(2))
                {
                    yeniziyaretci.Dil = oku.GetString(2);
                }
                if (!oku.IsDBNull(3))
                {
                    yeniziyaretci.Sistem = oku.GetString(3);
                }
                if (!oku.IsDBNull(4))
                {
                    yeniziyaretci.Browser = oku.GetString(4);
                }
                if (!oku.IsDBNull(5))
                {
                    yeniziyaretci.Tarih = oku.GetDateTime(5);
                }
                if (!oku.IsDBNull(6))
                {
                    yeniziyaretci.Link = oku.GetString(6);
                }
                if (!oku.IsDBNull(7))
                {
                    yeniziyaretci.Gonderen = oku.GetString(7);
                }
                if (!oku.IsDBNull(8))
                {
                    yeniziyaretci.Durum = oku.GetBoolean(8);
                }

                Listziyaretci.Add(yeniziyaretci);
            }
        }
        catch
        {
            throw;
        }
        finally
        {
            BaglantiyiKapat(baglanti);
        }
        return(Listziyaretci);
    }
        public static void esportaInWord()
        {
            string path    = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Utilities\\Veicoli.accdb";
            string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path;

            if (connStr != null)
            {
                OleDbConnection con = new OleDbConnection(connStr);
                using (con)
                {
                    OleDbCommand com = new OleDbCommand("SELECT * FROM VEICOLI", con);
                    con.Open();

                    OleDbDataReader reader = com.ExecuteReader();

                    if (reader.HasRows)
                    {
                        string filepath            = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Utilities\\Veicoli.docx";
                        WordprocessingDocument doc = WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document);

                        MainDocumentPart mainPart = doc.AddMainDocumentPart();

                        mainPart.Document = new Document();
                        Body body = mainPart.Document.AppendChild(new Body());

                        ClsWord.AddStyle(mainPart, "Intestazione", "style1", "Consolas", 28, "#FF8800", true, false, false);

                        Paragraph headingPar = ClsWord.CreateParagraphWithStyle("Intestazione", JustificationValues.Center);
                        ClsWord.AddTextToParagraph(headingPar, "Vendita veicoli");
                        body.AppendChild(headingPar);

                        while (reader.Read())
                        {
                            string usato  = String.Empty;
                            string kmzero = String.Empty;
                            if (reader.GetBoolean(8))
                            {
                                usato = "Sì";
                            }
                            else
                            {
                                usato = "No";
                            }
                            if (reader.GetBoolean(9))
                            {
                                kmzero = "Sì";
                            }
                            else
                            {
                                kmzero = "No";
                            }
                            if (reader.GetString(1) == "MOTO")
                            {
                                Paragraph p = body.AppendChild(new Paragraph());
                                Run       r = p.AppendChild(new Run());
                                r.AppendChild(new Text("- " + reader.GetString(1)));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Marca: " + reader.GetString(2)));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Modello: " + reader.GetString(3)));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Colore: " + reader.GetString(4)));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Cilindrata: " + reader.GetInt32(5).ToString()));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("PotenzaKw: " + reader.GetInt32(6).ToString()));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Data di immatricolazione: " + reader.GetDateTime(7).ToShortDateString()));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Usato: " + usato));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Kmzero: " + kmzero));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Km percorsi: " + reader.GetInt32(10).ToString() + " km"));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Sella: " + reader.GetString(11)));
                                r.AppendChild(new Break());
                            }
                            else
                            {
                                Paragraph p = body.AppendChild(new Paragraph());
                                Run       r = p.AppendChild(new Run());
                                r.AppendChild(new Text("- " + reader.GetString(1)));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Marca: " + reader.GetString(2)));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Modello: " + reader.GetString(3)));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Colore: " + reader.GetString(4)));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Cilindrata: " + reader.GetInt32(5).ToString()));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("PotenzaKw: " + reader.GetInt32(6).ToString()));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Data di immatricolazione: " + reader.GetDateTime(7).ToShortDateString()));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Usato: " + usato));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Kmzero: " + kmzero));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Km percorsi: " + reader.GetInt32(10).ToString() + " km"));
                                r.AppendChild(new Break());
                                r.AppendChild(new Text("Numero di airbag: " + reader.GetString(11)));
                                r.AppendChild(new Break());
                            }
                        }
                        doc.Close();
                        Console.Write("\nDocumento creato correttamente, desideri aprirlo?[S/N]: ");
                        if (Console.ReadLine() == "S")
                        {
                            Process.Start(filepath);
                        }
                        else
                        {
                            Thread.Sleep(2000);
                        }
                    }
                    else
                    {
                        Console.WriteLine("No rows found");
                    }
                }
            }
        }
Exemplo n.º 24
0
    public static List <kullanici> SelectAllkullanici(OleDbCommand komut)
    {
        List <kullanici> Listkullanici = new List <kullanici>();

        OleDbConnection baglanti = AcikBaglantiGetir();

        try
        {
            komut.Connection = baglanti;
            OleDbDataReader oku = komut.ExecuteReader();
            while (oku.Read())
            {
                kullanici yenikullanici = new kullanici();
                if (!oku.IsDBNull(0))
                {
                    yenikullanici.Id = oku.GetInt32(0);
                }
                if (!oku.IsDBNull(1))
                {
                    yenikullanici.AdiSoyadi = oku.GetString(1);
                }
                if (!oku.IsDBNull(2))
                {
                    yenikullanici.KullaniciAdi = oku.GetString(2);
                }
                if (!oku.IsDBNull(3))
                {
                    yenikullanici.Sifre = oku.GetString(3);
                }
                if (!oku.IsDBNull(4))
                {
                    yenikullanici.Mail = oku.GetString(4);
                }
                if (!oku.IsDBNull(5))
                {
                    yenikullanici.Tel = oku.GetString(5);
                }
                if (!oku.IsDBNull(6))
                {
                    yenikullanici.Adres = oku.GetString(6);
                }
                if (!oku.IsDBNull(7))
                {
                    yenikullanici.AdminMi = oku.GetBoolean(7);
                }
                if (!oku.IsDBNull(8))
                {
                    yenikullanici.Durum = oku.GetBoolean(8);
                }

                Listkullanici.Add(yenikullanici);
            }
        }
        catch
        {
            throw;
        }
        finally
        {
            BaglantiyiKapat(baglanti);
        }
        return(Listkullanici);
    }
Exemplo n.º 25
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if ((notifyIcon1.Visible) && 窗口.leave_count == 1)
     {
         //如果有在处理的请假信息  就查询
         try
         {
             OleDbCommand sql1 = 窗口.conn.CreateCommand();
             sql1.CommandText = "SELECT 请假时间,请假条编号,是否通过,结束时间 from 请假 where 请假人工号='" + a + "' and 是否查看=true and 是否通知 = false";
             OleDbDataReader rea = sql1.ExecuteReader();
             if (rea.Read())
             {
                 string       sql = "update 请假 set 是否通知=true where 请假条编号 =" + rea.GetValue(1);
                 OleDbCommand cmd = new OleDbCommand(sql, 窗口.conn);
                 int          res = cmd.ExecuteNonQuery();
                 窗口.leave_count = 0;
                 if (rea.GetBoolean(2))
                 {
                     MessageBox.Show("你的" + rea.GetDateTime(0).ToString("yyyy/MM/dd") + "至" + rea.GetDateTime(3).ToString("yyyy/MM/dd") + "的请假已通过");
                 }
                 else
                 {
                     MessageBox.Show("你的" + rea.GetDateTime(0).ToString("yyyy/MM/dd") + "至" + rea.GetDateTime(3).ToString("yyyy/MM/dd") + "的请假未通过");
                 }
             }
         }
         catch
         {
             this.Hide();
             this.Close();
             if (窗口.登录 != null)
             {
                 窗口.登录.Show();
             }
         }
     }
     if ((notifyIcon1.Visible) && 窗口.error_count > 0)
     { //如果有在处理的错误报告 就查询
         try
         {
             OleDbCommand sql2 = 窗口.conn.CreateCommand();
             sql2.CommandText = "SELECT 错误内容,编号 from 错误报告 where 申请人工号='" + a + "' and 是否处理=true and 是否通知 = false";
             OleDbDataReader read = sql2.ExecuteReader();
             if (read.Read())
             {
                 string       sql = "update 错误报告 set 是否通知=true where 编号 =" + read.GetValue(1);
                 OleDbCommand cmd = new OleDbCommand(sql, 窗口.conn);
                 int          res = cmd.ExecuteNonQuery();
                 if (res > 0)
                 {
                     MessageBox.Show("你提交的错误:\n" + read.GetString(0) + "\n已处理\n如修改过照片 请重新登录以更新");
                     窗口.error_count--;
                 }
             }
         }
         catch
         {
             this.Hide();
             this.Close();
             if (窗口.登录 != null)
             {
                 窗口.登录.Show();
             }
         }
     }
 }
Exemplo n.º 26
0
    public static ayar Selectayar(OleDbCommand komut)
    {
        ayar yeniayar = null;

        OleDbConnection baglanti = AcikBaglantiGetir();

        try
        {
            komut.Connection = baglanti;
            OleDbDataReader oku = komut.ExecuteReader();
            if (oku.Read())
            {
                yeniayar = new ayar();
                if (!oku.IsDBNull(0))
                {
                    yeniayar.Id = oku.GetInt32(0);
                }
                if (!oku.IsDBNull(1))
                {
                    yeniayar.SirketAdi = oku.GetString(1);
                }
                if (!oku.IsDBNull(2))
                {
                    yeniayar.SiteAdi = oku.GetString(2);
                }
                if (!oku.IsDBNull(3))
                {
                    yeniayar.Adres = oku.GetString(3);
                }
                if (!oku.IsDBNull(4))
                {
                    yeniayar.Telefon = oku.GetString(4);
                }
                if (!oku.IsDBNull(5))
                {
                    yeniayar.Telefon2 = oku.GetString(5);
                }
                if (!oku.IsDBNull(6))
                {
                    yeniayar.Faks = oku.GetString(6);
                }
                if (!oku.IsDBNull(7))
                {
                    yeniayar.Gsm = oku.GetString(7);
                }
                if (!oku.IsDBNull(8))
                {
                    yeniayar.Klasor = oku.GetString(8);
                }
                if (!oku.IsDBNull(9))
                {
                    yeniayar.AdminMail = oku.GetString(9);
                }
                if (!oku.IsDBNull(10))
                {
                    yeniayar.Mail = oku.GetString(10);
                }
                if (!oku.IsDBNull(11))
                {
                    yeniayar.MailServer = oku.GetString(11);
                }
                if (!oku.IsDBNull(12))
                {
                    yeniayar.MailPassword = oku.GetString(12);
                }
                if (!oku.IsDBNull(13))
                {
                    yeniayar.MailPort = oku.GetString(13);
                }
                if (!oku.IsDBNull(14))
                {
                    yeniayar.SorumluMail = oku.GetString(14);
                }
                if (!oku.IsDBNull(15))
                {
                    yeniayar.HataLoglama = oku.GetBoolean(15);
                }
                if (!oku.IsDBNull(16))
                {
                    yeniayar.HataMail = oku.GetBoolean(16);
                }
                if (!oku.IsDBNull(17))
                {
                    yeniayar.Aktif = oku.GetBoolean(17);
                }
            }
        }
        catch
        {
            throw;
        }
        finally
        {
            BaglantiyiKapat(baglanti);
        }
        return(yeniayar);
    }
Exemplo n.º 27
0
        //Onglet Recapitulatif
        private void btnCreeReca_Click(object sender, EventArgs e)
        {
            try
            {
                //Initialisation des variables
                connec.Open();
                string         mois             = dtpReca.Value.Month.ToString();
                string         annee            = dtpReca.Value.Year.ToString();
                string         text             = "____________________________________________________";
                string         typeNull         = "Type NULL";
                float          montant          = 0;
                int            recette          = 0;
                int            percu            = 0;
                int            indentation      = 20;
                int            hauteurDesLignes = 720;
                List <string>  un            = new List <string>();
                List <string>  de            = new List <string>();
                List <string>  tr            = new List <string>();
                List <string>  qu            = new List <string>();
                List <string>  ci            = new List <string>();
                List <string>  si            = new List <string>();
                List <Boolean> nbTransaction = new List <Boolean>();
                pdfDocument    myDoc         = new pdfDocument("Recapitulatif_" + mois + "_" + annee, "Pique_Sous");
                pdfPage        myPage        = myDoc.addPage();

                //SQL
                OleDbCommand    cd1 = new OleDbCommand("SELECT [Transaction].* FROM [Transaction] WHERE MONTH([dateTransaction]) = " + dtpReca.Value.Month.ToString(), connec);
                OleDbDataReader dr1 = cd1.ExecuteReader();

                //Lecture de la base
                while (dr1.Read())
                {
                    nbTransaction.Add(dr1.GetBoolean(4));
                    if (dr1.GetBoolean(4) == true)
                    {
                        recette++;
                    }
                    if (dr1.GetBoolean(5) == true)
                    {
                        percu++;
                    }
                    montant = montant + dr1.GetFloat(3);

                    un.Add(dr1[1].ToString().Substring(0, 11));
                    de.Add(dr1[2].ToString());
                    tr.Add(dr1[3].ToString());
                    qu.Add(dr1[4].ToString());
                    ci.Add(dr1[5].ToString());

                    if (dr1[6].ToString() != "")
                    {
                        si.Add(dr1[6].ToString());
                    }
                    else
                    {
                        si.Add(typeNull);
                    }
                }
                for (int i = 0; i < si.Count; i++)
                {
                    if (si[i] != typeNull)
                    {
                        //Pour eviter de faire une requette avec une jointure
                        OleDbCommand    cd2 = new OleDbCommand("SELECT [TypeTransaction].* FROM [TypeTransaction] where [codeType] = " + si[i], connec);
                        OleDbDataReader dr2 = cd2.ExecuteReader();
                        while (dr2.Read())
                        {
                            si[i] = dr2[1].ToString();
                        }
                    }
                }

                //Creation du text dans le PDF
                myPage.addText("Recapitulatif du : " + mois + "_" + annee, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText("Dépenses", indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - (30 + 25 * un.Count);
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText("Recette : " + recette.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(" Depenses : " + montant.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText("Reste a persevoir : " + percu.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText("Somme total dépensée : -" + montant.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText("nombres de transactions : " + nbTransaction.Count.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);

                //Initiallisation tableau PDF
                pdfTable myTable = new pdfTable(myDoc);
                myTable.borderSize  = 1;
                myTable.borderColor = sharpPDF.pdfColor.Black;
                myTable.tableHeader.addColumn(90);
                myTable.tableHeader.addColumn(120);
                myTable.tableHeader.addColumn(70);
                myTable.tableHeader.addColumn(70);
                myTable.tableHeader.addColumn(70);
                myTable.tableHeader.addColumn(110);
                pdfTableRow myRow = myTable.createRow();

                //Remplissage de la première ligne du tableau
                myRow[0].addText("Date Transaction");
                myRow[1].addText("Description");
                myRow[2].addText("Montant");
                myRow[3].addText("Recette ?");
                myRow[4].addText("Perçu ?");
                myRow[5].addText("Type de dépence ?");
                myTable.addRow(myRow);

                //Remplissage des ligne du tableau
                for (int i = 0; i < un.Count; i++)
                {
                    myRow = myTable.createRow();
                    myRow[0].addText(un[i]);
                    myRow[1].addText(de[i]);
                    myRow[2].addText(tr[i]);
                    myRow[3].addText(qu[i]);
                    myRow[4].addText(ci[i]);
                    myRow[5].addText(si[i]);
                    myTable.addRow(myRow);
                }

                //Place le tableau
                myTable.coordY = 650;
                myTable.coordX = 20;
                myPage.addTable(myTable);

                //creer le PDF
                FolderBrowserDialog fbd = new FolderBrowserDialog();
                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    myDoc.createPDF(fbd.SelectedPath + @"\Recapitulatif_" + mois + "_" + annee + ".pdf");
                }
                myPage = null;
                myDoc  = null;
                connec.Close();
                MessageBox.Show("PDF créé");
            }
            catch (InvalidOperationException erreur)
            {
                MessageBox.Show("Erreur de chaine de connexion ! pdf");
                MessageBox.Show(erreur.Message);
            }
            catch (OleDbException erreur)
            {
                MessageBox.Show("Erreur de requete SQL ! pdf");
                MessageBox.Show(erreur.Message);
            }
        }
 public override Family PopulateRecord(OleDbDataReader reader)
 {
     return(new Family
     {
         PID = reader.GetDouble(0),
         SaveDate = reader.GetDateTime(1),
         Stroke = reader.GetBoolean(2),
         CAD = reader.GetBoolean(3),
         MI = reader.GetBoolean(4),
         Father = reader.GetBoolean(5),
         Mother = reader.GetBoolean(6),
         NotSure = reader.GetBoolean(7),
         DiabetesType = reader.IsDBNull(8) == true ? null : reader.GetString(8),
         Breast = reader.GetBoolean(9),
         Liver = reader.GetBoolean(10),
         Gastric = reader.GetBoolean(11),
         Colon = reader.GetBoolean(12),
         Skin = reader.GetBoolean(13),
         Lung = reader.GetBoolean(14),
         CancerOthers = reader.IsDBNull(15) == true ? null : reader.GetString(15)
     });
 }
Exemplo n.º 29
0
        /// <summary>
        /// Loads the catalog's settings and sets up the class to take requests.
        /// </summary>
        /// <returns></returns>
        public void Load()
        {
            if (sync)
            {
                throw(new ContentManagerException("Cannot create a synchronized catalog.", 991));
            }

            StringBuilder s = new StringBuilder("SELECT ");

            s.Append(catalogFields);
            s.Append(" FROM kitCms_Catalogs WHERE CatalogID=");
            s.Append(iD);
            s.Append(";");

            OleDbDataReader r = this.runReader(s.ToString());

            if (r.Read())
            {
                name                     = r.GetString(0);
                description              = r.GetString(1);
                pressTime                = TimeSpan.FromTicks((long)r.GetDouble(2));
                pressDate                = r.GetDateTime(3);
                expireTime               = TimeSpan.FromTicks((long)r.GetDouble(4));
                expireDate               = r.GetDateTime(5);
                archiveTime              = TimeSpan.FromTicks((long)r.GetDouble(6));
                archiveDate              = r.GetDateTime(7);
                archiveOnExpiration      = r.GetBoolean(8);
                archiveCatalogID         = r.GetInt32(9);
                authorRoleID             = r.GetInt32(10);
                reviewerRoleID           = r.GetInt32(11);
                editorRoleID             = r.GetInt32(12);
                publisherRoleID          = r.GetInt32(13);
                adminRoleID              = r.GetInt32(14);
                authorDisabled           = r.GetBoolean(15);
                reviewDisabled           = r.GetBoolean(16);
                editDisabled             = r.GetBoolean(17);
                publishDisabled          = r.GetBoolean(18);
                dynamicParseTypeDisabled = r.GetBoolean(19);
                trackChangesDisabled     = r.GetBoolean(20);
                hitCounterDisabled       = r.GetBoolean(21);
                contentType              = (ContentType)r.GetByte(22);
                trackChangesType         = (ContentTrackChangesType)r.GetByte(23);
                hitCounterType           = (ContentHitCounterType)r.GetByte(24);
                enableHtmlAuthoring      = r.GetBoolean(25);
                enableCss                = r.GetBoolean(26);
                enableParagraphStyles    = r.GetBoolean(27);
                enableFontForeColor      = r.GetBoolean(28);
                enableFontBackColor      = r.GetBoolean(29);
                enableFormatting         = r.GetBoolean(30);
                enableImages             = r.GetBoolean(31);
                enableCustomCss          = r.GetBoolean(32);
                cssLink                  = r.GetString(33);
                cssStyles                = r.GetString(34);
                cssNames                 = r.GetString(35);
                paragraphStyles          = r.GetString(36);
                paragraphNames           = r.GetString(37);
                fontColorValues          = r.GetString(38);
                fontColorNames           = r.GetString(39);
                imageLocation            = r.GetString(40);
                sync                     = true;
            }
        }
Exemplo n.º 30
0
        private void Form_Load(object sender, EventArgs e)
        {
            if (insertMode)
            {
                btnAction.Text = "&Insert";
            }
            else
            {
                btnAction.Text     = "&Update";
                cbPost.Enabled     = false;
                txtStation.Enabled = false;
            }

            InitComboPost();

            if (staName == "" || postName == "")
            {
                return;
            }

            if (Database.Me.Connected)
            {
                string sql = "SELECT name,post,canlogin,keterangan FROM stations WHERE name=? and post=?";
                try
                {
                    Database.Me.OpenConnection();
                    using (OleDbCommand cmd = new OleDbCommand(sql, Database.Me.Connection))
                    {
                        cmd.Parameters.Add("?", OleDbType.VarChar, 32).Value = staName;
                        cmd.Parameters.Add("?", OleDbType.VarChar, 32).Value = postName;

                        using (OleDbDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                reader.Read();

                                txtStation.Text = staName;

                                string _post = reader.GetString(1).Trim();
                                cbPost.Text = _post;

                                bool _canLogin = reader.GetBoolean(2);
                                rbCanLogin.Checked    = _canLogin;
                                rbCannotLogin.Checked = !_canLogin;

                                var remark = reader.GetValue(3);
                                if (remark != null)
                                {
                                    txtRemark.Text = remark.ToString().Trim();
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log("QueueAdmin : Exception : " + ex.Message);
                }
            }
        }