public static Int32 Save(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, STD_QUESTION objSave)
        {
            Int32          objReturn = 0;
            STD_QUESTIONDB objDB     = new STD_QUESTIONDB();

            objReturn = objDB.Save(CURRENT_USER, CURRENT_REGISTRY_ID, objSave);

            return(objReturn);
        }
        public static STD_QUESTION GetItem(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, Int32 ID)
        {
            STD_QUESTION   objReturn = null;
            STD_QUESTIONDB objDB     = new STD_QUESTIONDB();

            objReturn = objDB.GetItem(CURRENT_USER, CURRENT_REGISTRY_ID, ID);

            return(objReturn);
        }
        private void LoadForm(int id)
        {
            ResetForm();

            STD_QUESTION question = ServiceInterfaceManager.STD_QUESTION_GET(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, id);

            if (question != null)
            {
                hideSurveyFieldId.Value = question.ID.ToString();
                txtQuestionNumber.Text  = question.QUESTION_NUMBER;
                txtSortOrder.Text       = question.SORT_ORDER.GetValueOrDefault().ToString();
                txtQuestionText.Text    = question.QUESTION_TEXT;

                gridFieldChoices.DataBind();
            }
        }
Beispiel #4
0
        public STD_QUESTION ParseReaderCustom(DataRow row)
        {
            STD_QUESTION objReturn = new STD_QUESTION
            {
                CREATED            = (DateTime)GetNullableObject(row.Field <object>("STD_QUESTION_CREATED")),
                CREATEDBY          = (string)GetNullableObject(row.Field <object>("STD_QUESTION_CREATEDBY")),
                ID                 = (Int32)GetNullableObject(row.Field <object>("STD_QUESTION_ID")),
                INACTIVE_DATE      = (DateTime?)GetNullableObject(row.Field <object>("STD_QUESTION_INACTIVE_DATE")),
                INACTIVE_FLAG      = (bool)GetNullableObject(row.Field <object>("STD_QUESTION_INACTIVE_FLAG")),
                QUESTION_NUMBER    = (string)GetNullableObject(row.Field <object>("STD_QUESTION_QUESTION_NUMBER")),
                QUESTION_TEXT      = (string)GetNullableObject(row.Field <object>("STD_QUESTION_QUESTION_TEXT")),
                SORT_ORDER         = (Int32?)GetNullableObject(row.Field <object>("STD_QUESTION_SORT_ORDER")),
                STD_SURVEY_TYPE_ID = (Int32)GetNullableObject(row.Field <object>("STD_QUESTION_STD_SURVEY_TYPE_ID")),
                UPDATED            = (DateTime)GetNullableObject(row.Field <object>("STD_QUESTION_UPDATED")),
                UPDATEDBY          = (string)GetNullableObject(row.Field <object>("STD_QUESTION_UPDATEDBY"))
            };

            return(objReturn);
        }
 public static Boolean Delete(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, STD_QUESTION objDelete)
 {
     return(Delete(CURRENT_USER, CURRENT_REGISTRY_ID, objDelete.ID));
 }
Beispiel #6
0
        private void SetupForm()
        {
            tblForm.Visible = false;

            viewPatient.LoadForm(UserSession.CurrentPatientId);

            SURVEYS survey = SURVEY;

            if (survey != null)
            {
                tblForm.Visible = true;

                if (survey.STD_SURVEY_TYPE != null)
                {
                    lblPageTitle.Text = survey.STD_SURVEY_TYPE.NAME;
                }

                List <SURVEY_RESULTS> results = RESULTS;
                if (results != null)
                {
                    //Select distinct question ids
                    List <Int32> questionIds = results.Select(data => data.STD_QUESTION_ID).Distinct().ToList();
                    if (questionIds != null && questionIds.Count > 0)
                    {
                        TableCell newCell  = null;
                        TableRow  newRow   = null;
                        int       rowIndex = 0;

                        foreach (Int32 questionId in questionIds)
                        {
                            List <SURVEY_RESULTS> questions = results.Where(data => data.STD_QUESTION_ID == questionId).ToList();
                            if (questions != null && questions.Count > 0)
                            {
                                Label lbl = new Label();

                                //Add question number and text to table
                                STD_QUESTION stdQuestion = questions.First().STD_QUESTION;
                                if (stdQuestion != null)
                                {
                                    lbl.ID = "lbl" + stdQuestion.ID.ToString();
                                    if (!string.IsNullOrEmpty(stdQuestion.QUESTION_NUMBER))
                                    {
                                        lbl.Text = stdQuestion.QUESTION_NUMBER + ") " + stdQuestion.QUESTION_TEXT;
                                    }
                                    else
                                    {
                                        lbl.Text = stdQuestion.QUESTION_TEXT;
                                    }

                                    newCell = new TableCell();
                                    newCell.Controls.Add(lbl);

                                    newRow = new TableRow();
                                    newRow.Cells.Add(newCell);

                                    tblForm.Rows.AddAt(rowIndex, newRow);
                                    rowIndex++;

                                    if (questions.Count > 1)
                                    {
                                        RadioButtonList rbl = new RadioButtonList();
                                        rbl.ID = "rbl" + stdQuestion.ID.ToString();

                                        foreach (SURVEY_RESULTS question in questions)
                                        {
                                            if (question.STD_QUESTION_CHOICE != null)
                                            {
                                                ListItem li = new ListItem(question.STD_QUESTION_CHOICE.CHOICE_TEXT, question.SURVEY_RESULT_ID.ToString());

                                                if (!Page.IsPostBack)
                                                {
                                                    li.Selected = question.SELECTED_FLAG;
                                                }
                                                else
                                                {
                                                    if (Request != null && Request.Form != null && Request.Form["ctl00$MainContent$" + rbl.ID] != null)
                                                    {
                                                        if (Request.Form["ctl00$MainContent$" + rbl.ID].ToString() == li.Value)
                                                        {
                                                            li.Selected = true;
                                                        }
                                                    }
                                                }

                                                rbl.Items.Add(li);
                                            }
                                        }

                                        newCell = new TableCell();
                                        newCell.Controls.Add(rbl);

                                        newRow = new TableRow();
                                        newRow.Cells.Add(newCell);

                                        tblForm.Rows.AddAt(rowIndex, newRow);
                                        rowIndex++;
                                    }
                                    else
                                    {
                                        SURVEY_RESULTS question = questions.First();
                                        if (question != null)
                                        {
                                            TextBox txt = new TextBox();
                                            txt.ID = "txt" + question.SURVEY_RESULT_ID.ToString();
                                            lbl.AssociatedControlID = txt.ID;
                                            txt.ToolTip             = "Enter a value for Question " + stdQuestion.QUESTION_NUMBER;

                                            if (!Page.IsPostBack)
                                            {
                                                txt.Text = question.RESULT_TEXT;
                                            }
                                            else
                                            {
                                                if (Request != null && Request.Form != null && Request.Form["ctl00$MainContent$" + txt.ID] != null)
                                                {
                                                    txt.Text = Request.Form["ctl00$MainContent$" + txt.ID].ToString();
                                                }
                                            }

                                            newCell = new TableCell();
                                            newCell.Controls.Add(txt);

                                            newRow = new TableRow();
                                            newRow.Cells.Add(newCell);

                                            tblForm.Rows.AddAt(rowIndex, newRow);
                                            rowIndex++;
                                        }
                                    }

                                    //Add blank row/cell
                                    newCell      = new TableCell();
                                    newCell.Text = "&nbsp;";

                                    newRow = new TableRow();
                                    newRow.Cells.Add(newCell);

                                    tblForm.Rows.AddAt(rowIndex, newRow);
                                    rowIndex++;
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #7
0
        public STD_QUESTION GetItem(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, Int32 ID)
        {
            STD_QUESTION objReturn = null;

            SqlConnection  sConn    = null;
            SqlCommand     sCmd     = null;
            SqlDataAdapter sAdapter = null;
            DataSet        objTemp  = null;

            try
            {
                sConn = new SqlConnection(SqlConnectionString);

                sConn.Open();

                sCmd = new SqlCommand("CRS.usp_STD_QUESTION_getitem", sConn);
                sCmd.CommandTimeout = SqlCommandTimeout;
                sCmd.CommandType    = CommandType.StoredProcedure;
                sCmd.Parameters.AddWithValue("@CURRENT_USER", CURRENT_USER);
                sCmd.Parameters.AddWithValue("@CURRENT_REGISTRY_ID", CURRENT_REGISTRY_ID);
                sCmd.Parameters.AddWithValue("@ID", ID);

                objTemp  = new DataSet();
                sAdapter = new SqlDataAdapter(sCmd);

                LogDetails logDetails = new LogDetails(String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                sAdapter.Fill(objTemp);
                LogManager.LogTiming(logDetails);
                CheckDataSet(objTemp);

                if (objTemp != null && objTemp.Tables.Count > 0 && objTemp.Tables[0].Rows.Count > 0)
                {
                    objReturn = ParseReader(objTemp.Tables[0].Rows[0]);
                }

                sConn.Close();
            }
            catch (Exception ex)
            {
                LogManager.LogError(ex.Message, String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                throw ex;
            }
            finally
            {
                if (sAdapter != null)
                {
                    sAdapter.Dispose();
                    sAdapter = null;
                }
                if (sCmd != null)
                {
                    sCmd.Dispose();
                    sCmd = null;
                }
                if (sConn != null)
                {
                    if (sConn.State != ConnectionState.Closed)
                    {
                        sConn.Close();
                    }
                    sConn.Dispose();
                    sConn = null;
                }
            }

            return(objReturn);
        }
Beispiel #8
0
        public Int32 Save(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, STD_QUESTION objSave)
        {
            Int32 objReturn = 0;

            SqlConnection  sConn    = null;
            SqlCommand     sCmd     = null;
            SqlParameter   p        = null;
            SqlDataAdapter sAdapter = null;
            DataSet        objTemp  = null;

            try
            {
                sConn = new SqlConnection(SqlConnectionString);

                sConn.Open();

                sCmd = new SqlCommand("CRS.usp_STD_QUESTION_save", sConn);
                sCmd.CommandTimeout = SqlCommandTimeout;
                sCmd.CommandType    = CommandType.StoredProcedure;
                sCmd.Parameters.AddWithValue("@CURRENT_USER", CURRENT_USER);
                sCmd.Parameters.AddWithValue("@CURRENT_REGISTRY_ID", CURRENT_REGISTRY_ID);

                p           = new SqlParameter("@CREATED", SqlDbType.DateTime, 8);
                p.Precision = 23;
                p.Scale     = 3;
                AddParameter(ref sCmd, ref p, objSave.CREATED);
                p           = new SqlParameter("@CREATEDBY", SqlDbType.VarChar, 30);
                p.Precision = 0;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.CREATEDBY);
                p           = new SqlParameter("@ID", SqlDbType.Int, 4);
                p.Direction = ParameterDirection.InputOutput;
                p.Precision = 10;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.ID);
                p           = new SqlParameter("@INACTIVE_DATE", SqlDbType.DateTime, 8);
                p.Precision = 23;
                p.Scale     = 3;
                AddParameter(ref sCmd, ref p, objSave.INACTIVE_DATE);
                p           = new SqlParameter("@INACTIVE_FLAG", SqlDbType.Bit, 1);
                p.Precision = 1;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.INACTIVE_FLAG);
                p           = new SqlParameter("@QUESTION_NUMBER", SqlDbType.VarChar, 50);
                p.Precision = 0;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.QUESTION_NUMBER);
                p           = new SqlParameter("@QUESTION_TEXT", SqlDbType.VarChar, 950);
                p.Precision = 0;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.QUESTION_TEXT);
                p           = new SqlParameter("@SORT_ORDER", SqlDbType.Int, 4);
                p.Precision = 10;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.SORT_ORDER);
                p           = new SqlParameter("@STD_SURVEY_TYPE_ID", SqlDbType.Int, 4);
                p.Precision = 10;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.STD_SURVEY_TYPE_ID);
                p           = new SqlParameter("@UPDATED", SqlDbType.DateTime, 8);
                p.Precision = 23;
                p.Scale     = 3;
                AddParameter(ref sCmd, ref p, objSave.UPDATED);
                p           = new SqlParameter("@UPDATEDBY", SqlDbType.VarChar, 30);
                p.Precision = 0;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.UPDATEDBY);

                objTemp  = new DataSet();
                sAdapter = new SqlDataAdapter(sCmd);

                LogDetails logDetails = new LogDetails(String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                //int cnt = sCmd.ExecuteNonQuery();
                sAdapter.Fill(objTemp);
                LogManager.LogTiming(logDetails);
                CheckDataSet(objTemp);

                objReturn = (Int32)sCmd.Parameters["@ID"].Value;

                sConn.Close();
            }
            catch (Exception ex)
            {
                LogManager.LogError(ex.Message, String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                throw ex;
            }
            finally
            {
                if (sAdapter != null)
                {
                    sAdapter.Dispose();
                    sAdapter = null;
                }
                if (sCmd != null)
                {
                    sCmd.Dispose();
                    sCmd = null;
                }
                if (sConn != null)
                {
                    if (sConn.State != ConnectionState.Closed)
                    {
                        sConn.Close();
                    }
                    sConn.Dispose();
                    sConn = null;
                }
            }

            return(objReturn);
        }
        private bool SaveForm(ref string strResult)
        {
            int oldQuestionID = 0;

            STD_QUESTION question = null;

            if (string.IsNullOrEmpty(txtQuestionNumber.Text))
            {
                strResult = "Question Number is Required<br /><br />";
            }
            else if (string.IsNullOrEmpty(txtSortOrder.Text))
            {
                strResult = "Sort Order is Required<br /><br />";
            }
            else if (string.IsNullOrEmpty(txtQuestionText.Text))
            {
                strResult = "Question Text is Required<br /><br />";
            }
            else
            {
                int id = 0;
                if (!string.IsNullOrEmpty(hideSurveyFieldId.Value))
                {
                    int.TryParse(hideSurveyFieldId.Value, out id);
                }
                if (id > 0)
                {
                    question = ServiceInterfaceManager.STD_QUESTION_GET(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, id);
                }
                if (question == null)
                {
                    question = new STD_QUESTION();
                }
                else
                {
                    //If text changes, INACTIVATE current question and save a new one
                    if (txtQuestionText.Text != question.QUESTION_TEXT)
                    {
                        oldQuestionID = question.ID;

                        ServiceInterfaceManager.STD_QUESTION_DELETE(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, question.ID);
                        question = new STD_QUESTION();
                    }
                }

                question.STD_SURVEY_TYPE_ID = UserSession.CurrentSurveyId;
                question.CREATEDBY          = question.UPDATEDBY = HttpContext.Current.User.Identity.Name;
                question.INACTIVE_FLAG      = false;

                question.QUESTION_NUMBER = txtQuestionNumber.Text;
                int sortOrder = 0;
                if (int.TryParse(txtSortOrder.Text, out sortOrder))
                {
                    question.SORT_ORDER = sortOrder;
                }
                question.QUESTION_TEXT = txtQuestionText.Text;

                question.ID = ServiceInterfaceManager.STD_QUESTION_SAVE(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, question);
                if (question.ID > 0)
                {
                    hideSurveyFieldId.Value = question.ID.ToString();
                    strResult = "Save successful<br /><br />";

                    if (oldQuestionID > 0)
                    {
                        ServiceInterfaceManager.STD_QUESTION_COPY_CHOICES(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, oldQuestionID, question.ID);
                    }

                    return(true);
                }
                else
                {
                    strResult = "Error saving Survey Field, please try again<br /><br />";
                }
            }
            //else
            //{
            //   strResult = "<ul><li>Question text is Required</li></ul>";
            // }

            return(false);
        }