Beispiel #1
0
        private void BtnPost_Click(object sender, EventArgs e)
        {
            if (TbLocation.Text.Length < 3)
            {
                MessageBox.Show("Location must be specified.", "Invalid ad",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (RtbContent.Text.Length == 0)
            {
                MessageBox.Show("Ad must have text.", "Invalid ad",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (TbTitle.Text.Length == 0)
            {
                MessageBox.Show("Ad must have a title.", "Invalid ad",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            AdType type = AdType.Other;

            Enum.TryParse <AdType>(CbCategory.SelectedValue.ToString(), out type);

            AdController.PostAd(TbTitle.Text, RtbContent.Text, TbLocation.Text, type);
            this.Close();
        }