Add project files.

This commit is contained in:
2025-03-25 22:59:42 +04:00
parent 20e9f92f3a
commit 4445accb75
30 changed files with 1424 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
using System.Windows;
using Npgsql;
namespace SportsTrainingApp.Challenges
{
public partial class formAddChallenges : Window
{
public formAddChallenges()
{
InitializeComponent();
dtStart.SelectedDate = DateTime.Now;
dtEnd.SelectedDate = DateTime.Now.AddDays(1);
}
private void AddChallenges()
{
using (var conn = new NpgsqlConnection(formMain.connectionString))
{
conn.Open();
using (var cmd = new NpgsqlCommand($@"INSERT INTO dbo.challenges(
name, description, start_date, end_date)
VALUES (@name, @description, @start_date, @end_date);", conn))
{
cmd.Parameters.AddWithValue("name", tbName.Text);
cmd.Parameters.AddWithValue("description", tbDescription.Text);
cmd.Parameters.AddWithValue("start_date", dtStart.SelectedDate);
cmd.Parameters.AddWithValue("end_date", dtEnd.SelectedDate);
cmd.ExecuteNonQuery();
}
this.Close();
}
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
AddChallenges();
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}