Exemplo n.º 1
0
        public void XmlDB2DataGridView(ref System.Windows.Forms.DataGridView dgv)
        {
            dgv.Rows.Clear();

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(mXmlDBPath);
            XmlNodeList root = xmlDoc.ChildNodes;

            foreach (XmlNode usernode in root[xmlDoc.ChildNodes.Count - 1].ChildNodes)
            {
                UserInfo curUser = new UserInfo();
                curUser.XmlNode2UserInfo(usernode);

                System.Windows.Forms.DataGridViewRow row = new System.Windows.Forms.DataGridViewRow();

                object[] objects = new string[16];
                objects.Initialize();
                //objects.SetValue(usernode.Attributes.GetNamedItem("id").InnerText.ToString(), 0);
                objects.SetValue(curUser.mId.ToString(), 0);
                objects.SetValue(curUser.mFirstName, 1);
                objects.SetValue(curUser.mLastName, 2);
                objects.SetValue(curUser.mFatherName, 3);
                objects.SetValue(curUser.mMotherName, 4);
                objects.SetValue(curUser.mB_Date.ToShortDateString(), 5);
                objects.SetValue(curUser.mCity, 6);
                objects.SetValue(curUser.mStreet, 7);
                objects.SetValue(curUser.mBuildingNum.ToString(), 8);
                objects.SetValue(curUser.mAppNum.ToString(), 9);
                objects.SetValue(curUser.mEMail, 10);
                objects.SetValue(curUser.mPhones, 11);
                objects.SetValue(curUser.mApplication, 12);            // application
                objects.SetValue(curUser.mSex.ToString(), 13);         // sex
                objects.SetValue(curUser.mPassedRect.ToString(), 14);  // passed rectify
                objects.SetValue(curUser.mReachMaster.ToString(), 15); // reach master


                //objects.SetValue(Enums.EnumProvider.Instance.GetSexEnumFromDescription(curUser.mSex.ToString()), 12);
                //objects.SetValue(curUser.mApplication, 13);
                //objects.SetValue(Enums.EnumProvider.Instance.GetPassedRectificationEnumFromDescription(curUser.mPassedRect.ToString()), 14);

                dgv.Rows.Insert(dgv.Rows.Count, objects);
                dgv.Update();
            }
        }
Exemplo n.º 2
0
        public void SetGrid(DateTime from, DateTime to, System.Windows.Forms.DataGridView grid)
        {
            var files = Global.BaseFiles(from, to);

            if (null == files || 0 == files.Count())
            {
                return;
            }
            Base b = new Base();

            table = new DataTable();
            ds.Tables.Add(table);
            table.Columns.Add().DataType = typeof(string);
            table.Columns.Add().DataType = typeof(string);
            table.Columns.Add().DataType = typeof(string);

            table.Columns[0].ColumnName = "Время";
            table.Columns[1].ColumnName = "Типоразмер";
            table.Columns[2].ColumnName = "Группа прочности";

            foreach (var path in files)
            {
                if (b.Open(path))
                {
                    System.Data.OleDb.OleDbCommand com = b.conn.CreateCommand();

                    System.Data.OleDb.OleDbParameter from_ = new System.Data.OleDb.OleDbParameter("", System.Data.OleDb.OleDbType.Date);
                    from_.Value = from;
                    com.Parameters.Add(from_);

                    System.Data.OleDb.OleDbParameter to_ = new System.Data.OleDb.OleDbParameter("", System.Data.OleDb.OleDbType.Date);
                    to_.Value = to;
                    com.Parameters.Add(to_);

                    com.CommandText =
                        "SELECT t.CurrentTime, t.Diameters, t.GroupStrength"
                        + " FROM TubesTable as t"
                        + " WHERE t.CurrentTime>=? and t.CurrentTime<?"
                    ;
                    System.Data.OleDb.OleDbDataReader reader = com.ExecuteReader();

                    while (reader.Read())
                    {
                        table.Rows.Add(
                            ((DateTime)reader[0]).ToString("dd.MM.yyyy HH:mm:ss")
                            , (string)reader[1]
                            , (string)reader[2]
                            );
                    }
                }
            }
            if (0 != table.Rows.Count)
            {
                grid.DataSource       = table;
                grid.Columns[0].Width = 120;
                grid.Columns[1].Width = 100;
                grid.Columns[2].Width = 70;
                for (int i = 0; i < grid.ColumnCount; ++i)
                {
                    grid.Columns[i].ReadOnly = true;
                }
                foreach (DataTable dt in ds.Tables)
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        if (dc.DataType == typeof(DateTime))
                        {
                            dc.DateTimeMode = DataSetDateTime.Unspecified;
                        }
                    }
                }
            }
            grid.Update();
        }