Beispiel #1
0
        protected override void ShowData(int ScheduleQuestionId)
        {
            base.ShowData(ScheduleQuestionId);

            oDetailButtonPanel.SetId = SetId;

            Clear();

            var dataQuery = new ScheduleQuestionDataModel();

            dataQuery.ScheduleQuestionId = ScheduleQuestionId;

            var entityList = ScheduleQuestionDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile);

            if (entityList.Count == 1)
            {
                foreach (var entityItem in entityList)
                {
                    lblScheduleQuestionId.Text = entityItem.ScheduleQuestionId.ToString();
                    lblScheduleId.Text         = entityItem.ScheduleId.ToString();
                    lblQuestionId.Text         = entityItem.QuestionId.ToString();
                    lblAnswer.Text             = entityItem.Answer.ToString();

                    oUpdateInfo.LoadText(entityItem.UpdatedDate, entityItem.UpdatedBy, entityItem.LastAction);

                    oHistoryList.Setup(PrimaryEntity, ScheduleQuestionId, "ScheduleQuestion");
                }
            }
        }
Beispiel #2
0
        public static void AddScheduleQuestions(int scheduleId, RequestProfile requestProfile)
        {
            // get all questions
            var questionData = QuestionDataManager.GetList(requestProfile);

            // filter question records using Question Category 'EOD Questions'
            questionData.DefaultView.RowFilter = "QuestionCategory = 'EOD Questions'";
            questionData = questionData.DefaultView.ToTable();

            var scheduleQuestionData = new ScheduleQuestionDataModel();

            // for loop for entering default answers for all questions
            for (var i = 0; i < questionData.Rows.Count; i++)
            {
                var questionid = int.Parse(questionData.Rows[i][QuestionDataModel.DataColumns.QuestionId].ToString());

                scheduleQuestionData = new ScheduleQuestionDataModel();

                scheduleQuestionData.ScheduleId = scheduleId;
                scheduleQuestionData.QuestionId = int.Parse(questionid.ToString());
                scheduleQuestionData.Answer     = "No";

                ScheduleQuestionDataManager.Create(scheduleQuestionData, requestProfile);
            }
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
0
        private void GetData(int scheduleId)
        {
            var dtScheduleQuestions = ScheduleQuestionDataManager.GetBySchedule(scheduleId, SessionVariables.RequestProfile);

            gvScheduleQuestions.DataSource = dtScheduleQuestions;
            gvScheduleQuestions.DataBind();
        }
Beispiel #6
0
        public static void SyncQuestions(int scheduleId, RequestProfile requestProfile)
        {
            // Get all ScheduleId related records from ScheduleQuestion
            var dtScheduleQuestion = ScheduleQuestionDataManager.GetBySchedule(scheduleId, requestProfile);

            // Get all Question Records
            var questionData = QuestionDataManager.GetList(requestProfile);

            // filter question records using Question Category 'EOD Questions'
            questionData.DefaultView.RowFilter = "QuestionCategory = 'EOD Questions'";
            questionData = questionData.DefaultView.ToTable();

            var scheduleQuestionData = new ScheduleQuestionDataModel();

            // for loop for entering default answers for all questions
            for (var i = 0; i < questionData.Rows.Count; i++)
            {
                var questionid = int.Parse(questionData.Rows[i][QuestionDataModel.DataColumns.QuestionId].ToString());

                var filterExpression = QuestionDataModel.DataColumns.QuestionId + " = " + questionid;

                // find if record for this question id exists in ScheduleQuestion for the particular ScheduleId
                var rows = dtScheduleQuestion.Select(filterExpression);

                // insert if no record found
                if (rows.Length == 0)
                {
                    scheduleQuestionData = new ScheduleQuestionDataModel();

                    scheduleQuestionData.ScheduleId = scheduleId;
                    scheduleQuestionData.QuestionId = int.Parse(questionid.ToString());
                    scheduleQuestionData.Answer     = "No";

                    ScheduleQuestionDataManager.Create(scheduleQuestionData, requestProfile);
                }
            }
            // refresh data table with newly added records
            dtScheduleQuestion = ScheduleQuestionDataManager.GetBySchedule(scheduleId, requestProfile);

            // for removing invalid category schedule questions
            for (var i = 0; i < dtScheduleQuestion.Rows.Count; i++)
            {
                var questionid = int.Parse(dtScheduleQuestion.Rows[i][ScheduleQuestionDataModel.DataColumns.QuestionId].ToString());

                var filterExpression = ScheduleQuestionDataModel.DataColumns.QuestionId + " = " + questionid;

                // find if record for this question id exists in ScheduleQuestion for the particular ScheduleId
                var rows = questionData.Select(filterExpression);

                // insert if no record found, so it is invalid
                if (rows.Length == 0)
                {
                    scheduleQuestionData = new ScheduleQuestionDataModel();
                    scheduleQuestionData.ScheduleQuestionId = int.Parse(dtScheduleQuestion.Rows[i][ScheduleQuestionDataModel.DataColumns.ScheduleQuestionId].ToString());
                    ScheduleQuestionDataManager.Delete(scheduleQuestionData, requestProfile);
                }
            }
        }
Beispiel #7
0
        protected override DataTable GetEntityData(int?entityKey)
        {
            var scheduleQuestiondata = new ScheduleQuestionDataModel();

            scheduleQuestiondata.ScheduleQuestionId = entityKey;
            var results = ScheduleQuestionDataManager.Search(scheduleQuestiondata, SessionVariables.RequestProfile);

            return(results);
        }
Beispiel #8
0
        private System.Data.DataTable GetData()
        {
            // TODO: on all export pages
            var data = new ScheduleQuestionDataModel();

            var dt = ScheduleQuestionDataManager.Search(data, SessionVariables.RequestProfile);

            return(dt);
        }
Beispiel #9
0
        private DataTable GetScheduleQuestionData(int scheduleId)
        {
            var dt = ScheduleQuestionDataManager.GetBySchedule(scheduleId, SessionVariables.RequestProfile);
            var scheduleQuestiondt = ScheduleQuestionDataManager.GetList(SessionVariables.RequestProfile);
            var resultdt           = scheduleQuestiondt.Clone();

            foreach (DataRow row in dt.Rows)
            {
                var rows = scheduleQuestiondt.Select("ScheduleQuestionId = " + row[ScheduleQuestionDataModel.DataColumns.ScheduleQuestionId]);
                resultdt.ImportRow(rows[0]);
            }

            return(resultdt);
        }
Beispiel #10
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                string[] deleteIndexList = DeleteIds.Split(',');
                foreach (string index in deleteIndexList)
                {
                    var data = new ScheduleQuestionDataModel();
                    data.ScheduleQuestionId = int.Parse(index);
                    ScheduleQuestionDataManager.Delete(data, SessionVariables.RequestProfile);
                }

                DeleteAndRedirect();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Beispiel #11
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"]);
        }
Beispiel #12
0
        protected override DataTable GetData()
        {
            try
            {
                SuperKey = ApplicationCommon.GetSuperKey();
                SetId    = ApplicationCommon.GetSetId();

                var selectedrows         = new DataTable();
                var scheduleQuestiondata = new ScheduleQuestionDataModel();

                selectedrows = ScheduleQuestionDataManager.GetDetails(scheduleQuestiondata, SessionVariables.RequestProfile).Clone();
                if (!string.IsNullOrEmpty(SuperKey))
                {
                    var systemEntityTypeId = (int)PrimaryEntity;
                    var lstEntityKeys      = ApplicationCommon.GetSuperKeyDetails(systemEntityTypeId, SuperKey);

                    foreach (var entityKey in lstEntityKeys)
                    {
                        scheduleQuestiondata.ScheduleQuestionId = entityKey;
                        var result = ScheduleQuestionDataManager.GetDetails(scheduleQuestiondata, SessionVariables.RequestProfile);
                        selectedrows.ImportRow(result.Rows[0]);
                    }
                }
                else
                {
                    scheduleQuestiondata.ScheduleQuestionId = SetId;
                    var result = ScheduleQuestionDataManager.GetDetails(scheduleQuestiondata, SessionVariables.RequestProfile);
                    selectedrows.ImportRow(result.Rows[0]);
                }
                return(selectedrows);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

            return(null);
        }
Beispiel #13
0
        public void LoadData(int scheduleQuestionId, bool showId)
        {
            // clear UI

            Clear();

            var dataQuery = new ScheduleQuestionDataModel();

            dataQuery.ScheduleQuestionId = scheduleQuestionId;

            var items = ScheduleQuestionDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile);

            if (items.Count != 1)
            {
                return;
            }

            var item = items[0];

            ScheduleQuestionId = item.ScheduleQuestionId;
            ScheduleId         = item.ScheduleId;
            QuestionId         = item.QuestionId;
            Answer             = item.Answer;

            if (!showId)
            {
                txtScheduleQuestionId.Text = item.ScheduleQuestionId.ToString();

                // only show Audit History in case of Update page, not for Clone.
                oHistoryList.Setup((int)Framework.Components.DataAccess.SystemEntity.ScheduleQuestion, scheduleQuestionId, "ScheduleQuestion");
            }
            else
            {
                txtScheduleQuestionId.Text = String.Empty;
            }

            oUpdateInfo.LoadText(item.UpdatedDate, item.UpdatedBy, item.LastAction);
        }
Beispiel #14
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);
        }
Beispiel #15
0
        protected override DataTable GetData()
        {
            var dt = ScheduleQuestionDataManager.Search(oSearchFilter.SearchParameters, SessionVariables.RequestProfile);

            return(dt);
        }