Hello
Pas mal de problème dans le projet et je n'arrive pas à trouver les erreurs.
Voici le dernier problème que j'ai et que j'arrive pas à résoudre depuis deux jours.
Voici mon Windows Form :
Add Reservation
Voici ma classe Reservation :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using BE; namespace WindowsFormsApplication1 { public partial class AdddReservationForm : Form { BL.IBL bl; public AdddReservationForm(BL.IBL bl) { InitializeComponent(); this.bl = bl; AR_DateTimereservation_label.Text = DateTime.Now.ToString(); AR_codeagency_comboBox.DataSource = bl.List_agency_id(); AR_clientid_comboBox.DataSource = bl.List_client_id(); ARR_roomtype_comboBox.DataSource = Enum.GetValues(typeof(Room.Room_Type)); } private Single_Reservation single() { Room sing_room = (Room)RAF_dataGridView.SelectedRows[0].DataBoundItem; return new Single_Reservation() { Reservation_num = int.Parse(AR_numreservation_textBox.Text), Agency_num = int.Parse(AR_codeagency_comboBox.Text), Client_ID = int.Parse(AR_clientid_comboBox.Text), Bed_reserv = int.Parse(AR_reservroom_comboBox.Text), reserv_Date = DateTime.Now, Client_pay = (Reservation.client_payement)RA_payement_comboBox.SelectedValue, Single_status = (Single_Reservation.single_statu)RA_statusclientcomboBox.SelectedValue, arrive_Date = ARR_DateTimearrive_dateTimePicker.Value, NumOfDay = int.Parse(ARR_numberday_textBox.Text), room_Reserv = sing_room }; } private Group_Reservation group() { List<Room> group_room = new List<Room>(); foreach (DataGridViewRow row in RAF_dataGridView.SelectedRows) { Room dataBoundItem = (Room)row.DataBoundItem; group_room.Add(dataBoundItem); } return new Group_Reservation() { Reservation_num = int.Parse(AR_numreservation_textBox.Text), Agency_num = int.Parse(AR_codeagency_comboBox.Text), Client_ID = int.Parse(AR_clientid_comboBox.Text), Bed_reserv = int.Parse(AR_reservroom_comboBox.Text), reserv_Date = DateTime.Now, Client_pay = (Reservation.client_payement)RA_payement_comboBox.SelectedValue, Single_status = (Group_Reservation.single_statu)RA_statusclientcomboBox.SelectedValue, arrive_Date = ARR_DateTimearrive_dateTimePicker.Value, NumOfDay = int.Parse(ARR_numberday_textBox.Text), rooms_Reserv = group_room }; } private void AR_resetreserv_button_Click_1(object sender, EventArgs e) { AR_numreservation_textBox.ResetText(); AR_codeagency_comboBox.Text = "Pick up a Code Agency"; AR_clientid_comboBox.Text = "Pick up a Client ID"; AR_reservroom_comboBox.Text = ""; AR_DateTimereservation_label.Text = DateTime.Now.ToString(); } private int i; private void AR_continue_button_Click(object sender, EventArgs e) { AR_type_panel.Visible = true; AR_resetreserv_button.Visible = false; AR_continue_button.Visible = false; AR_numreservation_textBox.ReadOnly = true; AR_codeagency_comboBox.Enabled = false; AR_clientid_comboBox.Enabled = false; AR_reservroom_comboBox.Enabled = false; RA_payement_comboBox.DataSource = Enum.GetValues(typeof(Reservation.client_payement)); if (AR_reservroom_comboBox.Text == "1") { RA_statusclientcomboBox.DataSource = Enum.GetValues(typeof(Single_Reservation.single_statu)); i = int.Parse(AR_reservroom_comboBox.Text); } else { RA_statusclientcomboBox.DataSource = Enum.GetValues(typeof(Group_Reservation.single_statu)); i = int.Parse(AR_reservroom_comboBox.Text); } } private void ARR_reset_button_Click(object sender, EventArgs e) { ARR_DateTimearrive_dateTimePicker.Value = DateTime.Today; ARR_numberday_textBox.ResetText(); ARR_roomtype_comboBox.Text = "Pick up a type of room"; ARR_safe_checkBox.Checked = false; ARR_seaview_checkBox.Checked = false; ARR_balcony_checkBox.Checked = false; ARR_blackglass_checkBox.Checked = false; ARR_keydoor_checkBox.Checked = false; ARR_minibar_checkBox.Checked = false; } private void ARR_add_button_Click(object sender, EventArgs e) { RA_panel.Visible = true; RAF_dataGridView.DataSource = bl.room_vacancy(ARR_DateTimearrive_dateTimePicker.Value, ARR_DateTimearrive_dateTimePicker.Value.AddDays(int.Parse(ARR_numberday_textBox.Text))); } private void RAF_select_button_Click(object sender, EventArgs e) { if (int.Parse(AR_reservroom_comboBox.Text) > 1) { if (i >= 1) { if (RAF_dataGridView.SelectedRows.Count != 1) { MessageBox.Show("You must select one room", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Group_Reservation GR = group(); bl.add_reservation(GR); i--; RA_panel.Visible = false; } } else { MessageBox.Show("All room is added in the reservation"); } } else { if (RAF_dataGridView.SelectedRows.Count != 1) { MessageBox.Show("You must select one room", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Single_Reservation SR = single(); bl.add_reservation(SR); } } } private void RA_continue_button_Click(object sender, EventArgs e) { ARR_panel.Visible = true; RA_continue_button.Visible = false; RA_reset_button.Visible = false; RA_payement_comboBox.Enabled = false; ; RA_statusclientcomboBox.Enabled = false; } } }
et voici ma classe single Reservation :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BE { public abstract class Reservation { //Mode payment public enum client_payement { cash, check, visa } private client_payement client_pay; public client_payement Client_pay { get { return client_pay; } set { client_pay = value; } } //num of the reservation private int reservation_num; public int Reservation_num { get { return reservation_num; } set { reservation_num = value; } } //Num of the agency private int agency_num; public int Agency_num { get { return agency_num; } set { agency_num = value; } } //Num of bed reserved private int bed_reserv; public int Bed_reserv { get { return bed_reserv; } set { bed_reserv = value; } } //Date of the reservation private DateTime reserv_date; public DateTime reserv_Date { get { return reserv_date; } set { reserv_date = value; } } //Date of arrival private DateTime arrive_date; public DateTime arrive_Date { get { return arrive_date; } set { arrive_date = value; } } //Number of day to reserv private int numOfDay; public int NumOfDay { get { return numOfDay; } set { numOfDay = value; } } //Date of departure /*private DateTime departure_date; public DateTime departure_Date { get { return departure_date; } set { departure_date = departure_date.AddDays(NumOfDay); } } */ //Price total of the reservation private int price_total; public abstract int price_Total { get; set; } //Name of the agent /*private string agent_name; public string Agent_name { get { return agent_name; } set { agent_name = value; } } */ //Client who reserv private int client_ID; public int Client_ID { get { return client_ID; } set { client_ID = value; } } /* private int code_room; public int code_Room { get { return code_room; } } */ //Constructor public Reservation(int r_n = 0, int a_n = 0, int b_r = 0, DateTime r_d = new DateTime(), DateTime a_r = new DateTime(), int n_d = 0, int cl_id = 0, client_payement client_p = client_payement.cash) { this.reservation_num = r_n; this.agency_num = a_n; this.bed_reserv = b_r; this.reserv_date = r_d; this.arrive_date = a_r; this.numOfDay = n_d; this.client_ID = cl_id; this.client_pay = client_p; } //ToString function public override string ToString() { return "\nReservation number :" + Reservation_num + "\nAgency number :" + Agency_num + "\nClient ID : " + client_ID + "\nNumber of bed :" + Bed_reserv + "\nDate Reservation :" + reserv_date + "\nDate Arrival : " + arrive_date + "\nNumber of day : " + NumOfDay + "\nPrice : " + price_total; } } }
Mon problème est que quand j'appuie sur le bouton select de Addreservation, le debogueur se stop ( en fermant le programme ) avant le constructeur de Single Reservation et je ne comprend pas la raison.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BE { public class Single_Reservation : Reservation { //Room reserved private Room room_reserv; public Room room_Reserv { get { return room_reserv; } set { room_reserv = value; } } //Status of the client public enum single_statu { soldier, student, highprice, family}; private single_statu single_status; public single_statu Single_status { get { return single_status; } set { single_status = value; } } //Price calculus public override int price_Total { get { return price_Total; } set { double p = room_reserv.Price_r; if (Single_status == single_statu.highprice) { p *= 1.20; } if (Single_status == single_statu.soldier) { p *= 0.90; } if (Single_status == single_statu.student) { p *= 0.95; } if (Single_status == single_statu.family) { p *= 0.80; } price_Total = (int)p; } } //Construtor public Single_Reservation(int r_n = 0, int a_n = 0, int b_r = 0, DateTime r_d = new DateTime(), DateTime a_r = new DateTime(), int n_d = 0, int cl_id = 0, client_payement client_p = client_payement.cash, single_statu s_s = single_statu.student,Room r_r = null) : base(r_n, a_n, b_r, r_d, a_r, n_d, cl_id, client_p) { this.single_status = s_s; this.room_reserv = r_r; } //ToString function public override string ToString() { return "This reservation cost : " + price_Total; } } }
Mon code est-il correct ou il y a certaine chose que je dois modifier pour ameliorer son fonctionnement ?
Merci de votre aide.
Ps : Dans un forum, on n'a pas exactement compris ce que je voulais dire.
j'ai bien essayé le try catch et aussi de cocher l'exception il se trouve que le problème doit être autre car mon compilateur m'affiche un message au moment du bogue avec une croix dans un rond rouge avec un message d'erreurle débogueur ne peut pas continuer à afficher le processus. Le processus a été arrêté
Partager