示例#1
0
文件: Main.cs 项目: tmldsousa/PWM
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (this.lvwTimers.SelectedItems.Count > 0)
            {
                var selectedLI = this.lvwTimers.SelectedItems[0];
                var timerName  = selectedLI.Text;
                using (var objCtx = new TimersDBEntities()) {
                    // GetTimer
                    var timer = (from t in objCtx.Timer
                                 where t.Name == timerName
                                 select t).FirstOrDefault();

                    var timerSession = new TimerSession();
                    timerSession.StartDate    = DateTime.Now;
                    timerSession.EndDate      = DateTime.Now;
                    timerSession.TotalSeconds = 0;
                    timerSession.IdTimer      = timer.Id;

                    objCtx.TimerSession.AddObject(timerSession);
                    objCtx.SaveChanges();

                    activeTimerSessionId = timerSession.Id;
                }

                setFormStatus(true, true);
                this.timerControl.Start();

                // Move progress bar
                setProgressBarPosition(selectedLI);

                this.progressBar.Visible = true;
            }
        }
示例#2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            TimerSession timerSession;
            TimeSpan     sessionTime = this.dtpEndDate.Value.Subtract(this.dtpStartDate.Value);

            switch (_editMode)
            {
            case EditMode.Undefined:
                break;

            case EditMode.Add:
                using (var objCtx = new TimersDBEntities()) {
                    timerSession = new TimerSession()
                    {
                        StartDate = this.dtpStartDate.Value, EndDate = this.dtpEndDate.Value, TotalSeconds = Convert.ToInt64(sessionTime.TotalSeconds), IdTimer = _idTimer
                    };
                    objCtx.TimerSession.AddObject(timerSession);
                    objCtx.SaveChanges();
                }
                break;

            case EditMode.Edit:
                using (var objCtx = new TimersDBEntities()) {
                    timerSession              = objCtx.TimerSession.SingleOrDefault(x => x.Id == _idTimerSession);
                    timerSession.StartDate    = this.dtpStartDate.Value;
                    timerSession.EndDate      = this.dtpEndDate.Value;
                    timerSession.TotalSeconds = Convert.ToInt64(sessionTime.TotalSeconds);
                    objCtx.SaveChanges();
                }
                break;

            default:
                break;
            }
        }
示例#3
0
        /// <summary>
        /// Create a new TimerSession object.
        /// </summary>
        /// <param name="id">Initial value of the Id property.</param>
        /// <param name="startDate">Initial value of the StartDate property.</param>
        /// <param name="endDate">Initial value of the EndDate property.</param>
        /// <param name="totalSeconds">Initial value of the TotalSeconds property.</param>
        /// <param name="idTimer">Initial value of the IdTimer property.</param>
        public static TimerSession CreateTimerSession(global::System.Int64 id, global::System.DateTime startDate, global::System.DateTime endDate, global::System.Int64 totalSeconds, global::System.Int64 idTimer)
        {
            TimerSession timerSession = new TimerSession();

            timerSession.Id           = id;
            timerSession.StartDate    = startDate;
            timerSession.EndDate      = endDate;
            timerSession.TotalSeconds = totalSeconds;
            timerSession.IdTimer      = idTimer;
            return(timerSession);
        }
示例#4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the TimerSession EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTimerSession(TimerSession timerSession)
 {
     base.AddObject("TimerSession", timerSession);
 }