123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- using System.Windows.Threading;
- using System.Data;
- using System.Data.SqlClient;
- namespace HotelCalifornia
- {
- /// <summary>
- /// Логика взаимодействия для ClientRoom.xaml
- /// </summary>
- public partial class ClientRoom : Window
- {
- public ClientRoom()
- {
- InitializeComponent();
- DispatcherTimer timer = new DispatcherTimer();
- timer.Tick += new EventHandler(Update_Timer_Tick);
- timer.Interval = new TimeSpan(0, 0, 1);
- timer.Start();
- }
- SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=kursah;Integrated Security=True");
- private void Update_Timer_Tick(object sender, EventArgs e)
- {
- timetxt.Text = DateTime.Now.ToString();
- }
- private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
- {
- DragMove();
- }
- private void Close(object sender, RoutedEventArgs e)
- {
- Application.Current.Shutdown();
- }
- private void WindMin_Click(object sender, RoutedEventArgs e)
- {
- this.WindowState = WindowState.Minimized;
- }
- private void Back(object sender, RoutedEventArgs e)
- {
- MessageBoxResult result = MessageBox.Show("Вы хотите вернуться к предыдущему окну?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
- switch (result)
- {
- case MessageBoxResult.Yes:
- Variant variant = new Variant();
- this.Close();
- variant.Show();
- break;
- case MessageBoxResult.No:
- break;
- }
- }
- private void dataClientRoom_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- }
- private void Add_Click(object sender, RoutedEventArgs e)
- {
- }
- private void Update_Click(object sender, RoutedEventArgs e)
- {
- }
- private void Delete_Click(object sender, RoutedEventArgs e)
- {
- }
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- fillroomcombo();
- }
- void fillroomcombo()
- {
- try
- {
- roomcombo.Items.Clear();
- con.Open();
- SqlCommand sql = con.CreateCommand();
- sql.CommandType = CommandType.Text;
- sql.CommandText = "Select Number_Room from Room";
- sql.ExecuteNonQuery();
- DataTable dt = new DataTable();
- SqlDataAdapter da = new SqlDataAdapter(sql);
- da.Fill(dt);
- foreach (DataRow dr in dt.Rows)
- {
- roomcombo.Items.Add(dr["Number_Room"].ToString());
- }
- con.Close();
- }
- catch (Exception ex)
- {
- con.Close();
- MessageBox.Show("Возникла ошибка! " + ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
- }
- }
|