Exemplo n.º 1
0
        /// <summary>
        /// Get
        /// Calls [usp_select_ProductType]
        /// </summary>
        public override ProductTypeDetails Get(System.Int32?productTypeId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_select_ProductType", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@ProductTypeId", SqlDbType.Int).Value = productTypeId;
                cn.Open();
                DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    //return GetProductTypeFromReader(reader);
                    ProductTypeDetails obj = new ProductTypeDetails();
                    obj.ProductTypeId = GetReaderValue_Int32(reader, "ProductTypeId", 0);
                    obj.Name          = GetReaderValue_String(reader, "Name", "");
                    return(obj);
                }
                else
                {
                    return(null);
                }
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get ProductType", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
Exemplo n.º 2
0
        private static ProductType PopulateFromDBDetailsObject(ProductTypeDetails obj)
        {
            ProductType objNew = new ProductType();

            objNew.ProductTypeId = obj.ProductTypeId;
            objNew.Name          = obj.Name;
            return(objNew);
        }