private void ClearBellList()
 {
     pnlScheduleContainer.Controls.Clear();
     ScheduleDataManager.BellDataUI.Clear();
     ScheduleDataManager.ResetDirtyFlag();
     this.Invalidate();
 }
        private void btnCloseBellList_Click(object sender, EventArgs e)
        {
            bool IsDirtyOrEmptyPath = (ScheduleDataManager.IsDirty || string.IsNullOrEmpty(ScheduleDataManager.BellListFilePath));

            if (IsDirtyOrEmptyPath)
            {
                var dlgResult = MessageBox.Show("Do you want to save the content?", "Want to Save", buttons: MessageBoxButtons.YesNoCancel);
                if (dlgResult == DialogResult.Yes)
                {
                    ScheduleDataManager.SaveDataToCSV();
                    ClearBellList();
                }
                else if (dlgResult == DialogResult.No)
                {
                    ClearBellList();
                }
                else if (dlgResult == DialogResult.Cancel)
                {
                    // Dont do anything, Cancelling Out...........
                }
            }
            else if (!IsDirtyOrEmptyPath)
            {
                var dlgResult = MessageBox.Show("Do you want to proceed? It will clear the current list.", "Want to Proceed", buttons: MessageBoxButtons.YesNo);
                if (dlgResult == DialogResult.Yes)
                {
                    ClearBellList();
                }
                else if (dlgResult == DialogResult.No)
                {
                    // Dont do anything, Cancelling Out...........
                }
            }
        }
        private void OpenBellList()
        {
            string filePath              = String.Empty;
            List <ScheduleData> dataUI   = new List <ScheduleData>();
            OpenFileDialog      OFDialog = new OpenFileDialog();

            DialogResult result = OFDialog.ShowDialog(); // Show the dialog.

            OFDialog.DefaultExt = BellConstants.BellCSVExtention;
            if (result == DialogResult.OK && !string.IsNullOrEmpty(OFDialog.FileName))
            {
                filePath = OFDialog.FileName;

                ScheduleDataManager.BellListFilePath = filePath;
                ScheduleDataManager.LoadData();

                dataUI = ScheduleDataManager.BellDataUI;
                pnlScheduleContainer.Controls.Clear();
                for (int i = 0; i < dataUI.Count; i++)
                {
                    ScheduleData      TempDataUi = dataUI[i];
                    ScheduleDataModel SDM        = new ScheduleDataModel();
                    SDM = TempDataUi.scheduleDM;
                    SDM.SerialNumber      = i + 1;
                    TempDataUi.scheduleDM = SDM;
                    TempDataUi.Location   = new Point(0, (i * 38));
                    TempDataUi.Controls["btnDelete"].Click += DeleteScheduleFromList;
                    TempDataUi.MakeDirty += ScheduleDataManager.ActionMakeDirty;
                    pnlScheduleContainer.Controls.Add(TempDataUi);
                }

                ScheduleDataManager.ResetDirtyFlag();
            }
        }
        public void DeleteScheduleFromList(object sender, EventArgs e)
        {
            int SerialNumber = ((ScheduleData)((Control)sender).Parent).scheduleDM.SerialNumber;

            ScheduleDataManager.DeleteScheduleData(SerialNumber);
            UpdateBellListUI();
        }
        private void btnDownloadBellList_Click(object sender, EventArgs e)
        {
            if ((ScheduleDataManager.IsDirty) &&
                (MessageBox.Show("Do you want to save the existing content?", "Want to Save", MessageBoxButtons.YesNo) == DialogResult.Yes))
            {
                ScheduleDataManager.SaveDataToCSV();
            }

            BellComunication BellComObj = BellComunication.ObjCommunication;
            string           content    = BellComObj.DownloadString();

            if (!BellConstants.IsSuccess)
            {
                if (string.IsNullOrEmpty(BellConstants.ErrorMessage))
                {
                    MessageBox.Show("Information is not downloaded due some unknown reason, please try again.");
                }
                else
                {
                    MessageBox.Show(BellConstants.ErrorMessage);
                }
                return;
            }

            string[] splitSeparator = { Environment.NewLine };
            string[] Content        = content.Split(splitSeparator, StringSplitOptions.RemoveEmptyEntries);
            {
                ScheduleDataManager.LoadData(Content);
                List <ScheduleData> dataUI = new List <ScheduleData>();
                dataUI = ScheduleDataManager.BellDataUI;
                pnlScheduleContainer.Controls.Clear();
                for (int i = 0; i < dataUI.Count; i++)
                {
                    ScheduleData      TempDataUi = dataUI[i];
                    ScheduleDataModel SDM        = new ScheduleDataModel();
                    SDM = TempDataUi.scheduleDM;
                    SDM.SerialNumber      = i + 1;
                    TempDataUi.scheduleDM = SDM;
                    TempDataUi.Location   = new Point(0, (i * 38));
                    TempDataUi.Controls["btnDelete"].Click += DeleteScheduleFromList;
                    TempDataUi.MakeDirty += ScheduleDataManager.ActionMakeDirty;
                    pnlScheduleContainer.Controls.Add(TempDataUi);
                }
            }
        }
 private void btnOpenBellList_Click(object sender, EventArgs e)
 {
     if (ScheduleDataManager.IsDirty)
     {
         var dlgResult = MessageBox.Show("Do you want to save the content?", "Want to Save", MessageBoxButtons.YesNoCancel);
         if (dlgResult == DialogResult.Yes)
         {
             ScheduleDataManager.SaveDataToCSV();
             OpenBellList();
         }
         else if (dlgResult == DialogResult.No)
         {
             OpenBellList();
         }
         else if (dlgResult == DialogResult.Cancel)
         {
             // Cancelling out the Open Bell List....
         }
     }
     else if (!ScheduleDataManager.IsDirty)
     {
         OpenBellList();
     }
 }
 private void btnSaveAsScheduleData_Click(object sender, EventArgs e)
 {
     ScheduleDataManager.SaveDataToCSV(SaveAs: true);
 }
 private void btnMultiDeviceUpload_Click(object sender, EventArgs e)
 {
     BellComunication.ObjCommunication.UploadBellsToMultipleDevice(ScheduleDataManager.GetListOfBells(), DeviceDataManager.DeviceDataUI);
 }
 private void btnUploadBell_Click(object sender, EventArgs e)
 {
     BellComunication.ObjCommunication.UploadBells(ScheduleDataManager.GetListOfBells());
 }
示例#10
0
 private void btnAddBellData_Click(object sender, EventArgs e)
 {
     pnlScheduleContainer.Controls.Add(ScheduleDataManager.AddEmptyScheduleData(DeleteScheduleFromList));
 }