Пример #1
0
        private void SilenceCreateNewElement(int pageSectionID, string ElementName)
        {
            Boolean flag          = true;
            var     sql           = new Sql();
            var     dataset       = new DataSetAutoTest();
            var     adapterGuimap = new GuiMapTableAdapter();

            if (pageSectionID > 0)
            {
                adapterGuimap.Fill(dataset.GuiMap);
                DataTableReader dtElementReader = dataset.GuiMap.CreateDataReader();

                while (dtElementReader.Read())
                {
                    //GuiMapID 0
                    var col1 = dtElementReader.GetValue(1).ToString().Trim();                  //GuiMapObjectName
                    var col2 = dtElementReader.GetValue(2).ToString().Trim();                  //TagTypeID === 2
                    var col3 = dtElementReader.GetValue(3).ToString().Trim();                  //TagTypeValue
                    var col4 = Convert.ToInt32(dtElementReader.GetValue(4).ToString().Trim()); //GuiProjectID == PageSection

                    if (col4 == pageSectionID && col3 == ElementName)
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    string guiMapObjectName = _pprefix + ElementName;
                    adapterGuimap.Insert(guiMapObjectName, 2, ElementName, pageSectionID);
                    string GuiMapId = adapterGuimap.GetLastGuiMapId().ToString();
                    sql.UpdateVersion("GuiMap", "GuiMapID", GuiMapId, this._VersionName, 1);
                }
            }
        }
Пример #2
0
        private static void PrintTable(DataTable dataTable)
        {
            DataTableReader reader = dataTable.CreateDataReader();

            //dataTable.Columns
            foreach (DataColumn d in dataTable.Columns)
            {
                Console.Write(string.Format("{0,-20}", d.ColumnName));
            }
            Console.Write("\r\n\r\n");
            while (reader.Read())
            {
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    if (reader.GetFieldType(i) == typeof(System.DateTime))
                    {
                        Console.Write(string.Format("{0,-20:dd-MM-yyyy}", reader.GetValue(i)));
                    }
                    else
                    {
                        Console.Write(string.Format("{0,-20}", reader.GetValue(i)));
                    }
                }
                Console.WriteLine();
            }
        }
Пример #3
0
        // Метод авторизации в клиент-серверном приложении
        private void autentification()
        {
            // Проверка заполнености полей авторизации:
            if (!textBox1.Text.Equals("") && !textBox2.Text.Equals(""))
            {
                DataTableReader reader = aFTDataSet.CreateDataReader();
                while (reader.Read())
                {
                    // Если логин найден в списке пользователей и пароль совпал с введенным
                    if (textBox1.Text.Equals(reader.GetValue(1)) && textBox2.Text.Equals(reader.GetValue(2)))
                    {
                        //MessageBox.Show("Авторизация прошла успешно!", "Уведомление", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        User.username = reader.GetValue(1).ToString();
                        User.password = reader.GetValue(2).ToString();
                        User.type     = reader.GetValue(3).ToString();
                        // Очистим поля ввода
                        textBox1.Text = ""; textBox2.Text = "";
                        // Создание объектов форм
                        Admin   admin       = new Admin();
                        Stuff   stuff       = new Stuff();
                        Student studentform = new Student();
                        // Теперь необходимо предоставить каждому пользователю соответствующую ему форму
                        switch (User.type)
                        {
                        // Открыть форму админа с рут правами
                        case "root":
                            admin.Show();
                            Hide();
                            break;

                        case "admin":
                            admin.Show();
                            Hide();
                            break;

                        case "stuff":
                            stuff.Show();
                            Hide();
                            break;

                        case "student":
                            studentform.Show();
                            Hide();
                            break;
                        }
                        return;
                    }
                }
                MessageBox.Show("Данная кобинация логина и пароля не опознана!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            // Иначе сообщить пользователю, что он нехороший человек
            else
            {
                MessageBox.Show("Не все поля ввода заполнены корректно!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #4
0
        // create a dictionary from two columns data
        Dictionary <object, string> GetLookup(string name)
        {
            var             dict   = new Dictionary <object, string>();
            DataTableReader reader = DemoDataSource(name).CreateDataReader();

            while (reader.Read())
            {
                dict.Add(reader.GetValue(0), reader.GetValue(1).ToString());
            }
            reader.Close();
            return(dict);
        }
Пример #5
0
        private void LoadDataToTree(DataTable dt)
        {
            DataTableReader dtReader = dt.CreateDataReader();

            while (dtReader.Read())
            {
                Employee newEmployee = new Employee(Convert.ToInt32(dtReader.GetValue(0)), dtReader.GetValue(1).ToString(), dtReader.GetValue(2).ToString(),
                                                    dtReader.GetValue(3).ToString(), Convert.ToInt32(dtReader.GetValue(4)), Convert.ToDouble(dtReader.GetValue(5)));
                tree.Add(newEmployee);
            }
            dtReader.Close();
        }
Пример #6
0
        public static string ToJson(this DataTableReader obj)
        {
            var sb = new StringBuilder();

            sb.Append("[");

            var isFirstRow = true;

            while (obj.Read())
            {
                if (!isFirstRow)
                {
                    sb.Append(",");
                }

                sb.Append("{");
                for (var i = 0; i < obj.FieldCount; i++)
                {
                    if (obj.GetValue(i) == null)
                    {
                        continue;
                    }
                    if (obj.GetValue(i) is DBNull)
                    {
                        continue;
                    }

                    if (i > 0)
                    {
                        sb.Append(", ");
                    }

                    sb.Append("\"" + obj.GetName(i) + "\":");

                    if (obj.GetValue(i).GetType().Name == "DateTime")
                    {
                        sb.Append("\"" + obj.GetDateTime(i).ToString("o") + "\"");
                    }
                    else
                    {
                        sb.Append(CleanupJsonData(obj.GetValue(i).ToString()));
                    }
                }

                sb.Append("}");
                isFirstRow = false;
            }

            sb.Append("]");
            return(sb.ToString());
        }
Пример #7
0
 public override IEnumerable <CellReader> ReadCells()
 {
     for (var i = 0; i < _reader.FieldCount; i++)
     {
         yield return(CellReader.Create(_reader.GetValue(i)));
     }
 }
Пример #8
0
        private void btnEntrar_Click(object sender, EventArgs e)
        {
            int login, correto;

            login = Convert.ToInt16(txtLogin.Text);
            frmVendas       frmVendas = new frmVendas();
            DataTableReader Dados     = new DataTableReader(clsFuncionario.recuperarSenha());
            bool            logado    = false;

            while (Dados.Read())
            {
                correto = Convert.ToInt16(Dados.GetValue(0));
                if (correto == login &&
                    String.Compare(Dados.GetString(1), Convert.ToString(txtSenha.Text)) == 0)
                {
                    logado       = true;
                    frmVendas.Ok = Convert.ToInt32(txtLogin.Text);
                    break;
                }
            }
            if (logado)
            {
                frmVendas.ShowDialog();
                this.Visible = false;
            }
            else
            {
                MessageBox.Show("Usuário ou Senha Inválidos", "Erro ao Autenticar",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtLogin.Text = "";
                txtSenha.Text = "";
                txtLogin.Focus();
            }
        }
    protected void lstDimensiones_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        if (e.Item.ItemType == ListViewItemType.DataItem)
        {
            if (this.datasetid.HasValue)
            {
                System.Data.DataRowView rowView = e.Item.DataItem as System.Data.DataRowView;
                int     DimensionId             = Convert.ToInt32(rowView["DIMENSIONID"]);
                Label   NumValores = (Label)e.Item.FindControl("lbNumDimensionX");
                TextBox Valores    = (TextBox)e.Item.FindControl("txtDimensionValues");

                StringBuilder sValores  = new StringBuilder();
                string        sComa     = string.Empty;
                int           nRecuento = 0;

                using (Clases.cKPI_DIMENSION_VALUES objDimensionValues = new Clases.cKPI_DIMENSION_VALUES())
                {
                    objDimensionValues.dimensionid = DimensionId;
                    objDimensionValues.datasetid   = this.datasetid.Value;
                    DataTableReader dtrValores = objDimensionValues.ObtenerDatos().CreateDataReader();
                    while (dtrValores.Read())
                    {
                        sValores.Append(sComa + dtrValores.GetValue(2).ToString());
                        sComa = ", ";
                        nRecuento++;
                    }
                }
                NumValores.Text = nRecuento.ToString();
                Valores.Text    = sValores.ToString();
            }
        }
    }
Пример #10
0
        private void ParseQuestDialog(string fileName)
        {
            var path = Path.GetDirectoryName(fileName) + "/QuestDialog.shn";

            if (!File.Exists(path))
            {
                MessageBox.Show("Failed to open corresponding QuestDialog.shn.\nYou can still edit quests, just without the dialogs.");
                return;
            }

            QuestDialog = new Dictionary <uint, string>();

            using (var file = new SHNFile(path))
                using (var reader = new DataTableReader(file.Table))
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            var id = Convert.ToUInt32(reader.GetValue(0));
                            QuestDialog.Remove(id);
                            QuestDialog.Add(id, reader.GetString(1));
                        }
                    }
                }
        }
        protected override IEnumerable <IDataObject> GetDataInternal()
        {
            var str = ConnectionString ?? MapConfig.Current.Variables["ConnectionString"].ToString();

            using (var connection = new SqlConnection(str))
            {
                SqlDataAdapter adapter = new SqlDataAdapter();

                adapter.SelectCommand = new SqlCommand(ActualQuery, connection);
                DataSet dataset = new DataSet();
                adapter.Fill(dataset);
                using (DataTableReader reader = dataset.CreateDataReader())
                {
                    while (reader.Read())
                    {
                        DataObject result = new DataObject();
                        for (int fieldIndex = 0; fieldIndex < reader.FieldCount; fieldIndex++)
                        {
                            result.SetValue(reader.GetName(fieldIndex), reader.GetValue(fieldIndex));
                        }

                        yield return(result);
                    }
                }
            }
        }
        /// <summary>
        /// Display an individual table using DataReader
        /// </summary>
        /// <param name="dataTable">DataTable</param>
        static void DisplayTableUsingDataReader(DataTable dataTable)
        {
            const int columnWidth = 10;

            WriteLine($"Data Reader => {dataTable.TableName} Table:");

            // Display the column names.
            for (int column = 0; column < dataTable.Columns.Count; column++)
            {
                Write($"{dataTable.Columns[column].ColumnName.Trim(),columnWidth}");
            }
            WriteLine("\n----------------------------------");

            // Get the DataTableReader type.
            DataTableReader dataTableReader = dataTable.CreateDataReader();

            // The DataTableReader works just like the DataReader.
            while (dataTableReader.Read())
            {
                for (var i = 0; i < dataTableReader.FieldCount; i++)
                {
                    Write($"{dataTableReader.GetValue(i).ToString().Trim(),columnWidth}");
                }
                WriteLine();
            }
            dataTableReader.Close();
        }
Пример #13
0
 static void PrintDataSet(DataSet ds)
 {
     Console.WriteLine("DataSet is named: {0}", ds.DataSetName);
     foreach (System.Collections.DictionaryEntry de in ds.ExtendedProperties)
     {
         Console.WriteLine("Key={0}, Value={1}", de.Key, de.Value);
     }
     Console.WriteLine();
     foreach (DataTable dt in ds.Tables)
     {
         Console.WriteLine("=> {0} Table:", dt.TableName);
         //columns
         for (int curCol = 0; curCol < dt.Columns.Count; curCol++)
         {
             Console.Write(dt.Columns[curCol].ColumnName.Trim() + "\t");
         }
         Console.WriteLine("\n------------------------------------");
         DataTableReader dtReader = dt.CreateDataReader();
         while (dtReader.Read())
         {
             for (int i = 0; i < dtReader.FieldCount; i++)
             {
                 Console.Write("{0}\t", dtReader.GetValue(i).ToString().Trim());
             }
             Console.WriteLine();
         }
         // dtReader.Close();
     }
 }
        public void GetCharsTest()
        {
            _dt.Columns.Add("col2", typeof(char[]));

            _dt.Rows.Clear();
            _dt.Rows.Add(new object[] { 1, "string", "string".ToCharArray() });
            _dt.Rows.Add(new object[] { 2, "string1", null });
            DataTableReader rdr = _dt.CreateDataReader();

            rdr.Read();

            // Unable to cast object of type 'System.String' to type 'System.Char[]'.
            Assert.Throws <InvalidCastException>(() => rdr.GetChars(1, 0, null, 0, 10));
            char[] char_arr = null;
            long   len      = 0;

            len = rdr.GetChars(2, 0, null, 0, 0);
            Assert.Equal(6, len);

            char_arr = new char[len];
            len      = rdr.GetChars(2, 0, char_arr, 0, 0);
            Assert.Equal(0, len);

            len      = rdr.GetChars(2, 0, null, 0, 0);
            char_arr = new char[len + 2];
            len      = rdr.GetChars(2, 0, char_arr, 2, 100);
            Assert.Equal(6, len);
            char[] val = (char[])rdr.GetValue(2);
            for (int i = 0; i < len; ++i)
            {
                Assert.Equal(val[i], char_arr[i + 2]);
            }
        }
Пример #15
0
        public static void EditData()    // Edit Data From Database
        {
            DialogResult result = MessageBox.Show("Data will be deleted first. Do you want to process?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                int  rows       = data.DataView.SelectedRows.Count;
                int  PrimaryKey = 0;
                bool FoundPK    = false;

                for (int i = 0; i < data.DataView.ColumnCount; i++)
                {
                    if (data.DataView.Columns[i].Name == "Npm")
                    {
                        PrimaryKey = i;
                        FoundPK    = true;
                    }
                }

                if (rows > 0 && FoundPK == true)
                {
                    data.ClearData.PerformClick();
                    string script = "select *from beasiswa where ";
                    bool   Can    = true;
                    foreach (DataGridViewRow Current in data.DataView.SelectedRows)
                    {
                        string NPM = data.DataView[0, Current.Index].Value.ToString();

                        if (Can)
                        {
                            script += " NPM = '" + NPM + "' ";
                            Can     = false;
                        }
                        else
                        {
                            script += "or NPM = '" + NPM + "' ";
                        }
                    }
                    script += ";";
                    DataTable       dt   = DatabaseScript.SQLscriptExecute(script);
                    DataTableReader read = dt.CreateDataReader();
                    data.InputData.Rows.Add(rows);
                    int i = 0;

                    while (read.Read())
                    {
                        for (int j = 0; j < 8; j++)
                        {
                            data.InputData[j, i].Value = read.GetValue(j).ToString();
                        }
                        DatabaseScript.SQLscriptExecute("DELETE FROM `db_ai`.`beasiswa` WHERE `Npm`='" + data.InputData[0, i].Value.ToString() + "';");
                        i++;
                    }
                }

                data.Refresh.PerformClick();
            }
        }
Пример #16
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string        connString = ConfigurationManager.ConnectionStrings["school_management_systemConnectionString"].ConnectionString;
        SqlConnection conn       = new SqlConnection();

        conn.ConnectionString = connString;
        conn.Open();
        SqlCommand cmd = new SqlCommand("select * from users where user_id=@userid and password_=@password", conn);

        cmd.Parameters.AddWithValue("@userid", TextBox1.Text);
        cmd.Parameters.AddWithValue("@password", TextBox2.Text);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable      dt = new DataTable();

        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            int x = dt.Columns.IndexOf("role_id");

            DataTableReader dr = new DataTableReader(dt);
            dr.Read();
            string role_id = dr.GetValue(x).ToString();
            string user_id = TextBox1.Text;
            Session["user_id"] = user_id;
            if (role_id.Equals("R1"))
            {
                Response.Redirect("student_home.aspx");
            }
            if (role_id.Equals("R2"))
            {
                Response.Redirect("faculty_home.aspx");
            }
            if (role_id.Equals("R3"))
            {
                Response.Redirect("StudentManager_homepage.aspx");
            }
            if (role_id.Equals("R4"))
            {
                Response.Redirect("FacultyManager_homepage.aspx");
            }
            if (role_id.Equals("R5"))
            {
                Response.Redirect("StaffManager_homepage.aspx");
            }
            if (role_id.Equals("R6"))
            {
                Response.Redirect("Staff_homepage.aspx");
            }
            if (role_id.Equals("R7"))
            {
                Response.Redirect("Exammanager_homepage.aspx");
            }
        }
        else
        {
            ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language$='text/javascript' src$='~/js/JScript'>alert('Invalid Username and Password')</script>");
        }
    }
Пример #17
0
        /// <summary>
        /// Henter tabellen Kunder fra databasen og lægger den ind i en liste af Kunde objekter
        /// </summary>
        /// <returns></returns>
        public static List <Kunde> GetKunderList()
        {
            List <Kunde>    kunder = new List <Kunde>();
            DataTable       table  = DatabaseAction.GetTable("SELECT * FROM Kunder");
            DataTableReader reader = table.CreateDataReader();

            while (reader.Read())
            {
                kunder.Add(new Kunde
                {
                    Kundenummer     = (int)reader.GetValue(0),
                    Oprettelsesdato = (DateTime)reader.GetValue(1),
                    Fornavn         = (string)reader.GetValue(2),
                    Efternavn       = (string)reader.GetValue(3),
                    Organisation    = reader.GetValue(4) == DBNull.Value ? "" : (string)reader.GetValue(4)
                });
            }
            return(kunder);
        }
Пример #18
0
        /// <summary>
        /// Henter tabellen Transaktioner fra databasen og lægger den ind i en liste af Transaktion objekter
        /// </summary>
        /// <returns></returns>
        public static List <Transaktion> GetTransaktionerList()
        {
            List <Transaktion> transaktioner = new List <Transaktion>();
            DataTable          table         = DatabaseAction.GetTable("SELECT * FROM Transaktioner");
            DataTableReader    reader        = table.CreateDataReader();

            while (reader.Read())
            {
                transaktioner.Add(new Transaktion
                {
                    Transaktionsnummer = (int)reader.GetValue(0),
                    Saldo       = (int)reader.GetValue(1),
                    Beløb       = (int)reader.GetValue(2),
                    Dato        = (DateTime)reader.GetValue(3),
                    Kontonummer = (int)reader.GetValue(4)
                });
            }
            return(transaktioner);
        }
Пример #19
0
        /// <summary>
        /// Henter tabellen Konti fra databasen og lægger den ind i en liste af Konto objekter
        /// </summary>
        /// <returns></returns>
        public static List <Konto> GetKontiList()
        {
            List <Konto>    konti  = new List <Konto>();
            DataTable       table  = DatabaseAction.GetTable("SELECT * FROM Konti");
            DataTableReader reader = table.CreateDataReader();

            while (reader.Read())
            {
                konti.Add(new Konto
                {
                    Kontonummer    = (int)reader.GetValue(0),
                    Saldo          = (int)reader.GetValue(1),
                    Kontotype      = (string)reader.GetValue(2),
                    Opretelsesdato = (DateTime)reader.GetValue(3),
                    Kundenummer    = (int)reader.GetValue(4)
                });
            }
            return(konti);
        }
Пример #20
0
        /// <summary>
        /// select some questions from the database depending on its level and kind
        /// </summary>
        /// <param name="level"> paramter used to get data from the database </param>
        /// <param name="kind"> paramter used to get data from the database </param>
        /// <param name="numberOfQuestions"> number of questions with the used constraints(level,kind) in the database </param>
        /// <returns> list of the selected question in the database </returns>
        public List <Question> getSomeQuestionWithKind(int level, string kind, out int numberOfQuestions)
        {
            List <Question> QuestionList;

            DAL.DataAccessLayer data  = new DAL.DataAccessLayer();
            SqlParameter[]      param = new SqlParameter[2];

            param[0]       = new SqlParameter(@"Levels", SqlDbType.Int);
            param[0].Value = level;

            param[1]       = new SqlParameter(@"Kind", SqlDbType.VarChar, 100);
            param[1].Value = kind;

            DataTable dataTable = data.selectData("getQuestionsWithKinds", param);

            DataTableReader tableReader = new DataTableReader(dataTable);
            Question        Question_Data;

            if (tableReader.HasRows)
            {
                numberOfQuestions = 0;
                QuestionList      = new List <Question>();
                while (tableReader.Read())
                {
                    Question_Data = new Question
                                    (
                        (int)tableReader.GetValue(0)    // Question_Number
                        , tableReader.GetString(1)      // Question
                        , tableReader.GetString(2)      // Answer
                        , tableReader.GetString(3)      // Kind
                        , (int)tableReader.GetValue(4)  // Level
                                    );
                    QuestionList.Add(Question_Data);
                    numberOfQuestions++;
                }
                return(QuestionList);
            }
            else
            {
                numberOfQuestions = 0;
                return(null);
            }
        }
Пример #21
0
        /// <summary>
        /// Gets the values of the specified column in the named table in the database with a where condition
        /// </summary>
        /// <param name="tableName">Name of table to get column values from</param>
        /// <param name="columnNumber">the identity of the column to retrieve (0 based index)</param>
        /// <param name="whereCondition">filters rows by this condition</param>
        /// <returns></returns>
        public static string[] GetColumnValuesAsString(string tableName, int columnNumber, string whereCondition)
        {
            DataSet         data   = SelectAllFromTable(tableName, whereCondition);
            DataTableReader reader = data.CreateDataReader();
            List <string>   values = new List <string>();

            while (reader.Read())
            {
                values.Add(reader.GetValue(columnNumber).ToString());
            }
            return(values.ToArray());
        }
Пример #22
0
        public ObservableCollection <DictEntry> GetDictionary()
        {
            // поскольку в объекте dataAccess объект FbDataAdapter уже мониторит одну таблицу
            // на предмет изменений, получение данных происходит без помощи адаптера
            DataTableReader reader = dataAccess.GetReader(dictionarySqlSelect);
            ObservableCollection <DictEntry> dictionary = new ObservableCollection <DictEntry>();

            if (reader != null)
            {
                while (reader.Read())
                {
                    DictEntry dictModel = new DictEntry()
                    {
                        Id   = reader.GetValue(0),
                        Name = reader.GetValue(1)
                    };
                    dictionary.Add(dictModel);
                }
            }
            return(dictionary);
        }
Пример #23
0
        private int SilenceCreateNewPageSection(string pageSectionName, int pageID)
        {
            int pageSectionID = 0;

            if (pageSectionName == string.Empty)
            {
                return(pageSectionID);
            }

            var     sql                = new Sql();
            var     dataset            = new DataSetAutoTest();
            var     adapterPageSection = new GuiPageSectionTableAdapter();
            Boolean flag               = true;

            adapterPageSection.Fill(dataset.GuiPageSection);

            DataTableReader dtReader = dataset.GuiPageSection.CreateDataReader();

            while (dtReader.Read())
            {
                var pID   = dtReader.GetValue(1).ToString().Trim();
                var pName = dtReader.GetValue(2).ToString().Trim();
                if (pName == pageSectionName && Convert.ToInt32(pID) == pageID)
                {
                    flag = false;

                    // get existing page section ID
                    pageSectionID = Convert.ToInt32(dtReader.GetValue(0).ToString().Trim());
                    break;
                }
            }
            dtReader.Close();

            if (!flag)
            {
                return(pageSectionID);
            }
            // create new page section
            adapterPageSection.Insert(pageID, pageSectionName);

            // Get new Page Section's ID
            adapterPageSection.Fill(dataset.GuiPageSection);

            dtReader = dataset.GuiPageSection.CreateDataReader();
            while (dtReader.Read())
            {
                var pID   = dtReader.GetValue(1).ToString().Trim();
                var pName = dtReader.GetValue(2).ToString().Trim();

                if (pName == pageSectionName && Convert.ToInt32(pID) == pageID)
                {
                    pageSectionID = Convert.ToInt32(dtReader.GetValue(0).ToString().Trim());
                    break;
                }
            }
            dtReader.Close();
            return(pageSectionID);
        }
Пример #24
0
        private static void PrintTable(DataTable dataTable)
        {
            DataTableReader tableReader = dataTable.CreateDataReader();

            while (tableReader.Read())
            {
                for (int i = 0; i < tableReader.FieldCount; i++)
                {
                    Console.Write($"{tableReader.GetValue(i),10}\t\t");
                }
                Console.WriteLine();
            }
            tableReader.Close();
        }
Пример #25
0
        /// <summary>
        /// 某一列的内容
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public List <T> getaRow <T>(String sql)
        {
            List <T>        list   = new List <T>();
            DataTable       dt     = db.Query(sql);
            DataTableReader reader = new DataTableReader(dt);

            while (reader.Read())
            {
                Object obj = reader.GetValue(0);
                list.Add((T)obj);
            }

            return(list);
        }
Пример #26
0
        public void PrintDataTable(DataTable dt)
        {
            this.textBox1.Text = "";
            DataTableReader dtReader = dt.CreateDataReader();

            while (dtReader.Read())
            {
                for (int i = 0; i < dtReader.FieldCount; i++)
                {
                    this.textBox1.Text += dtReader.GetValue(i).ToString().Trim();
                }
            }
            dtReader.Close();
        }
Пример #27
0
        /// <summary>
        /// 展示表数据
        /// </summary>
        /// <param name="dt"></param>
        static void PrintDataTable(DataTable dt)
        {
            DataTableReader dtReader = dt.CreateDataReader();

            while (dtReader.Read())
            {
                for (int i = 0; i < dtReader.FieldCount; i++)
                {
                    Console.Write("{0}\t", dtReader.GetValue(i).ToString().Trim());
                }
                Console.WriteLine();
            }
            dtReader.Close();
        }
Пример #28
0
        //protected System.Collections.Hashtable buildHeadersOrder(List<string> headersStrings, DataTable dt, int firstRowIndex)
        // {
        //     try
        //     {
        //         System.Collections.Hashtable ret = new System.Collections.Hashtable();
        //         for (int i = 0; i < headersStrings.Count; i++)
        //         {
        //             for (int j = 0; j < dt.Columns.Count; j++)
        //             {
        //                 if (dt.Rows[8][j].ToString().Equals(headersStrings[i]))
        //                 {
        //                     ret.Add(i, j);
        //                 }
        //             }



        //         }
        //         return ret;
        //     }
        //     catch (Exception ex)
        //     {
        //         return null;
        //     }
        // }


        private static void PrintTable(DataTable dt)
        {
            DataTableReader dtReader = dt.CreateDataReader();

            while (dtReader.Read())
            {
                for (int i = 0; i < dtReader.FieldCount; i++)
                {
                    MyLogger.Instance.Write(
                        dtReader.GetName(i).Trim() + " . "
                        + dtReader.GetValue(i).ToString().Trim());
                }
            }
            dtReader.Close();
        }
Пример #29
0
        // Метод проверки существования пользователя
        private bool name_free_detector()
        {
            DataTableReader reader = aFTDataSet.CreateDataReader();

            // Построчно считываем пользователей
            while (reader.Read())
            {
                // Если логин найден в списке пользователей и пароль совпал с введенным
                if (textBox1.Text.Equals(reader.GetValue(1)))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #30
0
        static void PrintTable(DataTable dt)
        {
            // Get the DataTableReader type.
            DataTableReader dtReader = dt.CreateDataReader();

            // The DataTableReader works just like the DataReader.
            while (dtReader.Read())
            {
                for (int i = 0; i < dtReader.FieldCount; i++)
                {
                    Console.Write("{0}\t", dtReader.GetValue(i).ToString().Trim());
                }
                Console.WriteLine();
            }
            dtReader.Close();
        }