public CustomAppointmentForm(SchedulerControl control, Appointment apt, Event ev)
        {
            Event = ev;
            InitializeComponent();

            Controller = new EventAppointmentFormController(control, apt);
        }
        private void GetDataFromForm()
        {
            if (Event == null) Event = new Event { EventId = Guid.NewGuid() };

            Event.Name = EventName.EditValue as string;
            Event.Description = EventDescription.EditValue as string;
            Event.Type = EventTypeReference.GetTypeByReference(EventType.EditValue as string);
            int personNumber;
            Int32.TryParse(EventPersonNumber.EditValue.ToString(), out personNumber);
            Event.PersonNumber = personNumber;
            Event.ManagerPersonId = EventManager.EditValue == null ? Guid.Empty : (Guid)EventManager.EditValue;
            Event.ContactPersonId = EventContactPerson.EditValue == null ? Guid.Empty : (Guid)EventContactPerson.EditValue;
            Event.OrganizationId = EventOrganization.EditValue == null ? Guid.Empty : (Guid)EventOrganization.EditValue;
            Event.RegistrationDate = RegistrationDateEdit.EditValue == null
                                         ? DateTime.Now
                                         : (DateTime) RegistrationDateEdit.EditValue;
            Event.ExitDate = ExitDateEdit.EditValue == null
                                         ? DateTime.Now
                                         : (DateTime)ExitDateEdit.EditValue;
        }
Ejemplo n.º 3
0
        public void UpdateEvent(Event ev)
        {
            if (ev == null) return;

            using (IDbConnection connection = CreateConnection())
            {
                IDbCommand command = connection.CreateCommand();

                #region sql statement

                command.CommandText = @"
            IF EXISTS(SELECT TOP 1 * FROM [dbo].[event] WHERE [event_id] = @event_id)
            UPDATE [dbo].[event]
               SET [contact_person_id] = @contact_person_id
              ,[manager_person_id] = @manager_person_id
              ,[name] = @name
              ,[type] = @type
              ,[person_number] = @person_number
              ,[review] = @review
              ,[price_cash] = @price_cash
              ,[price_non_cash] = @price_non_cash
              ,[loss] = @loss
              ,[description] = @description
              ,[state] = @state
              ,[registration_date] = @registration_date
              ,[exit_date] = @exit_date
              ,[organization_id] = @organization_id
             WHERE [event_id] = @event_id
            ELSE
            INSERT INTO [dbo].[event]
               ([event_id]           ,[contact_person_id]           ,[manager_person_id]           ,[name]
               ,[type]           ,[person_number]           ,[review]           ,[price_cash],[price_non_cash]
               ,[loss]           ,[description]           ,[state]      ,[organization_id],[registration_date],[exit_date])
             VALUES
               (@event_id           ,@contact_person_id           ,@manager_person_id           ,@name
               ,@type           ,@person_number           ,@review           ,@price_cash, @price_non_cash
               ,@loss           ,@description           ,@state , @organization_id,@registration_date,@exit_date)

            ";
                #endregion

                addParameter(command, "@event_id", ev.EventId);
                addParameter(command, "@contact_person_id", ev.ContactPersonId == Guid.Empty ? null : (object)ev.ContactPersonId);
                addParameter(command, "@manager_person_id", ev.ManagerPersonId == Guid.Empty ? null : (object)ev.ManagerPersonId);
                addParameter(command, "@organization_id", ev.OrganizationId == Guid.Empty ? null : (object)ev.OrganizationId);
                addParameter(command, "@person_number", ev.PersonNumber);
                addParameter(command, "@review", ev.Review);
                addParameter(command, "@price_cash", ev.CashPrice);
                addParameter(command, "@price_non_cash", ev.NonCashPrice);
                addParameter(command, "@loss", ev.Loss);
                addParameter(command, "@type", ev.Type);
                addParameter(command, "@name", ev.Name);
                addParameter(command, "@state", ev.State);
                addParameter(command, "@registration_date", ev.RegistrationDate);
                addParameter(command, "@exit_date", ev.ExitDate);
                addParameter(command, "@description", ev.Description);

                command.ExecuteNonQuery();
            }
        }
 public EventUpdatedEventArgs(Event ev)
 {
     Event = ev;
 }
 public EventChangedEventArgs(Event ev)
     : base(ev)
 {
 }