Exemplo n.º 1
0
 /// <summary>
 /// 如果傳入 DataSet 型別 , 代表新增
 /// </summary>
 /// <param name="ds"></param>
 public FormEditTip(MiniTipsDataSet ds)
 {
     _ds = ds;
     _tipsRow = _ds.Tips.NewTipsRow();
     _tipsRow.TipId = (UInt64)DateTime.Now.Ticks;
     _tipsRow.Subject = "";
     _tipsRow.Description = "";
     _tipsRow.Url = "http://";
     _tipsRow.CreateDate = DateTime.Now;
     _tipsRow.LastNotifiedDate = _tipsRow.CreateDate;
     _ds.Tips.Rows.Add(_tipsRow);
     InitializeComponent();
 }
Exemplo n.º 2
0
        /// <summary>
        /// 新增提醒項目
        /// </summary>
        private void AddTip()
        {
            MiniTipsDataSet newDs = new MiniTipsDataSet();
            FormEditTip tipForm = new FormEditTip(newDs);

            if (DialogResult.OK == tipForm.ShowDialog())
            {
                _ds.Merge(newDs);
                this._ds.SaveUserDb();
            }
            else
            {
                this._ds.RejectChanges();
            }
            // release all resorce
            newDs.Dispose();
            tipForm.Dispose();
        }
Exemplo n.º 3
0
 /// <summary>
 /// 如果時間到了會傳回 true
 /// </summary>
 /// <param name="row"></param>
 /// <returns></returns>
 public static bool check(MiniTipsDataSet.TipsTimeRow row)
 {
     switch ((int)row.TipType)
     {
         case 0:
             return TipsTimeChecker.checkOnce(row);
         case 1:
             return TipsTimeChecker.checkYear(row);
         case 2:
             return TipsTimeChecker.checkMonth(row);
         case 3:
             return TipsTimeChecker.checkWeek(row);
         case 4:
             return TipsTimeChecker.checkDay(row);
         case 5:
             return TipsTimeChecker.checkHour(row);
         default:
             return false;
     }
 }
Exemplo n.º 4
0
        private static bool checkHour(MiniTipsDataSet.TipsTimeRow row)
        {
            DateTime nowDateTime = DateTime.Now;
            DateTime newTipsTime;
            try
            {
                newTipsTime = new DateTime(
                           nowDateTime.Year,
                           nowDateTime.Month,
                           nowDateTime.Day,
                           nowDateTime.Hour,
                           row.TipDateTime.Minute,
                           row.TipDateTime.Second);
            }
            catch (ArgumentOutOfRangeException e)
            {
                // 有時候小月沒有 31 日也可能會錯 , 所以傳回 false
                return false;
            }
            if (row.TipsRow.LastNotifiedDate < newTipsTime && nowDateTime > newTipsTime)
            {

                if (nowDateTime.Ticks < newTipsTime.Ticks + 100000000)
                {
                    // 應提醒時間小於現在時間 10 秒內就通知
                    return true;
                }
                else if (true == row.EnableExpireNotify)
                {
                    // 如果有設定過期通知 , 判斷是否有在延長期限內
                    Int32 ExpireTime = 10000000 * ((row.ExpireDay * 86400) + (row.ExpireHour * 3600) + (row.ExpireMinute * 60));

                    if (nowDateTime.Ticks < (newTipsTime.Ticks + ExpireTime))
                    {
                        return true;
                    }
                }

            }
            return false;
        }
Exemplo n.º 5
0
 /// <summary>
 /// 如果傳入 DataRow , 代表編輯
 /// </summary>
 /// <param name="row"></param>
 public FormEditTip(MiniTipsDataSet.TipsRow row)
 {
     _tipsRow = row;
     this._ds = (MiniTipsDataSet)row.Table.DataSet;
     InitializeComponent();
 }
Exemplo n.º 6
0
        /// <summary>
        /// 匯入提醒檔案
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainMenu_Import_Click(object sender, EventArgs e)
        {
            DialogResult ret = this.openFileDialog_Import.ShowDialog();
            if (ret == DialogResult.OK)
            {
                MiniTipsDataSet newDs = new MiniTipsDataSet();
                _ds.mutext.WaitOne();
                try
                {
                    newDs.ReadXml(this.openFileDialog_Import.FileName);
                    _ds.Merge(newDs.Tips);
                    _ds.Merge(newDs.TipsTime);
                    _ds.SaveUserDb();
                }
                catch (System.Security.SecurityException ex)
                {
                    string errorMessage = "無法讀取檔案 , 可能是因為權限不足+ \r\n\r\n詳細錯誤訊息如下\r\n";
                    errorMessage += ex.ToString();
                    MessageBox.Show(errorMessage, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);

                }
                _ds.mutext.ReleaseMutex();
                newDs.Dispose();
                newDs = null;
            }
        }
Exemplo n.º 7
0
 private void FormList_Load(object sender, EventArgs e)
 {
     _ds = new MiniTipsDataSet();
     _ds.LoadUserDb();
     this.BindingSource_Tips.DataSource = this._ds.Tips;
     this.BindingSource_TipsNotified.DataSource = this._ds.TipsNotified;
     // 計時器開始
     Timer_Tip.Start();
 }
Exemplo n.º 8
0
        private static bool checkWeek(MiniTipsDataSet.TipsTimeRow row)
        {
            DateTime nowDateTime = DateTime.Now;
            byte NowWeek = (byte)(1 << ((int)DateTime.Now.DayOfWeek));
            if ((NowWeek & row.Week) > 0)
            {
                DateTime newTipsTime = new DateTime(
                       nowDateTime.Year,
                       nowDateTime.Month,
                       nowDateTime.Day,
                       row.TipDateTime.Hour,
                       row.TipDateTime.Minute,
                       row.TipDateTime.Second);
                if (row.TipsRow.LastNotifiedDate < newTipsTime && nowDateTime > newTipsTime)
                {

                    if (nowDateTime.Ticks < newTipsTime.Ticks + 100000000)
                    {
                        // 應提醒時間小於現在時間 10 秒內就通知
                        return true;
                    }
                    else if (true == row.EnableExpireNotify)
                    {
                        // 如果有設定過期通知 , 判斷是否有在延長期限內
                        Int32 ExpireTime = 10000000 * ((row.ExpireDay * 86400) + (row.ExpireHour * 3600) + (row.ExpireMinute * 60));

                        if (nowDateTime.Ticks < (newTipsTime.Ticks + ExpireTime))
                        {
                            return true;
                        }
                    }

                }

            }
            return false;
        }
Exemplo n.º 9
0
        private static bool checkOnce(MiniTipsDataSet.TipsTimeRow row)
        {
            DateTime nowDateTime = DateTime.Now;
            if (nowDateTime > row.TipDateTime && row.TipsRow.LastNotifiedDate < row.TipDateTime)
            {
                if (nowDateTime.Ticks < row.TipDateTime.Ticks + 100000000)
                {
                    // 應提醒時間小於現在時間 10 秒內就通知
                    return true;
                }
                else if (true == row.EnableExpireNotify)
                {
                    // 如果有設定過期通知 , 判斷是否有在延長期限內
                    Int32 ExpireTime = 10000000*((row.ExpireDay * 86400) + (row.ExpireHour * 3600) + (row.ExpireMinute * 60));

                    if (nowDateTime.Ticks < (row.TipDateTime.Ticks + ExpireTime))
                    {
                        return true;
                    }
                }
             }

            return false;
        }
Exemplo n.º 10
0
 public FormWizardTipTime(MiniTipsDataSet.TipsTimeRow row)
 {
     InitializeComponent();
     this._tipTimeRow = row;
 }
Exemplo n.º 11
0
 public NotifiedBox(MiniTipsDataSet.TipsNotifiedRow row)
 {
     InitializeComponent();
     _tipsNotifiedRow = row;
 }