Пример #1
0
    /// <summary>
    /// Apply button click.
    /// </summary>
    protected void btnApply_Click(object sender, EventArgs e)
    {
        cvTimeBegin.Validate();
        cvTimeEnd.Validate();
        cvCheckAdding.Validate();

        cvDayRepeatEvery.Validate();
        cvWeekRepeatEvery.Validate();
        cvEndDate.Validate();
        cvEndCount.Validate();

        if (!Page.IsValid)
            return;
        FillArrangement();
        try
        {
            // Create service wrapper.
            Office of = new Office();
            of.Load(OfficeID.Value);
            using (ArrangementServiceProxy c = new ArrangementServiceProxy("http://localhost:59874/ArrangementService.svc", CurrentUser.ID))
            {
                if (ArrangementID.HasValue)
                {
                    // One of cyclic arrangement
                    if (!cbCyclicArrangement.Checked && c.CheckCyclicArrangement(CurrentArrangement.ArrangementID))
                    {
                        c.DeleteOneOfCyclicArrangements(CurrentArrangement.ArrangementID, (DateTime)CurrentArrangementDate);
                        c.AddArrangement(CurrentArrangement.Name, CurrentArrangement.Description, CurrentArrangement.ConferenceHallID, CurrentArrangement.TimeBegin, CurrentArrangement.TimeEnd, CurrentArrangement.ListOfGuests, CurrentArrangement.Equipment);
                    }

                    // All cycle ore one of the plain arrangements
                    else
                    {
                        DateTime timeBegin = Calendar.SelectedDate.Date;
                        timeBegin = timeBegin.AddHours(CurrentArrangement.TimeBegin.Hour);
                        timeBegin = timeBegin.AddMinutes(CurrentArrangement.TimeBegin.Minute);
                        c.EditArrangement(CurrentArrangement.ArrangementID, CurrentArrangement.Name, CurrentArrangement.Description, CurrentArrangement.ConferenceHallID, timeBegin, CurrentArrangement.TimeEnd, CurrentArrangement.ListOfGuests, CurrentArrangement.Equipment);
                    }
                }
                else
                {
                    if (!cbCyclicArrangement.Checked)
                        c.AddArrangement(CurrentArrangement.Name, CurrentArrangement.Description, CurrentArrangement.ConferenceHallID, CurrentArrangement.TimeBegin, CurrentArrangement.TimeEnd, CurrentArrangement.ListOfGuests, CurrentArrangement.Equipment);
                    else
                    {
                        int Count = 0;
                        DateTime EndDate = new DateTime();
                        if (rbEnd.SelectedIndex == 0)
                            Int32.TryParse(tbCount.Text, out Count);
                        else
                        {
                            int year, month, day;
                            string[] date = tbEndDate.Text.Split('/');
                            Int32.TryParse(date[2], out year);
                            Int32.TryParse(date[0], out month);
                            Int32.TryParse(date[1], out day);
                            EndDate = new DateTime(year, month, day);
                        }

                        if (rbListDailyWeekly.SelectedIndex == 0)
                        {
                            int daysCycle = 1;
                            if (rbDaily.SelectedIndex == 1)
                                Int32.TryParse(tbDayRepeatEvery.Text, out daysCycle);
                            c.AddDailyCyclicArrangement(CurrentArrangement.Name, CurrentArrangement.Description, CurrentArrangement.ConferenceHallID, CurrentArrangement.TimeBegin, CurrentArrangement.TimeEnd, daysCycle, EndDate, Count, CurrentArrangement.ListOfGuests, CurrentArrangement.Equipment);
                        }
                        else
                        {
                            bool Mo = false, Tu = false, We = false, Th = false, Fr = false, Sa = false, Su = false;
                            foreach (ListItem item in cbDaysOfWeek.Items)
                            {
                                if (item.Selected)
                                    switch (item.Value)
                                    {
                                        case "Mo":
                                            Mo = true;
                                            break;
                                        case "Tu":
                                            Tu = true;
                                            break;
                                        case "We":
                                            We = true;
                                            break;
                                        case "Th":
                                            Th = true;
                                            break;
                                        case "Fr":
                                            Fr = true;
                                            break;
                                        case "Sa":
                                            Sa = true;
                                            break;
                                        case "Su":
                                            Su = true;
                                            break;
                                    }
                            }
                            int weeksCycle;
                            Int32.TryParse(tbWeekRepeatEvery.Text, out weeksCycle);
                            c.AddWeeklyCyclicArrangement(CurrentArrangement.Name, CurrentArrangement.Description, CurrentArrangement.ConferenceHallID, CurrentArrangement.TimeBegin, CurrentArrangement.TimeEnd, weeksCycle, Mo, Tu, We, Th, Fr, Sa, Su, EndDate, Count, CurrentArrangement.ListOfGuests, CurrentArrangement.Equipment);
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            ConfirmIt.PortalLib.Logger.Logger.Instance.Error(ex.Message, ex);
        }

        Response.Redirect("~//Admin//AdminArrangements//AdminArrangementsPage.aspx");
    }
Пример #2
0
 /// <summary>
 /// Apply button click.
 /// </summary>
 protected void btnApply_Click(object sender, EventArgs e)
 {
     cvTimeBegin.Validate();
     cvTimeEnd.Validate();
     cvCheckAdding.Validate();
     if (!Page.IsValid)
         return;
     FillArrangement();
     try
     {
         // Create service wrapper.
         Office of = new Office();
         of.Load(OfficeID.Value);
         using (ArrangementServiceProxy c = new ArrangementServiceProxy("http://localhost:59874/ArrangementService.svc", CurrentUser.ID))
         {
             if (ArrangementID.HasValue)
                 c.EditArrangement(CurrentArrangement.ArrangementID, CurrentArrangement.Name, CurrentArrangement.Description, CurrentArrangement.ConferenceHallID, CurrentArrangement.TimeBegin, CurrentArrangement.TimeEnd, CurrentArrangement.ListOfGuests, CurrentArrangement.Equipment);
             else
                 c.AddArrangement(CurrentArrangement.Name, CurrentArrangement.Description, CurrentArrangement.ConferenceHallID, CurrentArrangement.TimeBegin, CurrentArrangement.TimeEnd, CurrentArrangement.ListOfGuests, CurrentArrangement.Equipment);
         }
     }
     catch (Exception ex)
     { UlterSystems.PortalLib.Logger.Log.Error(ex.Message, ex); }
     Response.Redirect("~//Arrangements//Default.aspx");
 }