コード例 #1
0
        private void backExixtingEventButton_Click(object sender, EventArgs e)
        {
            PictureEvents pictureEvents = new PictureEvents(this);

            this.Hide();
            pictureEvents.Show();
        }
コード例 #2
0
        private void modifyButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (highRadioButton.Checked)
                {
                    importanceLabel.Text = "High";
                }
                else if (moderateRadioButton.Checked)
                {
                    importanceLabel.Text = "Moderate";
                }
                else if (lessImportantRadioButton.Checked)
                {
                    importanceLabel.Text = "Less Important";
                }
                SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString);
                string        sql        = "UPDATE Pictures SET PictureStory='" + pictureStoryTextBox.Text + "', Importance='" + importanceLabel.Text + "',ModifiedDate='" + modifyDateTimePicker.Value +
                                           "',PictureLocation='" + selectPictureLabel.Text + "'Where PictureId='" + Convert.ToInt32(pictureId) + "'";

                SqlCommand command = new SqlCommand(sql, connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    addPhotosPictureBox.ImageLocation = reader["PictureLocation"].ToString();
                    eventNameLabel.Text      = reader["EventName"].ToString();
                    selectPictureLabel.Text  = reader["PictureLocation"].ToString();
                    pictureStoryTextBox.Text = reader["PictureStory"].ToString();
                    importance = reader["Importance"].ToString();
                    if (importance == "High")
                    {
                        highRadioButton.Checked = true;
                    }
                    else if (importance == "Moderate")
                    {
                        moderateRadioButton.Checked = true;
                    }
                    else if (importance == "Less Important")
                    {
                        lessImportantRadioButton.Checked = true;
                    }
                }
                MessageBox.Show("Your picture is modified");
                PictureEvents pictureEvents = new PictureEvents(this);
                this.Hide();
                pictureEvents.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Database can not be accessed");
            }
        }
コード例 #3
0
 private void existingEventButton_Click(object sender, EventArgs e)
 {
     eventName = existingEventComboBox.Text;
     if (existingEventComboBox.Text == "")
     {
         MessageBox.Show("Event name is empty");
     }
     else
     {
         eventName = existingEventComboBox.Text;
         PictureEvents pictureEvents = new PictureEvents(this);
         this.Hide();
         pictureEvents.Show();
     }
 }
コード例 #4
0
        private void uploadButton_Click(object sender, EventArgs e)
        {
            if (highRadioButton.Checked || lessImportantRadioButton.Checked || moderateRadioButton.Checked)
            {
                if (highRadioButton.Checked)
                {
                    importanceLabel.Text = "High";
                }
                else if (lessImportantRadioButton.Checked)
                {
                    importanceLabel.Text = "Less Important";
                }
                else
                {
                    importanceLabel.Text = "Moderate";
                }


                SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString);
                connection.Open();
                string sql = "INSERT INTO Pictures(EventName, Username, PictureLocation, CreatedDate,  PictureStory, Importance) " +
                             "VALUES('" + eventName + "','" + username + "','" + selectPictureLabel.Text + "','" + aPdateTimePicker.Value + "','" + pictureStoryTextBox.Text + "','" + importanceLabel.Text + "')";
                //MessageBox.Show("SQL: " + sql);
                SqlCommand command = new SqlCommand(sql, connection);
                int        result  = command.ExecuteNonQuery();
                if (result > 0)
                {
                    MessageBox.Show("Picture added to Event: " + eventName);
                    PictureEvents pictureEvents = new PictureEvents(this);
                    this.Hide();
                    pictureEvents.Show();
                }
                else
                {
                    MessageBox.Show("Error");
                }
                connection.Close();
            }
            else
            {
                MessageBox.Show("Select Importance Level");
            }
        }