コード例 #1
0
        private void saveAll_Click(object sender, EventArgs e)
        {
            try
            {
                List <string> tableValues = new List <string>();

                InputSearcher.Clear();

                int contactCount = ContactsTable.Rows.Count;

                string ReadyContact = null;

                for (int i = 0; i < contactCount - 1; i++)
                {
                    ReadyContact = null;

                    for (int j = 0; j < 8; j++)
                    {
                        ReadyContact += ContactsTable.Rows[i].Cells[j].Value.ToString() + "|";
                    }

                    tableValues.Add(ReadyContact);
                }

                using (StreamWriter saveFile = new StreamWriter($@"{DirectoryApp}\contact.txt"))
                {
                    foreach (var Value in tableValues)
                    {
                        saveFile.WriteLine(Value.ToString() + Environment.NewLine);
                    }
                }

                Navigate.ToolTipTitle = "Informacja";

                Navigate.ToolTipIcon = ToolTipIcon.Info;

                Navigate.Show("Zapisano listę kontaktów.", saveAll, 5, saveAll.Height - 5, 1500);
            }

            catch
            {
                Navigate.ToolTipTitle = "Informacja";

                Navigate.ToolTipIcon = ToolTipIcon.Error;

                Navigate.Show("Błąd podczas zapisu!", saveAll, 5, saveAll.Height - 5, 2000);
            }
        }
コード例 #2
0
        private void addContact_Click(object sender, EventArgs e)
        {
            try
            {
                checkPosible = false;

                AddContact Window = new AddContact();

                DialogResult Check = Window.ShowDialog();

                if (checkPosible == false)
                {
                    List <string> readyValues = AddContact.newContact;

                    InputSearcher.Clear();

                    #region Pobieranie starwej wersji tabeli

                    List <string> oldValues = new List <string>();

                    int contactCount = ContactsTable.Rows.Count;

                    string ReadyContact = null;

                    for (int i = 0; i < contactCount - 1; i++)
                    {
                        ReadyContact = null;

                        for (int j = 0; j < 8; j++)
                        {
                            ReadyContact += ContactsTable.Rows[i].Cells[j].Value.ToString() + "|";
                        }

                        oldValues.Add(ReadyContact);
                    }

                    #endregion

                    ContactsTable.Rows.Clear();

                    #region Dodawanie nowych komórek do tabeli

                    for (int i = 0; i < oldValues.Count; i++)
                    {
                        string[] DivideValue = oldValues[i].Split('|');

                        ContactsTable.Rows.Add($"{DivideValue[0]}", $"{DivideValue[1]}", $"{DivideValue[2]}", $"{DivideValue[3]}", $"{DivideValue[4]}", $"{DivideValue[5]}", $"{DivideValue[6]}", $"{DivideValue[7]}");
                    }

                    ContactsTable.Rows.Add($"{readyValues[0]}", $"{readyValues[1]}", $"{readyValues[2]}", $"{readyValues[3]}", $"{readyValues[4]}", $"{readyValues[5]}", $"{readyValues[6]}", $"{readyValues[7]}");

                    ContactsTable.Rows.Add("", "", "", "", "", "", "", "");

                    int tableRow = ContactsTable.Rows.Count - 1;

                    ContactsTable.Rows[tableRow].DefaultCellStyle.BackColor = Color.FromArgb(224, 224, 224);

                    ContactsTable.ClearSelection();

                    #endregion

                    #region Nadpisywanie kopii komórek

                    try
                    {
                        copyOfContacts.Clear();

                        int contactCountCopy = ContactsTable.Rows.Count;

                        string ReadyContactCopy = null;

                        for (int i = 0; i < contactCountCopy - 1; i++)
                        {
                            ReadyContactCopy = null;

                            for (int j = 0; j < 8; j++)
                            {
                                ReadyContactCopy += ContactsTable.Rows[i].Cells[j].Value.ToString() + "|";
                            }

                            copyOfContacts.Add(ReadyContactCopy);
                        }
                    }

                    catch
                    {
                        //błąd tworzenia kopii kontaktów
                    }

                    #endregion
                }
            }

            catch
            {
                //błąd
            }
        }
コード例 #3
0
 private void SearcherTheme_Click(object sender, EventArgs e)
 {
     InputSearcher.Focus();
 }