コード例 #1
0
ファイル: UserFreeRequest.cs プロジェクト: githuis/P2Manage
        //Saves a request to the database.
        public void SaveUserRequest()
        {
            UserFreeRequest request = this;
            string          sql     = "INSERT INTO FreeRequestTable (start, end, text, username) values ('" + request._startTime.ToString() + "', '" + request._endTime.ToString() + "', '" + request._message + "', '" + request.User.UserName + "')";

            Database.Instance.Execute(sql);
            Core.Instance.GetAllFreeRequests().Add(this);
        }
コード例 #2
0
 //First checks that all required fields are filled
 //Validates Dates and User, see RequestValitation method
 //If these checks pass, clean the error message.
 //Then cast the user from the combobox into a user object and removes all commas (,) from the text
 //Then create a UserFreeRequest with dates, message and username
 //Then saves user and clears messagebox.
 private void SendRequest_Click(object sender, RoutedEventArgs e)
 {
     if (Start_Date.SelectedDate.HasValue && End_Date.SelectedDate.HasValue && SelectUserComboBox.SelectedItem != null)
     {
         if (RequestValitation(Start_Date.SelectedDate.Value, End_Date.SelectedDate.Value, SelectUserComboBox.SelectedItem.ToString()))
         {
             ErrorMessage.Content = "";
             User            user          = SelectUserComboBox.SelectedItem as User;
             string          message       = Message_Box.Text.Replace(",", "");
             UserFreeRequest ResultRequest = new UserFreeRequest(Start_Date.SelectedDate.Value, End_Date.SelectedDate.Value, message, user.UserName);
             ResultRequest.SaveUserRequest();
             Message_Box.Clear();
         }
         else
         {
             ErrorMessage.Content = "The selected start date is after the end date";
         }
     }
 }