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

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

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

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

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

            STD_REG_UDFs udf = ServiceInterfaceManager.STD_REG_UDFs_GET(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, id);

            if (udf != null)
            {
                hideUdfId.Value        = udf.ID.ToString();
                txtUdfName.Text        = udf.NAME;
                txtUdfCode.Text        = udf.CODE;
                txtUdfDescription.Text = udf.DESCRIPTION_TEXT;
            }
        }
        public STD_REG_UDFs ParseReaderCustom(DataRow row)
        {
            STD_REG_UDFs objReturn = new STD_REG_UDFs
            {
                CODE             = (string)GetNullableObject(row.Field <object>("STD_REG_UDFs_CODE")),
                CREATED          = (DateTime)GetNullableObject(row.Field <object>("STD_REG_UDFs_CREATED")),
                CREATEDBY        = (string)GetNullableObject(row.Field <object>("STD_REG_UDFs_CREATEDBY")),
                DESCRIPTION_TEXT = (string)GetNullableObject(row.Field <object>("STD_REG_UDFs_DESCRIPTION_TEXT")),
                ID              = (Int32)GetNullableObject(row.Field <object>("STD_REG_UDFs_ID")),
                NAME            = (string)GetNullableObject(row.Field <object>("STD_REG_UDFs_NAME")),
                STD_REGISTRY_ID = (Int32)GetNullableObject(row.Field <object>("STD_REG_UDFs_STD_REGISTRY_ID")),
                UPDATED         = (DateTime)GetNullableObject(row.Field <object>("STD_REG_UDFs_UPDATED")),
                UPDATEDBY       = (string)GetNullableObject(row.Field <object>("STD_REG_UDFs_UPDATEDBY"))
            };

            return(objReturn);
        }
        private bool SaveForm(ref string strResult)
        {
            STD_REG_UDFs udf = null;

            if (string.IsNullOrEmpty(txtUdfName.Text))
            {
                strResult = "UDF Name is Required<br /><br />";
            }
            else if (string.IsNullOrEmpty(txtUdfCode.Text))
            {
                strResult = "UDF Code is Required<br /><br />";
            }
            else if (string.IsNullOrEmpty(txtUdfDescription.Text))
            {
                strResult = "UDF Description is Required<br /><br />";
            }
            else
            {
                {
                    int id = 0;
                    if (!string.IsNullOrEmpty(hideUdfId.Value))
                    {
                        int.TryParse(hideUdfId.Value, out id);
                    }

                    if (id > 0)
                    {
                        udf = ServiceInterfaceManager.STD_REG_UDFs_GET(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, id);
                    }
                    else
                    {
                        List <STD_REG_UDFs> udfs = ServiceInterfaceManager.STD_REG_UDFs_GET_ALL_BY_REGISTRY(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId);
                        if (udfs != null)
                        {
                            if (udfs.Count >= 10)
                            {
                                strResult = "A maximum of 10 User-Defined Fields are allowed<br /><br />";
                                return(false);
                            }
                        }
                    }

                    if (udf == null)
                    {
                        udf = new STD_REG_UDFs();
                    }

                    udf.STD_REGISTRY_ID = UserSession.CurrentRegistryId;
                    udf.CREATEDBY       = udf.UPDATEDBY = HttpContext.Current.User.Identity.Name;

                    udf.NAME             = txtUdfName.Text;
                    udf.CODE             = txtUdfCode.Text;
                    udf.DESCRIPTION_TEXT = txtUdfDescription.Text;

                    udf.ID = ServiceInterfaceManager.STD_REG_UDFs_SAVE(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, udf);
                    if (udf.ID > 0)
                    {
                        hideUdfId.Value = udf.ID.ToString();
                        strResult       = "Save successful<br /><br />";
                        return(true);
                    }
                    else
                    {
                        strResult = "Error saving User-Defined Field, please try again<br /><br />";
                    }
                }
                // else
                //{
                //  strResult = "<ul><li>Field Name is Required</li></ul>";
                //}
            }
            return(false);
        }
 public static Boolean Delete(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, STD_REG_UDFs objDelete)
 {
     return(Delete(CURRENT_USER, CURRENT_REGISTRY_ID, objDelete.ID));
 }
        public STD_REG_UDFs GetItem(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, Int32 ID)
        {
            STD_REG_UDFs 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_REG_UDFs_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);
        }
        public Int32 Save(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, STD_REG_UDFs 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_REG_UDFs_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("@CODE", SqlDbType.VarChar, 50);
                p.Precision = 0;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.CODE);
                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("@DESCRIPTION_TEXT", SqlDbType.VarChar, 500);
                p.Precision = 0;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.DESCRIPTION_TEXT);
                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("@NAME", SqlDbType.VarChar, 100);
                p.Precision = 0;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.NAME);
                p           = new SqlParameter("@STD_REGISTRY_ID", SqlDbType.Int, 4);
                p.Precision = 10;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.STD_REGISTRY_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);
        }