protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!HasWriteAccess)
                return;

            string name = txtName.Text.Trim();
            string subject = txtSubject.Text.Trim();
            string body = htmlEditor != null ? htmlEditor.Content : ckeditor.Text;
            User.eGender? gender = null;
            bool? paidMember = null;
            bool? hasPhotos = null;
            bool? hasProfile = null;
            int? languageID = null;
            string country = null;
            string region = null;
            ScheduledAnnouncement.eType type;
            DateTime? date = null;
            int? days = null;

            if (ddType.SelectedIndex == 0)
            {
                Messagebox1.Show(Lang.TransA("Please select a type!"), Misc.MessageType.Error);
                return;
            }

            if (name.Length == 0)
            {
                Messagebox1.Show(Lang.TransA("Please enter name!"), Misc.MessageType.Error);
                return;
            }

            if (subject.Length == 0)
            {
                Messagebox1.Show(Lang.TransA("Please enter subject!"), Misc.MessageType.Error);
                return;
            }

            if (body.Length == 0)
            {
                Messagebox1.Show(Lang.TransA("Please enter body!"), Misc.MessageType.Error);
                return;
            }

            if (pnlDate.Visible && !datePicker1.ValidDateEntered)
            {
                Messagebox1.Show(Lang.TransA("Please select valid date!"), Misc.MessageType.Error);
                return;
            }

            if (pnlInactivity.Visible)
            {
                int inactivityDays;
                if (!Int32.TryParse(txtInactivity.Text.Trim(), out inactivityDays))
                {
                    Messagebox1.Show(Lang.TransA("Please enter a number!"), Misc.MessageType.Error);
                    return;
                }

                days = inactivityDays;
            }

            if (pnlAfterRegistration.Visible)
            {
                int daysAfterRegistration;
                if (!Int32.TryParse(txtAfterRegistration.Text.Trim(), out daysAfterRegistration))
                {
                    Messagebox1.Show(Lang.TransA("Please enter a number!"), Misc.MessageType.Error);
                    return;
                }

                days = daysAfterRegistration;
            }
            if (pnlBeforeSubscriptionEnd.Visible)
            {
                int daysBeforeEnd;
                if (!Int32.TryParse(txtBeforeSubscriptionEnd.Text.Trim(), out daysBeforeEnd))
                {
                    Messagebox1.Show(Lang.TransA("Please enter a number!"), Misc.MessageType.Error);
                    return;
                }

                days = daysBeforeEnd;
            }
            
            if (ddGender.SelectedIndex > 0)
                gender = (User.eGender?) Convert.ToInt32(ddGender.SelectedValue);
            if (ddPaid.SelectedIndex > 0)
                paidMember = ddPaid.SelectedIndex == 1;
            if (ddHasPhotos.SelectedIndex > 0)
                hasPhotos = ddHasPhotos.SelectedIndex == 1;
            if (ddHasProfile.SelectedIndex > 0)
                hasProfile = ddHasProfile.SelectedIndex == 1;
            if (ddLanguage.SelectedIndex > 0)
                languageID = Convert.ToInt32(ddLanguage.SelectedValue);
            if (ddCountry.SelectedValue.Trim().Length > 0)
                country = ddCountry.SelectedValue.Trim();
            if (ddRegion.SelectedValue.Trim().Length > 0)
                region = ddRegion.SelectedValue.Trim();
            type = (ScheduledAnnouncement.eType) Convert.ToInt32(ddType.SelectedValue);
            if (pnlDate.Visible)
                date = datePicker1.SelectedDate;

            ScheduledAnnouncement announcement = null;

            if (!CurrentAnnouncementID.HasValue) // add new
                announcement = new ScheduledAnnouncement();
            else
                announcement = ScheduledAnnouncement.Fetch(CurrentAnnouncementID.Value);
            announcement.Name = name;
            announcement.Subject = subject;
            announcement.Body = body;
            announcement.Gender = gender;
            announcement.PaidMember = paidMember;
            announcement.HasPhotos = hasPhotos;
            announcement.HasProfile = hasProfile;
            announcement.LanguageId = languageID;
            announcement.Country = country;
            announcement.Region = region;
            announcement.Type = type;
            announcement.Date = date;
            announcement.Days = days;

            announcement.Save();

            Messagebox1.Show(Lang.TransA("Announcements has been updated successfully!"), Misc.MessageType.Success);

            pnlAnnouncement.Visible = false;
            pnlAnnouncements.Visible = true;
            LoadAnnouncements();
        }
        private static ScheduledAnnouncement[] Fetch(int? id, User.eGender? gender, bool? paidMember, bool? hasPhotos,
                                                        bool? hasProfile, int? languageID, string country, string region,
                                                        eType? type)
        {
            using (SqlConnection conn = Config.DB.Open())
            {
                SqlDataReader reader = SqlHelper.ExecuteReader(conn, "FetchScheduledAnnouncement",
                                                                        id, gender, paidMember, hasPhotos,
                                                                        hasProfile, languageID, country, region, type);

                List<ScheduledAnnouncement> lScheduledAnnouncements = new List<ScheduledAnnouncement>();

                while (reader.Read())
                {
                    ScheduledAnnouncement scheduledAnnouncement = new ScheduledAnnouncement();

                    scheduledAnnouncement.id = (int)reader["ID"];
                    scheduledAnnouncement.name = (string) reader["Name"];
                    scheduledAnnouncement.subject = (string)reader["Subject"];
                    scheduledAnnouncement.body = (string)reader["Body"];
                    scheduledAnnouncement.gender = reader["Gender"] != DBNull.Value
                                                       ? (User.eGender?) ((int) reader["Gender"])
                                                       : null;
                    scheduledAnnouncement.paidMember = reader["PaidMember"] != DBNull.Value
                                                           ? (bool?) reader["PaidMember"]
                                                           : null;
                    scheduledAnnouncement.hasPhotos = reader["HasPhotos"] != DBNull.Value
                                                           ? (bool?)reader["HasPhotos"]
                                                           : null;
                    scheduledAnnouncement.hasProfile = reader["HasProfile"] != DBNull.Value
                                                           ? (bool?)reader["HasProfile"]
                                                           : null;
                    scheduledAnnouncement.languageID = reader["LanguageID"] != DBNull.Value
                                                           ? (int?)reader["LanguageID"]
                                                           : null;
                    scheduledAnnouncement.country = reader["Country"] != DBNull.Value
                                                           ? (string)reader["Country"]
                                                           : null;
                    scheduledAnnouncement.region = reader["Region"] != DBNull.Value
                                                           ? (string)reader["Region"]
                                                           : null;
                    scheduledAnnouncement.type = (eType) reader["Type"];
                    scheduledAnnouncement.date = reader["Date"] != DBNull.Value
                                                           ? (DateTime?)reader["Date"]
                                                           : null;
                    scheduledAnnouncement.days = reader["Days"] != DBNull.Value
                                                           ? (int?)reader["Days"]
                                                           : null;

                    lScheduledAnnouncements.Add(scheduledAnnouncement);
                }

                return lScheduledAnnouncements.ToArray();
            }
        }