PIbd-22_Elli_T.A._LabWork3 #3
@ -8,11 +8,13 @@ public class AthleteAccommodation
|
||||
|
||||
public int AthleteId { get; private set; }
|
||||
|
||||
public decimal Price { get; private set; }
|
||||
|
||||
public DateTime DateStart { get; private set; }
|
||||
|
||||
public DateTime DateEnd { get; private set; }
|
||||
|
||||
public static AthleteAccommodation CreateOpeartion(int id, int roomId, int athleteId)
|
||||
public static AthleteAccommodation CreateOpeartion(int id, int roomId, int athleteId, decimal price)
|
||||
{
|
||||
var dateStart = DateTime.Now;
|
||||
return new AthleteAccommodation
|
||||
@ -20,6 +22,7 @@ public class AthleteAccommodation
|
||||
Id = id,
|
||||
RoomId = roomId,
|
||||
AthleteId = athleteId,
|
||||
Price = price,
|
||||
DateStart = dateStart,
|
||||
DateEnd = dateStart.AddMonths(1)
|
||||
};
|
||||
|
@ -38,12 +38,15 @@
|
||||
dateTimePickerDateEnd = new DateTimePicker();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
labelPrice = new Label();
|
||||
numericUpDownPrice = new NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelRoom
|
||||
//
|
||||
labelRoom.AutoSize = true;
|
||||
labelRoom.Location = new Point(60, 27);
|
||||
labelRoom.Location = new Point(106, 27);
|
||||
labelRoom.Name = "labelRoom";
|
||||
labelRoom.Size = new Size(45, 15);
|
||||
labelRoom.TabIndex = 0;
|
||||
@ -52,7 +55,7 @@
|
||||
// labelAthlete
|
||||
//
|
||||
labelAthlete.AutoSize = true;
|
||||
labelAthlete.Location = new Point(36, 60);
|
||||
labelAthlete.Location = new Point(82, 60);
|
||||
labelAthlete.Name = "labelAthlete";
|
||||
labelAthlete.Size = new Size(69, 15);
|
||||
labelAthlete.TabIndex = 1;
|
||||
@ -61,7 +64,7 @@
|
||||
// labelDateStart
|
||||
//
|
||||
labelDateStart.AutoSize = true;
|
||||
labelDateStart.Location = new Point(36, 102);
|
||||
labelDateStart.Location = new Point(82, 128);
|
||||
labelDateStart.Name = "labelDateStart";
|
||||
labelDateStart.Size = new Size(69, 15);
|
||||
labelDateStart.TabIndex = 2;
|
||||
@ -70,7 +73,7 @@
|
||||
// labelDateEnd
|
||||
//
|
||||
labelDateEnd.AutoSize = true;
|
||||
labelDateEnd.Location = new Point(32, 135);
|
||||
labelDateEnd.Location = new Point(78, 163);
|
||||
labelDateEnd.Name = "labelDateEnd";
|
||||
labelDateEnd.Size = new Size(73, 15);
|
||||
labelDateEnd.TabIndex = 3;
|
||||
@ -80,7 +83,7 @@
|
||||
//
|
||||
comboBoxRoom.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxRoom.FormattingEnabled = true;
|
||||
comboBoxRoom.Location = new Point(111, 24);
|
||||
comboBoxRoom.Location = new Point(157, 24);
|
||||
comboBoxRoom.Name = "comboBoxRoom";
|
||||
comboBoxRoom.Size = new Size(200, 23);
|
||||
comboBoxRoom.TabIndex = 4;
|
||||
@ -89,7 +92,7 @@
|
||||
//
|
||||
comboBoxAthlete.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxAthlete.FormattingEnabled = true;
|
||||
comboBoxAthlete.Location = new Point(111, 57);
|
||||
comboBoxAthlete.Location = new Point(157, 57);
|
||||
comboBoxAthlete.Name = "comboBoxAthlete";
|
||||
comboBoxAthlete.Size = new Size(200, 23);
|
||||
comboBoxAthlete.TabIndex = 5;
|
||||
@ -97,7 +100,7 @@
|
||||
// dateTimePickerDateStart
|
||||
//
|
||||
dateTimePickerDateStart.Enabled = false;
|
||||
dateTimePickerDateStart.Location = new Point(111, 96);
|
||||
dateTimePickerDateStart.Location = new Point(157, 122);
|
||||
dateTimePickerDateStart.Name = "dateTimePickerDateStart";
|
||||
dateTimePickerDateStart.Size = new Size(200, 23);
|
||||
dateTimePickerDateStart.TabIndex = 6;
|
||||
@ -105,16 +108,16 @@
|
||||
// dateTimePickerDateEnd
|
||||
//
|
||||
dateTimePickerDateEnd.Enabled = false;
|
||||
dateTimePickerDateEnd.Location = new Point(111, 129);
|
||||
dateTimePickerDateEnd.Location = new Point(157, 157);
|
||||
dateTimePickerDateEnd.Name = "dateTimePickerDateEnd";
|
||||
dateTimePickerDateEnd.Size = new Size(200, 23);
|
||||
dateTimePickerDateEnd.TabIndex = 7;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(32, 168);
|
||||
buttonSave.Location = new Point(18, 202);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(133, 45);
|
||||
buttonSave.Size = new Size(159, 45);
|
||||
buttonSave.TabIndex = 8;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
@ -122,19 +125,41 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(178, 168);
|
||||
buttonCancel.Location = new Point(197, 202);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(133, 45);
|
||||
buttonCancel.Size = new Size(160, 45);
|
||||
buttonCancel.TabIndex = 9;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// labelPrice
|
||||
//
|
||||
labelPrice.AutoSize = true;
|
||||
labelPrice.Location = new Point(12, 92);
|
||||
labelPrice.Name = "labelPrice";
|
||||
labelPrice.Size = new Size(139, 15);
|
||||
labelPrice.TabIndex = 10;
|
||||
labelPrice.Text = "Стоимость проживания";
|
||||
//
|
||||
// numericUpDownPrice
|
||||
//
|
||||
numericUpDownPrice.DecimalPlaces = 2;
|
||||
numericUpDownPrice.Location = new Point(157, 90);
|
||||
numericUpDownPrice.Maximum = new decimal(new int[] { 999999999, 0, 0, 0 });
|
||||
numericUpDownPrice.Minimum = new decimal(new int[] { 1, 0, 0, 131072 });
|
||||
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||
numericUpDownPrice.Size = new Size(200, 23);
|
||||
numericUpDownPrice.TabIndex = 11;
|
||||
numericUpDownPrice.Value = new decimal(new int[] { 1, 0, 0, 131072 });
|
||||
//
|
||||
// FormAthleteAccommodation
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(342, 225);
|
||||
ClientSize = new Size(380, 267);
|
||||
Controls.Add(numericUpDownPrice);
|
||||
Controls.Add(labelPrice);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(dateTimePickerDateEnd);
|
||||
@ -148,6 +173,7 @@
|
||||
Name = "FormAthleteAccommodation";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Размещение спортсмена";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -164,5 +190,7 @@
|
||||
private DateTimePicker dateTimePickerDateEnd;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label labelPrice;
|
||||
private NumericUpDown numericUpDownPrice;
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ namespace ProjectAthletesAccommodation.Forms
|
||||
|
||||
_athleteAccommodationRepository.CreateAthleteAccommodation
|
||||
(AthleteAccommodation.CreateOpeartion(0, (int)comboBoxRoom.SelectedValue!,
|
||||
(int)comboBoxAthlete.SelectedValue!));
|
||||
(int)comboBoxAthlete.SelectedValue!, Convert.ToDecimal(numericUpDownPrice.Value)));
|
||||
|
||||
Close();
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ public class AthleteAccommodationRepository : IAthleteAccommodationRepository
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert =
|
||||
@"INSERT INTO AthleteAccommodation (RoomId, AthleteId, DateStart, DateEnd)
|
||||
VALUES (@RoomId, @AthleteId, @DateStart, @DateEnd)";
|
||||
@"INSERT INTO AthleteAccommodation (RoomId, AthleteId, Price, DateStart, DateEnd)
|
||||
VALUES (@RoomId, @AthleteId, @Price, @DateStart, @DateEnd)";
|
||||
connection.Execute(queryInsert, athleteAccommodation);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Loading…
x
Reference in New Issue
Block a user