private void ActivateButton_Click(object sender, RoutedEventArgs e)
        {
            if (Plans.Count <= 0)
                return;

            if (PlanGrid.SelectedIndex == -1)
            {
                MessageBox.Show("Please Select Plan", "Application Message", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            using (PSBContext DB = new PSBContext())
            {

                int planIndex = PlanGrid.SelectedIndex;

                if (Plans[planIndex].Active == true)
                {

                    MessageBox.Show("Plan Already Activated", "Application Info",
                        MessageBoxButton.OK, MessageBoxImage.Information);
                    return;

                }

                int planid = Plans[planIndex].PlanID;

                var newActivePlan = DB.Plans.Include("Actuals").Single(p => p.PlanID == planid);
                if (ActivePlan != null)
                {
                    ActivePlan = DB.Plans.Include("Actuals").Single(p => p.PlanID == ActivePlan.PlanID);
                    ActivePlan.Active = false;

                    DB.SaveChanges();
                }

                ActivePlan = newActivePlan;

                ActivePlan.Active = true;

                ActivePlan.StartTimestamp = DateTime.Now;

                Actual newActual = new Actual("", ActivePlan.Reference, DateTime.Now, ActivePlan.PlanID);

                DB.Actuals.Add(newActual);

                DB.SaveChanges();

            }

            UpdatePlansActuals();

            UpdateReference();
        }
        private void SerialNoTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (SerialNoTextBox.Text.Length == 12)
            {

                using (PSBContext db = new PSBContext())
                {
                    foreach (Plan p in Plans)
                    {
                        if (p.Reference == ActualReferenceTextBox.Text)
                        {
                            var actual = db.Actuals.Single(a => a.Reference == p.Reference
                                && (a.PlanID == p.PlanID)
                                && (a.EndTimestamp == null) && (a.SerialNo == String.Empty )
                                && (a.StartTimestamp >= CurrentShift.Start) && a.StartTimestamp <= CurrentShift.End);

                            actual.SerialNo = SerialNoTextBox.Text;
                            actual.EndTimestamp = DateTime.Now;

                            Actual newActual = new Actual("", p.Reference, actual.EndTimestamp.Value, p.PlanID);

                            db.Actuals.Add(newActual);
                            db.SaveChanges();

                            break;

                        }
                    }
                }

                UpdatePlansActuals();

                UpdateQuantity();

                SerialNoTextBox.Clear();
                ActualReferenceTextBox.Clear();
            }
        }
Ejemplo n.º 3
0
 public virtual void WriteRollback(DdlRules rules, TextWriter writer)
 {
     Expected.WriteDropStatement(rules, writer);
     Actual.WriteCreateStatement(rules, writer);
 }
Ejemplo n.º 4
0
 public override string ToString()
 {
     return(String.Format("Actual: {0} -> Target {1}", Actual.ToString(), Target.ToString()));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     Actual.Dispose();
 }
Ejemplo n.º 6
0
 public void It_should_return_a_correct_post()
 {
     Actual.Should().Be(ExpectedModel);
 }