Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.txtQuestionEN.Text == String.Empty)
            {
                MessageBox.Show("Please input question in English.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            if (this.cboGenre.SelectedIndex < 0)
            {
                MessageBox.Show("Please select genre.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            if (this.cboLevel.SelectedIndex < 0)
            {
                MessageBox.Show("Please select level.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            string     strMessage  = String.Empty;
            T_QUESTION objQuestion = new T_QUESTION();

            objQuestion.QuestionID = Guid.NewGuid().ToString().Replace("-", String.Empty);
            objQuestion.QuestionEN = this.txtQuestionEN.Text;
            objQuestion.QuestionCN = this.txtQuestionCN.Text;
            objQuestion.AnswerEN   = this.txtAnswerEN.Text;
            objQuestion.AnswerCN   = this.txtAnswerCN.Text;
            objQuestion.GenreID    = ((T_GENRE)this.cboGenre.SelectedItem).GENREID;
            objQuestion.Level      = ((LevelDatum)this.cboLevel.SelectedItem).LevelValue;
            objQuestion.Valid      = ValidFlags.VALID;
            QuestionDataFacade objQuestionDataFacade = new QuestionDataFacade();

            if (objQuestionDataFacade.NewAQuestion(objQuestion, ref strMessage))
            {
                this.txtQuestionEN.Text = String.Empty;
                this.txtQuestionCN.Text = String.Empty;
                this.txtAnswerEN.Text   = String.Empty;
                this.txtAnswerCN.Text   = String.Empty;
                this.txtQuestionEN.Focus();
            }
            else
            {
                MessageBox.Show(strMessage, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        public bool NewAQuestion(T_QUESTION argQuestion, ref string argMessage)
        {
            bool blnResult = false;

            using (YangsTransactionManager objMgr = YangsTransactionManager.Create(YangsTransactionMode.RequiresNew,
                                                                                   IsolationLevel.ReadCommitted, p_connectionName, true))
            {
                try
                {
                    SQLiteEntityAccess <T_QUESTION> objQuestionAccess = new SQLiteEntityAccess <T_QUESTION>();
                    objQuestionAccess.Create(argQuestion);
                    blnResult = true;
                }
                catch (Exception ex)
                {
                    YangsTransactionManager.SetAbort();
                    argMessage = ex.Message;
                }
            }

            return(blnResult);
        }