private void Mb_trainer_groups_Click(object sender, RoutedEventArgs e) { TrainerList sel_tr = dg_trainer.SelectedItem as TrainerList; View_win win = new View_win(this, typeof(TrainerList), sel_tr.id) { Title = sel_tr.sname + " " + sel_tr.fname + " " + sel_tr.pname }; win.Show(); }
private void Mb_gr_subs_Click(object sender, RoutedEventArgs e) { GroupList sel_gr = dg_group.SelectedItem as GroupList; View_win win = new View_win(this, typeof(GroupList), sel_gr.id) { Title = "Код группы: " + sel_gr.id + " (" + sel_gr.trainer + ")" }; win.Show(); }
private void Mb_cust_enter_Click(object sender, RoutedEventArgs e) { CustomList sel_cust = dg_customer.SelectedItem as CustomList; string sql = "select customer_in(" + sel_cust.id + ")"; NpgsqlCommand comm = new NpgsqlCommand(sql, conn); try { conn.Open(); bool enter = (bool)comm.ExecuteScalar(); conn.Close(); if (enter) //Клиент внутри { comm = new NpgsqlCommand("select cust_in_gr from log_view where customer_id = " + sel_cust.id + " and out_time is null", conn); conn.Open(); int cust_id = (int)comm.ExecuteScalar(); sql = "UPDATE public.log SET out_time = current_time(0) WHERE id_customer_in_group = " + cust_id + " and out_time is null; "; comm.CommandText = sql; comm.ExecuteNonQuery(); conn.Close(); UpdateCustomGrid(); } else { View_win win = new View_win(this, typeof(CustomList), sel_cust.id) { Title = sel_cust.sname + " " + sel_cust.fname + " " + sel_cust.pname }; win.Show(); } } catch (NpgsqlException ex) { MessageBox.Show(ex.Message, "Ошибка на сервере", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } finally { conn.Close(); } }