Esempio n. 1
0
        public static STD_QUESTION_CHOICE GetItem(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, Int32 STD_QUESTION_CHOICE_ID)
        {
            STD_QUESTION_CHOICE   objReturn = null;
            STD_QUESTION_CHOICEDB objDB     = new STD_QUESTION_CHOICEDB();

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

            return(objReturn);
        }
Esempio n. 2
0
        public static Int32 Save(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, STD_QUESTION_CHOICE objSave)
        {
            Int32 objReturn             = 0;
            STD_QUESTION_CHOICEDB objDB = new STD_QUESTION_CHOICEDB();

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

            return(objReturn);
        }
        private void LoadChoiceForm(int id)
        {
            ResetChoiceForm();

            STD_QUESTION_CHOICE choice = ServiceInterfaceManager.STD_QUESTION_CHOICE_GET(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, id);

            if (choice != null)
            {
                hideFieldChoiceId.Value = choice.STD_QUESTION_CHOICE_ID.ToString();
                txtChoiceName.Text      = choice.CHOICE_NAME;
                txtChoiceSortOrder.Text = choice.CHOICE_SORT_ORDER.GetValueOrDefault().ToString();
                txtChoiceText.Text      = choice.CHOICE_TEXT;
            }
        }
        public STD_QUESTION_CHOICE ParseReaderCustom(DataRow row)
        {
            STD_QUESTION_CHOICE objReturn = new STD_QUESTION_CHOICE
            {
                CHOICE_NAME            = (string)GetNullableObject(row.Field <object>("STD_QUESTION_CHOICE_CHOICE_NAME")),
                CHOICE_SORT_ORDER      = (Int32?)GetNullableObject(row.Field <object>("STD_QUESTION_CHOICE_CHOICE_SORT_ORDER")),
                CHOICE_TEXT            = (string)GetNullableObject(row.Field <object>("STD_QUESTION_CHOICE_CHOICE_TEXT")),
                CREATED                = (DateTime)GetNullableObject(row.Field <object>("STD_QUESTION_CHOICE_CREATED")),
                CREATEDBY              = (string)GetNullableObject(row.Field <object>("STD_QUESTION_CHOICE_CREATEDBY")),
                INACTIVE_DATE          = (DateTime?)GetNullableObject(row.Field <object>("STD_QUESTION_CHOICE_INACTIVE_DATE")),
                INACTIVE_FLAG          = (bool)GetNullableObject(row.Field <object>("STD_QUESTION_CHOICE_INACTIVE_FLAG")),
                STD_QUESTION_CHOICE_ID = (Int32)GetNullableObject(row.Field <object>("STD_QUESTION_CHOICE_STD_QUESTION_CHOICE_ID")),
                STD_QUESTION_ID        = (Int32)GetNullableObject(row.Field <object>("STD_QUESTION_CHOICE_STD_QUESTION_ID")),
                UPDATED                = (DateTime)GetNullableObject(row.Field <object>("STD_QUESTION_CHOICE_UPDATED")),
                UPDATEDBY              = (string)GetNullableObject(row.Field <object>("STD_QUESTION_CHOICE_UPDATEDBY"))
            };

            return(objReturn);
        }
Esempio n. 5
0
 public static Boolean Delete(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, STD_QUESTION_CHOICE objDelete)
 {
     return(Delete(CURRENT_USER, CURRENT_REGISTRY_ID, objDelete.STD_QUESTION_CHOICE_ID));
 }
        public STD_QUESTION_CHOICE GetItem(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, Int32 STD_QUESTION_CHOICE_ID)
        {
            STD_QUESTION_CHOICE 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_CHOICE_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("@STD_QUESTION_CHOICE_ID", STD_QUESTION_CHOICE_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);
        }
        public Int32 Save(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, STD_QUESTION_CHOICE 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_CHOICE_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("@CHOICE_NAME", SqlDbType.VarChar, 100);
                p.Precision = 0;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.CHOICE_NAME);
                p           = new SqlParameter("@CHOICE_SORT_ORDER", SqlDbType.Int, 4);
                p.Precision = 10;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.CHOICE_SORT_ORDER);
                p           = new SqlParameter("@CHOICE_TEXT", SqlDbType.VarChar, 4000);
                p.Precision = 0;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.CHOICE_TEXT);
                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("@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("@STD_QUESTION_CHOICE_ID", SqlDbType.Int, 4);
                p.Direction = ParameterDirection.InputOutput;
                p.Precision = 10;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.STD_QUESTION_CHOICE_ID);
                p           = new SqlParameter("@STD_QUESTION_ID", SqlDbType.Int, 4);
                p.Precision = 10;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.STD_QUESTION_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["@STD_QUESTION_CHOICE_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 SaveChoiceForm(ref string strResult)
        {
            STD_QUESTION_CHOICE choice = null;

            if (string.IsNullOrEmpty(txtChoiceName.Text))
            {
                strResult = "Choice Name is Required<br /><br />";
            }
            else if (string.IsNullOrEmpty(txtChoiceSortOrder.Text))
            {
                strResult = "Sort Order is Required<br /><br />";
            }
            else if (string.IsNullOrEmpty(txtChoiceText.Text))
            {
                strResult = "Choice Text is Required<br /><br />";
            }
            else
            {
                // if (!string.IsNullOrEmpty(txtChoiceText.Text))

                int id = 0;
                if (!string.IsNullOrEmpty(hideFieldChoiceId.Value))
                {
                    int.TryParse(hideFieldChoiceId.Value, out id);
                }
                if (id > 0)
                {
                    choice = ServiceInterfaceManager.STD_QUESTION_CHOICE_GET(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, id);
                }
                if (choice == null)
                {
                    choice = new STD_QUESTION_CHOICE();
                }
                else
                {
                    //If text changes, INACTIVATE current choice and save a new one
                    if (txtChoiceText.Text != choice.CHOICE_TEXT)
                    {
                        ServiceInterfaceManager.STD_QUESTION_CHOICE_DELETE(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, choice.STD_QUESTION_CHOICE_ID);
                        choice = new STD_QUESTION_CHOICE();
                    }
                }

                int fieldId = 0;
                if (string.IsNullOrEmpty(hideSurveyFieldId.Value) || !int.TryParse(hideSurveyFieldId.Value, out fieldId))
                {
                    if (SaveForm(ref strResult))
                    {
                        int.TryParse(hideSurveyFieldId.Value, out fieldId);
                        gridSurveyFields.DataBind();
                    }
                    else
                    {
                        strResult = "Error saving Survey Field and Field Choice, please save the Survey Field first before adding choices<br /><br />";
                        return(false);
                    }
                }

                choice.STD_QUESTION_ID = fieldId;
                choice.CREATEDBY       = choice.UPDATEDBY = HttpContext.Current.User.Identity.Name;
                choice.INACTIVE_FLAG   = false;

                choice.CHOICE_NAME = txtChoiceName.Text;
                int sortOrder = 0;
                if (int.TryParse(txtChoiceSortOrder.Text, out sortOrder))
                {
                    choice.CHOICE_SORT_ORDER = sortOrder;
                }
                choice.CHOICE_TEXT = txtChoiceText.Text;

                choice.STD_QUESTION_CHOICE_ID = ServiceInterfaceManager.STD_QUESTION_CHOICE_SAVE(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, choice);
                if (choice.STD_QUESTION_CHOICE_ID > 0)
                {
                    hideFieldChoiceId.Value = choice.STD_QUESTION_CHOICE_ID.ToString();
                    strResult = "Save successful<br /><br />";
                    return(true);
                }
                else
                {
                    strResult = "Error saving Field Choice, please try again<br /><br />";
                }

                //else
                // {
                // strResult = "<ul><li>Choice Name is Required</li></ul>";
                //}
            }
            return(false);
        }