Exemplo n.º 1
0
        private void FeedBack_Load(object sender, EventArgs e)
        {
            log.Info("********************************************************** Feedback Place Start ***********************************************************");
            InfoPlace ip = this.Owner as InfoPlace;

            label_name_place.Text = ip.label_name_place.Text.ToString();
            getAuthors();
        }
Exemplo n.º 2
0
        }                                                                       // count из таблиц

        private void listView_place_MouseClick(object sender, MouseEventArgs e) // просмотр инфы о месте
        {
            foreach (Form f in Application.OpenForms)                           // не разрешаем открыть еще одну форму
            {
                if (f.Name == "InfoPlace")
                {
                    MessageBox.Show("Форма уже открыта", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            InfoPlace ip = new InfoPlace();

            ip.Owner = this;
            ip.Show();
        }
        }                              // инициализация listview (колонки)

        private void getEventInPlace() // получить список мероприятий
        {
            InfoPlace     ip       = this.Owner as InfoPlace;
            string        id_place = ip.id;
            int           count    = 0;
            SqlConnection connect  = new SqlConnection(connection);

            try
            {
                connect.Open();
                string     sql_query       = $"select * from event where id_place = {id_place}";
                string     sql_query_count = $"select count(*) from event where id_place = {id_place}";
                SqlCommand cmd             = new SqlCommand(sql_query, connect);

                SqlCommand cmd_count = new SqlCommand(sql_query_count, connect);
                count = (int)cmd_count.ExecuteScalar();

                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();

                da.Fill(dt);

                listView_evantInPlace.Clear();
                fill_ListView_event();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ListViewItem lvi = new ListViewItem(dt.Rows[i][0].ToString());
                    for (int j = 1; j < dt.Columns.Count; j++)
                    {
                        lvi.SubItems.Add(dt.Rows[i][j].ToString());
                    }
                    listView_evantInPlace.Items.Add(lvi);
                }
                da.Dispose();
                log.Info($"Доступно {count.ToString()} мероприятия, id места проведения: {id_place.ToString()}.");
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally { connect.Close(); }
        }
Exemplo n.º 4
0
        private void addFeedBack()
        {
            getAuthorsId();
            getMaxIdFeedBack();

            InfoPlace ip = this.Owner as InfoPlace;

            string proc = "pr_insertFeedback_place";

            using (SqlConnection connect = new SqlConnection(connection))
            {
                connect.Open();
                SqlCommand cmd = new SqlCommand(proc, connect);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter id = new SqlParameter
                {
                    ParameterName = @"id",
                    Value         = maxIdFeedBack = maxIdFeedBack + 1
                };
                cmd.Parameters.Add(id);
                SqlParameter id_place = new SqlParameter
                {
                    ParameterName = @"id_place",
                    Value         = ip.id.ToString()
                };
                cmd.Parameters.Add(id_place);
                SqlParameter topic = new SqlParameter
                {
                    ParameterName = @"topic",
                    Value         = textBox_topic.Text.ToString()
                };
                cmd.Parameters.Add(topic);
                SqlParameter text_feedback = new SqlParameter
                {
                    ParameterName = @"text_feedback",
                    Value         = richTextBox_text_feedback.Text.ToString()
                };
                cmd.Parameters.Add(text_feedback);
                SqlParameter id_authors = new SqlParameter
                {
                    ParameterName = @"id_authors",
                    Value         = idAuthor.ToString()
                };
                cmd.Parameters.Add(id_authors);
                SqlParameter rating_place = new SqlParameter
                {
                    ParameterName = @"rating_place",
                    Value         = comboBox_rate.Text.ToString()
                };
                cmd.Parameters.Add(rating_place);
                SqlParameter date_feedback = new SqlParameter
                {
                    ParameterName = @"date_feedback",
                    Value         = System.DateTime.Now.ToString()
                };
                cmd.Parameters.Add(date_feedback);

                cmd.ExecuteScalar();

                log.Info($"Отзыв успешно добавлен! id места: {ip.id.ToString()}, id автора: {idAuthor.ToString()}.");
                MessageBox.Show("Запись успешно добавлена", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }       // добавить отзыв