Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            // BellComunication.ObjCommunication.UploadFile();

            //testing is going on

            //DeviceData t1 = new DeviceData();
            //Data.Add(t1);

            // for Schedule data

            ScheduleData sd1 = new ScheduleData();
        }
Esempio n. 3
0
 public void UpdateBellListUI()
 {
     pnlScheduleContainer.Controls.Clear();
     for (int i = 0; i < ScheduleDataManager.BellDataUI.Count; i++)
     {
         ScheduleData      TempDataUi = ScheduleDataManager.BellDataUI[i];
         ScheduleDataModel SDM        = new ScheduleDataModel();
         SDM = TempDataUi.scheduleDM;
         SDM.SerialNumber      = i + 1;
         TempDataUi.scheduleDM = SDM;
         TempDataUi.Location   = new Point(0, (i * 38));
         pnlScheduleContainer.Controls.Add(TempDataUi);
     }
 }
Esempio n. 4
0
        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);
                }
            }
        }
        public static ScheduleData AddEmptyScheduleData(EventHandler aEventHandler)
        {
            ScheduleData      EmptyData = new ScheduleData();
            ScheduleDataModel SDM       = new ScheduleDataModel();

            SDM.SerialNumber     = BellDataUI.Count + 1;
            SDM.IsDateRequired   = false;
            SDM.BellDate         = DateTime.Now;
            SDM.BellTime         = DateTime.Now;
            SDM.BellNumbers      = string.Empty;
            SDM.BellDays         = string.Empty;
            EmptyData.scheduleDM = SDM;
            EmptyData.Location   = new Point(0, (BellDataUI.Count * 38));
            EmptyData.Controls["btnDelete"].Click += aEventHandler;
            EmptyData.MakeDirty += ActionMakeDirty;
            BellDataUI.Add(EmptyData);
            MakeDirty();
            return(EmptyData);
        }
        public static ScheduleData FromCsv(string csvLine, int LineNumber)
        {
            string[] values = csvLine.Split(',');

            ScheduleDataModel SDM = new ScheduleDataModel();
            ScheduleData      SD  = new ScheduleData();

            if (values.Count() != 13)
            {
                Logger.LogObj.Info("There is some error while parsing the data at line number " + LineNumber + "Of file " + BellListFilePath);
                return(null);
            }

            //hours,minutes,seconds,year,month,day
            //DateTime.ParseExact("2014-01-01 23:00:00", "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)
            //name,hours,minutes,seconds,year,month,day,relays(bells),day of week,duration,pw type,use,once

            bool     IsDateRequired   = false;
            DateTime TempBellDateTime = GetCorrectTime(values, out IsDateRequired);


            SDM.SerialNumber   = 0;
            SDM.BellName       = values[0].ToString();
            SDM.BellTime       = TempBellDateTime;
            SDM.BellNumbers    = values[7].ToString();
            SDM.BellDays       = values[8].ToString();
            SDM.IsDateRequired = IsDateRequired;
            SDM.BellDate       = TempBellDateTime;
            SDM.BellDuration   = Convert.ToInt32(values[9]);
            SDM.PulseWidth     = values[10].ToString();
            SDM.IsBellUse      = (values[11] != "0");
            SDM.IsBellOnce     = (values[12] != "0");

            SD.scheduleDM = SDM;
            return(SD);
        }
        private void btnTest_Click(object sender, EventArgs e)
        {
            ScheduleData SD = new ScheduleData();

            SData.Add(SD);
        }