Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            CboFiles.DisplayMember = nameof(ItemData.Name);
            CboFiles.ValueMember   = nameof(ItemData.Id);

            CboWorkSheets.DisplayMember = nameof(ItemData.Name);
            CboWorkSheets.ValueMember   = nameof(ItemData.Id);

            List <ItemData> workbooks = Workbook_BLL.Workbooks().Select(kvp => new ItemData {
                Id = kvp.Key, Name = kvp.Value
            }).ToList();

            CboFiles.DataSource = workbooks;
        }
Beispiel #2
0
        private void Delete(bool confirm)
        {
            WaitingMessage.WaitingMessage waitingMessage = null;

            try
            {
                if (confirm &&
                    MessageBox.Show("Are you sure you want to DEFINITIVELY delete the opened workbook?",
                                    "Delete a workbook",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                waitingMessage = new WaitingMessage.WaitingMessage("Please wait while data are being erased from the database." + Environment.NewLine +
                                                                   "This may take few seconds...",
                                                                   "Delete a workbook",
                                                                   0);

                if (!Workbook_BLL.Delete(OpenedFile.Id))
                {
                    return;
                }

                CboFiles.DataSource = GetWorkbooks();

                UnloadWorkBook();
            }
            catch (Exception ex)
            {
                ErrorManagement.Log(ex);
            }
            finally
            {
                if (waitingMessage != null)
                {
                    waitingMessage.CloseMessage();
                }
            }
        }
Beispiel #3
0
        public bool Save()
        {
            if (WorkbookRow == null)
            {
                Id          = Workbook_BLL.Create(Name, Created, Modified);
                WorkbookRow = WorkBook_DAL.GetDataRow(Id);
                Imported    = WorkbookRow.Imported;
            }

            foreach (string wsName in WorkSheets.Keys)
            {
                WorkSheet worksheet = WorkSheets[wsName];

                worksheet.Save(Id);

                // Delete all worksheets those are empty
                if (worksheet.Cells.Count == 0)
                {
                    WorkSheets.Remove(wsName);
                }
            }

            return(Id != Constants.Constants.UNDEFINED_ID);
        }