|
@@ -30,6 +30,9 @@ namespace HotelCalifornia
|
|
timer.Tick += new EventHandler(Update_Timer_Tick);
|
|
timer.Tick += new EventHandler(Update_Timer_Tick);
|
|
timer.Interval = new TimeSpan(0, 0, 1);
|
|
timer.Interval = new TimeSpan(0, 0, 1);
|
|
timer.Start();
|
|
timer.Start();
|
|
|
|
+ //Начало даты
|
|
|
|
+ datein.DisplayDateStart = DateTime.Now;
|
|
|
|
+ dateout.DisplayDateStart = DateTime.Now;
|
|
}
|
|
}
|
|
|
|
|
|
//Строка подключения
|
|
//Строка подключения
|
|
@@ -80,6 +83,8 @@ namespace HotelCalifornia
|
|
numbroomtxt.Text = rowView["Number_Room"].ToString();
|
|
numbroomtxt.Text = rowView["Number_Room"].ToString();
|
|
datein.Text = rowView["Date_in"].ToString();
|
|
datein.Text = rowView["Date_in"].ToString();
|
|
dateout.Text = rowView["Date_out"].ToString();
|
|
dateout.Text = rowView["Date_out"].ToString();
|
|
|
|
+ clientcombo.Text = rowView["LastName_Client"].ToString();
|
|
|
|
+ roomcombo.Text = rowView["Number_Room"].ToString();
|
|
roomcombo.IsEnabled = false;
|
|
roomcombo.IsEnabled = false;
|
|
clientcombo.IsEnabled = false;
|
|
clientcombo.IsEnabled = false;
|
|
}
|
|
}
|
|
@@ -187,6 +192,10 @@ namespace HotelCalifornia
|
|
{
|
|
{
|
|
MessageBox.Show("Заполните все поля!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
MessageBox.Show("Заполните все поля!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
}
|
|
}
|
|
|
|
+ else if (datein.SelectedDate >= dateout.SelectedDate)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show("Дата указана неверно!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
|
+ }
|
|
else
|
|
else
|
|
{
|
|
{
|
|
try
|
|
try
|
|
@@ -201,7 +210,7 @@ namespace HotelCalifornia
|
|
if (dataSet.Tables[0].Rows.Count > 0)
|
|
if (dataSet.Tables[0].Rows.Count > 0)
|
|
{
|
|
{
|
|
string stridclient = dataSet.Tables[0].Rows[0]["ID_Client"].ToString();
|
|
string stridclient = dataSet.Tables[0].Rows[0]["ID_Client"].ToString();
|
|
- SqlCommand cmd2 = new SqlCommand("Select * from Rezervirovanie where ID_Client = '" + stridclient.ToString() + "'", con);
|
|
|
|
|
|
+ SqlCommand cmd2 = new SqlCommand("Select * from Rezervirovanie where ID_Client = '" + stridclient.ToString() + "'; Select * from RoomClient where ID_Client = '" + stridclient.ToString() + "'", con);
|
|
cmd2.CommandType = CommandType.Text;
|
|
cmd2.CommandType = CommandType.Text;
|
|
SqlDataAdapter adapter2 = new SqlDataAdapter();
|
|
SqlDataAdapter adapter2 = new SqlDataAdapter();
|
|
adapter2.SelectCommand = cmd2;
|
|
adapter2.SelectCommand = cmd2;
|
|
@@ -210,7 +219,12 @@ namespace HotelCalifornia
|
|
if (dataSet2.Tables[0].Rows.Count > 0)
|
|
if (dataSet2.Tables[0].Rows.Count > 0)
|
|
{
|
|
{
|
|
con.Close();
|
|
con.Close();
|
|
- MessageBox.Show("Клиент уже забронировал комнату", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
|
|
|
+ MessageBox.Show("Клиент уже забронировал комнату!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
|
+ }
|
|
|
|
+ else if (dataSet2.Tables[1].Rows.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ con.Close();
|
|
|
|
+ MessageBox.Show("Клиент уже заселён!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -228,18 +242,19 @@ namespace HotelCalifornia
|
|
SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
|
|
SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
|
|
dataAdapter.SelectCommand.ExecuteNonQuery();
|
|
dataAdapter.SelectCommand.ExecuteNonQuery();
|
|
con.Close();
|
|
con.Close();
|
|
- fillcomboroom();
|
|
|
|
- fill1comboroom();
|
|
|
|
- roomcombo.Text = "";
|
|
|
|
- clientcombo.Text = "";
|
|
|
|
- datein.SelectedDate = null;
|
|
|
|
- dateout.SelectedDate = null;
|
|
|
|
- showgrid();
|
|
|
|
MessageBox.Show("Бронирование успешно создано!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
MessageBox.Show("Бронирование успешно создано!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ fillcomboroom();
|
|
|
|
+ fill1comboroom();
|
|
|
|
+ roomcombo.Text = "";
|
|
|
|
+ clientcombo.Text = "";
|
|
|
|
+ datein.SelectedDate = null;
|
|
|
|
+ dateout.SelectedDate = null;
|
|
|
|
+ showgrid();
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
con.Close();
|
|
con.Close();
|
|
@@ -259,6 +274,10 @@ namespace HotelCalifornia
|
|
{
|
|
{
|
|
MessageBox.Show("Заполните все поля!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
MessageBox.Show("Заполните все поля!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
}
|
|
}
|
|
|
|
+ else if (datein.SelectedDate >= dateout.SelectedDate)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show("Дата указана неверно!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
|
+ }
|
|
else
|
|
else
|
|
{
|
|
{
|
|
try
|
|
try
|
|
@@ -308,7 +327,7 @@ namespace HotelCalifornia
|
|
try
|
|
try
|
|
{
|
|
{
|
|
con.Open();
|
|
con.Open();
|
|
- SqlCommand cmd1 = new SqlCommand("Select ID_Room from Room where Number_Room = '" + numbroomtxt.Text + "'", con);
|
|
|
|
|
|
+ SqlCommand cmd1 = new SqlCommand("Select ID_Room from Room where Number_Room = '" + numbroomtxt.Text + "'; Select ID_Client From Client where LastName_Client = '" + clientcombo.Text + "'", con);
|
|
cmd1.CommandType = CommandType.Text;
|
|
cmd1.CommandType = CommandType.Text;
|
|
SqlDataAdapter adapter1 = new SqlDataAdapter();
|
|
SqlDataAdapter adapter1 = new SqlDataAdapter();
|
|
adapter1.SelectCommand = cmd1;
|
|
adapter1.SelectCommand = cmd1;
|
|
@@ -317,7 +336,8 @@ namespace HotelCalifornia
|
|
if (dataSet1.Tables[0].Rows.Count > 0)
|
|
if (dataSet1.Tables[0].Rows.Count > 0)
|
|
{
|
|
{
|
|
string stridroom = dataSet1.Tables[0].Rows[0]["ID_Room"].ToString();
|
|
string stridroom = dataSet1.Tables[0].Rows[0]["ID_Room"].ToString();
|
|
- string sql = "DELETE FROM Rezervirovanie WHERE ID_Room = '" + stridroom.ToString() + "'; Update Room set Status_Room ='" + 1 + "' Where ID_Room = '" + stridroom.ToString() + "' ";
|
|
|
|
|
|
+ string stridclient = dataSet1.Tables[1].Rows[0]["ID_Client"].ToString();
|
|
|
|
+ string sql = "DELETE FROM Rezervirovanie WHERE ID_Room = '" + stridroom.ToString() + "'; Update Room set Status_Room ='" + 1 + "' Where ID_Room = '" + stridroom.ToString() + "'; DELETE FROM RoomClient WHERE ID_Client = '" + stridclient.ToString() + "';";
|
|
SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
|
|
SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
|
|
dataAdapter.SelectCommand.ExecuteNonQuery();
|
|
dataAdapter.SelectCommand.ExecuteNonQuery();
|
|
con.Close();
|
|
con.Close();
|