Example #1
0
        public ConstructionProgress addConstructionProgress(ConstructionProgress cp)
        {
            Connection con = Connection.getConnection();

            con.db.ConstructionProgress.Add(cp);
            con.db.SaveChanges();

            return(cp);
        }
Example #2
0
        public int getLastID()
        {
            Connection con = Connection.getConnection();

            ConstructionProgress cp = (from c in con.db.ConstructionProgress orderby c.progressID descending select c).FirstOrDefault();

            if (cp == null)
            {
                return(0);
            }
            return(cp.progressID);
        }
Example #3
0
        public ConstructionProgress createNewConstructionProgress(int attractionID, string title, string desc, DateTime?progressDate)
        {
            ConstructionProgressMediator mediator = new ConstructionProgressMediator();
            ConstructionProgress         cp       = new ConstructionProgress();

            cp.progressID   = mediator.getLastID() + 1;
            cp.attractionID = attractionID;
            cp.title        = title;
            cp.description  = desc;
            cp.progressDate = progressDate;

            return(cp);
        }
        private void submitBtn_Click(object sender, RoutedEventArgs e)
        {
            string   attractionIDStr = attractionIDTxt.Text.Trim();
            string   title           = titleTxt.Text.Trim();
            string   desc            = descTxt.Text.Trim();
            DateTime?progressDate    = progressDatePicker.SelectedDate;
            int      attractionID;

            bool success = int.TryParse(attractionIDStr, out attractionID);

            if (!success)
            {
                errorLbl.Text = "TaskID must be a number!";
            }
            else if (title == "" || desc == "" || !progressDate.HasValue)
            {
                errorLbl.Text = "Please input all field!";
            }
            else
            {
                if (new AttractionRideMediator().getAttractionOrRide(attractionID) == null)
                {
                    errorLbl.Text = "Attraction ID invalid!";
                }
                else
                {
                    ConstructionProgressMediator mediator = new ConstructionProgressMediator();
                    ConstructionProgressFactory  factory  = new ConstructionProgressFactory();

                    ConstructionProgress cp = mediator.addConstructionProgress(factory.createNewConstructionProgress(attractionID, title, desc, progressDate));
                    if (cp == null)
                    {
                        MessageBox.Show("Add construction progress failed!");
                    }
                    else
                    {
                        MessageBox.Show("Add construction progress success!");
                    }
                    this.Close();
                }
            }
        }
Example #5
0
        public ConstructionProgress addConstructionProgress(ConstructionProgress cp)
        {
            ConstructionProgressRepository repository = new ConstructionProgressRepository();

            return(repository.addConstructionProgress(cp));
        }