示例#1
0
        void Save()
        {
            long pollId = 0;

            AWAPI_Data.Data.awPoll poll = new AWAPI_Data.Data.awPoll();

            try
            {
                poll.title            = _title.Text;
                poll.description      = _description.Text;
                poll.answeredQuestion = _answeredQuestion.Text;
                poll.isEnabled        = _isEnabled.Checked;
                poll.isPublic         = true; //_isPublic.Checked;
                poll.isMultipleChoice = _isMultipleChoice.Checked;
                poll.pubDate          = AWAPI_Common.library.MiscLibrary.ConvertStringToDate(_publishStartDate.Text);
                //poll.pubEndDate = AWAPI_Common.library.MiscLibrary.ConvertStringToDate(_publishEndDate.Text, true);
                poll.siteId = App_Code.SessionInfo.CurrentSite.siteId;
                poll.userId = App_Code.SessionInfo.CurrentUser.userId;


                if (_id.Text.Trim() != "" &&           //if content is selected
                    !String.IsNullOrEmpty(_culture.SelectedValue) &&
                    !String.IsNullOrEmpty(App_Code.SessionInfo.CurrentSite.cultureCode) &&
                    App_Code.SessionInfo.CurrentSite.cultureCode != _culture.SelectedValue)
                {
                    _pollLibrary.UpdatePollForCulture(Convert.ToInt64(_id.Text), _culture.SelectedValue, poll.description, poll.answeredQuestion);
                }
                else
                {
                    if (_id.Text.Trim().Length == 0)
                    {
                        pollId = _pollLibrary.AddPoll(poll.siteId, poll.userId,
                                                      poll.title, poll.description, poll.answeredQuestion, poll.isEnabled, poll.isPublic,
                                                      poll.isMultipleChoice, poll.pubDate, poll.pubEndDate);

                        _id.Text = pollId.ToString();
                    }
                    else
                    {
                        pollId = Convert.ToInt64(_id.Text);
                        _pollLibrary.UpdatePoll(pollId, poll.title, poll.description, poll.answeredQuestion,
                                                poll.isEnabled, poll.isPublic, poll.isMultipleChoice,
                                                poll.pubDate, poll.pubEndDate);
                    }
                }

                ShowHideControls(true);

                PopulateList();

                AdminMaster.WriteMessage(AWAPI.Admin.AdminMaster.MessageType.INFO, "Poll has been saved.");
            }
            catch (Exception ex)
            {
                AdminMaster.WriteMessage(AWAPI.Admin.AdminMaster.MessageType.ERROR, ex.Message);
            }
        }
 private void detach_awPolls(awPoll entity)
 {
     this.SendPropertyChanging();
     entity.awSite_Poll = null;
 }
 private void attach_awPolls(awPoll entity)
 {
     this.SendPropertyChanging();
     entity.awSite_Poll = this;
 }
 partial void DeleteawPoll(awPoll instance);
 partial void UpdateawPoll(awPoll instance);
 partial void InsertawPoll(awPoll instance);