Пример #1
0
        public static void WriteMemberToList(ListMember member)
        {
            Object[] member_values = member.GetValues();

            string filename = (string)member_values[0];
            int    row      = Convert.ToInt32(member_values[1]);

            byte[] bytes;
            using (ExcelPackage p = new ExcelPackage(new FileInfo(filename)))
            {
                ExcelWorksheet ws = p.Workbook.Worksheets.First();

                ws.Cells[row, 1].Value = member_values[3];           //serial
                ws.Cells[row, 2].Value = member_values[4];           //uid
                ws.Cells[row, 3].Value = member_values[8];           //entry times
                ws.Cells[row, 4].Value = member_values[7];           //entry days
                ws.Cells[row, 5].Value = ws.Cells[row - 1, 5].Value; //copy down options
                ws.Cells[row, 6].Value = member_values[5];           //user
                ws.Cells[row, 7].Value = member_values[6];           //description

                bytes = p.GetAsByteArray();
            }

            File.WriteAllBytes(filename, bytes);
        }
Пример #2
0
        //add new card to selected list
        private void button4_Click(object sender, EventArgs e)
        {
            ListMember member = ListUtilities.GenerateNewMember((string)checkedListBox1.SelectedItem);

            FillTabPage3(member.GetValues().SubArray(0, 9).Cast <string>().ToArray());

            tabPage3.Name = "Add";
            tabControl1.TabPages.Add(tabPage3);

            tabControl1.SelectedTab = tabPage3;
        }
Пример #3
0
        private async Task SearchAndFill()
        {
            string tbt = textBox1.Text.Trim();

            if (tbt != previous_search)
            {
                dataGridView1.Enabled = false;

                previous_search = tbt;

                if (tbt != "")
                {
                    if (tbt.Length > 1)
                    {
                        if (tbt[0] == '*' && tbt[1] == 'h')
                        {
                            try
                            {
                                tbt = UInt64.Parse(tbt.Substring(2), System.Globalization.NumberStyles.HexNumber) + "";
                            }
                            catch (Exception ex)
                            {
                                return;
                            }
                        }
                    }
                    else
                    if (tbt[0] == '*')
                    {
                        tbt = "";
                    }

                    DataTable local_dt = null;

                    await Task.Run(() =>
                    {
                        local_dt = dt.Clone();
                        local_dt.Clear();

                        for (int index_counter = 0; index_counter < members.Length; index_counter++)
                        {
                            ListMember lm = members[index_counter];
                            if (lm.Contains(tbt))
                            {
                                local_dt.Rows.Add(new Func <Object[]>(() =>
                                {
                                    Object[] objects            = lm.GetValues();
                                    objects[objects.Length - 1] = index_counter;
                                    return(objects);
                                }).Invoke());
                            }
                        }
                    });

                    dataGridView1.DataSource = local_dt;
                    dt = local_dt;
                }
                else
                {
                    dt.Clear();
                }

                dataGridView1.Enabled = true;
            }
        }