private void materialFlatButton1_Click_1(object sender, EventArgs e)
        {
            try
            {
                EmailAttachments emailAttachments = new EmailAttachments();
                var attach       = emailAttachments.BrowseForFile();
                var notAddedList = new List <string>();
                if (attach != (null, null))
                {
                    foreach (var files in attach.Item1.Zip(attach.Item2, (paths, names) => (paths, names)))
                    {
                        var bytes = File.ReadAllBytes(files.paths);
                        var file  = Convert.ToBase64String(bytes);
                        var type  = emailAttachments.GetMIMEType(files.paths);
                        if (type == null)
                        {
                            notAddedList.Add(files.names);
                            continue;
                        }
                        SendGrid.Helpers.Mail.Attachment attachment = new SendGrid.Helpers.Mail.Attachment()
                        {
                            Content  = file,
                            Filename = files.names,
                            Type     = type
                        };
                        attachmentList.Add(attachment);
                    }
                    if (attachmentList.Count >= 1)
                    {
                        AttachmentsGrid.DataSource = null;
                        AttachmentsGrid.DataSource = attachmentList;
                        AttachmentsGrid.Columns["Content"].Visible     = false;
                        AttachmentsGrid.Columns["Type"].Visible        = false;
                        AttachmentsGrid.Columns["ContentId"].Visible   = false;
                        AttachmentsGrid.Columns["Disposition"].Visible = false;
                    }
                    if (notAddedList.Count >= 1)
                    {
                        string list = null;

                        foreach (var x in notAddedList)
                        {
                            list += x + " ";
                        }
                        var msg = $"Súbor/y {list} nebol pridaný, lebo tento typ súboru nie je možné odoslať emailom. Pre informácie o tom, ktoré " +
                                  "súbory nie je možné odoslať otvorte BlockedExtensions.txt";
                        MessageBox.Show(msg);
                    }
                    AttachmentsGrid.ClearSelection();
                }
                else
                {
                    return;
                }
            }
        //private void materialFlatButton1_Click(object sender, EventArgs e)
        //{
        //    this.Close();
        //}

        private void AddEmailTemplateAttachmentsBtn_Click(object sender, EventArgs e)
        {
            try
            {
                EmailAttachments emailAttachments = new EmailAttachments();
                var attach       = emailAttachments.BrowseForFile();
                var notAddedList = new List <string>();
                if (attach != (null, null))
                {
                    foreach (var files in attach.Item1.Zip(attach.Item2, (paths, names) => (paths, names)))
                    {
                        var type = emailAttachments.GetMIMEType(files.paths);
                        if (type == null)
                        {
                            notAddedList.Add(files.names);
                            continue;
                        }

                        Attachment attachment = new Attachment()
                        {
                            FilePath = files.paths,
                            FileName = files.names,
                            IdUser   = currentUser.Id,
                        };

                        if (editMode)
                        {
                            using (StudentDBDataContext con = new StudentDBDataContext(conn_str))
                            {
                                var att = attachment;
                                att.IdEmailTemplate = (int)TempGridView.CurrentRow.Cells[2].Value;
                                var emailTemp = con.GetTable <EmailTemplate>().First(x => x.Id == (int)TempGridView.CurrentRow.Cells[2].Value);
                                if (!AttachmentExists(att, emailTemp))
                                {
                                    con.Attachments.InsertOnSubmit(att);
                                    con.SubmitChanges();

                                    AttachmentsGrid.DataSource = null;
                                    AttachmentsGrid.DataSource = con.GetTable <Attachment>().Where(x => x.IdEmailTemplate == (int)TempGridView.CurrentRow.Cells[2].Value);
                                    AttachmentsGrid.Columns["FilePath"].Visible        = false;
                                    AttachmentsGrid.Columns["IdUSer"].Visible          = false;
                                    AttachmentsGrid.Columns["IdEmailTemplate"].Visible = false;
                                    AttachmentsGrid.Columns["Id"].Visible            = false;
                                    AttachmentsGrid.Columns["EmailTemplate"].Visible = false;
                                    AttachmentsGrid.Columns["User"].Visible          = false;

                                    if (notAddedList.Count >= 1)
                                    {
                                        string list = null;

                                        foreach (var x in notAddedList)
                                        {
                                            list += x + " ";
                                        }
                                        var msg = $"Súbor/y {list} nebol pridaný, lebo tento typ súboru nie je možné odoslať emailom. Pre informácie o tom, ktoré " +
                                                  "súbory nie je možné odoslať otvorte BlockedExtensions.txt";
                                        MessageBox.Show(msg);
                                    }
                                }
                                return;
                            }
                        }
                        else if (!attachmentList.Contains(attachment))
                        {
                            attachmentList.Add(attachment);
                        }
                    }
                    if (attachmentList.Count >= 1)
                    {
                        AttachmentsGrid.DataSource = null;
                        AttachmentsGrid.DataSource = attachmentList;
                        AttachmentsGrid.Columns["FilePath"].Visible        = false;
                        AttachmentsGrid.Columns["IdUSer"].Visible          = false;
                        AttachmentsGrid.Columns["IdEmailTemplate"].Visible = false;
                        AttachmentsGrid.Columns["Id"].Visible            = false;
                        AttachmentsGrid.Columns["EmailTemplate"].Visible = false;
                        AttachmentsGrid.Columns["User"].Visible          = false;
                    }
                    if (notAddedList.Count >= 1)
                    {
                        string list = null;

                        foreach (var x in notAddedList)
                        {
                            list += x + " ";
                        }
                        var msg = $"Súbor/y {list} nebol pridaný, lebo tento typ súboru nie je možné odoslať emailom. Pre informácie o tom, ktoré " +
                                  "súbory nie je možné odoslať otvorte BlockedExtensions.txt";
                        MessageBox.Show(msg);
                    }
                }
                else
                {
                    return;
                }
                AttachmentsGrid.ClearSelection();
            }