Example #1
0
        private void ExportToCSV()
        {
            List<ContactDB> exportList = GetCheckedContactList();
            if(exportList.Count() == 0)
            {
                MessageBox.Show(ContactManagentLibrary.Properties.Resources.choose_contact_to_export);
                return;
            }
            string fileName = "contacts_" + (DateTime.Now.ToString("MM-dd-yyyy hhmmss"));
            saveFileDialog1.FileName = fileName;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string path = saveFileDialog1.FileName;
                FileImExportController fileImEx = new FileImExportController();
                int res = fileImEx.ExportToCSVFile(exportList, path);

                if (res > 0)
                {
                    MessageBox.Show(ContactManagentLibrary.Properties.Resources.export_success);
                }
                else
                {
                    MessageBox.Show(ContactManagentLibrary.Properties.Resources.export_error);
                }
            }
        }