예제 #1
0
 public Log_win(Main_win super)
 {
     InitializeComponent();
     this.super = super;
     FillLogTable();
     FillTransactTable();
 }
예제 #2
0
 public Profile_win(Main_win super)
 {
     this.super = super;
     InitializeComponent();
     try
     {
         NpgsqlCommand comm = new NpgsqlCommand("select sname, fname, pname, birthday, mail, login from my_own_customer(" + super.user_id + ")", super.conn);
         super.conn.Open();
         NpgsqlDataReader reader = comm.ExecuteReader();
         reader.Read();
         l_name.Content   = reader.GetString(0) + " " + reader.GetString(1) + " " + reader.GetString(2);
         l_birth.Content += reader.GetDate(3).ToString();
         l_mail.Content  += reader.GetValue(4).ToString();
         l_login.Content += reader.GetString(5);
     }
     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 { super.conn.Close(); }
 }
예제 #3
0
 private void B_ent_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string           conn_param = "Server=127.0.0.1;Port=5432;User Id=Training_login;Password=0000;Database=Training;";
         string           sql        = "select login_customer('" + tb_log.Text + "', '" + tb_pass.Password + "')";
         NpgsqlConnection conn       = new NpgsqlConnection(conn_param);
         NpgsqlCommand    comm       = new NpgsqlCommand(sql, conn);
         conn.Open();
         int result = (int)comm.ExecuteScalar();
         conn.Close();
         if (result == -1)
         {
             MessageBox.Show("Пользователя с таким логином не существует", "Ошибка авторизации", MessageBoxButton.OK, MessageBoxImage.Asterisk);
         }
         else
         {
             if (result == -2)
             {
                 MessageBox.Show("Пара логин-пароль не совпадают", "Ошибка авторизации", MessageBoxButton.OK, MessageBoxImage.Warning);
             }
             else
             {
                 Main_win main = new Main_win(this, result, tb_log.Text, tb_pass.Password);
                 main.Show();
                 Hide();
             }
         }
     }catch (Exception ex) { MessageBox.Show(ex.Message); }
 }
예제 #4
0
        public Exrc_win(Main_win super, ExerciseList exercise)
        {
            InitializeComponent();
            this.super   = super;
            tb_name.Text = exercise.name;
            Title        = "Информация об упражнении";
            this.super   = super;
            List <XTreeViewItem> groups = new List <XTreeViewItem>();
            string        sql           = "select group_id, group_name from muscle_view, \"exercise-muscle\" where \"exercise-muscle\".id_muscle = muscle_view.muscle_id and \"exercise-muscle\".id_exercise = " + exercise.id + " group by group_id, group_name";
            NpgsqlCommand comm          = new NpgsqlCommand(sql, super.conn);

            try
            {
                super.conn.Open();
                NpgsqlDataReader reader = comm.ExecuteReader();
                for (int i = 0; reader.Read(); i++)
                {
                    groups.Add(new XTreeViewItem(reader.GetInt32(0), reader.GetString(1)));
                }
                super.conn.Close();
                comm.CommandText = "Select group_id, muscle_id, muscle_name from muscle_view, \"exercise-muscle\" where \"exercise-muscle\".id_muscle = muscle_view.muscle_id and \"exercise-muscle\".id_exercise = " + exercise.id;
                super.conn.Open();
                reader = comm.ExecuteReader();
                for (int i = 0; reader.Read(); i++)
                {
                    groups.Find(gr => gr.id == reader.GetInt32(0)).Items.Add(new XTreeViewItem(reader.GetInt32(1), reader.GetString(2)));
                }
                super.conn.Close();
                foreach (var item in groups)
                {
                    tv_main.Items.Add(item);
                }
            }
            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 { super.conn.Close(); }
        }
예제 #5
0
 public Trainer_win(Main_win super, int id)
 {
     InitializeComponent();
     this.super = super;
     try
     {
         NpgsqlCommand comm = new NpgsqlCommand("select * from trainer_view_cust where id = " + id, super.conn);
         super.conn.Open();
         NpgsqlDataReader reader = comm.ExecuteReader();
         reader.Read();
         l_name.Content  = reader.GetString(1) + " " + reader.GetString(2) + " " + reader.GetString(3);
         l_age.Content  += reader.GetDouble(4).ToString();
         l_mail.Content += reader.GetValue(5).ToString();
     }
     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 { super.conn.Close(); }
 }
예제 #6
0
        public Group_win(Main_win super, GroupList group)
        {
            InitializeComponent();
            this.super = super;
            this.group = group;
            Title      = "Тренер: " + group.trainer;
            NpgsqlCommand comm = new NpgsqlCommand("select * from customer_group where id = " + group.id, super.conn);

            try
            {
                super.conn.Open();
                NpgsqlDataReader reader = comm.ExecuteReader();
                reader.Read();
                var timestamps = (TimeSpan[])reader.GetValue(5);
                week = (bool[])reader.GetValue(6);
                for (int i = 0; i < timestamps.Length; i++)
                {
                    if (week[i])
                    {
                        timetable[i] = timestamps[i].Hours.ToString() + ":" + (timestamps[i].Minutes.ToString().Length == 1 ? "0" + timestamps[i].Minutes.ToString() : timestamps[i].Minutes.ToString());
                    }
                }
                int min_age_db;
                int max_age_db;
                try { min_age_db = reader.GetInt32(3); } catch { min_age_db = 0; }
                try { max_age_db = reader.GetInt32(4); } catch { max_age_db = 0; }
                num_cost.Text       = reader.GetInt32(2).ToString();
                num_minage.Text     = min_age_db.ToString();
                num_maxage.Text     = max_age_db.ToString();
                cb_minage.IsChecked = !num_minage.Text.Equals("0");
                cb_maxage.IsChecked = !num_maxage.Text.Equals("0");

                super.conn.Close();
                comm.CommandText = "select exercise.id, exercise.name " +
                                   "from exercise, \"customer_group-exercise\" " +
                                   "where \"customer_group-exercise\".id_exercise = exercise.id and \"customer_group-exercise\".id_group = " + group.id;
                super.conn.Open();
                reader = comm.ExecuteReader();
                for (int i = 0; reader.Read(); i++)
                {
                    exerciseList.Add(new ExerciseList(reader.GetInt32(0), reader.GetString(1)));
                }
                super.conn.Close();
                UpdateList();

                cb_mon.IsChecked = week[0];
                cb_tue.IsChecked = week[1];
                cb_wed.IsChecked = week[2];
                cb_thu.IsChecked = week[3];
                cb_fri.IsChecked = week[4];
                cb_sat.IsChecked = week[5];
                cb_sun.IsChecked = week[6];

                tp_mon.Text = timetable[0];
                tp_tue.Text = timetable[1];
                tp_wed.Text = timetable[2];
                tp_thu.Text = timetable[3];
                tp_fri.Text = timetable[4];
                tp_sat.Text = timetable[5];
                tp_sun.Text = timetable[6];
            }
            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 { super.conn.Close(); }
        }