public static BaseHelper ComboJobTitle(Model.ComboJobTitle data)
        {
            var retVal      = new BaseHelper();
            var objJSONPage = new Output.Combo();

            try
            {
                var entityPage = Combo.ComboJobTitle(data, objJSONPage);
                if (objJSONPage.ResultCode == 1)
                {
                    retVal.SQLElapsed += entityPage.SQLElapsed;
                    retVal.SQLInfo($"sp : {entityPage.SQLDetail}, elapsed : {entityPage.SQLElapsed}");

                    retVal.IsError = (entityPage.ResultCode == 1) ? false : true;
                }
                else
                {
                    objJSONPage.ResultCode   = objJSONPage.ResultCode;
                    objJSONPage.ErrorMessage = objJSONPage.ErrorMessage;
                }
            }
            catch (Exception ex)
            {
                retVal.Exception = ex;

                if (ex is System.Data.SqlClient.SqlException sqlEx)
                {
                    retVal.SQLInfo($"sp:{sqlEx.Procedure}, line:{sqlEx.LineNumber}, detail:{data.SqlDetail}");
                    retVal.SQLException = true;

                    objJSONPage.ResultCode   = 69998;
                    objJSONPage.ErrorMessage = "SQL Exception";
                }
                else
                {
                    objJSONPage.ResultCode   = 69999;
                    objJSONPage.ErrorMessage = "Unknown Error";
                }
            }
            finally
            {
                retVal.SerializeObject <Output.Combo>(objJSONPage);
            }

            return(retVal);
        }
예제 #2
0
        public static BasicEntity ComboJobTitle(Model.ComboJobTitle data, Output.Combo obj)
        {
            var retVal = new BasicEntity();

            retVal.AddParameter("@id", data.ID);

            data.SqlDetail = retVal.SQLCommandBuilder("spComboJobTitle");

            using (SqlDataReader reader = retVal.ExecReader())
            {
                while (reader.Read())
                {
                    obj.ResultCode    = (reader.IsDBNull(0)) ? 0 : reader.GetInt32(0);
                    obj.ErrorMessage  = (reader.IsDBNull(1)) ? string.Empty : reader.GetString(1);
                    retVal.ResultCode = obj.ResultCode;
                }

                if (retVal.ResultCode == 1)
                {
                    reader.NextResult();
                    while (reader.Read())
                    {
                        var item = new Output.ComboData();

                        item.ID   = (reader.IsDBNull(0)) ? 0 : reader.GetInt32(0);
                        item.Name = (reader.IsDBNull(1)) ? string.Empty : reader.GetString(1);

                        obj.Content.Data.Add(item);
                    }
                }

                reader.Close();
            }

            retVal.Close();

            return(retVal);
        }