예제 #1
0
        public override int?Save(string action)
        {
            var data = new ScheduleQuestionDataModel();

            data.ScheduleQuestionId = ScheduleQuestionId;
            data.ScheduleId         = ScheduleId;
            data.QuestionId         = QuestionId;
            data.Answer             = Answer;

            if (action == "Insert")
            {
                var dtScheduleQuestion = ScheduleQuestionDataManager.DoesExist(data, SessionVariables.RequestProfile);

                if (dtScheduleQuestion.Rows.Count == 0)
                {
                    ScheduleQuestionDataManager.Create(data, SessionVariables.RequestProfile);
                }
                else
                {
                    throw new Exception("Record with given ID already exists.");
                }
            }
            else
            {
                ScheduleQuestionDataManager.Update(data, SessionVariables.RequestProfile);
            }

            // not correct ... when doing insert, we didn't get/change the value of ScheduleID ?
            return(ScheduleQuestionId);
        }
예제 #2
0
        protected override void Update(Dictionary <string, string> values)
        {
            var data = new ScheduleQuestionDataModel();

            if (values.ContainsKey(ScheduleQuestionDataModel.DataColumns.ScheduleQuestionId))
            {
                data.ScheduleQuestionId = int.Parse(values[ScheduleQuestionDataModel.DataColumns.ScheduleQuestionId].ToString());
            }

            if (values.ContainsKey(ScheduleQuestionDataModel.DataColumns.ScheduleId))
            {
                data.ScheduleId = int.Parse(values[ScheduleQuestionDataModel.DataColumns.ScheduleId].ToString());
            }

            if (values.ContainsKey(ScheduleQuestionDataModel.DataColumns.QuestionId))
            {
                data.QuestionId = int.Parse(values[ScheduleQuestionDataModel.DataColumns.QuestionId].ToString());
            }

            if (values.ContainsKey(ScheduleQuestionDataModel.DataColumns.Answer))
            {
                data.Answer = values[ScheduleQuestionDataModel.DataColumns.Answer].ToString();
            }

            ScheduleQuestionDataManager.Update(data, SessionVariables.RequestProfile);

            base.Update(values);
        }
예제 #3
0
        protected void lbtnSubmit_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow row in gvScheduleQuestions.Rows)
            {
                var lblScheduleQuestionId = (Label)row.FindControl("lblScheduleQuestionId");
                var lblQuestionId         = (Label)row.FindControl("lblQuestionId");
                var drpAnswer             = (DropDownList)row.FindControl("drpAnswer");

                var data = new ScheduleQuestionDataModel();

                data.ScheduleId = (int)ViewState["SetId"];
                data.QuestionId = Convert.ToInt32(lblQuestionId.Text);
                data.Answer     = drpAnswer.SelectedValue;

                data.ScheduleQuestionId = Convert.ToInt32(lblScheduleQuestionId.Text);

                ScheduleQuestionDataManager.Update(data, SessionVariables.RequestProfile);
            }

            GetData((int)ViewState["SetId"]);
        }
예제 #4
0
        protected override DataTable UpdateData()
        {
            var UpdatedData = new DataTable();
            var data        = new ScheduleQuestionDataModel();

            UpdatedData = ScheduleQuestionDataManager.Search(data, SessionVariables.RequestProfile).Clone();
            for (var i = 0; i < SelectedData.Rows.Count; i++)
            {
                data.ScheduleQuestionId =
                    Convert.ToInt32(SelectedData.Rows[i][ScheduleQuestionDataModel.DataColumns.ScheduleQuestionId].ToString());
                data.ScheduleId = !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(ScheduleQuestionDataModel.DataColumns.ScheduleId))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(ScheduleQuestionDataModel.DataColumns.ScheduleId).ToString())
                                        : int.Parse(SelectedData.Rows[i][ScheduleQuestionDataModel.DataColumns.ScheduleId].ToString());

                data.QuestionId =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(ScheduleQuestionDataModel.DataColumns.QuestionId))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(ScheduleQuestionDataModel.DataColumns.QuestionId).ToString())
                                        : int.Parse(SelectedData.Rows[i][ScheduleQuestionDataModel.DataColumns.QuestionId].ToString());

                data.Answer =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(ScheduleQuestionDataModel.DataColumns.Answer))
                                        ?CheckAndGetRepeaterTextBoxValue(ScheduleQuestionDataModel.DataColumns.Answer).ToString()
                                        : SelectedData.Rows[i][ScheduleQuestionDataModel.DataColumns.Answer].ToString();

                ScheduleQuestionDataManager.Update(data, SessionVariables.RequestProfile);
                data = new ScheduleQuestionDataModel();
                data.ScheduleQuestionId = Convert.ToInt32(SelectedData.Rows[i][ScheduleQuestionDataModel.DataColumns.ScheduleQuestionId].ToString());
                var dt = ScheduleQuestionDataManager.Search(data, SessionVariables.RequestProfile);

                if (dt.Rows.Count == 1)
                {
                    UpdatedData.ImportRow(dt.Rows[0]);
                }
            }
            return(UpdatedData);
        }