Exemplo n.º 1
0
        private bool SaveItem()
        {
            bool success = false;

            lblErrorMessage.Text = "Saving Item <br>";
            try {
                lblErrorMessage.Text += string.Format("ItemID Before: {0} <br>", ItemID);
                bool       isUpdate = (IView == ItemView.Edit);
                TrngAnswer item     = (isUpdate) ? new SPA.TrngAnswer(ItemID) : new SPA.TrngAnswer();
                item.Answer     = txtAnswer.Text.Trim();
                item.IsCorrect  = ckbxIsCorrect.Checked;
                item.CourseID   = CourseID;
                item.SlideID    = SlideID;
                item.QuestionID = QuestionID;
                item.ModifiedBy = CurrentUser.DisplayName;

                if (!isUpdate)
                {
                    item.CreatedBy = item.ModifiedBy;
                    if (item.Insert())
                    {
                        success = true;
                        lblErrorMessage.Text += "Insert Successful <br>";
                    }
                    else
                    {
                        lblErrorMessage.Text += "Insert Unsuccessful <br>";
                    }
                }
                else
                {
                    if (item.Update())
                    {
                        success = true;
                    }
                }
                ItemID = (success) ? item.ID : 0;
                lblErrorMessage.Text += string.Format("ItemID After: {0} <br>", ItemID);
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
            return(success);
        }
Exemplo n.º 2
0
        private bool SaveItem()
        {
            bool success = false;

            try {
                bool isUpdate = (IView == ItemView.Edit);
                item           = (isUpdate) ? new SPA.TrngAnswer(ItemID) : new SPA.TrngAnswer();
                item.Answer    = txtAnswer.Text.Trim();
                item.IsCorrect = ckbxIsCorrect.Checked;

                if (!isUpdate)
                {
                    item.CreatedBy = item.ModifiedBy;
                    if (item.Insert())
                    {
                        Action.Write(string.Format("Added Answer ID: {0}, Answer: {1}", item.ID, item.Answer), CurrentUser.DisplayName);
                        success = true;
                    }
                }
                else
                {
                    if (item.Update())
                    {
                        Action.Write(string.Format("Updated Answer ID: {0}, Answer: {1}", item.ID, item.Answer), CurrentUser.DisplayName);
                        success = true;
                    }
                }
                ItemID = (success) ? item.ID : 0;
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
            return(success);
        }