Ejemplo n.º 1
0
 public void addNewEventTest()
 {
     CalendarEvent e = new CalendarEvent(1, "EventTest", DateTime.Now, DateTime.Now, 1, "Test Type");
     bool expected = true;
     bool actual;
     actual = CalendarDAL.addNewEvent(e);
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 2
0
 public void addCalendarEventTest()
 {
     CalendarBLL target = new CalendarBLL();
     CalendarEvent e = new CalendarEvent(1, "EventName", DateTime.Now, DateTime.Now, 1, "Test Type");
     bool expected = true;
     bool actual;
     actual = target.addCalendarEvent(e);
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 3
0
 public static bool addNewEvent(CalendarEvent e)
 {
     using (SqlConnection sqlConnection = new SqlConnection(CONNECTION_STRING))
     {
         sqlConnection.Open();
         using (SqlCommand sqlCommand = new SqlCommand("INSERT INTO CalendarEvent (Name, Start, [End], CalendarId, Type) "+
             "VALUES ('" + e.getName() + "','" + e.getStart().ToString() + "','" + e.getEnd().ToString() + "'," + e.getCalendarId() +
             ",'" + e.getType() + "')", sqlConnection))
         {
             using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
             {
                 sqlDataReader.Close();
             }
         }
         sqlConnection.Close();
     }
     return true;
 }
Ejemplo n.º 4
0
 public void CalendarEventConstructorTest1()
 {
     CalendarEvent target = new CalendarEvent();
     Assert.IsInstanceOfType(target, typeof(CalendarEvent));
 }
Ejemplo n.º 5
0
        protected void SaveNewEvent_Click(object sender, EventArgs e)
        {
            CalendarEvent newEvent = new CalendarEvent();

            if (NewEventNameTextBox.Text.Length == 0)
            {
                TopMostMessageBox.Show("Please enter an event name.", "Error", MessageBoxButtons.RetryCancel);
                return;
            }
            newEvent.setName(NewEventNameTextBox.Text);

            if (StartYear.Text.Length == 0)
            {
                TopMostMessageBox.Show("Please enter a start year.", "Error", MessageBoxButtons.RetryCancel);
                return;
            }
            else if (StartMonth.Text.Length == 0)
            {
                TopMostMessageBox.Show("Please enter a start month.", "Error", MessageBoxButtons.RetryCancel);
                return;
            }
            else if (StartDay.Text.Length == 0)
            {
                TopMostMessageBox.Show("Please enter a start day.", "Error", MessageBoxButtons.RetryCancel);
                return;
            }
            else if (StartHour.Text.Length == 0)
            {
                TopMostMessageBox.Show("Please enter a start hour.", "Error", MessageBoxButtons.RetryCancel);
                return;
            }
            else if (StartMinute.Text.Length == 0)
            {
                TopMostMessageBox.Show("Please enter a start minute.", "Error", MessageBoxButtons.RetryCancel);
                return;
            }

            if (EndYear.Text.Length == 0)
            {
                TopMostMessageBox.Show("Please enter a end year.", "Error", MessageBoxButtons.RetryCancel);
                return;
            }
            else if (EndMonth.Text.Length == 0)
            {
                TopMostMessageBox.Show("Please enter a end month.", "Error", MessageBoxButtons.RetryCancel);
                return;
            }
            else if (EndDay.Text.Length == 0)
            {
                TopMostMessageBox.Show("Please enter a end day.", "Error", MessageBoxButtons.RetryCancel);
                return;
            }
            else if (EndHour.Text.Length == 0)
            {
                TopMostMessageBox.Show("Please enter a end hour.", "Error", MessageBoxButtons.RetryCancel);
                return;
            }
            else if (EndMinute.Text.Length == 0)
            {
                TopMostMessageBox.Show("Please enter a end minute.", "Error", MessageBoxButtons.RetryCancel);
                return;
            }

            int startYear = Convert.ToInt32(StartYear.Text);
            int startMonth = Convert.ToInt32(StartMonth.Text);
            int startDay = Convert.ToInt32(StartDay.Text);
            int startHour = Convert.ToInt32(StartHour.Text);
            int startMinute = Convert.ToInt32(StartMinute.Text);
            int endYear = Convert.ToInt32(EndYear.Text);
            int endMonth = Convert.ToInt32(EndMonth.Text);
            int endDay = Convert.ToInt32(EndDay.Text);
            int endHour = Convert.ToInt32(EndHour.Text);
            int endMinute = Convert.ToInt32(EndMinute.Text);

            DateTime startTime = new DateTime(startYear, startMonth, startDay, startHour, startMinute, 0);
            DateTime endTime = new DateTime(endYear, endMonth, endDay, endHour, endMinute, 0);

            System.Diagnostics.Trace.WriteLine(startTime.ToString());
            System.Diagnostics.Trace.WriteLine(endTime.ToString());

            newEvent.setStart(startTime);
            newEvent.setEnd(endTime);
            newEvent.setCalendarId(currentCalendar.getCalendarId());
            newEvent.setType(TypeDropDownList.SelectedValue);

            CalendarBLL calendarBLL = new CalendarBLL();
            calendarBLL.addCalendarEvent(newEvent);

            ViewCalendarPanel.Visible = true;
            AddEventPanel.Visible = false;
        }
Ejemplo n.º 6
0
 public bool addCalendarEvent(CalendarEvent e)
 {
     return CalendarDAL.addNewEvent(e);
 }