コード例 #1
0
        ////////////////////////////////////////////////////////////////////////////////////
        private void PersonAllPackagesToGrid(TreeNode Node)
        {
            dataGridView1.Columns.Clear();

            dataGridView1.ColumnCount          = 3;
            dataGridView1.ColumnHeadersVisible = true;

            dataGridView1.Columns[0].Name         = "GUID";
            dataGridView1.Columns[0].Width        = 225;
            dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView1.Columns[1].Name         = "IDPack";
            dataGridView1.Columns[1].Width        = 225;
            dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView1.Columns[2].Name         = "BatchType";
            dataGridView1.Columns[2].Width        = 225;
            dataGridView1.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            int ind = 0;

            foreach (TreeNode child in Node.Nodes)
            {
                string[] row = { child.Text, "Comming Son", "Comming Son" };
                if (child.Nodes.Count > 0)
                {
                    string[]  s        = child.Nodes[0].Text.Split('_');
                    string    filename = child.Nodes[0].Parent.Text + "_" + s[2] + "_" + s[1] + "_" + s[0] + ".xml";
                    XDocument myDoc    = XDocument.Load(DefPatch + filename);
                    IEnumerable <XElement> FF1;
                    IEnumerable <XElement> FF2;

                    try
                    {
                        FF1    = myDoc.Descendants("_IDPack");
                        FF2    = myDoc.Descendants("_BatchType");
                        row[1] = "";
                        row[2] = "";

                        if (FF1.Count() > 0)
                        {
                            row[1] = FF1.First().Value;
                        }
                        if (FF2.Count() > 0)
                        {
                            row[2] = FF2.First().Value;
                        }
                        ind = dataGridView1.Rows.Add(row);
                    }
                    catch { }
                }
                dataGridView1.Rows[ind].Cells[0].Style.BackColor = Color.Gainsboro;
                dataGridView1.Rows[ind].Cells[1].Style.BackColor = Color.Gainsboro;
                dataGridView1.Rows[ind].Cells[2].Style.BackColor = Color.Gainsboro;
            }
        }
コード例 #2
0
        ////////////////////////////////////////////////////////////////////////////////////
        private void AllDocumFromPackageToGrid(TreeNode Node)
        {
            dataGridView1.Columns.Clear();

            dataGridView1.ColumnCount          = 5;
            dataGridView1.ColumnHeadersVisible = true;

            dataGridView1.Columns[0].Name         = "N";
            dataGridView1.Columns[0].Width        = 25;
            dataGridView1.Columns[1].Name         = "Header";
            dataGridView1.Columns[1].Width        = 150;
            dataGridView1.Columns[2].Name         = "Number";
            dataGridView1.Columns[2].Width        = 125;
            dataGridView1.Columns[3].Name         = "Date";
            dataGridView1.Columns[3].Width        = 75;
            dataGridView1.Columns[4].Name         = "Barcode";
            dataGridView1.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView1.Columns[4].FillWeight   = 125;


            int    ind      = 0;
            string filename = "";

            string[] row = new string[5];
            foreach (TreeNode child in Node.Nodes)
            {
                string[] s = child.Text.Split('_');
                filename = child.Parent.Text + "_" + s[2] + "_" + s[1] + "_" + s[0] + ".xml";

                XDocument myDoc = XDocument.Load(DefPatch + filename);
                IEnumerable <XElement> FF1;
                IEnumerable <XElement> FF2;
                IEnumerable <XElement> FF3;
                IEnumerable <XElement> FF4;
                try
                {
                    FF1    = myDoc.Descendants("_Header");
                    FF2    = myDoc.Descendants("_DocNum");
                    FF3    = myDoc.Descendants("_DateDoc");
                    FF4    = myDoc.Descendants("_Barcode");
                    row[0] = s[0];
                    row[1] = "";
                    row[2] = "";
                    row[3] = "";
                    row[4] = "";

                    if (FF1.Count() > 0)
                    {
                        row[1] = FF1.First().Value;
                    }
                    if (FF2.Count() > 0)
                    {
                        row[2] = FF2.First().Value;
                    }
                    if (FF3.Count() > 0)
                    {
                        row[3] = FF3.First().Value;
                    }
                    if (FF4.Count() > 0)
                    {
                        row[4] = FF4.First().Value;
                    }

                    ind = dataGridView1.Rows.Add(row);

                    dataGridView1.Rows[ind].Cells[0].Style.BackColor = Color.Gainsboro;
                    dataGridView1.Rows[ind].Cells[1].Style.BackColor = Color.Gainsboro;
                    dataGridView1.Rows[ind].Cells[2].Style.BackColor = Color.Gainsboro;
                    dataGridView1.Rows[ind].Cells[3].Style.BackColor = Color.Gainsboro;
                    dataGridView1.Rows[ind].Cells[4].Style.BackColor = Color.Gainsboro;
                }
                catch
                {
                }
            }
        }