Esempio n. 1
0
        private void UpdRow(int rowId)
        {
            var repSeason = new SeasonRepository(new CSBCDbContext());
            DateTime date;
            Season season;
            if (rowId != 0)
                season = repSeason.GetById(rowId);
            else
            {
                season = new Season();
            }
            try
            {
                season.CompanyID = Master.CompanyId;
                season.SeasonID = rowId;
                season.Description = txtName.Text;
                if (DateTime.TryParse(mskStartDate.Text, out date))
                    season.FromDate = date;
                if (DateTime.TryParse(mskEndDate.Text, out date))
                    season.ToDate = date;
                season.NewSchoolYear = chkNewSchool.Checked;
                season.CurrentSeason = chkCurrentSeason.Checked;
                season.CurrentSignUps = chkRegistration.Checked;
                season.CurrentSchedule = chkSchedules.Checked;

                // Set dates
                if (DateTime.TryParse(mskORStart.Text, out date))
                    season.SignUpsDate = date;
                if (DateTime.TryParse(mskOREnd.Text, out  date))
                    season.SignUpsEND = date;

                // Set fees
                decimal fee;
                season.ParticipationFee = Decimal.TryParse(txtPlayersFee.Text, out fee) ? fee : 0;
                season.SponsorFee = Decimal.TryParse(mskSponsorFee.Text, out fee) ? fee : 0;
                season.ConvenienceFee = Decimal.TryParse(mskSponsorFeeDiscounted.Text, out fee) ? fee : 0;

                season.CreatedUser = Session["UserName"].ToString();
                if (rowId == 0)
                    repSeason.Insert(season);
                else
                    repSeason.Update(season);

            }
            catch (Exception e)
            {
                lblError.Text = "SaveRecord::" + e.Message;
            }
        }